diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-15 18:48:16 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-15 18:48:16 +0100 |
| commit | 0b2a1fd9439d5ab1cdc076d7b9f1e763c4900b74 (patch) | |
| tree | a0a1724b1a8b2dbde94e938bb18b6ca4bb5ce800 /src/routines | |
| parent | 4a356bf56051361f2c72037f4fb043f8fdaa576c (diff) | |
| download | nanowasm-0b2a1fd9439d5ab1cdc076d7b9f1e763c4900b74.tar.gz | |
Add br_table
br_table is in fact a generalization of other branch types like br or
br_if, since br_table contains several branches for the same pc inside
the nw_lo section.
Therefore, this kind of branch forced some changes to nwp_break and
those relying on it.
Diffstat (limited to 'src/routines')
| -rw-r--r-- | src/routines/break.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/routines/break.c b/src/routines/break.c index 3ee94a1..bf13ca6 100644 --- a/src/routines/break.c +++ b/src/routines/break.c @@ -40,7 +40,7 @@ static enum nw_state skip(struct nw_interp *const i) i->exception = exc; #ifdef NW_LOG - nwp_log("%s from offset: %ld\n", exc, b->pc); + nwp_log("%s, offset: %#lx\n", exc, b->pc); #endif return NW_FATAL; } @@ -66,7 +66,7 @@ static enum nw_state get_dst(struct nw_interp *const i) if (n) return n; - else if (pc == b->pc) + else if (pc == b->pc && b->toffset_i++ >= b->table_offset) i->next = seek_dst; else return skip(i); @@ -232,12 +232,14 @@ static enum nw_state tell(struct nw_interp *const i) return NW_AGAIN; } -void nwp_break(struct nw_interp *const i, const nw_varuint32 relative_depth) +void nwp_break(struct nw_interp *const i, const nw_varuint32 relative_depth, + const nw_varuint32 table_offset) { const struct nw_i_sm_break b = {0}; struct nw_i_sm_break *const pb = &i->sm.brk; *pb = b; pb->relative_depth = relative_depth; + pb->table_offset = table_offset; i->next = tell; } |
