@@ -138,6 +138,16 @@ namespace evm2wasm
138138 .wast = ";; generated by ./wasm/generateInterface.js\n(func $STATICCALL (param $callback i32)(local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -96)))\n (i64.load (i32.add (get_global $sp) (i32.const -88)))\n (i64.load (i32.add (get_global $sp) (i32.const -80)))\n (i64.load (i32.add (get_global $sp) (i32.const -72)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (i64.store\n (i32.add (get_global $sp) (i32.const -160))\n (i64.extend_u/i32\n (i32.eqz (call $callStatic(call $check_overflow_i64\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24))))(i32.add (get_global $sp) (i32.const -32))(get_local $offset0)(get_local $length0)(get_local $callback)) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)\n )))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const -136)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -144)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const -152)) (i64.const 0)))",
139139 .imports = " (import \" ethereum\" \" callStatic\" (func $callStatic (param i64 i32 i32 i32 i32) (result i32)))"
140140 }
141+ },{
142+ opcodeEnum::RETURNDATACOPY, {
143+ .wast = ";; generated by ./wasm/generateInterface.js\n(func $RETURNDATACOPY (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -64)))\n (i64.load (i32.add (get_global $sp) (i32.const -56)))\n (i64.load (i32.add (get_global $sp) (i32.const -48)))\n (i64.load (i32.add (get_global $sp) (i32.const -40)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (call $returnDataCopy(get_local $offset0)(call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8))))(get_local $length0)))",
144+ .imports = " (import \" ethereum\" \" returnDataCopy\" (func $returnDataCopy (param i32 i32 i32) ))"
145+ }
146+ },{
147+ opcodeEnum::RETURNDATASIZE, {
148+ .wast = " ;; generated by ./wasm/generateInterface.js\n (func $RETURNDATASIZE (i64.store\n (i32.add (get_global $sp) (i32.const 32))\n (i64.extend_u/i32\n (call $getReturnDataSize)))\n ;; zero out mem\n (i64.store (i32.add (get_global $sp) (i32.const 56)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 48)) (i64.const 0))\n (i64.store (i32.add (get_global $sp) (i32.const 40)) (i64.const 0)))" ,
149+ .imports = " (import \" ethereum\" \" getReturnDataSize\" (func $getReturnDataSize (result i32)))"
150+ }
141151},{
142152 opcodeEnum::SSTORE, {
143153 .wast = " ;; generated by ./wasm/generateInterface.js\n (func $SSTORE (param $callback i32) (call $storageStore(get_global $sp)(i32.add (get_global $sp) (i32.const -32))(get_local $callback)))" ,
@@ -158,6 +168,11 @@ namespace evm2wasm
158168 .wast = " ;; generated by ./wasm/generateInterface.js\n (func $RETURN (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (call $return(get_local $offset0)(get_local $length0)))" ,
159169 .imports = " (import \" ethereum\" \" return\" (func $return (param i32 i32) ))"
160170 }
171+ },{
172+ opcodeEnum::REVERT, {
173+ .wast = " ;; generated by ./wasm/generateInterface.js\n (func $REVERT (local $offset0 i32)(local $length0 i32) (set_local $offset0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const 0)))\n (i64.load (i32.add (get_global $sp) (i32.const 8)))\n (i64.load (i32.add (get_global $sp) (i32.const 16)))\n (i64.load (i32.add (get_global $sp) (i32.const 24)))))(set_local $length0 (call $check_overflow\n (i64.load (i32.add (get_global $sp) (i32.const -32)))\n (i64.load (i32.add (get_global $sp) (i32.const -24)))\n (i64.load (i32.add (get_global $sp) (i32.const -16)))\n (i64.load (i32.add (get_global $sp) (i32.const -8)))))\n (call $memusegas (get_local $offset0) (get_local $length0))\n (set_local $offset0 (i32.add (get_global $memstart) (get_local $offset0))) (call $revert(get_local $offset0)(get_local $length0)))" ,
174+ .imports = " (import \" ethereum\" \" revert\" (func $revert (param i32 i32) ))"
175+ }
161176},{
162177 opcodeEnum::ADD, {
163178 .wast = "(func $ADD\n (local $sp i32)\n\n (local $a i64)\n (local $c i64)\n (local $d i64)\n (local $carry i64)\n\n (set_local $sp (get_global $sp))\n \n ;; d c b a\n ;; pop the stack \n (set_local $a (i64.load (i32.add (get_local $sp) (i32.const 24))))\n (set_local $c (i64.load (i32.add (get_local $sp) (i32.const 8))))\n (set_local $d (i64.load (get_local $sp)))\n ;; decement the stack pointer\n (set_local $sp (i32.sub (get_local $sp) (i32.const 8)))\n\n ;; d \n (set_local $carry (i64.add (get_local $d) (i64.load (i32.sub (get_local $sp) (i32.const 24)))))\n ;; save d to mem\n (i64.store (i32.sub (get_local $sp) (i32.const 24)) (get_local $carry))\n ;; check for overflow\n (set_local $carry (i64.extend_u/i32 (i64.lt_u (get_local $carry) (get_local $d))))\n\n ;; c use $d as reg\n (set_local $d (i64.add (i64.load (i32.sub (get_local $sp) (i32.const 16))) (get_local $carry)))\n (set_local $carry (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $carry))))\n (set_local $d (i64.add (get_local $c) (get_local $d)))\n ;; store the result\n (i64.store (i32.sub (get_local $sp) (i32.const 16)) (get_local $d))\n ;; check overflow\n (set_local $carry (i64.or (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $c))) (get_local $carry)))\n\n ;; b\n ;; add carry\n (set_local $d (i64.add (i64.load (i32.sub (get_local $sp) (i32.const 8))) (get_local $carry)))\n (set_local $carry (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $carry))))\n\n ;; use reg c\n (set_local $c (i64.load (i32.add (get_local $sp) (i32.const 24))))\n (set_local $d (i64.add (get_local $c) (get_local $d)))\n (i64.store (i32.sub (get_local $sp) (i32.const 8)) (get_local $d))\n ;; a\n (i64.store (get_local $sp) \n (i64.add ;; add a \n (get_local $a)\n (i64.add\n (i64.load (get_local $sp)) ;; load the operand\n (i64.or ;; carry \n (i64.extend_u/i32 (i64.lt_u (get_local $d) (get_local $c))) \n (get_local $carry)))))\n)\n",
0 commit comments