[wasm] fix js-api global/constructor
Fix WebAssembly's global/constructor js-api. Globals with a value of i64 is now valid even if Wasm BigInt feature isn't activated. Bug: v8:8319 Cq-Include-Trybots: luci.chromium.try:linux-blink-rel Change-Id: Ia41ad69efa5253064ecdb8f59b149393cd672b68 Reviewed-on: https://chromium-review.googlesource.com/c/1382747 Commit-Queue: Ben Smith <binji@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Ben Smith <binji@chromium.org> Cr-Commit-Position: refs/heads/master@{#58603}
This commit is contained in:
parent
0bd4e348e0
commit
4365bf23aa
@ -1132,8 +1132,6 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
}
|
||||
}
|
||||
|
||||
auto enabled_features = i::wasm::WasmFeaturesFromIsolate(i_isolate);
|
||||
|
||||
// The descriptor's type, called 'value'. It is called 'value' because this
|
||||
// descriptor is planned to be re-used as the global's type for reflection,
|
||||
// so calling it 'type' is redundant.
|
||||
@ -1150,21 +1148,14 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
type = i::wasm::kWasmI32;
|
||||
} else if (string->StringEquals(v8_str(isolate, "f32"))) {
|
||||
type = i::wasm::kWasmF32;
|
||||
} else if (enabled_features.bigint &&
|
||||
string->StringEquals(v8_str(isolate, "i64"))) {
|
||||
} else if (string->StringEquals(v8_str(isolate, "i64"))) {
|
||||
type = i::wasm::kWasmI64;
|
||||
} else if (string->StringEquals(v8_str(isolate, "f64"))) {
|
||||
type = i::wasm::kWasmF64;
|
||||
} else {
|
||||
if (enabled_features.bigint) {
|
||||
thrower.TypeError(
|
||||
"Descriptor property 'value' must be 'i32', 'i64', 'f32', or "
|
||||
"'f64'");
|
||||
} else {
|
||||
thrower.TypeError(
|
||||
"Descriptor property 'value' must be 'i32', 'f32', or 'f64'");
|
||||
}
|
||||
|
||||
thrower.TypeError(
|
||||
"Descriptor property 'value' must be 'i32', 'i64', 'f32', or "
|
||||
"'f64'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1194,10 +1185,14 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
break;
|
||||
}
|
||||
case i::wasm::kWasmI64: {
|
||||
DCHECK(enabled_features.bigint);
|
||||
|
||||
int64_t i64_value = 0;
|
||||
if (!value->IsUndefined()) {
|
||||
auto enabled_features = i::wasm::WasmFeaturesFromIsolate(i_isolate);
|
||||
if (!enabled_features.bigint) {
|
||||
thrower.TypeError("Can't set the value of i64 WebAssembly.Global");
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::BigInt> bigint_value;
|
||||
if (!value->ToBigInt(context).ToLocal(&bigint_value)) return;
|
||||
i64_value = bigint_value->Int64Value();
|
||||
|
@ -925,3 +925,10 @@ assertInstantiateSuccess(
|
||||
var instance = new WebAssembly.Instance(module);
|
||||
assertTrue(instance instanceof Instance);
|
||||
})();
|
||||
|
||||
(function TestPassBigIntInGlobalWhenNotEnabled() {
|
||||
assertThrows(() => new WebAssembly.Global({ value: "i64" }, 1), TypeError,
|
||||
/Can't set the value/);
|
||||
assertThrows(() => new WebAssembly.Global({ value: "i64" }, 1n), TypeError,
|
||||
/Can't set the value/);
|
||||
})();
|
||||
|
@ -22,9 +22,9 @@ function assertGlobalIsValid(global) {
|
||||
|
||||
assertThrows(() => new WebAssembly.Global({}), TypeError);
|
||||
assertThrows(() => new WebAssembly.Global({value: 'foo'}), TypeError);
|
||||
assertThrows(() => new WebAssembly.Global({value: 'i64'}), TypeError);
|
||||
assertThrows(() => new WebAssembly.Global({value: 'i128'}), TypeError);
|
||||
|
||||
for (let type of ['i32', 'f32', 'f64']) {
|
||||
for (let type of ['i32', 'f32', 'f64', 'i64']) {
|
||||
assertGlobalIsValid(new WebAssembly.Global({value: type}));
|
||||
}
|
||||
})();
|
||||
|
@ -9,7 +9,6 @@
|
||||
'table/grow': [FAIL],
|
||||
'table/get-set': [FAIL],
|
||||
'module/customSections': [FAIL],
|
||||
'global/constructor': [FAIL],
|
||||
'global/value-get-set': [FAIL],
|
||||
}], # ALWAYS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user