Merge pull request #10773 from ethereum/useArrayAllocationFunction

Fix array allocation.
This commit is contained in:
Alex Beregszaszi 2021-01-14 20:25:31 +00:00 committed by GitHub
commit 6ad0ea9f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4218,13 +4218,7 @@ string YulUtilFunctions::extractReturndataFunction()
data := <emptyArray>()
}
default {
// allocate some memory into data of size returndatasize() + PADDING
data := <allocate>(<roundUp>(add(returndatasize(), 0x20)))
// store array length into the front
mstore(data, returndatasize())
// append to data
data := <allocateArray>(returndatasize())
returndatacopy(add(data, 0x20), 0, returndatasize())
}
<!supportsReturndata>
@ -4234,8 +4228,7 @@ string YulUtilFunctions::extractReturndataFunction()
)")
("functionName", functionName)
("supportsReturndata", m_evmVersion.supportsReturndata())
("allocate", allocationFunction())
("roundUp", roundUpFunction())
("allocateArray", allocateMemoryArrayFunction(*TypeProvider::bytesMemory()))
("emptyArray", zeroValueFunction(*TypeProvider::bytesMemory()))
.render();
});