diff --git a/index.js b/index.js index 8da4a6dc..6fcb5eb2 100644 --- a/index.js +++ b/index.js @@ -187,6 +187,11 @@ exports.evm2wast = function (evmCode, opts = { segmentStackLow = segmentStackDeta } + // creates a stack trace + if (opts.stackTrace) { + segment += `(call $stackTrace (i32.const ${pc}) (i32.const ${opint}) (i32.const ${gasCount}) (get_global $sp))\n` + } + switch (op.name) { case 'JUMP': jumpFound = true @@ -316,11 +321,6 @@ exports.evm2wast = function (evmCode, opts = { segment += `(set_global $sp (i32.add (get_global $sp) (i32.const ${stackDeta * 32})))\n` } - // creates a stack trace - if (opts.stackTrace) { - segment += `(call $stackTrace (i32.const ${pc}) (i32.const ${opint}) (i32.const ${gasCount}) (get_global $sp))\n` - } - // adds the logic to save the stack pointer before exiting to wiat to for a callback // note, this must be done before the sp is updated above^ if (opts.useAsyncAPI && callbackFuncs.has(op.name)) {