author | Julian Seward <jseward@acm.org> |
Fri, 25 May 2018 13:31:46 +0200 | |
changeset 419885 | 998c04fd7948e070c3ffbe456d98a0d876911c72 |
parent 419884 | e5a47fceeee0bf002f521c9e35242769887cdeb0 |
child 419886 | 109d4f846f31e2263598fb40786f325bc26b9e20 |
push id | 34052 |
push user | ccoroiu@mozilla.com |
push date | Fri, 25 May 2018 17:52:14 +0000 |
treeherder | mozilla-central@94d7f0e1c4d0 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | lth |
bugs | 1461727 |
milestone | 62.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
js/src/jit-test/tests/wasm/globals.js | file | annotate | diff | comparison | revisions | |
js/src/wasm/WasmJS.cpp | file | annotate | diff | comparison | revisions |
--- a/js/src/jit-test/tests/wasm/globals.js +++ b/js/src/jit-test/tests/wasm/globals.js @@ -345,66 +345,66 @@ wasmAssert(`(module // WebAssembly.Global experiment if (typeof WebAssembly.Global === "function") { const Global = WebAssembly.Global; // These types should work: - assertEq(new Global({type: "i32"}) instanceof Global, true); - assertEq(new Global({type: "f32"}) instanceof Global, true); - assertEq(new Global({type: "f64"}) instanceof Global, true); + assertEq(new Global({value: "i32"}) instanceof Global, true); + assertEq(new Global({value: "f32"}) instanceof Global, true); + assertEq(new Global({value: "f64"}) instanceof Global, true); // These types should not work: - assertErrorMessage(() => new Global({type: "i64"}), TypeError, /bad type for a WebAssembly.Global/); - assertErrorMessage(() => new Global({}), TypeError, /bad type for a WebAssembly.Global/); - assertErrorMessage(() => new Global({type: "fnord"}), TypeError, /bad type for a WebAssembly.Global/); - assertErrorMessage(() => new Global(), TypeError, /Global requires more than 0 arguments/); + assertErrorMessage(() => new Global({value: "i64"}), TypeError, /bad type for a WebAssembly.Global/); + assertErrorMessage(() => new Global({}), TypeError, /bad type for a WebAssembly.Global/); + assertErrorMessage(() => new Global({value: "fnord"}), TypeError, /bad type for a WebAssembly.Global/); + assertErrorMessage(() => new Global(), TypeError, /Global requires more than 0 arguments/); // Coercion of init value; ".value" accessor - assertEq((new Global({type: "i32"}, 3.14)).value, 3); - assertEq((new Global({type: "f32"}, { valueOf: () => 33.5 })).value, 33.5); - assertEq((new Global({type: "f64"}, "3.25")).value, 3.25); + assertEq((new Global({value: "i32"}, 3.14)).value, 3); + assertEq((new Global({value: "f32"}, { valueOf: () => 33.5 })).value, 33.5); + assertEq((new Global({value: "f64"}, "3.25")).value, 3.25); // Nothing special about NaN, it coerces just fine - assertEq((new Global({type: "i32"}, NaN)).value, 0); + assertEq((new Global({value: "i32"}, NaN)).value, 0); // The default init value is zero. - assertEq((new Global({type: "i32"})).value, 0); - assertEq((new Global({type: "f32"})).value, 0); - assertEq((new Global({type: "f64"})).value, 0); + assertEq((new Global({value: "i32"})).value, 0); + assertEq((new Global({value: "f32"})).value, 0); + assertEq((new Global({value: "f64"})).value, 0); { // "value" is enumerable - let x = new Global({type: "i32"}); + let x = new Global({value: "i32"}); let s = ""; for ( let i in x ) s = s + i + ","; assertEq(s, "value,"); } // "value" is defined on the prototype, not on the object assertEq("value" in Global.prototype, true); // Can't set the value of an immutable global - assertErrorMessage(() => (new Global({type: "i32"})).value = 10, + assertErrorMessage(() => (new Global({value: "i32"})).value = 10, TypeError, /can't set value of immutable global/); { // Can set the value of a mutable global - let g = new Global({type: "i32", mutable: true}, 37); + let g = new Global({value: "i32", mutable: true}, 37); g.value = 10; assertEq(g.value, 10); } { // Misc internal conversions - let g = new Global({type: "i32"}, 42); + let g = new Global({value: "i32"}, 42); // valueOf assertEq(g - 5, 37); // @@toStringTag assertEq(g.toString(), "[object WebAssembly.Global]"); } @@ -508,26 +508,26 @@ if (typeof WebAssembly.Global === "funct { const mutErr = /imported global mutability mismatch/; const i64Err = /cannot pass i64 to or from JS/; let m1 = new Module(wasmTextToBinary(`(module (import "m" "g" (global i32)))`)); // Mutable Global matched to immutable import - let gm = new Global({type: "i32", mutable: true}, 42); + let gm = new Global({value: "i32", mutable: true}, 42); assertErrorMessage(() => new Instance(m1, {m: {g: gm}}), LinkError, mutErr); let m2 = new Module(wasmTextToBinary(`(module (import "m" "g" (global (mut i32))))`)); // Immutable Global matched to mutable import - let gi = new Global({type: "i32", mutable: false}, 42); + let gi = new Global({value: "i32", mutable: false}, 42); assertErrorMessage(() => new Instance(m2, {m: {g: gi}}), LinkError, mutErr); // Constant value is the same as immutable Global assertErrorMessage(() => new Instance(m2, {m: {g: 42}}), LinkError, mutErr);
--- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -2166,17 +2166,17 @@ WasmGlobalObject::construct(JSContext* c if (!args.get(0).isObject()) { JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "global"); return false; } RootedObject obj(cx, &args[0].toObject()); RootedValue typeVal(cx); - if (!JS_GetProperty(cx, obj, "type", &typeVal)) + if (!JS_GetProperty(cx, obj, "value", &typeVal)) return false; RootedString typeStr(cx, ToString(cx, typeVal)); if (!typeStr) return false; RootedLinearString typeLinearStr(cx, typeStr->ensureLinear(cx)); if (!typeLinearStr)