commit 2434b2fe3979559eb3bdf69fff1c30cada3ad9a9
parent 3850ab18521d02d00c75fc86a08d048314f8060c
Author: William Casarin <jb55@jb55.com>
Date: Fri, 23 Jul 2021 13:15:05 -0700
return if break has no local label target
Diffstat:
M | src/wasm.c | | | 37 | +++++++++++++++++++------------------ |
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/wasm.c b/src/wasm.c
@@ -4180,12 +4180,30 @@ static int unresolved_break(struct wasm_interp *interp, int index)
return 1;
}
+static int interp_return(struct wasm_interp *interp)
+{
+ int count;
+
+ if (unlikely(!count_local_resolvers(interp, &count))) {
+ return interp_error(interp, "failed to count fn labels?");
+ }
+
+ if (unlikely(!cursor_dropn(&interp->resolver_stack,
+ sizeof(struct resolver), count))) {
+ return interp_error(interp, "failed to drop %d local labels",
+ count);
+ }
+
+ return drop_callframe(interp);
+}
+
+
static int interp_br_jump(struct wasm_interp *interp, u32 index)
{
struct label *label;
if (unlikely(!(label = top_label(interp, index)))) {
- return interp_error(interp, "no label?");
+ return interp_return(interp);
}
if (is_label_resolved(label)) {
@@ -5148,23 +5166,6 @@ static int interp_select(struct wasm_interp *interp, struct select_instr *select
return stack_pushval(interp, &top);
}
-static int interp_return(struct wasm_interp *interp)
-{
- int count;
-
- if (unlikely(!count_local_resolvers(interp, &count))) {
- return interp_error(interp, "failed to count fn labels?");
- }
-
- if (unlikely(!cursor_dropn(&interp->resolver_stack,
- sizeof(struct resolver), count))) {
- return interp_error(interp, "failed to drop %d local labels",
- count);
- }
-
- return drop_callframe(interp);
-}
-
enum interp_end {
interp_end_err,
interp_end_next,