Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

fixes for stCallCodes/callcall_00 #246

Closed
wants to merge 13 commits into from
13 changes: 12 additions & 1 deletion wasm/generateInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,27 @@ function generateManifest (interfaceManifest, opts) {
call += '(get_local $callback)'
}

if (opcode === 'CALL') {
call =
`(i64.store
(i32.add (get_global $sp) (i32.const ${spOffset * 32}))
(i64.extend_u/i32
(i32.xor (i32.const 1) ${call}) ;; flip CALL result from EVM convention to POSIX convention, 0 -> 1, 1 -> 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not enough, because it could return 2, which is xor'd into 3.

)))`
} else {
call =
`(i64.store
(i32.add (get_global $sp) (i32.const ${spOffset * 32}))
(i64.extend_u/i32
${call})))
${call})))`
}

call += `
;; zero out mem
(i64.store (i32.add (get_global $sp) (i32.const ${spOffset * 32 + 8 * 3})) (i64.const 0))
(i64.store (i32.add (get_global $sp) (i32.const ${spOffset * 32 + 8 * 2})) (i64.const 0))
(i64.store (i32.add (get_global $sp) (i32.const ${spOffset * 32 + 8})) (i64.const 0))`

} else if (output === 'i64') {
if (useAsyncAPI && op.async) {
call += '(get_local $callback)'
Expand Down
Loading