summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm-binary-reader.c24
-rw-r--r--src/wasm-binary-writer.c3
2 files changed, 22 insertions, 5 deletions
diff --git a/src/wasm-binary-reader.c b/src/wasm-binary-reader.c
index 81cb0ea2..fa3fec86 100644
--- a/src/wasm-binary-reader.c
+++ b/src/wasm-binary-reader.c
@@ -1445,8 +1445,12 @@ static void read_function_body(Context* ctx,
in_u32_leb128(ctx, &sig_index, "call_indirect signature index");
RAISE_ERROR_UNLESS(sig_index < ctx->num_signatures,
"invalid call_indirect signature index");
+ uint32_t reserved;
+ in_u32_leb128(ctx, &reserved, "call_indirect reserved");
+ RAISE_ERROR_UNLESS(reserved == 0,
+ "call_indirect reserved value must be 0");
CALLBACK(on_call_indirect_expr, sig_index);
- CALLBACK_CTX(on_opcode_uint32, sig_index);
+ CALLBACK_CTX(on_opcode_uint32_uint32, sig_index, reserved);
break;
}
@@ -1501,15 +1505,25 @@ static void read_function_body(Context* ctx,
break;
}
- case WASM_OPCODE_CURRENT_MEMORY:
+ case WASM_OPCODE_CURRENT_MEMORY: {
+ uint32_t reserved;
+ in_u32_leb128(ctx, &reserved, "current_memory reserved");
+ RAISE_ERROR_UNLESS(reserved == 0,
+ "current_memory reserved value must be 0");
CALLBACK0(on_current_memory_expr);
- CALLBACK_CTX0(on_opcode_bare);
+ CALLBACK_CTX(on_opcode_uint32, reserved);
break;
+ }
- case WASM_OPCODE_GROW_MEMORY:
+ case WASM_OPCODE_GROW_MEMORY: {
+ uint32_t reserved;
+ in_u32_leb128(ctx, &reserved, "grow_memory reserved");
+ RAISE_ERROR_UNLESS(reserved == 0,
+ "grow_memory reserved value must be 0");
CALLBACK0(on_grow_memory_expr);
- CALLBACK_CTX0(on_opcode_bare);
+ CALLBACK_CTX(on_opcode_uint32, reserved);
break;
+ }
case WASM_OPCODE_I32_ADD:
case WASM_OPCODE_I32_SUB:
diff --git a/src/wasm-binary-writer.c b/src/wasm-binary-writer.c
index c24fc5b7..12a21322 100644
--- a/src/wasm-binary-writer.c
+++ b/src/wasm-binary-writer.c
@@ -378,6 +378,7 @@ static void write_expr(Context* ctx,
assert(index >= 0 && (size_t)index < module->func_types.size);
write_opcode(&ctx->stream, WASM_OPCODE_CALL_INDIRECT);
write_u32_leb128(&ctx->stream, index, "signature index");
+ write_u32_leb128(&ctx->stream, 0, "call_indirect reserved");
break;
}
case WASM_EXPR_TYPE_COMPARE:
@@ -413,6 +414,7 @@ static void write_expr(Context* ctx,
break;
case WASM_EXPR_TYPE_CURRENT_MEMORY:
write_opcode(&ctx->stream, WASM_OPCODE_CURRENT_MEMORY);
+ write_u32_leb128(&ctx->stream, 0, "current_memory reserved");
break;
case WASM_EXPR_TYPE_DROP:
write_opcode(&ctx->stream, WASM_OPCODE_DROP);
@@ -431,6 +433,7 @@ static void write_expr(Context* ctx,
}
case WASM_EXPR_TYPE_GROW_MEMORY:
write_opcode(&ctx->stream, WASM_OPCODE_GROW_MEMORY);
+ write_u32_leb128(&ctx->stream, 0, "grow_memory reserved");
break;
case WASM_EXPR_TYPE_IF: {
WasmLabelNode node;