Commit 7ce76fbc authored by Ben Smith's avatar Ben Smith Committed by Commit Bot

[wasm] Enable mutable-global by default

Mutable globals are now included in the wasm v1 spec.

Bug: v8:7625
Change-Id: Ib9b92d8348102f99a3b92820d0057b2c11a1e49a
Reviewed-on: https://chromium-review.googlesource.com/1095650
Commit-Queue: Ben Smith <binji@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53683}
parent f892a76f
...@@ -584,7 +584,7 @@ DEFINE_BOOL(experimental_wasm_se, true, ...@@ -584,7 +584,7 @@ DEFINE_BOOL(experimental_wasm_se, true,
"enable prototype sign extension opcodes for wasm") "enable prototype sign extension opcodes for wasm")
DEFINE_BOOL(experimental_wasm_anyref, false, DEFINE_BOOL(experimental_wasm_anyref, false,
"enable prototype anyref support for wasm") "enable prototype anyref support for wasm")
DEFINE_BOOL(experimental_wasm_mut_global, false, DEFINE_BOOL(experimental_wasm_mut_global, true,
"enable prototype import/export mutable global support for wasm") "enable prototype import/export mutable global support for wasm")
DEFINE_BOOL(wasm_opt, false, "enable wasm optimization") DEFINE_BOOL(wasm_opt, false, "enable wasm optimization")
......
...@@ -5,40 +5,6 @@ ...@@ -5,40 +5,6 @@
load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js"); load("test/mjsunit/wasm/wasm-module-builder.js");
(function exportImmutableGlobal() {
var builder = new WasmModuleBuilder();
let globals = [
[kWasmI32, 'i32_noinit'], // -
[kWasmI32, 'i32', 4711], // -
[kWasmF32, 'f32_noinit'], // -
[kWasmF32, 'f32', Math.fround(3.14)], // -
[kWasmF64, 'f64_noinit'], // -
[kWasmF64, 'f64', 1 / 7] // -
];
for (let g of globals) {
let global_builder = builder.addGlobal(g[0], false).exportAs(g[1]);
if (g[2]) global_builder.init = g[2];
}
var module = builder.instantiate();
for (let g of globals) {
assertEquals("number", typeof module.exports[g[1]], g[1]);
assertEquals(g[2] || 0, module.exports[g[1]], g[1]);
}
})();
(function cannotExportMutableGlobal() {
var builder = new WasmModuleBuilder();
builder.addGlobal(kWasmI32, true).exportAs('g');
assertThrows(() => builder.instantiate(), WebAssembly.CompileError);
})();
(function cannotExportI64Global() {
var builder = new WasmModuleBuilder();
builder.addGlobal(kWasmI64, false).exportAs('g');
assertThrows(() => builder.instantiate(), WebAssembly.LinkError);
})();
(function duplicateGlobalExportName() { (function duplicateGlobalExportName() {
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addGlobal(kWasmI64, false).exportAs('g'); builder.addGlobal(kWasmI64, false).exportAs('g');
......
...@@ -102,7 +102,7 @@ function TestExported(type, val, expected) { ...@@ -102,7 +102,7 @@ function TestExported(type, val, expected) {
builder.addGlobal(kWasmI32); // pad builder.addGlobal(kWasmI32); // pad
var instance = builder.instantiate(); var instance = builder.instantiate();
assertEquals(expected, instance.exports.foo); assertEquals(expected, instance.exports.foo.value);
} }
TestExported(kWasmI32, 455.5, 455); TestExported(kWasmI32, 455.5, 455);
...@@ -118,7 +118,9 @@ TestExported(kWasmF64, 87347.66666, 87347.66666); ...@@ -118,7 +118,9 @@ TestExported(kWasmF64, 87347.66666, 87347.66666);
g.init = 1234; g.init = 1234;
builder.addGlobal(kWasmI32); // pad builder.addGlobal(kWasmI32); // pad
assertThrows(()=> {builder.instantiate()}, WebAssembly.LinkError); var instance = builder.instantiate();
assertTrue(instance.exports.foo instanceof WebAssembly.Global);
assertThrows(() => {instance.exports.foo.value}, TypeError);
})(); })();
function TestImportedExported(type, val, expected) { function TestImportedExported(type, val, expected) {
...@@ -133,7 +135,7 @@ function TestImportedExported(type, val, expected) { ...@@ -133,7 +135,7 @@ function TestImportedExported(type, val, expected) {
builder.addGlobal(kWasmI32); // pad builder.addGlobal(kWasmI32); // pad
var instance = builder.instantiate({ttt: {foo: val}}); var instance = builder.instantiate({ttt: {foo: val}});
assertEquals(expected, instance.exports.bar); assertEquals(expected, instance.exports.bar.value);
} }
TestImportedExported(kWasmI32, 415.5, 415); TestImportedExported(kWasmI32, 415.5, 415);
......
...@@ -346,7 +346,7 @@ TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) { ...@@ -346,7 +346,7 @@ TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) {
kExternalGlobal, // global kExternalGlobal, // global
0, // global index 0, // global index
}; };
EXPECT_FAILURE(data); EXPECT_VERIFIES(data);
} }
} }
...@@ -1309,7 +1309,7 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) { ...@@ -1309,7 +1309,7 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
kLocalI32, // type kLocalI32, // type
1, // mutability 1, // mutability
}; };
EXPECT_FAILURE(data); EXPECT_VERIFIES(data);
} }
} }
......
...@@ -49,4 +49,11 @@ ...@@ -49,4 +49,11 @@
'tests/f64_cmp': [SKIP], 'tests/f64_cmp': [SKIP],
}], # variant == stress }], # variant == stress
[ALWAYS, {
# TODO(v8:7846): These tests will pass when the wasm-spec-tests repo is updated.
'tests/linking': [SKIP],
'tests/exports': [SKIP],
'tests/globals': [SKIP],
}],
] ]
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