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

Commit a9b26e9

Browse files
authored
Merge pull request #253 from ewasm/call-result
Flip CALL result from EEI/POSIX convention to EVM convention
2 parents 43d23c9 + d5a3914 commit a9b26e9

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

wasm/generateInterface.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,22 @@ function generateManifest (interfaceManifest, opts) {
313313
call += '(get_local $callback)'
314314
}
315315

316-
call =
317-
`(i64.store
318-
(i32.add (get_global $sp) (i32.const ${spOffset * 32}))
319-
(i64.extend_u/i32
320-
${call})))
316+
if (opcode === 'CALL' || opcode === 'CALLCODE' || opcode === 'DELEGATECALL') {
317+
call =
318+
`(i64.store
319+
(i32.add (get_global $sp) (i32.const ${spOffset * 32}))
320+
(i64.extend_u/i32
321+
(i32.eqz ${call}) ;; flip CALL result from EEI to EVM convention (0 -> 1, 1,2,.. -> 1)
322+
)))`
323+
} else {
324+
call =
325+
`(i64.store
326+
(i32.add (get_global $sp) (i32.const ${spOffset * 32}))
327+
(i64.extend_u/i32
328+
${call})))`
329+
}
321330

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

0 commit comments

Comments
 (0)