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(
// However, the bigint proposal allows importing constant i64 values,
// as non WebAssembly.Global object.
if (global.type == kWasmI64 && !enabled_.bigint &&
!(enabled_.mut_global && value->IsWasmGlobalObject())) {
!value->IsWasmGlobalObject()) {
ReportLinkError("global import cannot have type i64", import_index,
module_name, import_name);
return false;
......@@ -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) {
ReportLinkError(
"imported mutable global must be a WebAssembly.Global object",
import_index, module_name, import_name);
return false;
}
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) {
ReportLinkError(
"imported mutable global must be a WebAssembly.Global object",
import_index, module_name, import_name);
return false;
}
if (global.type == ValueType::kWasmAnyRef) {
......@@ -1882,11 +1881,8 @@ bool InstanceBuilder::ProcessImportedGlobal(
return true;
}
ReportLinkError(
enabled_.mut_global
? "global import must be a number or WebAssembly.Global object"
: "global import must be a number",
import_index, module_name, import_name);
ReportLinkError("global import must be a number or WebAssembly.Global object",
import_index, module_name, import_name);
return false;
}
......@@ -2192,68 +2188,41 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
}
case kExternalGlobal: {
const WasmGlobal& global = module_->globals[exp.index];
if (enabled_.mut_global) {
Handle<JSArrayBuffer> untagged_buffer;
Handle<FixedArray> tagged_buffer;
uint32_t offset;
if (global.mutability && global.imported) {
Handle<FixedArray> buffers_array(
instance->imported_mutable_globals_buffers(), isolate_);
untagged_buffer = buffers_array->GetValueChecked<JSArrayBuffer>(
isolate_, global.index);
Address global_addr =
instance->imported_mutable_globals()[global.index];
size_t buffer_size = untagged_buffer->byte_length();
Address backing_store =
reinterpret_cast<Address>(untagged_buffer->backing_store());
CHECK(global_addr >= backing_store &&
global_addr < backing_store + buffer_size);
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);
Handle<JSArrayBuffer> untagged_buffer;
Handle<FixedArray> tagged_buffer;
uint32_t offset;
if (global.mutability && global.imported) {
Handle<FixedArray> buffers_array(
instance->imported_mutable_globals_buffers(), isolate_);
untagged_buffer = buffers_array->GetValueChecked<JSArrayBuffer>(
isolate_, global.index);
Address global_addr =
instance->imported_mutable_globals()[global.index];
size_t buffer_size = untagged_buffer->byte_length();
Address backing_store =
reinterpret_cast<Address>(untagged_buffer->backing_store());
CHECK(global_addr >= backing_store &&
global_addr < backing_store + buffer_size);
offset = static_cast<uint32_t>(global_addr - backing_store);
} else {
// Export the value of the global variable as a number.
double num = 0;
switch (global.type) {
case kWasmI32:
num = ReadLittleEndianValue<int32_t>(
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();
if (global.type == kWasmAnyRef) {
tagged_buffer = handle(instance->tagged_globals_buffer(), isolate_);
} else {
untagged_buffer =
handle(instance->untagged_globals_buffer(), isolate_);
}
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;
}
case kExternalException: {
......
......@@ -566,11 +566,7 @@ class ModuleDecoderImpl : public Decoder {
global->type = consume_value_type();
global->mutability = consume_mutability();
if (global->mutability) {
if (enabled_features_.mut_global) {
module_->num_imported_mutable_globals++;
} else {
error("mutable globals cannot be imported");
}
module_->num_imported_mutable_globals++;
}
break;
}
......@@ -714,9 +710,6 @@ class ModuleDecoderImpl : public Decoder {
WasmGlobal* global = nullptr;
exp->index = consume_global_index(module_.get(), &global);
if (global) {
if (!enabled_features_.mut_global && global->mutability) {
error("mutable globals cannot be exported");
}
global->exported = true;
}
break;
......@@ -1191,7 +1184,6 @@ class ModuleDecoderImpl : public Decoder {
uint32_t num_imported_mutable_globals = 0;
for (WasmGlobal& global : module->globals) {
if (global.mutability && global.imported) {
DCHECK(enabled_features_.mut_global);
global.index = num_imported_mutable_globals++;
} else if (global.type == ValueType::kWasmAnyRef) {
global.offset = tagged_offset;
......
......@@ -21,8 +21,6 @@
SEPARATOR \
V(anyref, "anyref opcodes", false) \
SEPARATOR \
V(mut_global, "import/export mutable global support", true) \
SEPARATOR \
V(bigint, "JS BigInt support", false) \
SEPARATOR \
V(bulk_memory, "bulk memory opcodes", false)
......
......@@ -1770,24 +1770,21 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
auto enabled_features = i::wasm::WasmFeaturesFromFlags();
// Setup Global
if (enabled_features.mut_global) {
Handle<JSFunction> global_constructor = InstallConstructorFunc(
isolate, webassembly, "Global", WebAssemblyGlobal);
context->set_wasm_global_constructor(*global_constructor);
SetDummyInstanceTemplate(isolate, global_constructor);
JSFunction::EnsureHasInitialMap(global_constructor);
Handle<JSObject> global_proto(
JSObject::cast(global_constructor->instance_prototype()), isolate);
i::Handle<i::Map> global_map = isolate->factory()->NewMap(
i::WASM_GLOBAL_TYPE, WasmGlobalObject::kSize);
JSFunction::SetInitialMap(global_constructor, global_map, global_proto);
InstallFunc(isolate, global_proto, "valueOf", WebAssemblyGlobalValueOf, 0);
InstallGetterSetter(isolate, global_proto, "value",
WebAssemblyGlobalGetValue, WebAssemblyGlobalSetValue);
JSObject::AddProperty(isolate, global_proto,
factory->to_string_tag_symbol(),
v8_str(isolate, "WebAssembly.Global"), ro_attributes);
}
Handle<JSFunction> global_constructor =
InstallConstructorFunc(isolate, webassembly, "Global", WebAssemblyGlobal);
context->set_wasm_global_constructor(*global_constructor);
SetDummyInstanceTemplate(isolate, global_constructor);
JSFunction::EnsureHasInitialMap(global_constructor);
Handle<JSObject> global_proto(
JSObject::cast(global_constructor->instance_prototype()), isolate);
i::Handle<i::Map> global_map =
isolate->factory()->NewMap(i::WASM_GLOBAL_TYPE, WasmGlobalObject::kSize);
JSFunction::SetInitialMap(global_constructor, global_map, global_proto);
InstallFunc(isolate, global_proto, "valueOf", WebAssemblyGlobalValueOf, 0);
InstallGetterSetter(isolate, global_proto, "value", WebAssemblyGlobalGetValue,
WebAssemblyGlobalSetValue);
JSObject::AddProperty(isolate, global_proto, factory->to_string_tag_symbol(),
v8_str(isolate, "WebAssembly.Global"), ro_attributes);
// Setup Exception
if (enabled_features.eh) {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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-module-builder.js");
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-wasm-mut-global
load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js");
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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-module-builder.js");
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-wasm-mut-global
function assertGlobalIsValid(global) {
assertSame(WebAssembly.Global.prototype, global.__proto__);
assertSame(WebAssembly.Global, global.constructor);
......
......@@ -347,7 +347,6 @@ TEST_F(WasmModuleVerifyTest, ZeroGlobals) {
}
TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) {
WASM_FEATURE_SCOPE(mut_global);
{
static const byte data[] = {
SECTION(Global, // --
......@@ -1648,7 +1647,6 @@ TEST_F(WasmModuleVerifyTest, ImportTable_nosigs1) {
}
TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
WASM_FEATURE_SCOPE(mut_global);
{
static const byte data[] = {
SECTION(Import, // section header
......@@ -1676,7 +1674,6 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) {
}
TEST_F(WasmModuleVerifyTest, ImportTable_mutability_malformed) {
WASM_FEATURE_SCOPE(mut_global);
static const byte data[] = {
SECTION(Import,
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