2020-05-05 17:53:17 +00:00
|
|
|
contract c {
|
|
|
|
bytes data;
|
|
|
|
function test_short() public returns (uint256 r) {
|
|
|
|
assembly {
|
2020-07-01 17:25:14 +00:00
|
|
|
sstore(data.slot, 0)
|
2020-05-05 17:53:17 +00:00
|
|
|
}
|
|
|
|
for (uint8 i = 0; i < 15; i++) {
|
|
|
|
data.push(bytes1(i));
|
|
|
|
}
|
|
|
|
assembly {
|
2020-07-01 17:25:14 +00:00
|
|
|
r := sload(data.slot)
|
2020-05-05 17:53:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_long() public returns (uint256 r) {
|
|
|
|
assembly {
|
2020-07-01 17:25:14 +00:00
|
|
|
sstore(data.slot, 0)
|
2020-05-05 17:53:17 +00:00
|
|
|
}
|
|
|
|
for (uint8 i = 0; i < 33; i++) {
|
|
|
|
data.push(bytes1(i));
|
|
|
|
}
|
|
|
|
assembly {
|
2020-07-01 17:25:14 +00:00
|
|
|
r := sload(data.slot)
|
2020-05-05 17:53:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_pop() public returns (uint256 r) {
|
|
|
|
assembly {
|
2020-07-01 17:25:14 +00:00
|
|
|
sstore(data.slot, 0)
|
2020-05-05 17:53:17 +00:00
|
|
|
}
|
|
|
|
for (uint8 i = 0; i < 32; i++) {
|
|
|
|
data.push(bytes1(i));
|
|
|
|
}
|
|
|
|
data.pop();
|
2020-10-06 14:00:32 +00:00
|
|
|
data.pop();
|
2020-05-05 17:53:17 +00:00
|
|
|
assembly {
|
2020-07-01 17:25:14 +00:00
|
|
|
r := sload(data.slot)
|
2020-05-05 17:53:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
|
|
|
// ----
|
2021-01-08 03:45:19 +00:00
|
|
|
// storageEmpty -> 1
|
2020-05-05 17:53:17 +00:00
|
|
|
// test_short() -> 1780731860627700044960722568376587075150542249149356309979516913770823710
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 110938
|
2021-03-11 11:17:50 +00:00
|
|
|
// gas legacyOptimized: 109706
|
2021-01-08 03:45:19 +00:00
|
|
|
// storageEmpty -> 0
|
2020-05-05 17:53:17 +00:00
|
|
|
// test_long() -> 67
|
2021-04-12 10:53:09 +00:00
|
|
|
// gas irOptimized: 134320
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 213590
|
2021-03-11 11:17:50 +00:00
|
|
|
// gas legacyOptimized: 211044
|
2021-01-08 03:45:19 +00:00
|
|
|
// storageEmpty -> 0
|
2020-10-06 14:00:32 +00:00
|
|
|
// test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979433020
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 176030
|
2021-03-11 11:17:50 +00:00
|
|
|
// gas legacyOptimized: 173504
|
2021-01-08 03:45:19 +00:00
|
|
|
// storageEmpty -> 0
|