2020-11-19 10:00:18 +00:00
|
|
|
contract C {
|
|
|
|
struct S { uint x; uint y; uint z; }
|
|
|
|
function memorySize() internal pure returns (uint s) {
|
|
|
|
assembly { s := mload(0x40) }
|
|
|
|
}
|
|
|
|
function withValue() public pure returns (uint) {
|
|
|
|
S memory x = S(1, 2, 3);
|
|
|
|
uint memorySizeBefore = memorySize();
|
|
|
|
S memory t = x;
|
|
|
|
uint memorySizeAfter = memorySize();
|
|
|
|
return memorySizeAfter - memorySizeBefore;
|
|
|
|
}
|
|
|
|
function withoutValue() public pure returns (uint) {
|
|
|
|
uint memorySizeBefore = memorySize();
|
|
|
|
S memory t;
|
|
|
|
uint memorySizeAfter = memorySize();
|
|
|
|
return memorySizeAfter - memorySizeBefore;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ====
|
2020-11-21 20:05:39 +00:00
|
|
|
// compileToEwasm: also
|
2021-03-12 23:02:36 +00:00
|
|
|
// compileViaYul: also
|
2020-11-19 10:00:18 +00:00
|
|
|
// ----
|
|
|
|
// withValue() -> 0x00
|
|
|
|
// withoutValue() -> 0x60
|