[wasm] Add support to construct 'exnref' type globals.

R=ahaas@chromium.org
TEST=mjsunit/wasm/exceptions-global
BUG=v8:8091

Change-Id: I9eb4c92cca087719afda2da5d11c206aaed28c95
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1771788
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63414}
This commit is contained in:
Michael Starzinger 2019-08-27 14:19:33 +02:00 committed by Commit Bot
parent 27b52b2e18
commit 7f00bb5ad6
2 changed files with 7 additions and 5 deletions

View File

@ -1223,6 +1223,9 @@ bool GetValueType(Isolate* isolate, MaybeLocal<Value> maybe,
} else if (enabled_features.anyref &&
string->StringEquals(v8_str(isolate, "anyfunc"))) {
*type = i::wasm::kWasmFuncRef;
} else if (enabled_features.eh &&
string->StringEquals(v8_str(isolate, "exnref"))) {
*type = i::wasm::kWasmExnRef;
} else {
// Unrecognized type.
*type = i::wasm::kWasmStmt;
@ -1337,7 +1340,8 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
global_obj->SetF64(f64_value);
break;
}
case i::wasm::kWasmAnyRef: {
case i::wasm::kWasmAnyRef:
case i::wasm::kWasmExnRef: {
if (args.Length() < 2) {
// When no inital value is provided, we have to use the WebAssembly
// default value 'null', and not the JS default value 'undefined'.

View File

@ -115,10 +115,8 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception2);
})();
// TODO(mstarzinger): Add the following test once proposal makes it clear how
// far interaction with the mutable globals proposal is intended to go.
// Test loading an imported mutable "exnref" being changed from the outside.
/*(function TestGlobalExnRefGetImportedMutableAndRethrow() {
(function TestGlobalExnRefGetImportedMutableAndRethrow() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let g_index = builder.addImportedGlobal("m", "exn", kWasmExnRef, true);
@ -135,7 +133,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception1);
let exception2 = mutable_global.value = "an even fancier exception";
assertThrowsEquals(() => instance.exports.rethrow_exnref(), exception2);
})();*/
})();
// Test custom initialization index for a global "exnref" variable.
(function TestGlobalExnRefInitIndex() {