[wasm] Don't allow anyref globals when anyref is not enabled
R=mstarzinger@chromium.org Bug: v8:7581 Change-Id: I93044dc0065d1d0146ec9b5190e50ca63ce94f4e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1530808 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#60341}
This commit is contained in:
parent
979b3a33d7
commit
d2542089c7
@ -1192,6 +1192,7 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||||||
v8::Local<v8::String> string;
|
v8::Local<v8::String> string;
|
||||||
if (!value->ToString(context).ToLocal(&string)) return;
|
if (!value->ToString(context).ToLocal(&string)) return;
|
||||||
|
|
||||||
|
auto enabled_features = i::wasm::WasmFeaturesFromIsolate(i_isolate);
|
||||||
if (string->StringEquals(v8_str(isolate, "i32"))) {
|
if (string->StringEquals(v8_str(isolate, "i32"))) {
|
||||||
type = i::wasm::kWasmI32;
|
type = i::wasm::kWasmI32;
|
||||||
} else if (string->StringEquals(v8_str(isolate, "f32"))) {
|
} else if (string->StringEquals(v8_str(isolate, "f32"))) {
|
||||||
@ -1200,9 +1201,11 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||||||
type = i::wasm::kWasmI64;
|
type = i::wasm::kWasmI64;
|
||||||
} else if (string->StringEquals(v8_str(isolate, "f64"))) {
|
} else if (string->StringEquals(v8_str(isolate, "f64"))) {
|
||||||
type = i::wasm::kWasmF64;
|
type = i::wasm::kWasmF64;
|
||||||
} else if (string->StringEquals(v8_str(isolate, "anyref"))) {
|
} else if (enabled_features.anyref &&
|
||||||
|
string->StringEquals(v8_str(isolate, "anyref"))) {
|
||||||
type = i::wasm::kWasmAnyRef;
|
type = i::wasm::kWasmAnyRef;
|
||||||
} else if (string->StringEquals(v8_str(isolate, "anyfunc"))) {
|
} else if (enabled_features.anyref &&
|
||||||
|
string->StringEquals(v8_str(isolate, "anyfunc"))) {
|
||||||
type = i::wasm::kWasmAnyFunc;
|
type = i::wasm::kWasmAnyFunc;
|
||||||
} else {
|
} else {
|
||||||
thrower.TypeError(
|
thrower.TypeError(
|
||||||
|
@ -21,6 +21,10 @@ function assertGlobalIsValid(global) {
|
|||||||
assertThrows(() => new WebAssembly.Global({}), TypeError);
|
assertThrows(() => new WebAssembly.Global({}), TypeError);
|
||||||
assertThrows(() => new WebAssembly.Global({value: 'foo'}), TypeError);
|
assertThrows(() => new WebAssembly.Global({value: 'foo'}), TypeError);
|
||||||
assertThrows(() => new WebAssembly.Global({value: 'i128'}), TypeError);
|
assertThrows(() => new WebAssembly.Global({value: 'i128'}), TypeError);
|
||||||
|
// Without --experimental-wasm-anyref, globals of type {anyref} and {anyfunc}
|
||||||
|
// are not allowed.
|
||||||
|
assertThrows(() => new WebAssembly.Global({value: 'anyref'}), TypeError);
|
||||||
|
assertThrows(() => new WebAssembly.Global({value: 'anyfunc'}), TypeError);
|
||||||
|
|
||||||
for (let type of ['i32', 'f32', 'f64', 'i64']) {
|
for (let type of ['i32', 'f32', 'f64', 'i64']) {
|
||||||
assertGlobalIsValid(new WebAssembly.Global({value: type}));
|
assertGlobalIsValid(new WebAssembly.Global({value: type}));
|
||||||
|
Loading…
Reference in New Issue
Block a user