[wasm-gc] Remove --wasm-gc-js-interop
This removes the temporary option and sets its value to {true} everywhere. Bug: v8:7748 Change-Id: Icbc3071b531b130c0eb007758452d09b65491c04 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3974510 Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Reviewed-by: Matthias Liedtke <mliedtke@chromium.org> Cr-Commit-Position: refs/heads/main@{#83880}
This commit is contained in:
parent
57a84e1e63
commit
12d8e6a54a
@ -6483,45 +6483,17 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
WasmInternalFunction::kExternalOffset));
|
||||
}
|
||||
}
|
||||
case wasm::HeapType::kEq: {
|
||||
// TODO(7748): Update this when JS interop is settled.
|
||||
auto done = gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
// Do not wrap i31s.
|
||||
gasm_->GotoIf(IsSmi(node), &done, node);
|
||||
if (type.kind() == wasm::kRefNull) {
|
||||
// Do not wrap {null}.
|
||||
gasm_->GotoIf(IsNull(node), &done, node);
|
||||
}
|
||||
gasm_->Goto(&done, BuildAllocateObjectWrapper(node, context));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
}
|
||||
case wasm::HeapType::kEq:
|
||||
case wasm::HeapType::kStruct:
|
||||
case wasm::HeapType::kArray:
|
||||
// TODO(7748): Update this when JS interop is settled.
|
||||
if (type.kind() == wasm::kRefNull) {
|
||||
auto done =
|
||||
gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
// Do not wrap {null}.
|
||||
gasm_->GotoIf(IsNull(node), &done, node);
|
||||
gasm_->Goto(&done, BuildAllocateObjectWrapper(node, context));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
} else {
|
||||
return BuildAllocateObjectWrapper(node, context);
|
||||
}
|
||||
case wasm::HeapType::kString:
|
||||
// Either {node} is already a tagged JS string, or if type.kind() is
|
||||
// wasm::kRefNull, it's the null object. Either way it's good to go
|
||||
// already to JS.
|
||||
return node;
|
||||
case wasm::HeapType::kExtern:
|
||||
case wasm::HeapType::kAny:
|
||||
return node;
|
||||
case wasm::HeapType::kNone:
|
||||
case wasm::HeapType::kNoFunc:
|
||||
case wasm::HeapType::kNoExtern:
|
||||
case wasm::HeapType::kI31:
|
||||
case wasm::HeapType::kAny:
|
||||
UNREACHABLE();
|
||||
default:
|
||||
DCHECK(type.has_index());
|
||||
@ -6548,15 +6520,6 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(7748): Temporary solution to allow round-tripping of Wasm objects
|
||||
// through JavaScript, where they show up as opaque boxes. This will disappear
|
||||
// once we have a proper WasmGC <-> JS interaction story.
|
||||
Node* BuildAllocateObjectWrapper(Node* input, Node* context) {
|
||||
if (v8_flags.wasm_gc_js_interop) return input;
|
||||
return gasm_->CallBuiltin(Builtin::kWasmAllocateObjectWrapper,
|
||||
Operator::kEliminatable, input, context);
|
||||
}
|
||||
|
||||
enum UnwrapExternalFunctions : bool {
|
||||
kUnwrapWasmExternalFunctions = true,
|
||||
kLeaveFunctionsAlone = false
|
||||
|
@ -266,66 +266,20 @@ Reduction WasmGCLowering::ReduceTypeGuard(Node* node) {
|
||||
|
||||
Reduction WasmGCLowering::ReduceWasmExternInternalize(Node* node) {
|
||||
DCHECK_EQ(node->opcode(), IrOpcode::kWasmExternInternalize);
|
||||
Node* effect = NodeProperties::GetEffectInput(node);
|
||||
Node* control = NodeProperties::GetControlInput(node);
|
||||
Node* object = NodeProperties::GetValueInput(node, 0);
|
||||
gasm_.InitializeEffectControl(effect, control);
|
||||
auto end = gasm_.MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
|
||||
if (!v8_flags.wasm_gc_js_interop) {
|
||||
Node* context = gasm_.LoadImmutable(
|
||||
MachineType::TaggedPointer(), instance_node_,
|
||||
WasmInstanceObject::kNativeContextOffset - kHeapObjectTag);
|
||||
Node* obj = gasm_.CallBuiltin(
|
||||
Builtin::kWasmGetOwnProperty, Operator::kEliminatable, object,
|
||||
RootNode(RootIndex::kwasm_wrapped_object_symbol), context);
|
||||
// Invalid object wrappers (i.e. any other JS object that doesn't have the
|
||||
// magic hidden property) will return {undefined}. Map that to {object}.
|
||||
Node* is_undefined =
|
||||
gasm_.TaggedEqual(obj, RootNode(RootIndex::kUndefinedValue));
|
||||
gasm_.GotoIf(is_undefined, &end, object);
|
||||
gasm_.Goto(&end, obj);
|
||||
} else {
|
||||
gasm_.Goto(&end, object);
|
||||
}
|
||||
gasm_.Bind(&end);
|
||||
Node* replacement = end.PhiAt(0);
|
||||
ReplaceWithValue(node, replacement, gasm_.effect(), gasm_.control());
|
||||
// TODO(7748): Canonicalize HeapNumbers.
|
||||
ReplaceWithValue(node, object);
|
||||
node->Kill();
|
||||
return Replace(replacement);
|
||||
return Replace(object);
|
||||
}
|
||||
|
||||
// TODO(7748): WasmExternExternalize is a no-op. Consider removing it.
|
||||
Reduction WasmGCLowering::ReduceWasmExternExternalize(Node* node) {
|
||||
DCHECK_EQ(node->opcode(), IrOpcode::kWasmExternExternalize);
|
||||
Node* effect = NodeProperties::GetEffectInput(node);
|
||||
Node* control = NodeProperties::GetControlInput(node);
|
||||
Node* object = NodeProperties::GetValueInput(node, 0);
|
||||
gasm_.InitializeEffectControl(effect, control);
|
||||
|
||||
auto end = gasm_.MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
if (!v8_flags.wasm_gc_js_interop) {
|
||||
auto wrap = gasm_.MakeLabel();
|
||||
gasm_.GotoIf(gasm_.IsI31(object), &end, object);
|
||||
gasm_.GotoIf(gasm_.IsDataRefMap(gasm_.LoadMap(object)), &wrap);
|
||||
// This includes the case where {node == null}.
|
||||
gasm_.Goto(&end, object);
|
||||
|
||||
gasm_.Bind(&wrap);
|
||||
Node* context = gasm_.LoadImmutable(
|
||||
MachineType::TaggedPointer(), instance_node_,
|
||||
WasmInstanceObject::kNativeContextOffset - kHeapObjectTag);
|
||||
Node* wrapped = gasm_.CallBuiltin(Builtin::kWasmAllocateObjectWrapper,
|
||||
Operator::kEliminatable, object, context);
|
||||
gasm_.Goto(&end, wrapped);
|
||||
} else {
|
||||
gasm_.Goto(&end, object);
|
||||
}
|
||||
|
||||
gasm_.Bind(&end);
|
||||
Node* replacement = end.PhiAt(0);
|
||||
ReplaceWithValue(node, replacement, gasm_.effect(), gasm_.control());
|
||||
ReplaceWithValue(node, object);
|
||||
node->Kill();
|
||||
return Replace(replacement);
|
||||
return Replace(object);
|
||||
}
|
||||
|
||||
} // namespace compiler
|
||||
|
@ -1117,7 +1117,6 @@ DEFINE_IMPLICATION(experimental_wasm_gc, experimental_wasm_typed_funcref)
|
||||
DEFINE_IMPLICATION(experimental_wasm_stack_switching,
|
||||
experimental_wasm_type_reflection)
|
||||
|
||||
DEFINE_BOOL(wasm_gc_js_interop, true, "experimental WasmGC-JS interop")
|
||||
DEFINE_BOOL(wasm_gc_structref_as_dataref, true,
|
||||
"compatibility mode: Treat structref as dataref")
|
||||
|
||||
|
@ -1838,44 +1838,10 @@ class LiftoffCompiler {
|
||||
return;
|
||||
}
|
||||
case kExprExternInternalize:
|
||||
if (!v8_flags.wasm_gc_js_interop) {
|
||||
LiftoffRegList pinned;
|
||||
LiftoffRegister context_reg =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned));
|
||||
LOAD_TAGGED_PTR_INSTANCE_FIELD(context_reg.gp(), NativeContext,
|
||||
pinned);
|
||||
LiftoffAssembler::VarState& extern_value =
|
||||
__ cache_state()->stack_state.back();
|
||||
|
||||
LiftoffAssembler::VarState context(kPointerKind, context_reg, 0);
|
||||
|
||||
CallRuntimeStub(
|
||||
WasmCode::kWasmExternInternalize,
|
||||
MakeSig::Returns(kPointerKind).Params(kPointerKind, kPointerKind),
|
||||
{extern_value, context}, decoder->position());
|
||||
__ DropValues(1);
|
||||
__ PushRegister(kRefNull, LiftoffRegister(kReturnRegister0));
|
||||
}
|
||||
// TODO(7748): Canonicalize heap numbers.
|
||||
return;
|
||||
case kExprExternExternalize:
|
||||
if (!v8_flags.wasm_gc_js_interop) {
|
||||
LiftoffRegList pinned;
|
||||
LiftoffRegister context_reg =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned));
|
||||
LOAD_TAGGED_PTR_INSTANCE_FIELD(context_reg.gp(), NativeContext,
|
||||
pinned);
|
||||
LiftoffAssembler::VarState& value =
|
||||
__ cache_state()->stack_state.back();
|
||||
|
||||
LiftoffAssembler::VarState context(kPointerKind, context_reg, 0);
|
||||
|
||||
CallRuntimeStub(
|
||||
WasmCode::kWasmExternExternalize,
|
||||
MakeSig::Returns(kPointerKind).Params(kPointerKind, kPointerKind),
|
||||
{value, context}, decoder->position());
|
||||
__ DropValues(1);
|
||||
__ PushRegister(kRefNull, LiftoffRegister(kReturnRegister0));
|
||||
}
|
||||
// This is a no-op.
|
||||
return;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -2262,15 +2262,6 @@ void WasmObjectToJSReturnValue(v8::ReturnValue<v8::Value>& return_value,
|
||||
case i::wasm::HeapType::kArray:
|
||||
case i::wasm::HeapType::kEq:
|
||||
case i::wasm::HeapType::kAny: {
|
||||
if (!i::v8_flags.wasm_gc_js_interop && value->IsWasmObject()) {
|
||||
// Transform wasm object into JS-compliant representation.
|
||||
i::Handle<i::JSObject> wrapper =
|
||||
isolate->factory()->NewJSObject(isolate->object_function());
|
||||
i::JSObject::AddProperty(
|
||||
isolate, wrapper, isolate->factory()->wasm_wrapped_object_symbol(),
|
||||
value, i::NONE);
|
||||
value = wrapper;
|
||||
}
|
||||
return_value.Set(Utils::ToLocal(value));
|
||||
return;
|
||||
}
|
||||
@ -2282,17 +2273,6 @@ void WasmObjectToJSReturnValue(v8::ReturnValue<v8::Value>& return_value,
|
||||
i::Handle<i::WasmInternalFunction>::cast(value)->external(),
|
||||
isolate);
|
||||
}
|
||||
return_value.Set(Utils::ToLocal(value));
|
||||
return;
|
||||
}
|
||||
if (!i::v8_flags.wasm_gc_js_interop && value->IsWasmObject()) {
|
||||
// Transform wasm object into JS-compliant representation.
|
||||
i::Handle<i::JSObject> wrapper =
|
||||
isolate->factory()->NewJSObject(isolate->object_function());
|
||||
i::JSObject::AddProperty(
|
||||
isolate, wrapper, isolate->factory()->wasm_wrapped_object_symbol(),
|
||||
value, i::NONE);
|
||||
value = wrapper;
|
||||
}
|
||||
return_value.Set(Utils::ToLocal(value));
|
||||
return;
|
||||
|
@ -267,8 +267,6 @@ MaybeHandle<Object> WasmTableObject::JSToWasmElement(
|
||||
const char** error_message) {
|
||||
// Any `entry` has to be in its JS representation.
|
||||
DCHECK(!entry->IsWasmInternalFunction());
|
||||
DCHECK_IMPLIES(!v8_flags.wasm_gc_js_interop,
|
||||
!entry->IsWasmArray() && !entry->IsWasmStruct());
|
||||
const WasmModule* module =
|
||||
!table->instance().IsUndefined()
|
||||
? WasmInstanceObject::cast(table->instance()).module()
|
||||
@ -2214,24 +2212,6 @@ Handle<AsmWasmData> AsmWasmData::New(
|
||||
return result;
|
||||
}
|
||||
|
||||
namespace {
|
||||
// If {in_out_value} is a wrapped wasm struct/array, it gets unwrapped in-place
|
||||
// and this returns {true}. Otherwise, the value remains unchanged and this
|
||||
// returns {false}.
|
||||
bool TryUnpackObjectWrapper(Isolate* isolate, Handle<Object>& in_out_value) {
|
||||
if (in_out_value->IsUndefined(isolate) || in_out_value->IsNull(isolate) ||
|
||||
!in_out_value->IsJSObject()) {
|
||||
return false;
|
||||
}
|
||||
Handle<Name> key = isolate->factory()->wasm_wrapped_object_symbol();
|
||||
LookupIterator it(isolate, in_out_value, key,
|
||||
LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
if (it.state() != LookupIterator::DATA) return false;
|
||||
in_out_value = it.GetDataValue();
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace wasm {
|
||||
MaybeHandle<Object> JSToWasmObject(Isolate* isolate, const WasmModule* module,
|
||||
Handle<Object> value, ValueType expected,
|
||||
@ -2257,8 +2237,6 @@ MaybeHandle<Object> JSToWasmObject(Isolate* isolate, const WasmModule* module,
|
||||
}
|
||||
V8_FALLTHROUGH;
|
||||
case kRef: {
|
||||
// TODO(7748): Follow any changes in proposed JS API. In particular,
|
||||
// finalize the v8_flags.wasm_gc_js_interop situation.
|
||||
// TODO(7748): Allow all in-range numbers for i31. Make sure to convert
|
||||
// Smis to i31refs if needed.
|
||||
// TODO(7748): Streamline interaction of undefined and (ref any).
|
||||
@ -2284,19 +2262,13 @@ MaybeHandle<Object> JSToWasmObject(Isolate* isolate, const WasmModule* module,
|
||||
return {};
|
||||
}
|
||||
case HeapType::kAny: {
|
||||
if (!v8_flags.wasm_gc_js_interop) {
|
||||
TryUnpackObjectWrapper(isolate, value);
|
||||
}
|
||||
if (!value->IsNull(isolate)) return value;
|
||||
*error_message = "null is not allowed for (ref any)";
|
||||
return {};
|
||||
}
|
||||
case HeapType::kStruct: {
|
||||
if (v8_flags.wasm_gc_js_interop
|
||||
? value->IsWasmStruct() ||
|
||||
(value->IsWasmArray() &&
|
||||
v8_flags.wasm_gc_structref_as_dataref)
|
||||
: TryUnpackObjectWrapper(isolate, value)) {
|
||||
if (value->IsWasmStruct() ||
|
||||
(value->IsWasmArray() && v8_flags.wasm_gc_structref_as_dataref)) {
|
||||
return value;
|
||||
}
|
||||
*error_message =
|
||||
@ -2304,9 +2276,7 @@ MaybeHandle<Object> JSToWasmObject(Isolate* isolate, const WasmModule* module,
|
||||
return {};
|
||||
}
|
||||
case HeapType::kArray: {
|
||||
if ((v8_flags.wasm_gc_js_interop ||
|
||||
TryUnpackObjectWrapper(isolate, value)) &&
|
||||
value->IsWasmArray()) {
|
||||
if (value->IsWasmArray()) {
|
||||
return value;
|
||||
}
|
||||
*error_message =
|
||||
@ -2314,10 +2284,7 @@ MaybeHandle<Object> JSToWasmObject(Isolate* isolate, const WasmModule* module,
|
||||
return {};
|
||||
}
|
||||
case HeapType::kEq: {
|
||||
if (value->IsSmi() ||
|
||||
(v8_flags.wasm_gc_js_interop
|
||||
? value->IsWasmStruct() || value->IsWasmArray()
|
||||
: TryUnpackObjectWrapper(isolate, value))) {
|
||||
if (value->IsSmi() || value->IsWasmStruct() || value->IsWasmArray()) {
|
||||
return value;
|
||||
}
|
||||
*error_message =
|
||||
@ -2404,9 +2371,7 @@ MaybeHandle<Object> JSToWasmObject(Isolate* isolate, const WasmModule* module,
|
||||
// A struct or array type with index is expected.
|
||||
DCHECK(module->has_struct(expected.ref_index()) ||
|
||||
module->has_array(expected.ref_index()));
|
||||
if (v8_flags.wasm_gc_js_interop
|
||||
? !value->IsWasmStruct() && !value->IsWasmArray()
|
||||
: !TryUnpackObjectWrapper(isolate, value)) {
|
||||
if (!value->IsWasmStruct() && !value->IsWasmArray()) {
|
||||
*error_message = "object incompatible with wasm type";
|
||||
return {};
|
||||
}
|
||||
|
@ -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-gc --wasm-gc-js-interop
|
||||
// Flags: --experimental-wasm-gc
|
||||
|
||||
d8.file.execute("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-gc --wasm-gc-js-interop --allow-natives-syntax
|
||||
// Flags: --experimental-wasm-gc --allow-natives-syntax
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.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-gc --wasm-gc-js-interop --allow-natives-syntax
|
||||
// Flags: --experimental-wasm-gc --allow-natives-syntax
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.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-gc --wasm-gc-js-interop --allow-natives-syntax
|
||||
// Flags: --experimental-wasm-gc --allow-natives-syntax
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.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-gc --wasm-gc-js-interop --allow-natives-syntax
|
||||
// Flags: --experimental-wasm-gc --allow-natives-syntax
|
||||
|
||||
import {struct, array} from 'gc-js-interop-export.mjs';
|
||||
|
||||
|
@ -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-gc --wasm-gc-js-interop --allow-natives-syntax
|
||||
// Flags: --experimental-wasm-gc --allow-natives-syntax
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.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-gc --wasm-gc-js-interop --allow-natives-syntax
|
||||
// Flags: --experimental-wasm-gc --allow-natives-syntax
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.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-gc --wasm-gc-js-interop --wasm-test-streaming
|
||||
// Flags: --experimental-wasm-gc --wasm-test-streaming
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.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-gc --wasm-gc-js-interop --allow-natives-syntax
|
||||
// Flags: --experimental-wasm-gc --allow-natives-syntax
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.js');
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --experimental-wasm-gc --experimental-wasm-stringref
|
||||
// Flags: --wasm-gc-js-interop --no-wasm-gc-structref-as-dataref
|
||||
// Flags: --no-wasm-gc-structref-as-dataref
|
||||
|
||||
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user