Commit b466a99f authored by Ben Smith's avatar Ben Smith Committed by Commit Bot

[wasm] Rename type to value in Global constructor

This was renamed recently in the spec.

Change-Id: I825e47e8b4113ddb2c3356ee8e7663705ba65e1c
Reviewed-on: https://chromium-review.googlesource.com/1079851Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Ben Smith <binji@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53448}
parent 53d4dfc3
...@@ -888,11 +888,13 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -888,11 +888,13 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
} }
} }
// The descriptor's 'type'. // 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.
i::wasm::ValueType type; i::wasm::ValueType type;
{ {
v8::MaybeLocal<v8::Value> maybe = v8::MaybeLocal<v8::Value> maybe =
descriptor->Get(context, v8_str(isolate, "type")); descriptor->Get(context, v8_str(isolate, "value"));
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
if (!maybe.ToLocal(&value)) return; if (!maybe.ToLocal(&value)) return;
v8::Local<v8::String> string; v8::Local<v8::String> string;
...@@ -909,7 +911,7 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -909,7 +911,7 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
type = i::wasm::kWasmF64; type = i::wasm::kWasmF64;
} else { } else {
thrower.TypeError( thrower.TypeError(
"Descriptor property 'type' must be 'i32', 'f32', or 'f64'"); "Descriptor property 'value' must be 'i32', 'f32', or 'f64'");
return; return;
} }
} }
......
...@@ -8,7 +8,7 @@ load("test/mjsunit/wasm/wasm-constants.js"); ...@@ -8,7 +8,7 @@ load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js"); load("test/mjsunit/wasm/wasm-module-builder.js");
(function TestBasic() { (function TestBasic() {
let global = new WebAssembly.Global({type: 'i32'}, 1); let global = new WebAssembly.Global({value: 'i32'}, 1);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
builder.addImportedGlobal("mod", "g", kWasmI32); builder.addImportedGlobal("mod", "g", kWasmI32);
builder.addFunction("main", kSig_i_v) builder.addFunction("main", kSig_i_v)
...@@ -20,7 +20,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -20,7 +20,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
})(); })();
(function TestTypeMismatch() { (function TestTypeMismatch() {
let global = new WebAssembly.Global({type: 'f32'}, 1); let global = new WebAssembly.Global({value: 'f32'}, 1);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
builder.addImportedGlobal("mod", "g", kWasmI32); builder.addImportedGlobal("mod", "g", kWasmI32);
...@@ -28,13 +28,13 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -28,13 +28,13 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
})(); })();
(function TestMutableMismatch() { (function TestMutableMismatch() {
let global = new WebAssembly.Global({type: 'f64'}, 1); let global = new WebAssembly.Global({value: 'f64'}, 1);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
builder.addImportedGlobal("mod", "g", kWasmF64, true); builder.addImportedGlobal("mod", "g", kWasmF64, true);
assertThrows(() => builder.instantiate({mod: {g: global}})); assertThrows(() => builder.instantiate({mod: {g: global}}));
global = new WebAssembly.Global({type: 'i32', mutable: true}, 1); global = new WebAssembly.Global({value: 'i32', mutable: true}, 1);
builder = new WasmModuleBuilder(); builder = new WasmModuleBuilder();
builder.addImportedGlobal("mod", "g", kWasmI32); builder.addImportedGlobal("mod", "g", kWasmI32);
...@@ -73,7 +73,7 @@ function addGlobalGetterAndSetter(builder, index, name, type) { ...@@ -73,7 +73,7 @@ function addGlobalGetterAndSetter(builder, index, name, type) {
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
for (let [index, {name, type}] of globalDesc.entries()) { for (let [index, {name, type}] of globalDesc.entries()) {
globals[name] = new WebAssembly.Global({type: name, mutable: true}); globals[name] = new WebAssembly.Global({value: name, mutable: true});
builder.addImportedGlobal("mod", name, type, true); builder.addImportedGlobal("mod", name, type, true);
addGlobalGetterAndSetter(builder, index, name, type); addGlobalGetterAndSetter(builder, index, name, type);
} }
......
...@@ -21,11 +21,11 @@ function assertGlobalIsValid(global) { ...@@ -21,11 +21,11 @@ function assertGlobalIsValid(global) {
assertThrows(() => new WebAssembly.Global(""), TypeError); assertThrows(() => new WebAssembly.Global(""), TypeError);
assertThrows(() => new WebAssembly.Global({}), TypeError); assertThrows(() => new WebAssembly.Global({}), TypeError);
assertThrows(() => new WebAssembly.Global({type: 'foo'}), TypeError); assertThrows(() => new WebAssembly.Global({value: 'foo'}), TypeError);
assertThrows(() => new WebAssembly.Global({type: 'i64'}), TypeError); assertThrows(() => new WebAssembly.Global({value: 'i64'}), TypeError);
for (let type of ['i32', 'f32', 'f64']) { for (let type of ['i32', 'f32', 'f64']) {
assertGlobalIsValid(new WebAssembly.Global({type})); assertGlobalIsValid(new WebAssembly.Global({value: type}));
} }
})(); })();
...@@ -215,7 +215,7 @@ const f64_values = [ ...@@ -215,7 +215,7 @@ const f64_values = [
]; ];
function GlobalI32(value, mutable = false) { function GlobalI32(value, mutable = false) {
return new WebAssembly.Global({type: 'i32', mutable}, value); return new WebAssembly.Global({value: 'i32', mutable}, value);
} }
function GlobalI64(mutable = false) { function GlobalI64(mutable = false) {
...@@ -227,11 +227,11 @@ function GlobalI64(mutable = false) { ...@@ -227,11 +227,11 @@ function GlobalI64(mutable = false) {
} }
function GlobalF32(value, mutable = false) { function GlobalF32(value, mutable = false) {
return new WebAssembly.Global({type: 'f32', mutable}, value); return new WebAssembly.Global({value: 'f32', mutable}, value);
} }
function GlobalF64(value, mutable = false) { function GlobalF64(value, mutable = false) {
return new WebAssembly.Global({type: 'f64', mutable}, value); return new WebAssembly.Global({value: 'f64', mutable}, value);
} }
(function TestDefaultValue() { (function TestDefaultValue() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment