diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index b66b9cf25..508b74497 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -183,15 +183,15 @@ string YulUtilFunctions::requireOrAssertFunction(bool _assert, Type const* _mess return Whiskers(R"( function (condition ) { if iszero(condition) { - let fmp := mload() - mstore(fmp, ) - let end := (add(fmp, ) ) - revert(fmp, sub(end, fmp)) + let memPtr := () + mstore(memPtr, ) + let end := (add(memPtr, ) ) + revert(memPtr, sub(end, memPtr)) } } )") ("functionName", functionName) - ("freeMemPointer", to_string(CompilerUtils::freeMemoryPointer)) + ("allocateUnbounded", allocateUnboundedFunction()) ("errorHash", formatNumber(errorHash)) ("abiEncodeFunc", encodeFunc) ("hashHeaderSize", to_string(hashHeaderSize)) @@ -2301,19 +2301,19 @@ string YulUtilFunctions::copyArrayFromStorageToMemoryFunction(ArrayType const& _ solAssert(_from.baseType() == _to.baseType(), ""); ABIFunctions abi(m_evmVersion, m_revertStrings, m_functionCollector); return Whiskers(R"( - function (slot) -> memptr { - memptr := () - let end := (slot, memptr) - mstore(, end) + function (slot) -> memPtr { + memPtr := () + let end := (slot, memPtr) + (memPtr, sub(end, memPtr)) } )") ("functionName", functionName) - ("allocateTemp", allocationTemporaryMemoryFunction()) + ("allocateUnbounded", allocateUnboundedFunction()) ( "encode", abi.abiEncodeAndReturnUpdatedPosFunction(_from, _to, ABIFunctions::EncodingOptions{}) ) - ("freeMemoryPointer", to_string(CompilerUtils::freeMemoryPointer)) + ("finalizeAllocation", finalizeAllocationFunction()) .render(); } else @@ -2324,10 +2324,10 @@ string YulUtilFunctions::copyArrayFromStorageToMemoryFunction(ArrayType const& _ solAssert(!_from.isByteArray(), ""); solAssert(*_to.withLocation(DataLocation::Storage, _from.isPointer()) == _from, ""); return Whiskers(R"( - function (slot) -> memptr { + function (slot) -> memPtr { let length := (slot) - memptr := (length) - let mpos := memptr + memPtr := (length) + let mpos := memPtr mpos := add(mpos, 0x20) let spos := (slot) for { let i := 0 } lt(i, length) { i := add(i, 1) } { @@ -2793,28 +2793,24 @@ string YulUtilFunctions::prepareStoreFunction(Type const& _type) string YulUtilFunctions::allocationFunction() { - string functionName = "allocateMemory"; + string functionName = "allocate_memory"; return m_functionCollector.createFunction(functionName, [&]() { return Whiskers(R"( function (size) -> memPtr { - memPtr := mload() - let newFreePtr := add(memPtr, (size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { () } - mstore(, newFreePtr) + memPtr := () + (memPtr, size) } )") ("functionName", functionName) - ("freeMemoryPointer", to_string(CompilerUtils::freeMemoryPointer)) - ("roundUp", roundUpFunction()) - ("panic", panicFunction(PanicCode::ResourceError)) + ("allocateUnbounded", allocateUnboundedFunction()) + ("finalizeAllocation", finalizeAllocationFunction()) .render(); }); } -string YulUtilFunctions::allocationTemporaryMemoryFunction() +string YulUtilFunctions::allocateUnboundedFunction() { - string functionName = "allocateTemporaryMemory"; + string functionName = "allocate_unbounded"; return m_functionCollector.createFunction(functionName, [&]() { return Whiskers(R"( function () -> memPtr { @@ -2827,15 +2823,22 @@ string YulUtilFunctions::allocationTemporaryMemoryFunction() }); } -string YulUtilFunctions::releaseTemporaryMemoryFunction() +string YulUtilFunctions::finalizeAllocationFunction() { - string functionName = "releaseTemporaryMemory"; - return m_functionCollector.createFunction(functionName, [&](){ + string functionName = "finalize_allocation"; + return m_functionCollector.createFunction(functionName, [&]() { return Whiskers(R"( - function () { + function (memPtr, size) { + let newFreePtr := add(memPtr, (size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { () } + mstore(, newFreePtr) } )") ("functionName", functionName) + ("freeMemoryPointer", to_string(CompilerUtils::freeMemoryPointer)) + ("roundUp", roundUpFunction()) + ("panic", panicFunction(PanicCode::ResourceError)) .render(); }); } @@ -3625,7 +3628,7 @@ string YulUtilFunctions::packedHashFunction( return m_functionCollector.createFunction(functionName, [&]() { Whiskers templ(R"( function () -> hash { - let pos := mload() + let pos := () let end := (pos ) hash := keccak256(pos, sub(end, pos)) } @@ -3633,7 +3636,7 @@ string YulUtilFunctions::packedHashFunction( templ("functionName", functionName); templ("variables", suffixedVariableNameList("var_", 1, 1 + sizeOnStack)); templ("comma", sizeOnStack > 0 ? "," : ""); - templ("freeMemoryPointer", to_string(CompilerUtils::freeMemoryPointer)); + templ("allocateUnbounded", allocateUnboundedFunction()); templ("packedEncode", ABIFunctions(m_evmVersion, m_revertStrings, m_functionCollector).tupleEncoderPacked(_givenTypes, _targetTypes)); return templ.render(); }); @@ -4149,7 +4152,7 @@ string YulUtilFunctions::tryDecodeErrorMessageFunction() function () -> ret { if lt(returndatasize(), 0x44) { leave } - let data := mload() + let data := () returndatacopy(data, 4, sub(returndatasize(), 4)) let offset := mload(data) @@ -4167,13 +4170,13 @@ string YulUtilFunctions::tryDecodeErrorMessageFunction() let end := add(add(msg, 0x20), length) if gt(end, add(data, sub(returndatasize(), 4))) { leave } - mstore(, add(add(msg, 0x20), (length))) + (data, add(offset, add(0x20, length))) ret := msg } )") ("functionName", functionName) - ("freeMemoryPointer", to_string(CompilerUtils::freeMemoryPointer)) - ("roundUp", roundUpFunction()) + ("allocateUnbounded", allocateUnboundedFunction()) + ("finalizeAllocation", finalizeAllocationFunction()) .render(); }); } diff --git a/libsolidity/codegen/YulUtilFunctions.h b/libsolidity/codegen/YulUtilFunctions.h index 6f1642f52..074c348a0 100644 --- a/libsolidity/codegen/YulUtilFunctions.h +++ b/libsolidity/codegen/YulUtilFunctions.h @@ -352,16 +352,20 @@ public: /// @returns the name of a function that allocates memory. /// Modifies the "free memory pointer" - /// Arguments: size - /// Return value: pointer + /// signature: (size) -> memPtr std::string allocationFunction(); - /// @returns the name of the function that allocates temporary memory with predefined size - /// Return value: pointer - std::string allocationTemporaryMemoryFunction(); + /// @returns the name of the function that allocates memory whose size might be defined later. + /// The allocation can be finalized using finalizeAllocationFunction. + /// Any other allocation will invalidate the memory pointer unless finalizeAllocationFunction + /// is called. + /// signature: () -> memPtr + std::string allocateUnboundedFunction(); - /// @returns the name of the function that releases previously allocated temporary memory - std::string releaseTemporaryMemoryFunction(); + /// @returns the name of the function that finalizes an unbounded memory allocation, + /// i.e. sets its size and makes the allocation permanent. + /// signature: (memPtr, size) -> + std::string finalizeAllocationFunction(); /// @returns the name of a function that zeroes an array. /// signature: (dataStart, dataSizeInBytes) -> diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index e8fc1f55d..01139a231 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1035,13 +1035,13 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) } solAssert(indexedArgs.size() <= 4, "Too many indexed arguments."); Whiskers templ(R"({ - let := + let := () let := ( ) (, sub(, ) ) })"); templ("pos", m_context.newYulVariable()); templ("end", m_context.newYulVariable()); - templ("freeMemory", freeMemory()); + templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); templ("encode", abi.tupleEncoder(nonIndexedArgTypes, nonIndexedParamTypes)); templ("nonIndexedArgs", joinHumanReadablePrefixed(nonIndexedArgs)); templ("log", "log" + to_string(indexedArgs.size())); @@ -1107,8 +1107,11 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) else { // Used to reset the free memory pointer later. + // TODO This is an abuse of the `allocateUnbounded` function. + // We might want to introduce a new set of memory handling functions here + // a la "setMemoryCheckPoint" and "freeUntilCheckPoint". string freeMemoryPre = m_context.newYulVariable(); - m_code << "let " << freeMemoryPre << " := " << freeMemory() << "\n"; + m_code << "let " << freeMemoryPre << " := " << m_utils.allocateUnboundedFunction() << "()\n"; IRVariable array = convert(*arguments[0], *TypeProvider::bytesMemory()); IRVariable hashVariable(m_context.newYulVariable(), *TypeProvider::fixedBytes(32)); @@ -1125,26 +1128,26 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) IRVariable selectorVariable(m_context.newYulVariable(), *TypeProvider::fixedBytes(4)); define(selectorVariable, hashVariable); selector = selectorVariable.name(); - m_code << "mstore(" << to_string(CompilerUtils::freeMemoryPointer) << ", " << freeMemoryPre << ")\n"; + m_code << m_utils.finalizeAllocationFunction() << "(" << freeMemoryPre << ", 0)\n"; } } else if (functionType->kind() == FunctionType::Kind::ABIEncodeWithSelector) selector = convert(*arguments.front(), *TypeProvider::fixedBytes(4)).name(); Whiskers templ(R"( - let := () - let := add(, 0x20) + let := () + let := add(, 0x20) - mstore(, ) - := add(, 4) + mstore(, ) + := add(, 4) - let := () + let := () mstore(, sub(, add(, 0x20))) - mstore(, ()) + (, sub(, )) )"); templ("data", IRVariable(_functionCall).part("mpos").name()); - templ("allocateTemporary", m_utils.allocationTemporaryMemoryFunction()); - templ("mpos", m_context.newYulVariable()); + templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); + templ("memPtr", m_context.newYulVariable()); templ("mend", m_context.newYulVariable()); templ("selector", selector); templ("encode", @@ -1153,8 +1156,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) m_context.abiFunctions().tupleEncoder(argumentTypes, targetTypes, false) ); templ("arguments", joinHumanReadablePrefixed(argumentVars)); - templ("freeMemPtr", to_string(CompilerUtils::freeMemoryPointer)); - templ("roundUp", m_utils.roundUpFunction()); + templ("finalizeAllocation", m_utils.finalizeAllocationFunction()); m_code << templ.render(); break; @@ -1214,7 +1216,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) solAssert(type(*arguments.front()).isImplicitlyConvertibleTo(*TypeProvider::stringMemory()),""); Whiskers templ(R"({ - let := () + let := () mstore(, ) let := (add(, 4) ) revert(, sub(, )) @@ -1222,7 +1224,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) templ("pos", m_context.newYulVariable()); templ("end", m_context.newYulVariable()); templ("hash", util::selectorFromSignature("Error(string)").str()); - templ("allocateTemporary", m_utils.allocationTemporaryMemoryFunction()); + templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); templ( "argumentVars", joinHumanReadablePrefixed(IRVariable{*arguments.front()}.stackSlots()) @@ -1396,7 +1398,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) m_context.subObjectsCreated().insert(contract); Whiskers t(R"( - let := () + let := () let := add(, datasize("")) if or(gt(, 0xffffffffffffffff), lt(, )) { () } datacopy(, dataoffset(""), datasize("")) @@ -1411,12 +1413,10 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) if iszero(
) { () } - () )"); t("memPos", m_context.newYulVariable()); t("memEnd", m_context.newYulVariable()); - t("allocateTemporaryMemory", m_utils.allocationTemporaryMemoryFunction()); - t("releaseTemporaryMemory", m_utils.releaseTemporaryMemoryFunction()); + t("allocateUnbounded", m_utils.allocateUnboundedFunction()); t("object", IRNames::creationObject(*contract)); t("panic", m_utils.panicFunction(PanicCode::ResourceError)); t("abiEncode", @@ -1489,7 +1489,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) argumentStrings += IRVariable(*arg).stackSlots(); } Whiskers templ(R"( - let := () + let := () let := ( ) mstore(0, 0) @@ -1501,7 +1501,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) templ("call", m_context.evmVersion().hasStaticCall() ? "staticcall" : "call"); templ("isCall", !m_context.evmVersion().hasStaticCall()); templ("shl", m_utils.shiftLeftFunction(offset * 8)); - templ("allocateTemporary", m_utils.allocationTemporaryMemoryFunction()); + templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); templ("pos", m_context.newYulVariable()); templ("end", m_context.newYulVariable()); templ("isECRecover", FunctionType::Kind::ECRecover == functionType->kind()); @@ -2398,14 +2398,14 @@ void IRGeneratorForStatements::appendExternalFunctionCall( // We could also just use MLOAD; POP right before the gas calculation, but the optimizer // would remove that, so we use MSTORE here. if (!funType.gasSet() && returnInfo.estimatedReturnSize > 0) - m_code << "mstore(add(" << freeMemory() << ", " << to_string(returnInfo.estimatedReturnSize) << "), 0)\n"; + m_code << "mstore(add(" << m_utils.allocateUnboundedFunction() << "() , " << to_string(returnInfo.estimatedReturnSize) << "), 0)\n"; } Whiskers templ(R"( if iszero(extcodesize(
)) { } // storage for arguments and returned data - let := + let := () mstore(, ()) let := (add(, 4) ) @@ -2421,7 +2421,7 @@ void IRGeneratorForStatements::appendExternalFunctionCall( // update freeMemoryPointer according to dynamic return size - mstore(, add(, ())) + (, ) // decode return parameters from external try-call into retVars := (, add(, )) @@ -2434,7 +2434,8 @@ void IRGeneratorForStatements::appendExternalFunctionCall( templ("success", IRNames::trySuccessConditionVariable(_functionCall)); else templ("success", m_context.newYulVariable()); - templ("freeMemory", freeMemory()); + templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); + templ("finalizeAllocation", m_utils.finalizeAllocationFunction()); templ("shl28", m_utils.shiftLeftFunction(8 * (32 - 4))); templ("funSel", IRVariable(_functionCall.expression()).part("functionSelector").name()); @@ -2456,7 +2457,6 @@ void IRGeneratorForStatements::appendExternalFunctionCall( templ("roundUp", m_utils.roundUpFunction()); templ("abiDecode", m_context.abiFunctions().tupleDecoder(returnInfo.returnTypes, true)); templ("dynamicReturnSize", returnInfo.dynamicReturnSize); - templ("freeMemoryPointer", to_string(CompilerUtils::freeMemoryPointer)); templ("noTryCall", !_functionCall.annotation().tryCall); @@ -2524,7 +2524,7 @@ void IRGeneratorForStatements::appendBareCall( solAssert(!_functionCall.annotation().tryCall, ""); Whiskers templ(R"( - let := mload() + let := () let := sub(( , ), ) let := add(, 0x20) @@ -2537,7 +2537,7 @@ void IRGeneratorForStatements::appendBareCall( )"); - templ("freeMemoryPointer", to_string(CompilerUtils::freeMemoryPointer)); + templ("allocateUnbounded", m_utils.allocateUnboundedFunction()); templ("pos", m_context.newYulVariable()); templ("length", m_context.newYulVariable()); @@ -2597,11 +2597,6 @@ void IRGeneratorForStatements::appendBareCall( m_code << templ.render(); } -string IRGeneratorForStatements::freeMemory() -{ - return "mload(" + to_string(CompilerUtils::freeMemoryPointer) + ")"; -} - IRVariable IRGeneratorForStatements::convert(IRVariable const& _from, Type const& _to) { if (_from.type() == _to) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.h b/libsolidity/codegen/ir/IRGeneratorForStatements.h index b978e632d..e212398b8 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.h +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.h @@ -125,10 +125,6 @@ private: std::vector> const& _arguments ); - /// @returns code that evaluates to the first unused memory slot (which does not have to - /// be empty). - static std::string freeMemory(); - /// Generates the required conversion code and @returns an IRVariable referring to the value of @a _variable /// converted to type @a _to. IRVariable convert(IRVariable const& _variable, Type const& _to); diff --git a/test/cmdlineTests/exp_base_literal/output b/test/cmdlineTests/exp_base_literal/output index 7d682d779..67279507b 100644 --- a/test/cmdlineTests/exp_base_literal/output +++ b/test/cmdlineTests/exp_base_literal/output @@ -39,7 +39,7 @@ object "C_81" { if callvalue() { revert(0, 0) } let param_0, param_1, param_2, param_3 := abi_decode_tuple_t_uint256t_uint256t_uint256t_uint256(4, calldatasize()) let ret_0, ret_1, ret_2, ret_3 := fun_f_80(param_0, param_1, param_2, param_3) - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple_t_uint256_t_int256_t_uint256_t_uint256__to_t_uint256_t_int256_t_uint256_t_uint256__fromStack(memPos , ret_0, ret_1, ret_2, ret_3) return(memPos, sub(memEnd, memPos)) } @@ -108,12 +108,13 @@ object "C_81" { } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) } function checked_exp_t_rational_0_by_1_t_uint256(exponent) -> power { @@ -202,6 +203,13 @@ object "C_81" { converted := cleanup_t_int256(value) } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function fun_f_80(vloc_a_4, vloc_b_6, vloc_c_8, vloc_d_10) -> vloc__13, vloc__15, vloc__17, vloc__19 { let zero_value_for_type_t_uint256_1 := zero_value_for_split_t_uint256() vloc__13 := zero_value_for_type_t_uint256_1 diff --git a/test/cmdlineTests/ir_compiler_subobjects/output b/test/cmdlineTests/ir_compiler_subobjects/output index ddd500333..ee9ae8138 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/output +++ b/test/cmdlineTests/ir_compiler_subobjects/output @@ -64,12 +64,12 @@ object "D_16" { returndatacopy(_1, _1, returndatasize()) revert(_1, returndatasize()) } - return(allocateMemory(_1), _1) + return(allocate_memory(_1), _1) } } revert(0, 0) } - function allocateMemory(size) -> memPtr + function allocate_memory(size) -> memPtr { memPtr := mload(64) let newFreePtr := add(memPtr, and(add(size, 31), not(31))) diff --git a/test/cmdlineTests/name_simplifier/output b/test/cmdlineTests/name_simplifier/output index c403dc211..67d63a68c 100644 --- a/test/cmdlineTests/name_simplifier/output +++ b/test/cmdlineTests/name_simplifier/output @@ -35,7 +35,7 @@ object "C_59" { let _4 := calldataload(add(4, offset)) if gt(_4, _3) { panic_error_0x41() } let _5 := mul(_4, _2) - let dst := allocateMemory(add(_5, _2)) + let dst := allocate_memory(add(_5, _2)) let dst_1 := dst mstore(dst, _4) dst := add(dst, _2) @@ -45,14 +45,14 @@ object "C_59" { for { } lt(i, _4) { i := add(i, 1) } { if slt(sub(calldatasize(), src), _2) { revert(_1, _1) } - let value := allocateMemory(_2) + let value := allocate_memory(_2) mstore(value, calldataload(src)) mstore(dst, value) dst := add(dst, _2) src := add(src, _2) } let ret, ret_1 := fun_sumArray_58(dst_1) - let memPos := allocateMemory(_1) + let memPos := allocate_memory(_1) return(memPos, sub(abi_encode_uint256_t_string(memPos, ret, ret_1), memPos)) } } @@ -76,7 +76,7 @@ object "C_59" { } tail := add(add(headStart, and(add(length, 31), not(31))), 96) } - function allocateMemory(size) -> memPtr + function allocate_memory(size) -> memPtr { memPtr := mload(64) let newFreePtr := add(memPtr, and(add(size, 31), not(31))) @@ -85,7 +85,7 @@ object "C_59" { } function copy_literal_to_memory_64902fd228f7ef267f3b474dd6ef84bae434cf5546eee948e7ca26df3eda1927() -> memPtr { - let memPtr_1 := allocateMemory(160) + let memPtr_1 := allocate_memory(160) mstore(memPtr_1, 100) memPtr := memPtr_1 mstore(add(memPtr_1, 0x20), "longstringlongstringlongstringlo") diff --git a/test/cmdlineTests/optimizer_array_sload/output b/test/cmdlineTests/optimizer_array_sload/output index 8c8eafd0a..89646c926 100644 --- a/test/cmdlineTests/optimizer_array_sload/output +++ b/test/cmdlineTests/optimizer_array_sload/output @@ -40,7 +40,7 @@ object "Arraysum_34" { mstore(_1, _1) vloc_sum := checked_add_t_uint256(vloc_sum, sload(add(keccak256(_1, 0x20), vloc_i))) } - let memPos := allocateMemory(_1) + let memPos := allocate_memory(_1) return(memPos, sub(abi_encode_uint(memPos, vloc_sum), memPos)) } } @@ -51,7 +51,7 @@ object "Arraysum_34" { tail := add(headStart, 32) mstore(headStart, value0) } - function allocateMemory(size) -> memPtr + function allocate_memory(size) -> memPtr { memPtr := mload(64) let newFreePtr := add(memPtr, and(add(size, 31), not(31))) diff --git a/test/cmdlineTests/standard_generatedSources/output.json b/test/cmdlineTests/standard_generatedSources/output.json index 24c823afe..56c87b7ce 100644 --- a/test/cmdlineTests/standard_generatedSources/output.json +++ b/test/cmdlineTests/standard_generatedSources/output.json @@ -1,8 +1,8 @@ -{"contracts":{"a.sol":{"A":{"evm":{"bytecode":{"generatedSources":[],"object":""},"deployedBytecode":{"generatedSources":[{"ast":{"nodeType":"YulBlock","src":"0:3017:1","statements":[{"body":{"nodeType":"YulBlock","src":"126:520:1","statements":[{"nodeType":"YulAssignment","src":"136:89:1","value":{"arguments":[{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"217:6:1"}],"functionName":{"name":"array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"160:56:1"},"nodeType":"YulFunctionCall","src":"160:64:1"}],"functionName":{"name":"allocateMemory","nodeType":"YulIdentifier","src":"145:14:1"},"nodeType":"YulFunctionCall","src":"145:80:1"},"variableNames":[{"name":"array","nodeType":"YulIdentifier","src":"136:5:1"}]},{"nodeType":"YulVariableDeclaration","src":"234:16:1","value":{"name":"array","nodeType":"YulIdentifier","src":"245:5:1"},"variables":[{"name":"dst","nodeType":"YulTypedName","src":"238:3:1","type":""}]},{"expression":{"arguments":[{"name":"array","nodeType":"YulIdentifier","src":"266:5:1"},{"name":"length","nodeType":"YulIdentifier","src":"273:6:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"259:6:1"},"nodeType":"YulFunctionCall","src":"259:21:1"},"nodeType":"YulExpressionStatement","src":"259:21:1"},{"nodeType":"YulAssignment","src":"281:23:1","value":{"arguments":[{"name":"array","nodeType":"YulIdentifier","src":"292:5:1"},{"kind":"number","nodeType":"YulLiteral","src":"299:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"288:3:1"},"nodeType":"YulFunctionCall","src":"288:16:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"281:3:1"}]},{"nodeType":"YulVariableDeclaration","src":"313:17:1","value":{"name":"offset","nodeType":"YulIdentifier","src":"324:6:1"},"variables":[{"name":"src","nodeType":"YulTypedName","src":"317:3:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"379:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"388:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"391:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"381:6:1"},"nodeType":"YulFunctionCall","src":"381:12:1"},"nodeType":"YulExpressionStatement","src":"381:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"349:3:1"},{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"358:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"366:4:1","type":"","value":"0x20"}],"functionName":{"name":"mul","nodeType":"YulIdentifier","src":"354:3:1"},"nodeType":"YulFunctionCall","src":"354:17:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"345:3:1"},"nodeType":"YulFunctionCall","src":"345:27:1"},{"name":"end","nodeType":"YulIdentifier","src":"374:3:1"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"342:2:1"},"nodeType":"YulFunctionCall","src":"342:36:1"},"nodeType":"YulIf","src":"339:2:1"},{"body":{"nodeType":"YulBlock","src":"464:176:1","statements":[{"nodeType":"YulVariableDeclaration","src":"478:21:1","value":{"name":"src","nodeType":"YulIdentifier","src":"496:3:1"},"variables":[{"name":"elementPos","nodeType":"YulTypedName","src":"482:10:1","type":""}]},{"expression":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"519:3:1"},{"arguments":[{"name":"elementPos","nodeType":"YulIdentifier","src":"545:10:1"},{"name":"end","nodeType":"YulIdentifier","src":"557:3:1"}],"functionName":{"name":"abi_decode_t_uint256","nodeType":"YulIdentifier","src":"524:20:1"},"nodeType":"YulFunctionCall","src":"524:37:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"512:6:1"},"nodeType":"YulFunctionCall","src":"512:50:1"},"nodeType":"YulExpressionStatement","src":"512:50:1"},{"nodeType":"YulAssignment","src":"575:21:1","value":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"586:3:1"},{"kind":"number","nodeType":"YulLiteral","src":"591:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"582:3:1"},"nodeType":"YulFunctionCall","src":"582:14:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"575:3:1"}]},{"nodeType":"YulAssignment","src":"609:21:1","value":{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"620:3:1"},{"kind":"number","nodeType":"YulLiteral","src":"625:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"616:3:1"},"nodeType":"YulFunctionCall","src":"616:14:1"},"variableNames":[{"name":"src","nodeType":"YulIdentifier","src":"609:3:1"}]}]},"condition":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"426:1:1"},{"name":"length","nodeType":"YulIdentifier","src":"429:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"423:2:1"},"nodeType":"YulFunctionCall","src":"423:13:1"},"nodeType":"YulForLoop","post":{"nodeType":"YulBlock","src":"437:18:1","statements":[{"nodeType":"YulAssignment","src":"439:14:1","value":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"448:1:1"},{"kind":"number","nodeType":"YulLiteral","src":"451:1:1","type":"","value":"1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"444:3:1"},"nodeType":"YulFunctionCall","src":"444:9:1"},"variableNames":[{"name":"i","nodeType":"YulIdentifier","src":"439:1:1"}]}]},"pre":{"nodeType":"YulBlock","src":"408:14:1","statements":[{"nodeType":"YulVariableDeclaration","src":"410:10:1","value":{"kind":"number","nodeType":"YulLiteral","src":"419:1:1","type":"","value":"0"},"variables":[{"name":"i","nodeType":"YulTypedName","src":"414:1:1","type":""}]}]},"src":"404:236:1"}]},"name":"abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"96:6:1","type":""},{"name":"length","nodeType":"YulTypedName","src":"104:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"112:3:1","type":""}],"returnVariables":[{"name":"array","nodeType":"YulTypedName","src":"120:5:1","type":""}],"src":"24:622:1"},{"body":{"nodeType":"YulBlock","src":"746:226:1","statements":[{"body":{"nodeType":"YulBlock","src":"795:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"804:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"807:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"797:6:1"},"nodeType":"YulFunctionCall","src":"797:12:1"},"nodeType":"YulExpressionStatement","src":"797:12:1"}]},"condition":{"arguments":[{"arguments":[{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"774:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"782:4:1","type":"","value":"0x1f"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"770:3:1"},"nodeType":"YulFunctionCall","src":"770:17:1"},{"name":"end","nodeType":"YulIdentifier","src":"789:3:1"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"766:3:1"},"nodeType":"YulFunctionCall","src":"766:27:1"}],"functionName":{"name":"iszero","nodeType":"YulIdentifier","src":"759:6:1"},"nodeType":"YulFunctionCall","src":"759:35:1"},"nodeType":"YulIf","src":"756:2:1"},{"nodeType":"YulVariableDeclaration","src":"820:34:1","value":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"847:6:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"834:12:1"},"nodeType":"YulFunctionCall","src":"834:20:1"},"variables":[{"name":"length","nodeType":"YulTypedName","src":"824:6:1","type":""}]},{"nodeType":"YulAssignment","src":"863:103:1","value":{"arguments":[{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"939:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"947:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"935:3:1"},"nodeType":"YulFunctionCall","src":"935:17:1"},{"name":"length","nodeType":"YulIdentifier","src":"954:6:1"},{"name":"end","nodeType":"YulIdentifier","src":"962:3:1"}],"functionName":{"name":"abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"872:62:1"},"nodeType":"YulFunctionCall","src":"872:94:1"},"variableNames":[{"name":"array","nodeType":"YulIdentifier","src":"863:5:1"}]}]},"name":"abi_decode_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"724:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"732:3:1","type":""}],"returnVariables":[{"name":"array","nodeType":"YulTypedName","src":"740:5:1","type":""}],"src":"669:303:1"},{"body":{"nodeType":"YulBlock","src":"1030:87:1","statements":[{"nodeType":"YulAssignment","src":"1040:29:1","value":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"1062:6:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"1049:12:1"},"nodeType":"YulFunctionCall","src":"1049:20:1"},"variableNames":[{"name":"value","nodeType":"YulIdentifier","src":"1040:5:1"}]},{"expression":{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"1105:5:1"}],"functionName":{"name":"validator_revert_t_uint256","nodeType":"YulIdentifier","src":"1078:26:1"},"nodeType":"YulFunctionCall","src":"1078:33:1"},"nodeType":"YulExpressionStatement","src":"1078:33:1"}]},"name":"abi_decode_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"1008:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"1016:3:1","type":""}],"returnVariables":[{"name":"value","nodeType":"YulTypedName","src":"1024:5:1","type":""}],"src":"978:139:1"},{"body":{"nodeType":"YulBlock","src":"1214:314:1","statements":[{"body":{"nodeType":"YulBlock","src":"1260:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1269:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1272:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1262:6:1"},"nodeType":"YulFunctionCall","src":"1262:12:1"},"nodeType":"YulExpressionStatement","src":"1262:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"dataEnd","nodeType":"YulIdentifier","src":"1235:7:1"},{"name":"headStart","nodeType":"YulIdentifier","src":"1244:9:1"}],"functionName":{"name":"sub","nodeType":"YulIdentifier","src":"1231:3:1"},"nodeType":"YulFunctionCall","src":"1231:23:1"},{"kind":"number","nodeType":"YulLiteral","src":"1256:2:1","type":"","value":"32"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"1227:3:1"},"nodeType":"YulFunctionCall","src":"1227:32:1"},"nodeType":"YulIf","src":"1224:2:1"},{"nodeType":"YulBlock","src":"1286:235:1","statements":[{"nodeType":"YulVariableDeclaration","src":"1301:45:1","value":{"arguments":[{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1332:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1343:1:1","type":"","value":"0"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1328:3:1"},"nodeType":"YulFunctionCall","src":"1328:17:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"1315:12:1"},"nodeType":"YulFunctionCall","src":"1315:31:1"},"variables":[{"name":"offset","nodeType":"YulTypedName","src":"1305:6:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"1393:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1402:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1405:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1395:6:1"},"nodeType":"YulFunctionCall","src":"1395:12:1"},"nodeType":"YulExpressionStatement","src":"1395:12:1"}]},"condition":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"1365:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"1373:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"1362:2:1"},"nodeType":"YulFunctionCall","src":"1362:30:1"},"nodeType":"YulIf","src":"1359:2:1"},{"nodeType":"YulAssignment","src":"1423:88:1","value":{"arguments":[{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1483:9:1"},{"name":"offset","nodeType":"YulIdentifier","src":"1494:6:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1479:3:1"},"nodeType":"YulFunctionCall","src":"1479:22:1"},{"name":"dataEnd","nodeType":"YulIdentifier","src":"1503:7:1"}],"functionName":{"name":"abi_decode_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"1433:45:1"},"nodeType":"YulFunctionCall","src":"1433:78:1"},"variableNames":[{"name":"value0","nodeType":"YulIdentifier","src":"1423:6:1"}]}]}]},"name":"abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"1184:9:1","type":""},{"name":"dataEnd","nodeType":"YulTypedName","src":"1195:7:1","type":""}],"returnVariables":[{"name":"value0","nodeType":"YulTypedName","src":"1207:6:1","type":""}],"src":"1123:405:1"},{"body":{"nodeType":"YulBlock","src":"1599:53:1","statements":[{"expression":{"arguments":[{"name":"pos","nodeType":"YulIdentifier","src":"1616:3:1"},{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"1639:5:1"}],"functionName":{"name":"cleanup_t_uint256","nodeType":"YulIdentifier","src":"1621:17:1"},"nodeType":"YulFunctionCall","src":"1621:24:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"1609:6:1"},"nodeType":"YulFunctionCall","src":"1609:37:1"},"nodeType":"YulExpressionStatement","src":"1609:37:1"}]},"name":"abi_encode_t_uint256_to_t_uint256_fromStack","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"1587:5:1","type":""},{"name":"pos","nodeType":"YulTypedName","src":"1594:3:1","type":""}],"src":"1534:118:1"},{"body":{"nodeType":"YulBlock","src":"1756:124:1","statements":[{"nodeType":"YulAssignment","src":"1766:26:1","value":{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1778:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1789:2:1","type":"","value":"32"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1774:3:1"},"nodeType":"YulFunctionCall","src":"1774:18:1"},"variableNames":[{"name":"tail","nodeType":"YulIdentifier","src":"1766:4:1"}]},{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"1846:6:1"},{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1859:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1870:1:1","type":"","value":"0"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1855:3:1"},"nodeType":"YulFunctionCall","src":"1855:17:1"}],"functionName":{"name":"abi_encode_t_uint256_to_t_uint256_fromStack","nodeType":"YulIdentifier","src":"1802:43:1"},"nodeType":"YulFunctionCall","src":"1802:71:1"},"nodeType":"YulExpressionStatement","src":"1802:71:1"}]},"name":"abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"1728:9:1","type":""},{"name":"value0","nodeType":"YulTypedName","src":"1740:6:1","type":""}],"returnVariables":[{"name":"tail","nodeType":"YulTypedName","src":"1751:4:1","type":""}],"src":"1658:222:1"},{"body":{"nodeType":"YulBlock","src":"1926:266:1","statements":[{"nodeType":"YulAssignment","src":"1936:19:1","value":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1952:2:1","type":"","value":"64"}],"functionName":{"name":"mload","nodeType":"YulIdentifier","src":"1946:5:1"},"nodeType":"YulFunctionCall","src":"1946:9:1"},"variableNames":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1936:6:1"}]},{"nodeType":"YulVariableDeclaration","src":"1964:58:1","value":{"arguments":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1986:6:1"},{"arguments":[{"name":"size","nodeType":"YulIdentifier","src":"2016:4:1"}],"functionName":{"name":"round_up_to_mul_of_32","nodeType":"YulIdentifier","src":"1994:21:1"},"nodeType":"YulFunctionCall","src":"1994:27:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1982:3:1"},"nodeType":"YulFunctionCall","src":"1982:40:1"},"variables":[{"name":"newFreePtr","nodeType":"YulTypedName","src":"1968:10:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"2133:22:1","statements":[{"expression":{"arguments":[],"functionName":{"name":"panic_error_0x41","nodeType":"YulIdentifier","src":"2135:16:1"},"nodeType":"YulFunctionCall","src":"2135:18:1"},"nodeType":"YulExpressionStatement","src":"2135:18:1"}]},"condition":{"arguments":[{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"2076:10:1"},{"kind":"number","nodeType":"YulLiteral","src":"2088:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"2073:2:1"},"nodeType":"YulFunctionCall","src":"2073:34:1"},{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"2112:10:1"},{"name":"memPtr","nodeType":"YulIdentifier","src":"2124:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"2109:2:1"},"nodeType":"YulFunctionCall","src":"2109:22:1"}],"functionName":{"name":"or","nodeType":"YulIdentifier","src":"2070:2:1"},"nodeType":"YulFunctionCall","src":"2070:62:1"},"nodeType":"YulIf","src":"2067:2:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2171:2:1","type":"","value":"64"},{"name":"newFreePtr","nodeType":"YulIdentifier","src":"2175:10:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"2164:6:1"},"nodeType":"YulFunctionCall","src":"2164:22:1"},"nodeType":"YulExpressionStatement","src":"2164:22:1"}]},"name":"allocateMemory","nodeType":"YulFunctionDefinition","parameters":[{"name":"size","nodeType":"YulTypedName","src":"1910:4:1","type":""}],"returnVariables":[{"name":"memPtr","nodeType":"YulTypedName","src":"1919:6:1","type":""}],"src":"1886:306:1"},{"body":{"nodeType":"YulBlock","src":"2280:229:1","statements":[{"body":{"nodeType":"YulBlock","src":"2385:22:1","statements":[{"expression":{"arguments":[],"functionName":{"name":"panic_error_0x41","nodeType":"YulIdentifier","src":"2387:16:1"},"nodeType":"YulFunctionCall","src":"2387:18:1"},"nodeType":"YulExpressionStatement","src":"2387:18:1"}]},"condition":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"2357:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"2365:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"2354:2:1"},"nodeType":"YulFunctionCall","src":"2354:30:1"},"nodeType":"YulIf","src":"2351:2:1"},{"nodeType":"YulAssignment","src":"2417:25:1","value":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"2429:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"2437:4:1","type":"","value":"0x20"}],"functionName":{"name":"mul","nodeType":"YulIdentifier","src":"2425:3:1"},"nodeType":"YulFunctionCall","src":"2425:17:1"},"variableNames":[{"name":"size","nodeType":"YulIdentifier","src":"2417:4:1"}]},{"nodeType":"YulAssignment","src":"2479:23:1","value":{"arguments":[{"name":"size","nodeType":"YulIdentifier","src":"2491:4:1"},{"kind":"number","nodeType":"YulLiteral","src":"2497:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"2487:3:1"},"nodeType":"YulFunctionCall","src":"2487:15:1"},"variableNames":[{"name":"size","nodeType":"YulIdentifier","src":"2479:4:1"}]}]},"name":"array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"length","nodeType":"YulTypedName","src":"2264:6:1","type":""}],"returnVariables":[{"name":"size","nodeType":"YulTypedName","src":"2275:4:1","type":""}],"src":"2198:311:1"},{"body":{"nodeType":"YulBlock","src":"2560:32:1","statements":[{"nodeType":"YulAssignment","src":"2570:16:1","value":{"name":"value","nodeType":"YulIdentifier","src":"2581:5:1"},"variableNames":[{"name":"cleaned","nodeType":"YulIdentifier","src":"2570:7:1"}]}]},"name":"cleanup_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"2542:5:1","type":""}],"returnVariables":[{"name":"cleaned","nodeType":"YulTypedName","src":"2552:7:1","type":""}],"src":"2515:77:1"},{"body":{"nodeType":"YulBlock","src":"2626:152:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2643:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"2646:77:1","type":"","value":"35408467139433450592217433187231851964531694900788300625387963629091585785856"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"2636:6:1"},"nodeType":"YulFunctionCall","src":"2636:88:1"},"nodeType":"YulExpressionStatement","src":"2636:88:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2740:1:1","type":"","value":"4"},{"kind":"number","nodeType":"YulLiteral","src":"2743:4:1","type":"","value":"0x41"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"2733:6:1"},"nodeType":"YulFunctionCall","src":"2733:15:1"},"nodeType":"YulExpressionStatement","src":"2733:15:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2764:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"2767:4:1","type":"","value":"0x24"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"2757:6:1"},"nodeType":"YulFunctionCall","src":"2757:15:1"},"nodeType":"YulExpressionStatement","src":"2757:15:1"}]},"name":"panic_error_0x41","nodeType":"YulFunctionDefinition","src":"2598:180:1"},{"body":{"nodeType":"YulBlock","src":"2832:54:1","statements":[{"nodeType":"YulAssignment","src":"2842:38:1","value":{"arguments":[{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"2860:5:1"},{"kind":"number","nodeType":"YulLiteral","src":"2867:2:1","type":"","value":"31"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"2856:3:1"},"nodeType":"YulFunctionCall","src":"2856:14:1"},{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2876:2:1","type":"","value":"31"}],"functionName":{"name":"not","nodeType":"YulIdentifier","src":"2872:3:1"},"nodeType":"YulFunctionCall","src":"2872:7:1"}],"functionName":{"name":"and","nodeType":"YulIdentifier","src":"2852:3:1"},"nodeType":"YulFunctionCall","src":"2852:28:1"},"variableNames":[{"name":"result","nodeType":"YulIdentifier","src":"2842:6:1"}]}]},"name":"round_up_to_mul_of_32","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"2815:5:1","type":""}],"returnVariables":[{"name":"result","nodeType":"YulTypedName","src":"2825:6:1","type":""}],"src":"2784:102:1"},{"body":{"nodeType":"YulBlock","src":"2935:79:1","statements":[{"body":{"nodeType":"YulBlock","src":"2992:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"3001:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"3004:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"2994:6:1"},"nodeType":"YulFunctionCall","src":"2994:12:1"},"nodeType":"YulExpressionStatement","src":"2994:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"2958:5:1"},{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"2983:5:1"}],"functionName":{"name":"cleanup_t_uint256","nodeType":"YulIdentifier","src":"2965:17:1"},"nodeType":"YulFunctionCall","src":"2965:24:1"}],"functionName":{"name":"eq","nodeType":"YulIdentifier","src":"2955:2:1"},"nodeType":"YulFunctionCall","src":"2955:35:1"}],"functionName":{"name":"iszero","nodeType":"YulIdentifier","src":"2948:6:1"},"nodeType":"YulFunctionCall","src":"2948:43:1"},"nodeType":"YulIf","src":"2945:2:1"}]},"name":"validator_revert_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"2928:5:1","type":""}],"src":"2892:122:1"}]},"contents":"{ +{"contracts":{"a.sol":{"A":{"evm":{"bytecode":{"generatedSources":[],"object":""},"deployedBytecode":{"generatedSources":[{"ast":{"nodeType":"YulBlock","src":"0:3209:1","statements":[{"body":{"nodeType":"YulBlock","src":"126:521:1","statements":[{"nodeType":"YulAssignment","src":"136:90:1","value":{"arguments":[{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"218:6:1"}],"functionName":{"name":"array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"161:56:1"},"nodeType":"YulFunctionCall","src":"161:64:1"}],"functionName":{"name":"allocate_memory","nodeType":"YulIdentifier","src":"145:15:1"},"nodeType":"YulFunctionCall","src":"145:81:1"},"variableNames":[{"name":"array","nodeType":"YulIdentifier","src":"136:5:1"}]},{"nodeType":"YulVariableDeclaration","src":"235:16:1","value":{"name":"array","nodeType":"YulIdentifier","src":"246:5:1"},"variables":[{"name":"dst","nodeType":"YulTypedName","src":"239:3:1","type":""}]},{"expression":{"arguments":[{"name":"array","nodeType":"YulIdentifier","src":"267:5:1"},{"name":"length","nodeType":"YulIdentifier","src":"274:6:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"260:6:1"},"nodeType":"YulFunctionCall","src":"260:21:1"},"nodeType":"YulExpressionStatement","src":"260:21:1"},{"nodeType":"YulAssignment","src":"282:23:1","value":{"arguments":[{"name":"array","nodeType":"YulIdentifier","src":"293:5:1"},{"kind":"number","nodeType":"YulLiteral","src":"300:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"289:3:1"},"nodeType":"YulFunctionCall","src":"289:16:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"282:3:1"}]},{"nodeType":"YulVariableDeclaration","src":"314:17:1","value":{"name":"offset","nodeType":"YulIdentifier","src":"325:6:1"},"variables":[{"name":"src","nodeType":"YulTypedName","src":"318:3:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"380:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"389:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"392:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"382:6:1"},"nodeType":"YulFunctionCall","src":"382:12:1"},"nodeType":"YulExpressionStatement","src":"382:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"350:3:1"},{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"359:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"367:4:1","type":"","value":"0x20"}],"functionName":{"name":"mul","nodeType":"YulIdentifier","src":"355:3:1"},"nodeType":"YulFunctionCall","src":"355:17:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"346:3:1"},"nodeType":"YulFunctionCall","src":"346:27:1"},{"name":"end","nodeType":"YulIdentifier","src":"375:3:1"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"343:2:1"},"nodeType":"YulFunctionCall","src":"343:36:1"},"nodeType":"YulIf","src":"340:2:1"},{"body":{"nodeType":"YulBlock","src":"465:176:1","statements":[{"nodeType":"YulVariableDeclaration","src":"479:21:1","value":{"name":"src","nodeType":"YulIdentifier","src":"497:3:1"},"variables":[{"name":"elementPos","nodeType":"YulTypedName","src":"483:10:1","type":""}]},{"expression":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"520:3:1"},{"arguments":[{"name":"elementPos","nodeType":"YulIdentifier","src":"546:10:1"},{"name":"end","nodeType":"YulIdentifier","src":"558:3:1"}],"functionName":{"name":"abi_decode_t_uint256","nodeType":"YulIdentifier","src":"525:20:1"},"nodeType":"YulFunctionCall","src":"525:37:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"513:6:1"},"nodeType":"YulFunctionCall","src":"513:50:1"},"nodeType":"YulExpressionStatement","src":"513:50:1"},{"nodeType":"YulAssignment","src":"576:21:1","value":{"arguments":[{"name":"dst","nodeType":"YulIdentifier","src":"587:3:1"},{"kind":"number","nodeType":"YulLiteral","src":"592:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"583:3:1"},"nodeType":"YulFunctionCall","src":"583:14:1"},"variableNames":[{"name":"dst","nodeType":"YulIdentifier","src":"576:3:1"}]},{"nodeType":"YulAssignment","src":"610:21:1","value":{"arguments":[{"name":"src","nodeType":"YulIdentifier","src":"621:3:1"},{"kind":"number","nodeType":"YulLiteral","src":"626:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"617:3:1"},"nodeType":"YulFunctionCall","src":"617:14:1"},"variableNames":[{"name":"src","nodeType":"YulIdentifier","src":"610:3:1"}]}]},"condition":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"427:1:1"},{"name":"length","nodeType":"YulIdentifier","src":"430:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"424:2:1"},"nodeType":"YulFunctionCall","src":"424:13:1"},"nodeType":"YulForLoop","post":{"nodeType":"YulBlock","src":"438:18:1","statements":[{"nodeType":"YulAssignment","src":"440:14:1","value":{"arguments":[{"name":"i","nodeType":"YulIdentifier","src":"449:1:1"},{"kind":"number","nodeType":"YulLiteral","src":"452:1:1","type":"","value":"1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"445:3:1"},"nodeType":"YulFunctionCall","src":"445:9:1"},"variableNames":[{"name":"i","nodeType":"YulIdentifier","src":"440:1:1"}]}]},"pre":{"nodeType":"YulBlock","src":"409:14:1","statements":[{"nodeType":"YulVariableDeclaration","src":"411:10:1","value":{"kind":"number","nodeType":"YulLiteral","src":"420:1:1","type":"","value":"0"},"variables":[{"name":"i","nodeType":"YulTypedName","src":"415:1:1","type":""}]}]},"src":"405:236:1"}]},"name":"abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"96:6:1","type":""},{"name":"length","nodeType":"YulTypedName","src":"104:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"112:3:1","type":""}],"returnVariables":[{"name":"array","nodeType":"YulTypedName","src":"120:5:1","type":""}],"src":"24:623:1"},{"body":{"nodeType":"YulBlock","src":"747:226:1","statements":[{"body":{"nodeType":"YulBlock","src":"796:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"805:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"808:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"798:6:1"},"nodeType":"YulFunctionCall","src":"798:12:1"},"nodeType":"YulExpressionStatement","src":"798:12:1"}]},"condition":{"arguments":[{"arguments":[{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"775:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"783:4:1","type":"","value":"0x1f"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"771:3:1"},"nodeType":"YulFunctionCall","src":"771:17:1"},{"name":"end","nodeType":"YulIdentifier","src":"790:3:1"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"767:3:1"},"nodeType":"YulFunctionCall","src":"767:27:1"}],"functionName":{"name":"iszero","nodeType":"YulIdentifier","src":"760:6:1"},"nodeType":"YulFunctionCall","src":"760:35:1"},"nodeType":"YulIf","src":"757:2:1"},{"nodeType":"YulVariableDeclaration","src":"821:34:1","value":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"848:6:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"835:12:1"},"nodeType":"YulFunctionCall","src":"835:20:1"},"variables":[{"name":"length","nodeType":"YulTypedName","src":"825:6:1","type":""}]},{"nodeType":"YulAssignment","src":"864:103:1","value":{"arguments":[{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"940:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"948:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"936:3:1"},"nodeType":"YulFunctionCall","src":"936:17:1"},{"name":"length","nodeType":"YulIdentifier","src":"955:6:1"},{"name":"end","nodeType":"YulIdentifier","src":"963:3:1"}],"functionName":{"name":"abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"873:62:1"},"nodeType":"YulFunctionCall","src":"873:94:1"},"variableNames":[{"name":"array","nodeType":"YulIdentifier","src":"864:5:1"}]}]},"name":"abi_decode_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"725:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"733:3:1","type":""}],"returnVariables":[{"name":"array","nodeType":"YulTypedName","src":"741:5:1","type":""}],"src":"670:303:1"},{"body":{"nodeType":"YulBlock","src":"1031:87:1","statements":[{"nodeType":"YulAssignment","src":"1041:29:1","value":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"1063:6:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"1050:12:1"},"nodeType":"YulFunctionCall","src":"1050:20:1"},"variableNames":[{"name":"value","nodeType":"YulIdentifier","src":"1041:5:1"}]},{"expression":{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"1106:5:1"}],"functionName":{"name":"validator_revert_t_uint256","nodeType":"YulIdentifier","src":"1079:26:1"},"nodeType":"YulFunctionCall","src":"1079:33:1"},"nodeType":"YulExpressionStatement","src":"1079:33:1"}]},"name":"abi_decode_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"offset","nodeType":"YulTypedName","src":"1009:6:1","type":""},{"name":"end","nodeType":"YulTypedName","src":"1017:3:1","type":""}],"returnVariables":[{"name":"value","nodeType":"YulTypedName","src":"1025:5:1","type":""}],"src":"979:139:1"},{"body":{"nodeType":"YulBlock","src":"1215:314:1","statements":[{"body":{"nodeType":"YulBlock","src":"1261:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1270:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1273:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1263:6:1"},"nodeType":"YulFunctionCall","src":"1263:12:1"},"nodeType":"YulExpressionStatement","src":"1263:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"dataEnd","nodeType":"YulIdentifier","src":"1236:7:1"},{"name":"headStart","nodeType":"YulIdentifier","src":"1245:9:1"}],"functionName":{"name":"sub","nodeType":"YulIdentifier","src":"1232:3:1"},"nodeType":"YulFunctionCall","src":"1232:23:1"},{"kind":"number","nodeType":"YulLiteral","src":"1257:2:1","type":"","value":"32"}],"functionName":{"name":"slt","nodeType":"YulIdentifier","src":"1228:3:1"},"nodeType":"YulFunctionCall","src":"1228:32:1"},"nodeType":"YulIf","src":"1225:2:1"},{"nodeType":"YulBlock","src":"1287:235:1","statements":[{"nodeType":"YulVariableDeclaration","src":"1302:45:1","value":{"arguments":[{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1333:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1344:1:1","type":"","value":"0"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1329:3:1"},"nodeType":"YulFunctionCall","src":"1329:17:1"}],"functionName":{"name":"calldataload","nodeType":"YulIdentifier","src":"1316:12:1"},"nodeType":"YulFunctionCall","src":"1316:31:1"},"variables":[{"name":"offset","nodeType":"YulTypedName","src":"1306:6:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"1394:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"1403:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"1406:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"1396:6:1"},"nodeType":"YulFunctionCall","src":"1396:12:1"},"nodeType":"YulExpressionStatement","src":"1396:12:1"}]},"condition":{"arguments":[{"name":"offset","nodeType":"YulIdentifier","src":"1366:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"1374:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"1363:2:1"},"nodeType":"YulFunctionCall","src":"1363:30:1"},"nodeType":"YulIf","src":"1360:2:1"},{"nodeType":"YulAssignment","src":"1424:88:1","value":{"arguments":[{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1484:9:1"},{"name":"offset","nodeType":"YulIdentifier","src":"1495:6:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1480:3:1"},"nodeType":"YulFunctionCall","src":"1480:22:1"},{"name":"dataEnd","nodeType":"YulIdentifier","src":"1504:7:1"}],"functionName":{"name":"abi_decode_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulIdentifier","src":"1434:45:1"},"nodeType":"YulFunctionCall","src":"1434:78:1"},"variableNames":[{"name":"value0","nodeType":"YulIdentifier","src":"1424:6:1"}]}]}]},"name":"abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"1185:9:1","type":""},{"name":"dataEnd","nodeType":"YulTypedName","src":"1196:7:1","type":""}],"returnVariables":[{"name":"value0","nodeType":"YulTypedName","src":"1208:6:1","type":""}],"src":"1124:405:1"},{"body":{"nodeType":"YulBlock","src":"1600:53:1","statements":[{"expression":{"arguments":[{"name":"pos","nodeType":"YulIdentifier","src":"1617:3:1"},{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"1640:5:1"}],"functionName":{"name":"cleanup_t_uint256","nodeType":"YulIdentifier","src":"1622:17:1"},"nodeType":"YulFunctionCall","src":"1622:24:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"1610:6:1"},"nodeType":"YulFunctionCall","src":"1610:37:1"},"nodeType":"YulExpressionStatement","src":"1610:37:1"}]},"name":"abi_encode_t_uint256_to_t_uint256_fromStack","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"1588:5:1","type":""},{"name":"pos","nodeType":"YulTypedName","src":"1595:3:1","type":""}],"src":"1535:118:1"},{"body":{"nodeType":"YulBlock","src":"1757:124:1","statements":[{"nodeType":"YulAssignment","src":"1767:26:1","value":{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1779:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1790:2:1","type":"","value":"32"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1775:3:1"},"nodeType":"YulFunctionCall","src":"1775:18:1"},"variableNames":[{"name":"tail","nodeType":"YulIdentifier","src":"1767:4:1"}]},{"expression":{"arguments":[{"name":"value0","nodeType":"YulIdentifier","src":"1847:6:1"},{"arguments":[{"name":"headStart","nodeType":"YulIdentifier","src":"1860:9:1"},{"kind":"number","nodeType":"YulLiteral","src":"1871:1:1","type":"","value":"0"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"1856:3:1"},"nodeType":"YulFunctionCall","src":"1856:17:1"}],"functionName":{"name":"abi_encode_t_uint256_to_t_uint256_fromStack","nodeType":"YulIdentifier","src":"1803:43:1"},"nodeType":"YulFunctionCall","src":"1803:71:1"},"nodeType":"YulExpressionStatement","src":"1803:71:1"}]},"name":"abi_encode_tuple_t_uint256__to_t_uint256__fromStack_reversed","nodeType":"YulFunctionDefinition","parameters":[{"name":"headStart","nodeType":"YulTypedName","src":"1729:9:1","type":""},{"name":"value0","nodeType":"YulTypedName","src":"1741:6:1","type":""}],"returnVariables":[{"name":"tail","nodeType":"YulTypedName","src":"1752:4:1","type":""}],"src":"1659:222:1"},{"body":{"nodeType":"YulBlock","src":"1928:88:1","statements":[{"nodeType":"YulAssignment","src":"1938:30:1","value":{"arguments":[],"functionName":{"name":"allocate_unbounded","nodeType":"YulIdentifier","src":"1948:18:1"},"nodeType":"YulFunctionCall","src":"1948:20:1"},"variableNames":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1938:6:1"}]},{"expression":{"arguments":[{"name":"memPtr","nodeType":"YulIdentifier","src":"1997:6:1"},{"name":"size","nodeType":"YulIdentifier","src":"2005:4:1"}],"functionName":{"name":"finalize_allocation","nodeType":"YulIdentifier","src":"1977:19:1"},"nodeType":"YulFunctionCall","src":"1977:33:1"},"nodeType":"YulExpressionStatement","src":"1977:33:1"}]},"name":"allocate_memory","nodeType":"YulFunctionDefinition","parameters":[{"name":"size","nodeType":"YulTypedName","src":"1912:4:1","type":""}],"returnVariables":[{"name":"memPtr","nodeType":"YulTypedName","src":"1921:6:1","type":""}],"src":"1887:129:1"},{"body":{"nodeType":"YulBlock","src":"2062:35:1","statements":[{"nodeType":"YulAssignment","src":"2072:19:1","value":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2088:2:1","type":"","value":"64"}],"functionName":{"name":"mload","nodeType":"YulIdentifier","src":"2082:5:1"},"nodeType":"YulFunctionCall","src":"2082:9:1"},"variableNames":[{"name":"memPtr","nodeType":"YulIdentifier","src":"2072:6:1"}]}]},"name":"allocate_unbounded","nodeType":"YulFunctionDefinition","returnVariables":[{"name":"memPtr","nodeType":"YulTypedName","src":"2055:6:1","type":""}],"src":"2022:75:1"},{"body":{"nodeType":"YulBlock","src":"2185:229:1","statements":[{"body":{"nodeType":"YulBlock","src":"2290:22:1","statements":[{"expression":{"arguments":[],"functionName":{"name":"panic_error_0x41","nodeType":"YulIdentifier","src":"2292:16:1"},"nodeType":"YulFunctionCall","src":"2292:18:1"},"nodeType":"YulExpressionStatement","src":"2292:18:1"}]},"condition":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"2262:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"2270:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"2259:2:1"},"nodeType":"YulFunctionCall","src":"2259:30:1"},"nodeType":"YulIf","src":"2256:2:1"},{"nodeType":"YulAssignment","src":"2322:25:1","value":{"arguments":[{"name":"length","nodeType":"YulIdentifier","src":"2334:6:1"},{"kind":"number","nodeType":"YulLiteral","src":"2342:4:1","type":"","value":"0x20"}],"functionName":{"name":"mul","nodeType":"YulIdentifier","src":"2330:3:1"},"nodeType":"YulFunctionCall","src":"2330:17:1"},"variableNames":[{"name":"size","nodeType":"YulIdentifier","src":"2322:4:1"}]},{"nodeType":"YulAssignment","src":"2384:23:1","value":{"arguments":[{"name":"size","nodeType":"YulIdentifier","src":"2396:4:1"},{"kind":"number","nodeType":"YulLiteral","src":"2402:4:1","type":"","value":"0x20"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"2392:3:1"},"nodeType":"YulFunctionCall","src":"2392:15:1"},"variableNames":[{"name":"size","nodeType":"YulIdentifier","src":"2384:4:1"}]}]},"name":"array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr","nodeType":"YulFunctionDefinition","parameters":[{"name":"length","nodeType":"YulTypedName","src":"2169:6:1","type":""}],"returnVariables":[{"name":"size","nodeType":"YulTypedName","src":"2180:4:1","type":""}],"src":"2103:311:1"},{"body":{"nodeType":"YulBlock","src":"2465:32:1","statements":[{"nodeType":"YulAssignment","src":"2475:16:1","value":{"name":"value","nodeType":"YulIdentifier","src":"2486:5:1"},"variableNames":[{"name":"cleaned","nodeType":"YulIdentifier","src":"2475:7:1"}]}]},"name":"cleanup_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"2447:5:1","type":""}],"returnVariables":[{"name":"cleaned","nodeType":"YulTypedName","src":"2457:7:1","type":""}],"src":"2420:77:1"},{"body":{"nodeType":"YulBlock","src":"2546:238:1","statements":[{"nodeType":"YulVariableDeclaration","src":"2556:58:1","value":{"arguments":[{"name":"memPtr","nodeType":"YulIdentifier","src":"2578:6:1"},{"arguments":[{"name":"size","nodeType":"YulIdentifier","src":"2608:4:1"}],"functionName":{"name":"round_up_to_mul_of_32","nodeType":"YulIdentifier","src":"2586:21:1"},"nodeType":"YulFunctionCall","src":"2586:27:1"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"2574:3:1"},"nodeType":"YulFunctionCall","src":"2574:40:1"},"variables":[{"name":"newFreePtr","nodeType":"YulTypedName","src":"2560:10:1","type":""}]},{"body":{"nodeType":"YulBlock","src":"2725:22:1","statements":[{"expression":{"arguments":[],"functionName":{"name":"panic_error_0x41","nodeType":"YulIdentifier","src":"2727:16:1"},"nodeType":"YulFunctionCall","src":"2727:18:1"},"nodeType":"YulExpressionStatement","src":"2727:18:1"}]},"condition":{"arguments":[{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"2668:10:1"},{"kind":"number","nodeType":"YulLiteral","src":"2680:18:1","type":"","value":"0xffffffffffffffff"}],"functionName":{"name":"gt","nodeType":"YulIdentifier","src":"2665:2:1"},"nodeType":"YulFunctionCall","src":"2665:34:1"},{"arguments":[{"name":"newFreePtr","nodeType":"YulIdentifier","src":"2704:10:1"},{"name":"memPtr","nodeType":"YulIdentifier","src":"2716:6:1"}],"functionName":{"name":"lt","nodeType":"YulIdentifier","src":"2701:2:1"},"nodeType":"YulFunctionCall","src":"2701:22:1"}],"functionName":{"name":"or","nodeType":"YulIdentifier","src":"2662:2:1"},"nodeType":"YulFunctionCall","src":"2662:62:1"},"nodeType":"YulIf","src":"2659:2:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2763:2:1","type":"","value":"64"},{"name":"newFreePtr","nodeType":"YulIdentifier","src":"2767:10:1"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"2756:6:1"},"nodeType":"YulFunctionCall","src":"2756:22:1"},"nodeType":"YulExpressionStatement","src":"2756:22:1"}]},"name":"finalize_allocation","nodeType":"YulFunctionDefinition","parameters":[{"name":"memPtr","nodeType":"YulTypedName","src":"2532:6:1","type":""},{"name":"size","nodeType":"YulTypedName","src":"2540:4:1","type":""}],"src":"2503:281:1"},{"body":{"nodeType":"YulBlock","src":"2818:152:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2835:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"2838:77:1","type":"","value":"35408467139433450592217433187231851964531694900788300625387963629091585785856"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"2828:6:1"},"nodeType":"YulFunctionCall","src":"2828:88:1"},"nodeType":"YulExpressionStatement","src":"2828:88:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2932:1:1","type":"","value":"4"},{"kind":"number","nodeType":"YulLiteral","src":"2935:4:1","type":"","value":"0x41"}],"functionName":{"name":"mstore","nodeType":"YulIdentifier","src":"2925:6:1"},"nodeType":"YulFunctionCall","src":"2925:15:1"},"nodeType":"YulExpressionStatement","src":"2925:15:1"},{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"2956:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"2959:4:1","type":"","value":"0x24"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"2949:6:1"},"nodeType":"YulFunctionCall","src":"2949:15:1"},"nodeType":"YulExpressionStatement","src":"2949:15:1"}]},"name":"panic_error_0x41","nodeType":"YulFunctionDefinition","src":"2790:180:1"},{"body":{"nodeType":"YulBlock","src":"3024:54:1","statements":[{"nodeType":"YulAssignment","src":"3034:38:1","value":{"arguments":[{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"3052:5:1"},{"kind":"number","nodeType":"YulLiteral","src":"3059:2:1","type":"","value":"31"}],"functionName":{"name":"add","nodeType":"YulIdentifier","src":"3048:3:1"},"nodeType":"YulFunctionCall","src":"3048:14:1"},{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"3068:2:1","type":"","value":"31"}],"functionName":{"name":"not","nodeType":"YulIdentifier","src":"3064:3:1"},"nodeType":"YulFunctionCall","src":"3064:7:1"}],"functionName":{"name":"and","nodeType":"YulIdentifier","src":"3044:3:1"},"nodeType":"YulFunctionCall","src":"3044:28:1"},"variableNames":[{"name":"result","nodeType":"YulIdentifier","src":"3034:6:1"}]}]},"name":"round_up_to_mul_of_32","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"3007:5:1","type":""}],"returnVariables":[{"name":"result","nodeType":"YulTypedName","src":"3017:6:1","type":""}],"src":"2976:102:1"},{"body":{"nodeType":"YulBlock","src":"3127:79:1","statements":[{"body":{"nodeType":"YulBlock","src":"3184:16:1","statements":[{"expression":{"arguments":[{"kind":"number","nodeType":"YulLiteral","src":"3193:1:1","type":"","value":"0"},{"kind":"number","nodeType":"YulLiteral","src":"3196:1:1","type":"","value":"0"}],"functionName":{"name":"revert","nodeType":"YulIdentifier","src":"3186:6:1"},"nodeType":"YulFunctionCall","src":"3186:12:1"},"nodeType":"YulExpressionStatement","src":"3186:12:1"}]},"condition":{"arguments":[{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"3150:5:1"},{"arguments":[{"name":"value","nodeType":"YulIdentifier","src":"3175:5:1"}],"functionName":{"name":"cleanup_t_uint256","nodeType":"YulIdentifier","src":"3157:17:1"},"nodeType":"YulFunctionCall","src":"3157:24:1"}],"functionName":{"name":"eq","nodeType":"YulIdentifier","src":"3147:2:1"},"nodeType":"YulFunctionCall","src":"3147:35:1"}],"functionName":{"name":"iszero","nodeType":"YulIdentifier","src":"3140:6:1"},"nodeType":"YulFunctionCall","src":"3140:43:1"},"nodeType":"YulIf","src":"3137:2:1"}]},"name":"validator_revert_t_uint256","nodeType":"YulFunctionDefinition","parameters":[{"name":"value","nodeType":"YulTypedName","src":"3120:5:1","type":""}],"src":"3084:122:1"}]},"contents":"{ // uint256[] function abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr(offset, length, end) -> array { - array := allocateMemory(array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr(length)) + array := allocate_memory(array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr(length)) let dst := array mstore(array, length) dst := add(array, 0x20) let src := offset @@ -52,12 +52,13 @@ } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) } function array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr(length) -> size { @@ -75,6 +76,13 @@ cleaned := value } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function panic_error_0x41() { mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(4, 0x41) diff --git a/test/cmdlineTests/standard_irOptimized_requested/output.json b/test/cmdlineTests/standard_irOptimized_requested/output.json index 089caea4d..a689809b7 100644 --- a/test/cmdlineTests/standard_irOptimized_requested/output.json +++ b/test/cmdlineTests/standard_irOptimized_requested/output.json @@ -26,7 +26,7 @@ object \"C_7\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) fun_f_6() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple__to__fromStack(memPos) return(memPos, sub(memEnd, memPos)) } @@ -40,9 +40,15 @@ object \"C_7\" { } function abi_encode_tuple__to__fromStack(headStart) -> tail { tail := add(headStart, 0) } - function allocateMemory(size) -> memPtr + function allocate_memory(size) -> memPtr + { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + function allocate_unbounded() -> memPtr + { memPtr := mload(64) } + function finalize_allocation(memPtr, size) { - memPtr := mload(64) let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } mstore(64, newFreePtr) diff --git a/test/cmdlineTests/standard_ir_requested/output.json b/test/cmdlineTests/standard_ir_requested/output.json index d96c7d206..392ba22aa 100644 --- a/test/cmdlineTests/standard_ir_requested/output.json +++ b/test/cmdlineTests/standard_ir_requested/output.json @@ -38,7 +38,7 @@ object \"C_7\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) fun_f_6() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple__to__fromStack(memPos ) return(memPos, sub(memEnd, memPos)) } @@ -58,8 +58,16 @@ object \"C_7\" { } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) + } + + function finalize_allocation(memPtr, size) { let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) // protect against overflow if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } diff --git a/test/cmdlineTests/standard_viair_requested/output.json b/test/cmdlineTests/standard_viair_requested/output.json index 1ec7ed40a..05b9ec0e5 100644 --- a/test/cmdlineTests/standard_viair_requested/output.json +++ b/test/cmdlineTests/standard_viair_requested/output.json @@ -89,7 +89,7 @@ object \"D_16\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) fun_f_15() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple__to__fromStack(memPos ) return(memPos, sub(memEnd, memPos)) } @@ -109,21 +109,25 @@ object \"D_16\" { } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) + } + + function finalize_allocation(memPtr, size) { let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) // protect against overflow if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } mstore(64, newFreePtr) } - function allocateTemporaryMemory() -> memPtr { - memPtr := mload(64) - } - function fun_f_15() { - let _1 := allocateTemporaryMemory() + let _1 := allocate_unbounded() let _2 := add(_1, datasize(\"C_3\")) if or(gt(_2, 0xffffffffffffffff), lt(_2, _1)) { panic_error_0x41() } datacopy(_1, dataoffset(\"C_3\"), datasize(\"C_3\")) @@ -133,7 +137,6 @@ object \"D_16\" { if iszero(expr_12_address) { revert_forward_1() } - releaseTemporaryMemory() let vloc_c_8_address := expr_12_address } @@ -144,9 +147,6 @@ object \"D_16\" { revert(0, 0x24) } - function releaseTemporaryMemory() { - } - function revert_forward_1() { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) diff --git a/test/cmdlineTests/viair_abicoder_v1/output b/test/cmdlineTests/viair_abicoder_v1/output index 94460f5bc..9b1d6801f 100644 --- a/test/cmdlineTests/viair_abicoder_v1/output +++ b/test/cmdlineTests/viair_abicoder_v1/output @@ -39,7 +39,7 @@ object "test_11" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) let ret_0 := fun_f_10() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple_t_bool__to_t_bool__fromStack(memPos , ret_0) return(memPos, sub(memEnd, memPos)) } @@ -65,18 +65,26 @@ object "test_11" { } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) } function cleanup_t_bool(value) -> cleaned { cleaned := iszero(iszero(value)) } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function fun_f_10() -> vloc__5 { let zero_value_for_type_t_bool_1 := zero_value_for_split_t_bool() vloc__5 := zero_value_for_type_t_bool_1 diff --git a/test/cmdlineTests/viair_subobjects/output b/test/cmdlineTests/viair_subobjects/output index d5a8ac8f8..36019c4b8 100644 --- a/test/cmdlineTests/viair_subobjects/output +++ b/test/cmdlineTests/viair_subobjects/output @@ -76,12 +76,12 @@ object "D_16" { returndatacopy(_1, _1, returndatasize()) revert(_1, returndatasize()) } - return(allocateMemory(_1), _1) + return(allocate_memory(_1), _1) } } revert(0, 0) } - function allocateMemory(size) -> memPtr + function allocate_memory(size) -> memPtr { memPtr := mload(64) let newFreePtr := add(memPtr, and(add(size, 31), not(31))) diff --git a/test/cmdlineTests/yul_string_format_ascii/output.json b/test/cmdlineTests/yul_string_format_ascii/output.json index f1be667b4..53923f14f 100644 --- a/test/cmdlineTests/yul_string_format_ascii/output.json +++ b/test/cmdlineTests/yul_string_format_ascii/output.json @@ -38,7 +38,7 @@ object \"C_11\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) let ret_0 := fun_f_10() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack(memPos , ret_0) return(memPos, sub(memEnd, memPos)) } @@ -68,22 +68,23 @@ object \"C_11\" { } - function allocateMemory(size) -> memPtr { - memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) } function allocate_memory_array_t_string_memory_ptr(length) -> memPtr { let allocSize := array_allocation_size_t_string_memory_ptr(length) - memPtr := allocateMemory(allocSize) + memPtr := allocate_memory(allocSize) mstore(memPtr, length) } + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + function array_allocation_size_t_string_memory_ptr(length) -> size { // Make sure we can allocate memory without overflow if gt(length, 0xffffffffffffffff) { panic_error_0x41() } @@ -128,6 +129,13 @@ object \"C_11\" { } } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function fun_f_10() -> vloc__5_mpos { let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr() vloc__5_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json b/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json index 0006d53ef..c720f1ef8 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32/output.json @@ -38,7 +38,7 @@ object \"C_11\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) let ret_0 := fun_f_10() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple_t_bytes32__to_t_bytes32__fromStack(memPos , ret_0) return(memPos, sub(memEnd, memPos)) } @@ -64,12 +64,13 @@ object \"C_11\" { } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) } function cleanup_t_bytes32(value) -> cleaned { @@ -80,6 +81,13 @@ object \"C_11\" { converted := 0x6162636162630000000000000000000000000000000000000000000000000000 } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function fun_f_10() -> vloc__5 { let zero_value_for_type_t_bytes32_1 := zero_value_for_split_t_bytes32() vloc__5 := zero_value_for_type_t_bytes32_1 diff --git a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json index bc9f3a100..e81a460d1 100644 --- a/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_bytes32_from_number/output.json @@ -38,7 +38,7 @@ object \"C_11\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) let ret_0 := fun_f_10() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple_t_bytes4__to_t_bytes4__fromStack(memPos , ret_0) return(memPos, sub(memEnd, memPos)) } @@ -64,12 +64,13 @@ object \"C_11\" { } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) } function cleanup_t_bytes4(value) -> cleaned { @@ -84,6 +85,13 @@ object \"C_11\" { converted := shift_left_224(cleanup_t_rational_1633837924_by_1(value)) } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function fun_f_10() -> vloc__5 { let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4() vloc__5 := zero_value_for_type_t_bytes4_1 diff --git a/test/cmdlineTests/yul_string_format_ascii_long/output.json b/test/cmdlineTests/yul_string_format_ascii_long/output.json index cdb9d52a0..ea594bc7e 100644 --- a/test/cmdlineTests/yul_string_format_ascii_long/output.json +++ b/test/cmdlineTests/yul_string_format_ascii_long/output.json @@ -38,7 +38,7 @@ object \"C_11\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) let ret_0 := fun_f_10() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack(memPos , ret_0) return(memPos, sub(memEnd, memPos)) } @@ -68,22 +68,23 @@ object \"C_11\" { } - function allocateMemory(size) -> memPtr { - memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) } function allocate_memory_array_t_string_memory_ptr(length) -> memPtr { let allocSize := array_allocation_size_t_string_memory_ptr(length) - memPtr := allocateMemory(allocSize) + memPtr := allocate_memory(allocSize) mstore(memPtr, length) } + function allocate_unbounded() -> memPtr { + memPtr := mload(64) + } + function array_allocation_size_t_string_memory_ptr(length) -> size { // Make sure we can allocate memory without overflow if gt(length, 0xffffffffffffffff) { panic_error_0x41() } @@ -128,6 +129,13 @@ object \"C_11\" { } } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function fun_f_10() -> vloc__5_mpos { let zero_value_for_type_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr() vloc__5_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos diff --git a/test/cmdlineTests/yul_string_format_hex/output.json b/test/cmdlineTests/yul_string_format_hex/output.json index 804794803..aed925226 100644 --- a/test/cmdlineTests/yul_string_format_hex/output.json +++ b/test/cmdlineTests/yul_string_format_hex/output.json @@ -38,7 +38,7 @@ object \"C_11\" { if callvalue() { revert(0, 0) } abi_decode_tuple_(4, calldatasize()) let ret_0 := fun_f_10() - let memPos := allocateMemory(0) + let memPos := allocate_memory(0) let memEnd := abi_encode_tuple_t_bytes4__to_t_bytes4__fromStack(memPos , ret_0) return(memPos, sub(memEnd, memPos)) } @@ -64,12 +64,13 @@ object \"C_11\" { } - function allocateMemory(size) -> memPtr { + function allocate_memory(size) -> memPtr { + memPtr := allocate_unbounded() + finalize_allocation(memPtr, size) + } + + function allocate_unbounded() -> memPtr { memPtr := mload(64) - let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) - // protect against overflow - if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } - mstore(64, newFreePtr) } function cleanup_t_bytes4(value) -> cleaned { @@ -84,6 +85,13 @@ object \"C_11\" { converted := shift_left_224(cleanup_t_rational_2864434397_by_1(value)) } + function finalize_allocation(memPtr, size) { + let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) + // protect against overflow + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } + mstore(64, newFreePtr) + } + function fun_f_10() -> vloc__5 { let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4() vloc__5 := zero_value_for_type_t_bytes4_1 diff --git a/test/libsolidity/gasTests/abiv2.sol b/test/libsolidity/gasTests/abiv2.sol index 4664d82de..54164e1b0 100644 --- a/test/libsolidity/gasTests/abiv2.sol +++ b/test/libsolidity/gasTests/abiv2.sol @@ -14,9 +14,9 @@ contract C { } // ---- // creation: -// codeDepositCost: 1175600 -// executionCost: 1221 -// totalCost: 1176821 +// codeDepositCost: 1181400 +// executionCost: 1227 +// totalCost: 1182627 // external: // a(): 1130 // b(uint256): infinite diff --git a/test/libsolidity/semanticTests/various/code_access_padding.sol b/test/libsolidity/semanticTests/various/code_access_padding.sol index fb8675e7b..d2f333bf2 100644 --- a/test/libsolidity/semanticTests/various/code_access_padding.sol +++ b/test/libsolidity/semanticTests/various/code_access_padding.sol @@ -14,7 +14,6 @@ contract C { } } } - // ==== // compileViaYul: also // ----