Commit e4bae133 authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Mutable globals cannot be imported

This fixes another spec tests.

R=rossberg@chromium.org, titzer@chromium.org
TEST=WasmModuleVerifyTest.ImportTable_mutable_global

Review-Url: https://codereview.chromium.org/2484803002
Cr-Commit-Position: refs/heads/master@{#40831}
parent 68fdaf6d
...@@ -337,6 +337,9 @@ class ModuleDecoder : public Decoder { ...@@ -337,6 +337,9 @@ class ModuleDecoder : public Decoder {
WasmGlobal* global = &module->globals.back(); WasmGlobal* global = &module->globals.back();
global->type = consume_value_type(); global->type = consume_value_type();
global->mutability = consume_u8("mutability") != 0; global->mutability = consume_u8("mutability") != 0;
if (global->mutability) {
error("mutable globals cannot be imported");
}
break; break;
} }
default: default:
......
...@@ -894,6 +894,37 @@ TEST_F(WasmModuleVerifyTest, ImportTable_nosigs1) { ...@@ -894,6 +894,37 @@ TEST_F(WasmModuleVerifyTest, ImportTable_nosigs1) {
EXPECT_VERIFIES(data); EXPECT_VERIFIES(data);
} }
TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
{
static const byte data[] = {
SECTION(Import, 8), // section header
1, // number of imports
NAME_LENGTH(1), // --
'm', // module name
NAME_LENGTH(1), // --
'f', // global name
kExternalGlobal, // import kind
kLocalI32, // type
0, // mutability
};
EXPECT_VERIFIES(data);
}
{
static const byte data[] = {
SECTION(Import, 8), // section header
1, // sig table
NAME_LENGTH(1), // --
'm', // module name
NAME_LENGTH(1), // --
'f', // global name
kExternalGlobal, // import kind
kLocalI32, // type
1, // mutability
};
EXPECT_FAILURE(data);
}
}
TEST_F(WasmModuleVerifyTest, ImportTable_nosigs2) { TEST_F(WasmModuleVerifyTest, ImportTable_nosigs2) {
static const byte data[] = { static const byte data[] = {
SECTION(Import, 6), 1, // sig table SECTION(Import, 6), 1, // sig table
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment