Commit 2755543a authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Remove --experimental-wasm-mut-global flag

The flag has been enabled by default since June 2018, see
https://crrev.com/c/1095650.

R=binji@chromium.org

Bug: v8:7625
Change-Id: I7cb4874db7f632b593f912e084b9fb7b8d568afe
Reviewed-on: https://chromium-review.googlesource.com/c/1402546Reviewed-by: 's avatarBen Smith <binji@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58689}
parent d024b9a1
...@@ -1825,7 +1825,7 @@ bool InstanceBuilder::ProcessImportedGlobal( ...@@ -1825,7 +1825,7 @@ bool InstanceBuilder::ProcessImportedGlobal(
// However, the bigint proposal allows importing constant i64 values, // However, the bigint proposal allows importing constant i64 values,
// as non WebAssembly.Global object. // as non WebAssembly.Global object.
if (global.type == kWasmI64 && !enabled_.bigint && if (global.type == kWasmI64 && !enabled_.bigint &&
!(enabled_.mut_global && value->IsWasmGlobalObject())) { !value->IsWasmGlobalObject()) {
ReportLinkError("global import cannot have type i64", import_index, ReportLinkError("global import cannot have type i64", import_index,
module_name, import_name); module_name, import_name);
return false; return false;
...@@ -1846,20 +1846,19 @@ bool InstanceBuilder::ProcessImportedGlobal( ...@@ -1846,20 +1846,19 @@ bool InstanceBuilder::ProcessImportedGlobal(
} }
} }
} }
if (enabled_.mut_global) {
if (value->IsWasmGlobalObject()) {
auto global_object = Handle<WasmGlobalObject>::cast(value);
return ProcessImportedWasmGlobalObject(
instance, import_index, next_imported_mutable_global_index,
module_name, import_name, global, global_object);
}
if (global.mutability) { if (value->IsWasmGlobalObject()) {
ReportLinkError( auto global_object = Handle<WasmGlobalObject>::cast(value);
"imported mutable global must be a WebAssembly.Global object", return ProcessImportedWasmGlobalObject(
import_index, module_name, import_name); instance, import_index, next_imported_mutable_global_index, module_name,
return false; import_name, global, global_object);
} }
if (global.mutability) {
ReportLinkError(
"imported mutable global must be a WebAssembly.Global object",
import_index, module_name, import_name);
return false;
} }
if (global.type == ValueType::kWasmAnyRef) { if (global.type == ValueType::kWasmAnyRef) {
...@@ -1882,11 +1881,8 @@ bool InstanceBuilder::ProcessImportedGlobal( ...@@ -1882,11 +1881,8 @@ bool InstanceBuilder::ProcessImportedGlobal(
return true; return true;
} }
ReportLinkError( ReportLinkError("global import must be a number or WebAssembly.Global object",
enabled_.mut_global import_index, module_name, import_name);
? "global import must be a number or WebAssembly.Global object"
: "global import must be a number",
import_index, module_name, import_name);
return false; return false;
} }
...@@ -2192,68 +2188,41 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) { ...@@ -2192,68 +2188,41 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
} }
case kExternalGlobal: { case kExternalGlobal: {
const WasmGlobal& global = module_->globals[exp.index]; const WasmGlobal& global = module_->globals[exp.index];
if (enabled_.mut_global) { Handle<JSArrayBuffer> untagged_buffer;
Handle<JSArrayBuffer> untagged_buffer; Handle<FixedArray> tagged_buffer;
Handle<FixedArray> tagged_buffer; uint32_t offset;
uint32_t offset;
if (global.mutability && global.imported) {
if (global.mutability && global.imported) { Handle<FixedArray> buffers_array(
Handle<FixedArray> buffers_array( instance->imported_mutable_globals_buffers(), isolate_);
instance->imported_mutable_globals_buffers(), isolate_); untagged_buffer = buffers_array->GetValueChecked<JSArrayBuffer>(
untagged_buffer = buffers_array->GetValueChecked<JSArrayBuffer>( isolate_, global.index);
isolate_, global.index); Address global_addr =
Address global_addr = instance->imported_mutable_globals()[global.index];
instance->imported_mutable_globals()[global.index];
size_t buffer_size = untagged_buffer->byte_length();
size_t buffer_size = untagged_buffer->byte_length(); Address backing_store =
Address backing_store = reinterpret_cast<Address>(untagged_buffer->backing_store());
reinterpret_cast<Address>(untagged_buffer->backing_store()); CHECK(global_addr >= backing_store &&
CHECK(global_addr >= backing_store && global_addr < backing_store + buffer_size);
global_addr < backing_store + buffer_size); offset = static_cast<uint32_t>(global_addr - backing_store);
offset = static_cast<uint32_t>(global_addr - backing_store);
} else {
if (global.type == kWasmAnyRef) {
tagged_buffer =
handle(instance->tagged_globals_buffer(), isolate_);
} else {
untagged_buffer =
handle(instance->untagged_globals_buffer(), isolate_);
}
offset = global.offset;
}
// Since the global's array untagged_buffer is always provided,
// allocation should never fail.
Handle<WasmGlobalObject> global_obj =
WasmGlobalObject::New(isolate_, untagged_buffer, tagged_buffer,
global.type, offset, global.mutability)
.ToHandleChecked();
desc.set_value(global_obj);
} else { } else {
// Export the value of the global variable as a number. if (global.type == kWasmAnyRef) {
double num = 0; tagged_buffer = handle(instance->tagged_globals_buffer(), isolate_);
switch (global.type) { } else {
case kWasmI32: untagged_buffer =
num = ReadLittleEndianValue<int32_t>( handle(instance->untagged_globals_buffer(), isolate_);
GetRawGlobalPtr<int32_t>(global));
break;
case kWasmF32:
num =
ReadLittleEndianValue<float>(GetRawGlobalPtr<float>(global));
break;
case kWasmF64:
num = ReadLittleEndianValue<double>(
GetRawGlobalPtr<double>(global));
break;
case kWasmI64:
thrower_->LinkError(
"export of globals of type I64 is not allowed.");
return;
default:
UNREACHABLE();
} }
desc.set_value(isolate_->factory()->NewNumber(num)); offset = global.offset;
} }
// Since the global's array untagged_buffer is always provided,
// allocation should never fail.
Handle<WasmGlobalObject> global_obj =
WasmGlobalObject::New(isolate_, untagged_buffer, tagged_buffer,
global.type, offset, global.mutability)
.ToHandleChecked();
desc.set_value(global_obj);
break; break;
} }
case kExternalException: { case kExternalException: {
......
...@@ -566,11 +566,7 @@ class ModuleDecoderImpl : public Decoder { ...@@ -566,11 +566,7 @@ class ModuleDecoderImpl : public Decoder {
global->type = consume_value_type(); global->type = consume_value_type();
global->mutability = consume_mutability(); global->mutability = consume_mutability();
if (global->mutability) { if (global->mutability) {
if (enabled_features_.mut_global) { module_->num_imported_mutable_globals++;
module_->num_imported_mutable_globals++;
} else {
error("mutable globals cannot be imported");
}
} }
break; break;
} }
...@@ -714,9 +710,6 @@ class ModuleDecoderImpl : public Decoder { ...@@ -714,9 +710,6 @@ class ModuleDecoderImpl : public Decoder {
WasmGlobal* global = nullptr; WasmGlobal* global = nullptr;
exp->index = consume_global_index(module_.get(), &global); exp->index = consume_global_index(module_.get(), &global);
if (global) { if (global) {
if (!enabled_features_.mut_global && global->mutability) {
error("mutable globals cannot be exported");
}
global->exported = true; global->exported = true;
} }
break; break;
...@@ -1191,7 +1184,6 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1191,7 +1184,6 @@ class ModuleDecoderImpl : public Decoder {
uint32_t num_imported_mutable_globals = 0; uint32_t num_imported_mutable_globals = 0;
for (WasmGlobal& global : module->globals) { for (WasmGlobal& global : module->globals) {
if (global.mutability && global.imported) { if (global.mutability && global.imported) {
DCHECK(enabled_features_.mut_global);
global.index = num_imported_mutable_globals++; global.index = num_imported_mutable_globals++;
} else if (global.type == ValueType::kWasmAnyRef) { } else if (global.type == ValueType::kWasmAnyRef) {
global.offset = tagged_offset; global.offset = tagged_offset;
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
SEPARATOR \ SEPARATOR \
V(anyref, "anyref opcodes", false) \ V(anyref, "anyref opcodes", false) \
SEPARATOR \ SEPARATOR \
V(mut_global, "import/export mutable global support", true) \
SEPARATOR \
V(bigint, "JS BigInt support", false) \ V(bigint, "JS BigInt support", false) \
SEPARATOR \ SEPARATOR \
V(bulk_memory, "bulk memory opcodes", false) V(bulk_memory, "bulk memory opcodes", false)
......
...@@ -1770,24 +1770,21 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) { ...@@ -1770,24 +1770,21 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
auto enabled_features = i::wasm::WasmFeaturesFromFlags(); auto enabled_features = i::wasm::WasmFeaturesFromFlags();
// Setup Global // Setup Global
if (enabled_features.mut_global) { Handle<JSFunction> global_constructor =
Handle<JSFunction> global_constructor = InstallConstructorFunc( InstallConstructorFunc(isolate, webassembly, "Global", WebAssemblyGlobal);
isolate, webassembly, "Global", WebAssemblyGlobal); context->set_wasm_global_constructor(*global_constructor);
context->set_wasm_global_constructor(*global_constructor); SetDummyInstanceTemplate(isolate, global_constructor);
SetDummyInstanceTemplate(isolate, global_constructor); JSFunction::EnsureHasInitialMap(global_constructor);
JSFunction::EnsureHasInitialMap(global_constructor); Handle<JSObject> global_proto(
Handle<JSObject> global_proto( JSObject::cast(global_constructor->instance_prototype()), isolate);
JSObject::cast(global_constructor->instance_prototype()), isolate); i::Handle<i::Map> global_map =
i::Handle<i::Map> global_map = isolate->factory()->NewMap( isolate->factory()->NewMap(i::WASM_GLOBAL_TYPE, WasmGlobalObject::kSize);
i::WASM_GLOBAL_TYPE, WasmGlobalObject::kSize); JSFunction::SetInitialMap(global_constructor, global_map, global_proto);
JSFunction::SetInitialMap(global_constructor, global_map, global_proto); InstallFunc(isolate, global_proto, "valueOf", WebAssemblyGlobalValueOf, 0);
InstallFunc(isolate, global_proto, "valueOf", WebAssemblyGlobalValueOf, 0); InstallGetterSetter(isolate, global_proto, "value", WebAssemblyGlobalGetValue,
InstallGetterSetter(isolate, global_proto, "value", WebAssemblyGlobalSetValue);
WebAssemblyGlobalGetValue, WebAssemblyGlobalSetValue); JSObject::AddProperty(isolate, global_proto, factory->to_string_tag_symbol(),
JSObject::AddProperty(isolate, global_proto, v8_str(isolate, "WebAssembly.Global"), ro_attributes);
factory->to_string_tag_symbol(),
v8_str(isolate, "WebAssembly.Global"), ro_attributes);
}
// Setup Exception // Setup Exception
if (enabled_features.eh) { if (enabled_features.eh) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --experimental-wasm-anyref --expose-gc --experimental-wasm-mut-global // Flags: --experimental-wasm-anyref --expose-gc
load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js"); load("test/mjsunit/wasm/wasm-module-builder.js");
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --experimental-wasm-mut-global
load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js"); load("test/mjsunit/wasm/wasm-module-builder.js");
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --experimental-wasm-mut-global --expose-gc // Flags: --expose-gc
load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js"); load("test/mjsunit/wasm/wasm-module-builder.js");
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --experimental-wasm-mut-global
function assertGlobalIsValid(global) { function assertGlobalIsValid(global) {
assertSame(WebAssembly.Global.prototype, global.__proto__); assertSame(WebAssembly.Global.prototype, global.__proto__);
assertSame(WebAssembly.Global, global.constructor); assertSame(WebAssembly.Global, global.constructor);
......
...@@ -347,7 +347,6 @@ TEST_F(WasmModuleVerifyTest, ZeroGlobals) { ...@@ -347,7 +347,6 @@ TEST_F(WasmModuleVerifyTest, ZeroGlobals) {
} }
TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) { TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) {
WASM_FEATURE_SCOPE(mut_global);
{ {
static const byte data[] = { static const byte data[] = {
SECTION(Global, // -- SECTION(Global, // --
...@@ -1648,7 +1647,6 @@ TEST_F(WasmModuleVerifyTest, ImportTable_nosigs1) { ...@@ -1648,7 +1647,6 @@ TEST_F(WasmModuleVerifyTest, ImportTable_nosigs1) {
} }
TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) { TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
WASM_FEATURE_SCOPE(mut_global);
{ {
static const byte data[] = { static const byte data[] = {
SECTION(Import, // section header SECTION(Import, // section header
...@@ -1676,7 +1674,6 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) { ...@@ -1676,7 +1674,6 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
} }
TEST_F(WasmModuleVerifyTest, ImportTable_mutability_malformed) { TEST_F(WasmModuleVerifyTest, ImportTable_mutability_malformed) {
WASM_FEATURE_SCOPE(mut_global);
static const byte data[] = { static const byte data[] = {
SECTION(Import, SECTION(Import,
ENTRY_COUNT(1), // -- ENTRY_COUNT(1), // --
......
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