diff --git a/test/cmdlineTests/standard_ewasm_requested/output.json b/test/cmdlineTests/standard_ewasm_requested/output.json index 60a59e7fe..aaa63db62 100644 --- a/test/cmdlineTests/standard_ewasm_requested/output.json +++ b/test/cmdlineTests/standard_ewasm_requested/output.json @@ -1,4 +1,4 @@ -{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d0100000001330b6000006000017e6000017f60017e0060017e017e60017e017f60027e7e0060017f0060017f017f60027f7f0060037f7f7f0002510408657468657265756d08636f6465436f7079000a08657468657265756d06726576657274000908657468657265756d0c67657443616c6c56616c7565000708657468657265756d0666696e6973680009030c0b00050208080101040603000503010001060100071102066d656d6f72790200046d61696e000400b6030c435f335f6465706c6f7965640061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010ad20205a10104027f017e017f047e024010022100200041c0006a210120012000490440000b420021022002a7210320031005ad42208621042002422088210520042005a71005ad84210620012006370000200141086a2006370000200141106a2006370000428001a71005ad4220862107200141186a2007428001422088a71005ad8437000020022002200284200284520440000b20022005520440000b1003200310000b0b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b4203017f017e017f02404200210120012001200184200184520440000b20012001422088520440000b2001a72102200241c0006a210020002002490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b0abc040bb40102027f057e024042004200420084420084520440000b420042c000422088520440000b42c000a72100200041c0006a210120012000490440000b1009210220012002370000200141086a2002370000200141106a2002370000200141186a100a370000410010024100290000100b2103410041086a290000100b2104410041106a290000100b210520032004842005410041186a290000100b848450450440100e0b42a903210642c9012006100c2006100d0b0b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100741107421022002200041107610077221010b20010b2201027e02404200a71008ad422086210120014200422088a71008ad8421000b20000b2401027e0240428001a71008ad42208621012001428001422088a71008ad8421000b20000b2201027e02402000a71008ad422086210220022000422088a71008ad8421010b20010b3001047f024020011005210220001005210310062104200441c0006a210520052004490440000b20052003200210000b0b2801037f024020001005210110062102200241c0006a210320032002490440000b2003200110030b0b2601037f02401006210010062101200141c0006a210220022001490440000b2002200010010b0b","wast":"(module +{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d010000000125086000006000017e6000017f60017e017f60017f0060017f017f60027f7f0060037f7f7f0002510408657468657265756d08636f6465436f7079000708657468657265756d06726576657274000608657468657265756d0c67657443616c6c56616c7565000408657468657265756d0666696e697368000603090800020302020505010503010001060100071102066d656d6f72790200046d61696e000400b6030c435f335f6465706c6f7965640061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010ad20205a10104027f017e017f047e024010022100200041c0006a210120012000490440000b420021022002a7210320031005ad42208621042002422088210520042005a71005ad84210620012006370000200141086a2006370000200141106a2006370000428001a71005ad4220862107200141186a2007428001422088a71005ad8437000020022002200284200284520440000b20022005520440000b1003200310000b0b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b4203017f017e017f02404200210120012001200184200184520440000b20012001422088520440000b2001a72102200241c0006a210020002002490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b0aa603089a0102027f047e024010072100200041c0006a210120012000490440000b4200a7100aad422086210220024200422088a7100aad84210320012003370000200141086a2003370000200141106a2003370000200141186a100b37000041001002410829000021044200420084200441002900008484504504401008100510010b42a9032105100842b801100620051006100010082005100610030b0b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b1e01027f024010052101200141c0006a210020002001490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100941107421022002200041107610097221010b20010b2401027e0240428001a7100aad42208621012001428001422088a7100aad8421000b20000b","wast":"(module ;; custom section for sub-module ;; The Keccak-256 hash of the text representation of \"C_3_deployed\": d5523336521d49fa8bd64dba28ece7291aa7d45c646a23eabd038bbeecc2d803 ;; (@custom \"C_3_deployed\" \"0061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010ad20205a10104027f017e017f047e024010022100200041c0006a210120012000490440000b420021022002a7210320031005ad42208621042002422088210520042005a71005ad84210620012006370000200141086a2006370000200141106a2006370000428001a71005ad4220862107200141186a2007428001422088a71005ad8437000020022002200284200284520440000b20022005520440000b1003200310000b0b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b4203017f017e017f02404200210120012001200184200184520440000b20012001422088520440000b2001a72102200241c0006a210020002002490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b\") @@ -10,59 +10,38 @@ (export \"main\" (func $main)) (func $main - (local $v i32) + (local $p i32) (local $r i32) - (local $_1 i64) - (local $z1 i64) - (local $z2 i64) + (local $hi i64) + (local $y i64) (local $z3 i64) - (local $_2 i64) + (local $_1 i64) (block $label_ - (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then + (local.set $p (call $u256_to_i32_726)) + (local.set $r (i32.add (local.get $p) (i32.const 64))) + (if (i32.lt_u (local.get $r) (local.get $p)) (then (unreachable))) - (if (i64.ne (i64.const 0) (i64.shr_u (i64.const 64) (i64.const 32))) (then - (unreachable))) - (local.set $v (i32.wrap_i64 (i64.const 64))) - (local.set $r (i32.add (local.get $v) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $v)) (then - (unreachable))) - (local.set $_1 (call $bswap64_388)) - (i64.store (local.get $r) (local.get $_1)) - (i64.store (i32.add (local.get $r) (i32.const 8)) (local.get $_1)) - (i64.store (i32.add (local.get $r) (i32.const 16)) (local.get $_1)) - (i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64_389)) + (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) + (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) + (i64.store (local.get $r) (local.get $y)) + (i64.store (i32.add (local.get $r) (i32.const 8)) (local.get $y)) + (i64.store (i32.add (local.get $r) (i32.const 16)) (local.get $y)) + (i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64)) (call $eth.getCallValue (i32.const 0)) - (local.set $z1 (call $bswap64 (i64.load (i32.const 0)))) - (local.set $z2 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8))))) - (local.set $z3 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16))))) - (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $z1) (local.get $z2)) (i64.or (local.get $z3) (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24)))))))) (then - (call $revert))) - (local.set $_2 (datasize \"C_3_deployed\")) - (call $codecopy (dataoffset \"C_3_deployed\") (local.get $_2)) - (call $return (local.get $_2)) + (local.set $z3 (i64.load (i32.const 8))) + (if (i32.eqz (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (local.get $z3) (i64.load (i32.const 0)))))) (then + (call $eth.revert (call $to_internal_i32ptr) (call $u256_to_i32_344)))) + (local.set $_1 (datasize \"C_3_deployed\")) + (call $eth.codeCopy (call $to_internal_i32ptr) (call $u256_to_i32 (dataoffset \"C_3_deployed\")) (call $u256_to_i32 (local.get $_1))) + (call $eth.finish (call $to_internal_i32ptr) (call $u256_to_i32 (local.get $_1))) ) ) -(func $u256_to_i32_687 - (param $x4 i64) - (result i32) - (local $v i32) - (block $label__1 - (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then - (unreachable))) - (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then - (unreachable))) - (local.set $v (i32.wrap_i64 (local.get $x4))) - - ) - (local.get $v) -) - -(func $u256_to_i32 +(func $u256_to_i32_344 (result i32) (local $v i32) (local $_1 i64) - (block $label__2 + (block $label__1 (local.set $_1 (i64.const 0)) (if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then (unreachable))) @@ -74,11 +53,54 @@ (local.get $v) ) +(func $u256_to_i32 + (param $x4 i64) + (result i32) + (local $v i32) + (block $label__2 + (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then + (unreachable))) + (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then + (unreachable))) + (local.set $v (i32.wrap_i64 (local.get $x4))) + + ) + (local.get $v) +) + +(func $u256_to_i32_726 + (result i32) + (local $v i32) + (block $label__3 + (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then + (unreachable))) + (if (i64.ne (i64.const 0) (i64.shr_u (i64.const 64) (i64.const 32))) (then + (unreachable))) + (local.set $v (i32.wrap_i64 (i64.const 64))) + + ) + (local.get $v) +) + +(func $to_internal_i32ptr + (result i32) + (local $r i32) + (local $p i32) + (block $label__4 + (local.set $p (call $u256_to_i32_344)) + (local.set $r (i32.add (local.get $p) (i32.const 64))) + (if (i32.lt_u (local.get $r) (local.get $p)) (then + (unreachable))) + + ) + (local.get $r) +) + (func $bswap16 (param $x i32) (result i32) (local $y i32) - (block $label__3 + (block $label__5 (local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255)))) ) @@ -90,7 +112,7 @@ (result i32) (local $y i32) (local $hi i32) - (block $label__4 + (block $label__6 (local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16))) (local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16))))) @@ -98,23 +120,11 @@ (local.get $y) ) -(func $bswap64_388 +(func $bswap64 (result i64) (local $y i64) (local $hi i64) - (block $label__5 - (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) - (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) - - ) - (local.get $y) -) - -(func $bswap64_389 - (result i64) - (local $y i64) - (local $hi i64) - (block $label__6 + (block $label__7 (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 128)))) (i64.const 32))) (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 128) (i64.const 32))))))) @@ -122,65 +132,5 @@ (local.get $y) ) -(func $bswap64 - (param $x i64) - (result i64) - (local $y i64) - (local $hi i64) - (block $label__7 - (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32))) - (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32))))))) - - ) - (local.get $y) -) - -(func $codecopy - (param $y4 i64) - (param $z4 i64) - (local $_1 i32) - (local $_2 i32) - (local $p i32) - (local $r i32) - (block $label__8 - (local.set $_1 (call $u256_to_i32_687 (local.get $z4))) - (local.set $_2 (call $u256_to_i32_687 (local.get $y4))) - (local.set $p (call $u256_to_i32)) - (local.set $r (i32.add (local.get $p) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $p)) (then - (unreachable))) - (call $eth.codeCopy (local.get $r) (local.get $_2) (local.get $_1)) - ) -) - -(func $return - (param $y4 i64) - (local $_1 i32) - (local $p i32) - (local $r i32) - (block $label__9 - (local.set $_1 (call $u256_to_i32_687 (local.get $y4))) - (local.set $p (call $u256_to_i32)) - (local.set $r (i32.add (local.get $p) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $p)) (then - (unreachable))) - (call $eth.finish (local.get $r) (local.get $_1)) - ) -) - -(func $revert - (local $_1 i32) - (local $p i32) - (local $r i32) - (block $label__10 - (local.set $_1 (call $u256_to_i32)) - (local.set $p (call $u256_to_i32)) - (local.set $r (i32.add (local.get $p) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $p)) (then - (unreachable))) - (call $eth.revert (local.get $r) (local.get $_1)) - ) -) - ) "}}}},"sources":{"A":{"id":0}}} diff --git a/test/libyul/ewasmTranslationTests/callvalue.yul b/test/libyul/ewasmTranslationTests/callvalue.yul index 99bfa0f31..5d34b58b6 100644 --- a/test/libyul/ewasmTranslationTests/callvalue.yul +++ b/test/libyul/ewasmTranslationTests/callvalue.yul @@ -4,6 +4,6 @@ // ---- // Trace: // Memory dump: -// 20: 5555555500000000000000000000000000000000000000000000000000000000 +// 20: 0000000000000000000000000000000000000000000000000000000055555555 // Storage dump: -// 0000000000000000000000000000000000000000000000000000000000000000: 5555555500000000000000000000000000000000000000000000000000000000 +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000055555555 diff --git a/test/libyul/ewasmTranslationTests/difficulty.yul b/test/libyul/ewasmTranslationTests/difficulty.yul index fe706155d..c467d51a7 100644 --- a/test/libyul/ewasmTranslationTests/difficulty.yul +++ b/test/libyul/ewasmTranslationTests/difficulty.yul @@ -4,6 +4,6 @@ // ---- // Trace: // Memory dump: -// 20: 9999990900000000000000000000000000000000000000000000000000000000 +// 20: 0000000000000000000000000000000000000000000000000000000009999999 // Storage dump: -// 0000000000000000000000000000000000000000000000000000000000000000: 9999990900000000000000000000000000000000000000000000000000000000 +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000009999999 diff --git a/test/libyul/ewasmTranslationTests/gasprice.yul b/test/libyul/ewasmTranslationTests/gasprice.yul index 1d668fa6f..2c9d80452 100644 --- a/test/libyul/ewasmTranslationTests/gasprice.yul +++ b/test/libyul/ewasmTranslationTests/gasprice.yul @@ -4,6 +4,6 @@ // ---- // Trace: // Memory dump: -// 20: 6666666600000000000000000000000000000000000000000000000000000000 +// 20: 0000000000000000000000000000000000000000000000000000000066666666 // Storage dump: -// 0000000000000000000000000000000000000000000000000000000000000000: 6666666600000000000000000000000000000000000000000000000000000000 +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000066666666