diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-12 00:32:15 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-12 00:32:15 +0100 |
| commit | cf2882c2e754f49c46ce2ca12c3ca07e4cabc459 (patch) | |
| tree | 4d092f802c57e51db3da2194b0340f8b3741848e | |
| parent | 900fabee73c16bda1542b96d564936e6318d6f58 (diff) | |
Fix prev_op
Assigning prev_op inside nwp_execute defeated the purpose because this
function is meant to start the state machine for the given instruction.
In other words, inspecting prev_op would in fact return the current
opcode, instead of the previous opcode.
| -rw-r--r-- | include/nanowasm/private.h | 2 | ||||
| -rw-r--r-- | src/interp/resume.c | 2 | ||||
| -rw-r--r-- | src/interp/routines/execute.c | 5 |
3 files changed, 6 insertions, 3 deletions
diff --git a/include/nanowasm/private.h b/include/nanowasm/private.h index d42023f..6b134f1 100644 --- a/include/nanowasm/private.h +++ b/include/nanowasm/private.h @@ -106,7 +106,7 @@ struct nw_frame struct nw_fn fn; struct nw_return prev_ret; int child; - unsigned char prev_op; + unsigned char op, prev_op; size_t fr_start, local_start, local_end; long start, pc; }; diff --git a/src/interp/resume.c b/src/interp/resume.c index cf9ece2..2494928 100644 --- a/src/interp/resume.c +++ b/src/interp/resume.c @@ -13,6 +13,8 @@ void nwp_interp_resume(struct nw_interp *const i) { + i->fr.prev_op = i->fr.op; + if (i->set) nwp_interp_limited(i); else diff --git a/src/interp/routines/execute.c b/src/interp/routines/execute.c index 49711ae..fe1e8d7 100644 --- a/src/interp/routines/execute.c +++ b/src/interp/routines/execute.c @@ -17,12 +17,13 @@ static enum nw_state execute(struct nw_interp *const i) { struct nw_i_sm_b *const b = &i->sm.bytecode; + const unsigned char op = b->op; #ifdef NW_LOG - nwp_log("opcode: %s, pc=%#lx\n", nwp_op_tostr(b->op), b->pc); + nwp_log("opcode: %s, pc=%#lx\n", nwp_op_tostr(op), b->pc); #endif + i->fr.op = op; b->f(i); - i->fr.prev_op = b->op; return NW_AGAIN; } |
