Update tests.

This commit is contained in:
chriseth 2021-01-14 17:27:55 +01:00
parent 3cc07694ed
commit bbd29b24ab
16 changed files with 161 additions and 83 deletions

View File

@ -39,7 +39,7 @@ object "C_81" {
if callvalue() { revert(0, 0) } 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 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 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) 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)) 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) 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 { function checked_exp_t_rational_0_by_1_t_uint256(exponent) -> power {
@ -202,6 +203,13 @@ object "C_81" {
converted := cleanup_t_int256(value) 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 { 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() let zero_value_for_type_t_uint256_1 := zero_value_for_split_t_uint256()
vloc__13 := zero_value_for_type_t_uint256_1 vloc__13 := zero_value_for_type_t_uint256_1

View File

@ -64,12 +64,12 @@ object "D_16" {
returndatacopy(_1, _1, returndatasize()) returndatacopy(_1, _1, returndatasize())
revert(_1, returndatasize()) revert(_1, returndatasize())
} }
return(allocateMemory(_1), _1) return(allocate_memory(_1), _1)
} }
} }
revert(0, 0) revert(0, 0)
} }
function allocateMemory(size) -> memPtr function allocate_memory(size) -> memPtr
{ {
memPtr := mload(64) memPtr := mload(64)
let newFreePtr := add(memPtr, and(add(size, 31), not(31))) let newFreePtr := add(memPtr, and(add(size, 31), not(31)))

View File

@ -35,7 +35,7 @@ object "C_59" {
let _4 := calldataload(add(4, offset)) let _4 := calldataload(add(4, offset))
if gt(_4, _3) { panic_error_0x41() } if gt(_4, _3) { panic_error_0x41() }
let _5 := mul(_4, _2) let _5 := mul(_4, _2)
let dst := allocateMemory(add(_5, _2)) let dst := allocate_memory(add(_5, _2))
let dst_1 := dst let dst_1 := dst
mstore(dst, _4) mstore(dst, _4)
dst := add(dst, _2) dst := add(dst, _2)
@ -45,14 +45,14 @@ object "C_59" {
for { } lt(i, _4) { i := add(i, 1) } for { } lt(i, _4) { i := add(i, 1) }
{ {
if slt(sub(calldatasize(), src), _2) { revert(_1, _1) } if slt(sub(calldatasize(), src), _2) { revert(_1, _1) }
let value := allocateMemory(_2) let value := allocate_memory(_2)
mstore(value, calldataload(src)) mstore(value, calldataload(src))
mstore(dst, value) mstore(dst, value)
dst := add(dst, _2) dst := add(dst, _2)
src := add(src, _2) src := add(src, _2)
} }
let ret, ret_1 := fun_sumArray_58(dst_1) 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)) 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) tail := add(add(headStart, and(add(length, 31), not(31))), 96)
} }
function allocateMemory(size) -> memPtr function allocate_memory(size) -> memPtr
{ {
memPtr := mload(64) memPtr := mload(64)
let newFreePtr := add(memPtr, and(add(size, 31), not(31))) let newFreePtr := add(memPtr, and(add(size, 31), not(31)))
@ -85,7 +85,7 @@ object "C_59" {
} }
function copy_literal_to_memory_64902fd228f7ef267f3b474dd6ef84bae434cf5546eee948e7ca26df3eda1927() -> memPtr function copy_literal_to_memory_64902fd228f7ef267f3b474dd6ef84bae434cf5546eee948e7ca26df3eda1927() -> memPtr
{ {
let memPtr_1 := allocateMemory(160) let memPtr_1 := allocate_memory(160)
mstore(memPtr_1, 100) mstore(memPtr_1, 100)
memPtr := memPtr_1 memPtr := memPtr_1
mstore(add(memPtr_1, 0x20), "longstringlongstringlongstringlo") mstore(add(memPtr_1, 0x20), "longstringlongstringlongstringlo")

View File

@ -40,7 +40,7 @@ object "Arraysum_34" {
mstore(_1, _1) mstore(_1, _1)
vloc_sum := checked_add_t_uint256(vloc_sum, sload(add(keccak256(_1, 0x20), vloc_i))) 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)) return(memPos, sub(abi_encode_uint(memPos, vloc_sum), memPos))
} }
} }
@ -51,7 +51,7 @@ object "Arraysum_34" {
tail := add(headStart, 32) tail := add(headStart, 32)
mstore(headStart, value0) mstore(headStart, value0)
} }
function allocateMemory(size) -> memPtr function allocate_memory(size) -> memPtr
{ {
memPtr := mload(64) memPtr := mload(64)
let newFreePtr := add(memPtr, and(add(size, 31), not(31))) let newFreePtr := add(memPtr, and(add(size, 31), not(31)))

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@ object \"C_7\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
fun_f_6() fun_f_6()
let memPos := allocateMemory(0) let memPos := allocate_memory(0)
let memEnd := abi_encode_tuple__to__fromStack(memPos) let memEnd := abi_encode_tuple__to__fromStack(memPos)
return(memPos, sub(memEnd, memPos)) return(memPos, sub(memEnd, memPos))
} }
@ -40,9 +40,15 @@ object \"C_7\" {
} }
function abi_encode_tuple__to__fromStack(headStart) -> tail function abi_encode_tuple__to__fromStack(headStart) -> tail
{ tail := add(headStart, 0) } { 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)) let newFreePtr := add(memPtr, round_up_to_mul_of_32(size))
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr) mstore(64, newFreePtr)

