mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 04:05:32 +00:00
Bug 1490286 - Ignore 'undefined' value when constructing wasm global. r=jseward
The WebIDL spec stipulates that if an undefined value is provided explicitly then the behavior is as for when the value is missing: we use the default value, which for floating numeric types is zero, not NaN. --HG-- extra : rebase_source : 1d27823efd287aa4be708a6c9e79147afd5311f4
This commit is contained in:
parent
0da68cc82b
commit
b16f6a6356
@ -47,9 +47,8 @@ assertEq(new WebAssembly.Global({value: "anyref"}) instanceof WebAssembly.Global
|
||||
assertEq(g.value instanceof Symbol, true);
|
||||
assertEq(g.value.toString(), "Symbol(status)");
|
||||
|
||||
assertErrorMessage(() => new WebAssembly.Global({value: "anyref"}, undefined),
|
||||
TypeError,
|
||||
"can't convert undefined to object");
|
||||
g = new WebAssembly.Global({value: "anyref"}, undefined);
|
||||
assertEq(g.value, null);
|
||||
})();
|
||||
|
||||
(function() {
|
||||
|
@ -2465,20 +2465,23 @@ WasmGlobalObject::construct(JSContext* cx, unsigned argc, Value* vp)
|
||||
|
||||
// Extract the initial value, or provide a suitable default.
|
||||
RootedVal globalVal(cx);
|
||||
if (args.length() >= 2) {
|
||||
RootedValue valueVal(cx, args.get(1));
|
||||
|
||||
// Initialize with default value.
|
||||
switch (globalType.code()) {
|
||||
case ValType::I32: globalVal = Val(uint32_t(0)); break;
|
||||
case ValType::I64: globalVal = Val(uint64_t(0)); break;
|
||||
case ValType::F32: globalVal = Val(float(0.0)); break;
|
||||
case ValType::F64: globalVal = Val(double(0.0)); break;
|
||||
case ValType::AnyRef: globalVal = Val(nullptr); break;
|
||||
case ValType::Ref: MOZ_CRASH("Ref NYI");
|
||||
}
|
||||
|
||||
// Override with non-undefined value, if provided.
|
||||
RootedValue valueVal(cx, args.get(1));
|
||||
if (!valueVal.isUndefined()) {
|
||||
if (!ToWebAssemblyValue(cx, globalType, valueVal, &globalVal)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
switch (globalType.code()) {
|
||||
case ValType::I32: globalVal = Val(uint32_t(0)); break;
|
||||
case ValType::I64: globalVal = Val(uint64_t(0)); break;
|
||||
case ValType::F32: globalVal = Val(float(0.0)); break;
|
||||
case ValType::F64: globalVal = Val(double(0.0)); break;
|
||||
case ValType::AnyRef: globalVal = Val(nullptr); break;
|
||||
case ValType::Ref: MOZ_CRASH("Ref NYI");
|
||||
}
|
||||
}
|
||||
|
||||
WasmGlobalObject* global = WasmGlobalObject::create(cx, globalVal, isMutable);
|
||||
|
@ -3,37 +3,12 @@
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490232
|
||||
expected: FAIL
|
||||
|
||||
[Explicit value undefined for type f32]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490286
|
||||
expected: FAIL
|
||||
|
||||
[Explicit value undefined for type f64]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490286
|
||||
expected: FAIL
|
||||
|
||||
[constructor.any.worker.html]
|
||||
[Order of evaluation]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490232
|
||||
expected: FAIL
|
||||
|
||||
[Explicit value undefined for type f32]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490286
|
||||
expected: FAIL
|
||||
|
||||
[Explicit value undefined for type f64]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490286
|
||||
expected: FAIL
|
||||
|
||||
[constructor.any.js]
|
||||
[Order of evaluation]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490232
|
||||
expected: FAIL
|
||||
|
||||
[Explicit value undefined for type f32]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490286
|
||||
expected: FAIL
|
||||
|
||||
[Explicit value undefined for type f64]
|
||||
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1490286
|
||||
expected: FAIL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user