View File

@ -38,7 +38,7 @@ object \"C_7\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
fun_f_6() fun_f_6()
let memPos := allocateMemory(0) let memPos := allocate_memory(0)
let memEnd := abi_encode_tuple__to__fromStack(memPos ) let memEnd := abi_encode_tuple__to__fromStack(memPos )
return(memPos, sub(memEnd, 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) memPtr := mload(64)
}
function finalize_allocation(memPtr, size) {
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) let newFreePtr := add(memPtr, round_up_to_mul_of_32(size))
// protect against overflow // protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }

View File

@ -89,7 +89,7 @@ object \"D_16\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
fun_f_15() fun_f_15()
let memPos := allocateMemory(0) let memPos := allocate_memory(0)
let memEnd := abi_encode_tuple__to__fromStack(memPos ) let memEnd := abi_encode_tuple__to__fromStack(memPos )
return(memPos, sub(memEnd, 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) memPtr := mload(64)
}
function finalize_allocation(memPtr, size) {
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) let newFreePtr := add(memPtr, round_up_to_mul_of_32(size))
// protect against overflow // protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr) mstore(64, newFreePtr)
} }
function allocateTemporaryMemory() -> memPtr {
memPtr := mload(64)
}
function fun_f_15() { function fun_f_15() {
let _1 := allocateTemporaryMemory() let _1 := allocate_unbounded()
let _2 := add(_1, datasize(\"C_3\")) let _2 := add(_1, datasize(\"C_3\"))
if or(gt(_2, 0xffffffffffffffff), lt(_2, _1)) { panic_error_0x41() } if or(gt(_2, 0xffffffffffffffff), lt(_2, _1)) { panic_error_0x41() }
datacopy(_1, dataoffset(\"C_3\"), datasize(\"C_3\")) datacopy(_1, dataoffset(\"C_3\"), datasize(\"C_3\"))
@ -133,7 +137,6 @@ object \"D_16\" {
if iszero(expr_12_address) { revert_forward_1() } if iszero(expr_12_address) { revert_forward_1() }
releaseTemporaryMemory()
let vloc_c_8_address := expr_12_address let vloc_c_8_address := expr_12_address
} }
@ -144,9 +147,6 @@ object \"D_16\" {
revert(0, 0x24) revert(0, 0x24)
} }
function releaseTemporaryMemory() {
}
function revert_forward_1() { function revert_forward_1() {
returndatacopy(0, 0, returndatasize()) returndatacopy(0, 0, returndatasize())
revert(0, returndatasize()) revert(0, returndatasize())

View File

@ -39,7 +39,7 @@ object "test_11" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_f_10() 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) let memEnd := abi_encode_tuple_t_bool__to_t_bool__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos)) 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) 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 { function cleanup_t_bool(value) -> cleaned {
cleaned := iszero(iszero(value)) 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 { function fun_f_10() -> vloc__5 {
let zero_value_for_type_t_bool_1 := zero_value_for_split_t_bool() let zero_value_for_type_t_bool_1 := zero_value_for_split_t_bool()
vloc__5 := zero_value_for_type_t_bool_1 vloc__5 := zero_value_for_type_t_bool_1

View File

@ -76,12 +76,12 @@ object "D_16" {
returndatacopy(_1, _1, returndatasize()) returndatacopy(_1, _1, returndatasize())
revert(_1, returndatasize()) revert(_1, returndatasize())
} }
return(allocateMemory(_1), _1) return(allocate_memory(_1), _1)
} }
} }
revert(0, 0) revert(0, 0)
} }
function allocateMemory(size) -> memPtr function allocate_memory(size) -> memPtr
{ {
memPtr := mload(64) memPtr := mload(64)
let newFreePtr := add(memPtr, and(add(size, 31), not(31))) let newFreePtr := add(memPtr, and(add(size, 31), not(31)))

View File

@ -38,7 +38,7 @@ object \"C_11\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_f_10() 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) let memEnd := abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos)) return(memPos, sub(memEnd, memPos))
} }
@ -68,22 +68,23 @@ object \"C_11\" {
} }
function allocateMemory(size) -> memPtr { function allocate_memory(size) -> memPtr {
memPtr := mload(64) memPtr := allocate_unbounded()
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) finalize_allocation(memPtr, size)
// protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr)
} }
function allocate_memory_array_t_string_memory_ptr(length) -> memPtr { function allocate_memory_array_t_string_memory_ptr(length) -> memPtr {
let allocSize := array_allocation_size_t_string_memory_ptr(length) let allocSize := array_allocation_size_t_string_memory_ptr(length)
memPtr := allocateMemory(allocSize) memPtr := allocate_memory(allocSize)
mstore(memPtr, length) mstore(memPtr, length)
} }
function allocate_unbounded() -> memPtr {
memPtr := mload(64)
}
function array_allocation_size_t_string_memory_ptr(length) -> size { function array_allocation_size_t_string_memory_ptr(length) -> size {
// Make sure we can allocate memory without overflow // Make sure we can allocate memory without overflow
if gt(length, 0xffffffffffffffff) { panic_error_0x41() } 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 { 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() 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 vloc__5_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos

View File

@ -38,7 +38,7 @@ object \"C_11\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_f_10() 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) let memEnd := abi_encode_tuple_t_bytes32__to_t_bytes32__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos)) 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) 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 { function cleanup_t_bytes32(value) -> cleaned {
@ -80,6 +81,13 @@ object \"C_11\" {
converted := 0x6162636162630000000000000000000000000000000000000000000000000000 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 { function fun_f_10() -> vloc__5 {
let zero_value_for_type_t_bytes32_1 := zero_value_for_split_t_bytes32() let zero_value_for_type_t_bytes32_1 := zero_value_for_split_t_bytes32()
vloc__5 := zero_value_for_type_t_bytes32_1 vloc__5 := zero_value_for_type_t_bytes32_1

View File

@ -38,7 +38,7 @@ object \"C_11\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_f_10() 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) let memEnd := abi_encode_tuple_t_bytes4__to_t_bytes4__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos)) 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) 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 { function cleanup_t_bytes4(value) -> cleaned {
@ -84,6 +85,13 @@ object \"C_11\" {
converted := shift_left_224(cleanup_t_rational_1633837924_by_1(value)) 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 { function fun_f_10() -> vloc__5 {
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4() let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
vloc__5 := zero_value_for_type_t_bytes4_1 vloc__5 := zero_value_for_type_t_bytes4_1

View File

@ -38,7 +38,7 @@ object \"C_11\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_f_10() 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) let memEnd := abi_encode_tuple_t_string_memory_ptr__to_t_string_memory_ptr__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos)) return(memPos, sub(memEnd, memPos))
} }
@ -68,22 +68,23 @@ object \"C_11\" {
} }
function allocateMemory(size) -> memPtr { function allocate_memory(size) -> memPtr {
memPtr := mload(64) memPtr := allocate_unbounded()
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size)) finalize_allocation(memPtr, size)
// protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr)
} }
function allocate_memory_array_t_string_memory_ptr(length) -> memPtr { function allocate_memory_array_t_string_memory_ptr(length) -> memPtr {
let allocSize := array_allocation_size_t_string_memory_ptr(length) let allocSize := array_allocation_size_t_string_memory_ptr(length)
memPtr := allocateMemory(allocSize) memPtr := allocate_memory(allocSize)
mstore(memPtr, length) mstore(memPtr, length)
} }
function allocate_unbounded() -> memPtr {
memPtr := mload(64)
}
function array_allocation_size_t_string_memory_ptr(length) -> size { function array_allocation_size_t_string_memory_ptr(length) -> size {
// Make sure we can allocate memory without overflow // Make sure we can allocate memory without overflow
if gt(length, 0xffffffffffffffff) { panic_error_0x41() } 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 { 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() 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 vloc__5_mpos := zero_value_for_type_t_string_memory_ptr_1_mpos

View File

@ -38,7 +38,7 @@ object \"C_11\" {
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
abi_decode_tuple_(4, calldatasize()) abi_decode_tuple_(4, calldatasize())
let ret_0 := fun_f_10() 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) let memEnd := abi_encode_tuple_t_bytes4__to_t_bytes4__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos)) 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) 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 { function cleanup_t_bytes4(value) -> cleaned {
@ -84,6 +85,13 @@ object \"C_11\" {
converted := shift_left_224(cleanup_t_rational_2864434397_by_1(value)) 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 { function fun_f_10() -> vloc__5 {
let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4() let zero_value_for_type_t_bytes4_1 := zero_value_for_split_t_bytes4()
vloc__5 := zero_value_for_type_t_bytes4_1 vloc__5 := zero_value_for_type_t_bytes4_1

View File

@ -14,9 +14,9 @@ contract C {
} }
// ---- // ----
// creation: // creation:
// codeDepositCost: 1175600 // codeDepositCost: 1181400
// executionCost: 1221 // executionCost: 1227
// totalCost: 1176821 // totalCost: 1182627
// external: // external:
// a(): 1130 // a(): 1130
// b(uint256): infinite // b(uint256): infinite