Revert "[wasm-gc] Introduce wasm null object"
This reverts commit 2e357c4814
.
Reason for revert: Speculative revert for https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Clusterfuzz%20Linux%20MSAN%20no%20origins/33231/overview
Original change's description:
> [wasm-gc] Introduce wasm null object
>
> We introduce a wasm null object, separate from JS null. Its purpose is
> to support trapping null accesses for wasm objects.
> This will be achieved by allocating a large payload for it (larger than
> any wasm struct) and memory-protecting it (see linked CL). The two null
> objects get mapped to each other at the wasm-JS boundary.
> Since externref objects live on the JS side of the boundary,
> null-related instructions in wasm now need an additional type argument
> to handle the correct null object.
>
> Bug: v8:7748
> Change-Id: I06da00fcd279cc5376e69ab7858e3782f5b5081e
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4200639
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#85648}
Bug: v8:7748
Change-Id: Ie53febf49b946217e0057959c757d811a97ca1eb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4219105
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Nico Hartmann <nicohartmann@chromium.org>
Auto-Submit: Nico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85649}
This commit is contained in:
parent
2e357c4814
commit
79efc8f090
3
BUILD.gn
3
BUILD.gn
@ -557,8 +557,7 @@ if (v8_enable_static_roots == "") {
|
||||
assert(!v8_enable_static_roots ||
|
||||
(v8_enable_pointer_compression && v8_enable_shared_ro_heap &&
|
||||
v8_enable_pointer_compression_shared_cage &&
|
||||
v8_enable_external_code_space && v8_enable_webassembly &&
|
||||
v8_enable_i18n_support),
|
||||
v8_enable_webassembly && v8_enable_i18n_support),
|
||||
"Trying to enable static roots in a configuration that is not supported")
|
||||
|
||||
if (v8_enable_webassembly && !target_is_simulator && v8_current_cpu == "x64") {
|
||||
|
@ -344,11 +344,6 @@ class V8_EXPORT Value : public Data {
|
||||
*/
|
||||
bool IsWasmModuleObject() const;
|
||||
|
||||
/**
|
||||
* Returns true if this value is the WasmNull object.
|
||||
*/
|
||||
bool IsWasmNull() const;
|
||||
|
||||
/**
|
||||
* Returns true if the value is a Module Namespace Object.
|
||||
*/
|
||||
|
@ -3827,11 +3827,9 @@ VALUE_IS_SPECIFIC_TYPE(Set, JSSet)
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
VALUE_IS_SPECIFIC_TYPE(WasmMemoryObject, WasmMemoryObject)
|
||||
VALUE_IS_SPECIFIC_TYPE(WasmModuleObject, WasmModuleObject)
|
||||
VALUE_IS_SPECIFIC_TYPE(WasmNull, WasmNull)
|
||||
#else
|
||||
bool Value::IsWasmMemoryObject() const { return false; }
|
||||
bool Value::IsWasmModuleObject() const { return false; }
|
||||
bool Value::IsWasmNull() const { return false; }
|
||||
#endif // V8_ENABLE_WEBASSEMBLY
|
||||
VALUE_IS_SPECIFIC_TYPE(WeakMap, JSWeakMap)
|
||||
VALUE_IS_SPECIFIC_TYPE(WeakSet, JSWeakSet)
|
||||
|
@ -97,10 +97,10 @@ builtin WasmInt32ToHeapNumber(val: int32): HeapNumber {
|
||||
return AllocateHeapNumberWithValue(Convert<float64>(val));
|
||||
}
|
||||
|
||||
builtin WasmFuncRefToJS(val: WasmInternalFunction|WasmNull): JSFunction|Null|
|
||||
builtin WasmFuncRefToJS(val: WasmInternalFunction|Null): JSFunction|Null|
|
||||
Undefined {
|
||||
typeswitch (val) {
|
||||
case (WasmNull): {
|
||||
case (Null): {
|
||||
return Null;
|
||||
}
|
||||
case (func: WasmInternalFunction): {
|
||||
|
@ -186,7 +186,6 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
|
||||
V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \
|
||||
V(null_to_string, null_to_string, NullToString) \
|
||||
V(NullValue, null_value, Null) \
|
||||
IF_WASM(V, WasmNull, wasm_null, WasmNull) \
|
||||
V(number_string, number_string, NumberString) \
|
||||
V(number_to_string, number_to_string, NumberToString) \
|
||||
V(Object_string, Object_string, ObjectString) \
|
||||
|
@ -55,8 +55,15 @@ std::ostream& operator<<(std::ostream& os, TrapId trap_id) {
|
||||
}
|
||||
|
||||
TrapId TrapIdOf(const Operator* const op) {
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
// Combining this with the #else into a single DCHECK() does not with MSVC.
|
||||
DCHECK(op->opcode() == IrOpcode::kTrapIf ||
|
||||
op->opcode() == IrOpcode::kTrapUnless ||
|
||||
op->opcode() == IrOpcode::kAssertNotNull);
|
||||
#else
|
||||
DCHECK(op->opcode() == IrOpcode::kTrapIf ||
|
||||
op->opcode() == IrOpcode::kTrapUnless);
|
||||
#endif
|
||||
return OpParameter<TrapId>(op);
|
||||
}
|
||||
|
||||
|
@ -740,22 +740,6 @@ bool operator==(CheckMinusZeroParameters const& lhs,
|
||||
return lhs.mode() == rhs.mode() && lhs.feedback() == rhs.feedback();
|
||||
}
|
||||
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
V8_EXPORT_PRIVATE std::ostream& operator<<(
|
||||
std::ostream& os, AssertNotNullParameters const& params) {
|
||||
return os << params.type << ", " << params.trap_id;
|
||||
}
|
||||
|
||||
size_t hash_value(AssertNotNullParameters const& params) {
|
||||
return base::hash_combine(params.type, params.trap_id);
|
||||
}
|
||||
|
||||
bool operator==(AssertNotNullParameters const& lhs,
|
||||
AssertNotNullParameters const& rhs) {
|
||||
return lhs.type == rhs.type && lhs.trap_id == rhs.trap_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PURE_OP_LIST(V) \
|
||||
V(BooleanNot, Operator::kNoProperties, 1, 0) \
|
||||
V(NumberEqual, Operator::kCommutative, 2, 0) \
|
||||
@ -1254,6 +1238,40 @@ struct SimplifiedOperatorGlobalCache final {
|
||||
LoadStackArgumentOperator kLoadStackArgument;
|
||||
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
// Note: The following two operators have a control input solely to find the
|
||||
// typing context from the control path in wasm-gc-operator-reducer.
|
||||
struct IsNullOperator final : public Operator {
|
||||
IsNullOperator()
|
||||
: Operator(IrOpcode::kIsNull, Operator::kPure, "IsNull", 1, 0, 1, 1, 0,
|
||||
0) {}
|
||||
};
|
||||
IsNullOperator kIsNull;
|
||||
|
||||
struct IsNotNullOperator final : public Operator {
|
||||
IsNotNullOperator()
|
||||
: Operator(IrOpcode::kIsNotNull, Operator::kPure, "IsNotNull", 1, 0, 1,
|
||||
1, 0, 0) {}
|
||||
};
|
||||
IsNotNullOperator kIsNotNull;
|
||||
|
||||
struct NullOperator final : public Operator {
|
||||
NullOperator()
|
||||
: Operator(IrOpcode::kNull, Operator::kPure, "Null", 0, 0, 0, 1, 0, 0) {
|
||||
}
|
||||
};
|
||||
NullOperator kNull;
|
||||
|
||||
struct AssertNotNullOperator final : public Operator1<TrapId> {
|
||||
explicit AssertNotNullOperator(TrapId trap_id)
|
||||
: Operator1(
|
||||
IrOpcode::kAssertNotNull,
|
||||
Operator::kNoWrite | Operator::kNoThrow | Operator::kIdempotent,
|
||||
"AssertNotNull", 1, 1, 1, 1, 1, 1, trap_id) {}
|
||||
};
|
||||
AssertNotNullOperator kAssertNotNullIllegalCast{TrapId::kTrapIllegalCast};
|
||||
AssertNotNullOperator kAssertNotNullNullDereference{
|
||||
TrapId::kTrapNullDereference};
|
||||
|
||||
struct WasmArrayLengthOperator final : public Operator {
|
||||
WasmArrayLengthOperator()
|
||||
: Operator(IrOpcode::kWasmArrayLength, Operator::kEliminatable,
|
||||
@ -1499,48 +1517,22 @@ const Operator* SimplifiedOperatorBuilder::RttCanon(int index) {
|
||||
"RttCanon", 0, 0, 0, 1, 0, 0, index);
|
||||
}
|
||||
|
||||
// Note: The following two operators have a control input solely to find the
|
||||
// typing context from the control path in wasm-gc-operator-reducer.
|
||||
struct IsNullOperator final : public Operator1<wasm::ValueType> {
|
||||
explicit IsNullOperator(wasm::ValueType type)
|
||||
: Operator1(IrOpcode::kIsNull, Operator::kPure, "IsNull", 1, 0, 1, 1, 0,
|
||||
0, type) {}
|
||||
};
|
||||
const Operator* SimplifiedOperatorBuilder::Null() { return &cache_.kNull; }
|
||||
|
||||
struct IsNotNullOperator final : public Operator1<wasm::ValueType> {
|
||||
explicit IsNotNullOperator(wasm::ValueType type)
|
||||
: Operator1(IrOpcode::kIsNotNull, Operator::kPure, "IsNotNull", 1, 0, 1,
|
||||
1, 0, 0, type) {}
|
||||
};
|
||||
|
||||
struct NullOperator final : public Operator1<wasm::ValueType> {
|
||||
explicit NullOperator(wasm::ValueType type)
|
||||
: Operator1(IrOpcode::kNull, Operator::kPure, "Null", 0, 0, 0, 1, 0, 0,
|
||||
type) {}
|
||||
};
|
||||
|
||||
struct AssertNotNullOperator final : public Operator1<AssertNotNullParameters> {
|
||||
explicit AssertNotNullOperator(wasm::ValueType type, TrapId trap_id)
|
||||
: Operator1(
|
||||
IrOpcode::kAssertNotNull,
|
||||
Operator::kNoWrite | Operator::kNoThrow | Operator::kIdempotent,
|
||||
"AssertNotNull", 1, 1, 1, 1, 1, 1, {type, trap_id}) {}
|
||||
};
|
||||
|
||||
const Operator* SimplifiedOperatorBuilder::Null(wasm::ValueType type) {
|
||||
return zone()->New<NullOperator>(type);
|
||||
const Operator* SimplifiedOperatorBuilder::AssertNotNull(TrapId trap_id) {
|
||||
switch (trap_id) {
|
||||
case TrapId::kTrapNullDereference:
|
||||
return &cache_.kAssertNotNullNullDereference;
|
||||
case TrapId::kTrapIllegalCast:
|
||||
return &cache_.kAssertNotNullIllegalCast;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
const Operator* SimplifiedOperatorBuilder::AssertNotNull(wasm::ValueType type,
|
||||
TrapId trap_id) {
|
||||
return zone()->New<AssertNotNullOperator>(type, trap_id);
|
||||
}
|
||||
|
||||
const Operator* SimplifiedOperatorBuilder::IsNull(wasm::ValueType type) {
|
||||
return zone()->New<IsNullOperator>(type);
|
||||
}
|
||||
const Operator* SimplifiedOperatorBuilder::IsNotNull(wasm::ValueType type) {
|
||||
return zone()->New<IsNotNullOperator>(type);
|
||||
const Operator* SimplifiedOperatorBuilder::IsNull() { return &cache_.kIsNull; }
|
||||
const Operator* SimplifiedOperatorBuilder::IsNotNull() {
|
||||
return &cache_.kIsNotNull;
|
||||
}
|
||||
|
||||
const Operator* SimplifiedOperatorBuilder::StringAsWtf16() {
|
||||
|
@ -743,21 +743,6 @@ size_t hash_value(FastApiCallParameters const&);
|
||||
|
||||
bool operator==(FastApiCallParameters const&, FastApiCallParameters const&);
|
||||
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
struct AssertNotNullParameters {
|
||||
wasm::ValueType type;
|
||||
TrapId trap_id;
|
||||
};
|
||||
|
||||
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
|
||||
AssertNotNullParameters const&);
|
||||
|
||||
size_t hash_value(AssertNotNullParameters const&);
|
||||
|
||||
bool operator==(AssertNotNullParameters const&, AssertNotNullParameters const&);
|
||||
|
||||
#endif
|
||||
|
||||
// Interface for building simplified operators, which represent the
|
||||
// medium-level operations of V8, including adding numbers, allocating objects,
|
||||
// indexing into objects and arrays, etc.
|
||||
@ -1161,10 +1146,10 @@ class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
|
||||
const Operator* CheckTurboshaftTypeOf();
|
||||
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
const Operator* AssertNotNull(wasm::ValueType type, TrapId trap_id);
|
||||
const Operator* IsNull(wasm::ValueType type);
|
||||
const Operator* IsNotNull(wasm::ValueType type);
|
||||
const Operator* Null(wasm::ValueType type);
|
||||
const Operator* AssertNotNull(TrapId trap_id);
|
||||
const Operator* IsNull();
|
||||
const Operator* IsNotNull();
|
||||
const Operator* Null();
|
||||
const Operator* RttCanon(int index);
|
||||
const Operator* WasmTypeCheck(WasmTypeCheckConfig config);
|
||||
const Operator* WasmTypeCast(WasmTypeCheckConfig config);
|
||||
|
@ -278,12 +278,10 @@ Node* WasmGraphBuilder::EffectPhi(unsigned count, Node** effects_and_control) {
|
||||
effects_and_control);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::RefNull(wasm::ValueType type) {
|
||||
Node* WasmGraphBuilder::RefNull() {
|
||||
return (v8_flags.experimental_wasm_gc && parameter_mode_ == kInstanceMode)
|
||||
? gasm_->Null(type)
|
||||
: (type == wasm::kWasmExternRef || type == wasm::kWasmNullExternRef)
|
||||
? LOAD_ROOT(NullValue, null_value)
|
||||
: LOAD_ROOT(WasmNull, wasm_null);
|
||||
? gasm_->Null()
|
||||
: LOAD_ROOT(NullValue, null_value);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::RefFunc(uint32_t function_index) {
|
||||
@ -754,7 +752,6 @@ Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
|
||||
wasm::ValueType type,
|
||||
wasm::WasmCodePosition position) {
|
||||
const Operator* op;
|
||||
MachineOperatorBuilder* m = mcgraph()->machine();
|
||||
@ -1016,11 +1013,11 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
|
||||
? BuildCcallConvertFloat(input, position, opcode)
|
||||
: BuildIntConvertFloat(input, position, opcode);
|
||||
case wasm::kExprRefIsNull:
|
||||
return IsNull(input, type);
|
||||
return IsNull(input);
|
||||
// We abuse ref.as_non_null, which isn't otherwise used in this switch, as
|
||||
// a sentinel for the negation of ref.is_null.
|
||||
case wasm::kExprRefAsNonNull:
|
||||
return gasm_->Word32Equal(gasm_->Int32Constant(0), IsNull(input, type));
|
||||
return gasm_->Int32Sub(gasm_->Int32Constant(1), IsNull(input));
|
||||
case wasm::kExprI32AsmjsLoadMem8S:
|
||||
return BuildAsmjsLoadMem(MachineType::Int8(), input);
|
||||
case wasm::kExprI32AsmjsLoadMem8U:
|
||||
@ -1147,11 +1144,11 @@ void WasmGraphBuilder::TrapIfFalse(wasm::TrapReason reason, Node* cond,
|
||||
SetSourcePosition(control(), position);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::AssertNotNull(Node* object, wasm::ValueType type,
|
||||
Node* WasmGraphBuilder::AssertNotNull(Node* object,
|
||||
wasm::WasmCodePosition position,
|
||||
wasm::TrapReason reason) {
|
||||
TrapId trap_id = GetTrapIdForTrap(reason);
|
||||
Node* result = gasm_->AssertNotNull(object, type, trap_id);
|
||||
Node* result = gasm_->AssertNotNull(object, trap_id);
|
||||
SetSourcePosition(result, position);
|
||||
return result;
|
||||
}
|
||||
@ -2611,10 +2608,10 @@ Node* WasmGraphBuilder::BuildDiv64Call(Node* left, Node* right,
|
||||
return gasm_->Load(result_type, stack_slot, 0);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::IsNull(Node* object, wasm::ValueType type) {
|
||||
Node* WasmGraphBuilder::IsNull(Node* object) {
|
||||
return (v8_flags.experimental_wasm_gc && parameter_mode_ == kInstanceMode)
|
||||
? gasm_->IsNull(object, type)
|
||||
: gasm_->TaggedEqual(object, RefNull(type));
|
||||
? gasm_->IsNull(object)
|
||||
: gasm_->TaggedEqual(object, RefNull());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
@ -2988,8 +2985,7 @@ Node* WasmGraphBuilder::BuildCallRef(const wasm::FunctionSig* sig,
|
||||
IsReturnCall continuation,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
args[0] =
|
||||
AssertNotNull(args[0], wasm::kWasmFuncRef /* good enough */, position);
|
||||
args[0] = AssertNotNull(args[0], position);
|
||||
}
|
||||
|
||||
Node* function = args[0];
|
||||
@ -3095,9 +3091,9 @@ Node* WasmGraphBuilder::ReturnCallIndirect(uint32_t table_index,
|
||||
kReturnCall);
|
||||
}
|
||||
|
||||
void WasmGraphBuilder::BrOnNull(Node* ref_object, wasm::ValueType type,
|
||||
Node** null_node, Node** non_null_node) {
|
||||
BranchExpectFalse(IsNull(ref_object, type), null_node, non_null_node);
|
||||
void WasmGraphBuilder::BrOnNull(Node* ref_object, Node** null_node,
|
||||
Node** non_null_node) {
|
||||
BranchExpectFalse(IsNull(ref_object), null_node, non_null_node);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::BuildI32Rol(Node* left, Node* right) {
|
||||
@ -5263,7 +5259,7 @@ Node* WasmGraphBuilder::DefaultValue(wasm::ValueType type) {
|
||||
case wasm::kS128:
|
||||
return S128Zero();
|
||||
case wasm::kRefNull:
|
||||
return RefNull(type);
|
||||
return RefNull();
|
||||
case wasm::kRtt:
|
||||
case wasm::kVoid:
|
||||
case wasm::kBottom:
|
||||
@ -5367,9 +5363,8 @@ Node* WasmGraphBuilder::ArrayNew(uint32_t array_index,
|
||||
mcgraph()->machine()->BitcastFloat64ToInt64(), initial_value);
|
||||
break;
|
||||
case wasm::kRefNull:
|
||||
initial_value_i64 = initial_value == nullptr
|
||||
? gasm_->Null(type->element_type())
|
||||
: initial_value;
|
||||
initial_value_i64 =
|
||||
initial_value == nullptr ? gasm_->Null() : initial_value;
|
||||
if (kSystemPointerSize == 4) {
|
||||
initial_value_i64 = graph()->NewNode(
|
||||
mcgraph()->machine()->ChangeInt32ToInt64(), initial_value_i64);
|
||||
@ -5516,10 +5511,9 @@ void WasmGraphBuilder::EqCheck(Node* object, bool object_can_be_null,
|
||||
// TODO(7748): Is the extra null check actually beneficial for performance?
|
||||
if (object_can_be_null) {
|
||||
if (null_succeeds) {
|
||||
callbacks.succeed_if(IsNull(object, wasm::kWasmAnyRef),
|
||||
BranchHint::kFalse);
|
||||
callbacks.succeed_if(IsNull(object), BranchHint::kFalse);
|
||||
} else {
|
||||
callbacks.fail_if(IsNull(object, wasm::kWasmAnyRef), BranchHint::kFalse);
|
||||
callbacks.fail_if(IsNull(object), BranchHint::kFalse);
|
||||
}
|
||||
}
|
||||
callbacks.succeed_if(gasm_->IsI31(object), BranchHint::kFalse);
|
||||
@ -5534,10 +5528,9 @@ void WasmGraphBuilder::ManagedObjectInstanceCheck(Node* object,
|
||||
bool null_succeeds) {
|
||||
if (object_can_be_null) {
|
||||
if (null_succeeds) {
|
||||
callbacks.succeed_if(IsNull(object, wasm::kWasmAnyRef),
|
||||
BranchHint::kFalse);
|
||||
callbacks.succeed_if(IsNull(object), BranchHint::kFalse);
|
||||
} else {
|
||||
callbacks.fail_if(IsNull(object, wasm::kWasmAnyRef), BranchHint::kFalse);
|
||||
callbacks.fail_if(IsNull(object), BranchHint::kFalse);
|
||||
}
|
||||
}
|
||||
callbacks.fail_if(gasm_->IsI31(object), BranchHint::kFalse);
|
||||
@ -5606,7 +5599,7 @@ Node* WasmGraphBuilder::RefTestAbstract(Node* object, wasm::HeapType type,
|
||||
case wasm::HeapType::kNoExtern:
|
||||
case wasm::HeapType::kNoFunc:
|
||||
DCHECK(null_succeeds);
|
||||
return IsNull(object, wasm::ValueType::RefNull(type));
|
||||
return IsNull(object);
|
||||
case wasm::HeapType::kAny:
|
||||
// Any may never need a cast as it is either implicitly convertible or
|
||||
// never convertible for any given type.
|
||||
@ -5639,8 +5632,7 @@ Node* WasmGraphBuilder::RefCastAbstract(Node* object, wasm::HeapType type,
|
||||
case wasm::HeapType::kNoExtern:
|
||||
case wasm::HeapType::kNoFunc: {
|
||||
DCHECK(null_succeeds);
|
||||
TrapIfFalse(wasm::kTrapIllegalCast,
|
||||
IsNull(object, wasm::ValueType::RefNull(type)), position);
|
||||
TrapIfFalse(wasm::kTrapIllegalCast, IsNull(object), position);
|
||||
return object;
|
||||
}
|
||||
case wasm::HeapType::kAny:
|
||||
@ -5694,10 +5686,10 @@ void WasmGraphBuilder::BrOnEq(Node* object, Node* /*rtt*/,
|
||||
[=](Callbacks callbacks) -> void {
|
||||
if (config.from.is_nullable()) {
|
||||
if (config.to.is_nullable()) {
|
||||
callbacks.succeed_if(gasm_->IsNull(object, config.from),
|
||||
callbacks.succeed_if(gasm_->IsNull(object),
|
||||
BranchHint::kFalse);
|
||||
} else {
|
||||
callbacks.fail_if(gasm_->IsNull(object, config.from),
|
||||
callbacks.fail_if(gasm_->IsNull(object),
|
||||
BranchHint::kFalse);
|
||||
}
|
||||
}
|
||||
@ -5783,7 +5775,7 @@ Node* WasmGraphBuilder::RefIsI31(Node* object, bool null_succeeds) {
|
||||
auto done = gasm_->MakeLabel(MachineRepresentation::kWord32);
|
||||
gasm_->GotoIf(gasm_->IsI31(object), &done, BranchHint::kTrue,
|
||||
Int32Constant(1));
|
||||
gasm_->Goto(&done, gasm_->IsNull(object, wasm::kWasmAnyRef));
|
||||
gasm_->Goto(&done, gasm_->IsNull(object));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
}
|
||||
@ -5794,7 +5786,7 @@ Node* WasmGraphBuilder::RefAsI31(Node* object, wasm::WasmCodePosition position,
|
||||
bool null_succeeds) {
|
||||
if (null_succeeds) {
|
||||
auto done = gasm_->MakeLabel();
|
||||
gasm_->GotoIf(gasm_->IsNull(object, wasm::kWasmAnyRef), &done);
|
||||
gasm_->GotoIf(gasm_->IsNull(object), &done);
|
||||
TrapIfFalse(wasm::kTrapIllegalCast, gasm_->IsI31(object), position);
|
||||
gasm_->Goto(&done);
|
||||
gasm_->Bind(&done);
|
||||
@ -5813,11 +5805,9 @@ void WasmGraphBuilder::BrOnI31(Node* object, Node* /* rtt */,
|
||||
[=](Callbacks callbacks) -> void {
|
||||
if (config.from.is_nullable()) {
|
||||
if (config.to.is_nullable()) {
|
||||
callbacks.succeed_if(gasm_->IsNull(object, config.from),
|
||||
BranchHint::kFalse);
|
||||
callbacks.succeed_if(gasm_->IsNull(object), BranchHint::kFalse);
|
||||
} else {
|
||||
callbacks.fail_if(gasm_->IsNull(object, config.from),
|
||||
BranchHint::kFalse);
|
||||
callbacks.fail_if(gasm_->IsNull(object), BranchHint::kFalse);
|
||||
}
|
||||
}
|
||||
callbacks.fail_if_not(gasm_->IsI31(object), BranchHint::kTrue);
|
||||
@ -5837,8 +5827,7 @@ Node* WasmGraphBuilder::StructGet(Node* struct_object,
|
||||
bool is_signed,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
struct_object =
|
||||
AssertNotNull(struct_object, wasm::kWasmStructRef, position);
|
||||
struct_object = AssertNotNull(struct_object, position);
|
||||
}
|
||||
return gasm_->StructGet(struct_object, struct_type, field_index, is_signed);
|
||||
}
|
||||
@ -5849,8 +5838,7 @@ void WasmGraphBuilder::StructSet(Node* struct_object,
|
||||
CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
struct_object =
|
||||
AssertNotNull(struct_object, wasm::kWasmStructRef, position);
|
||||
struct_object = AssertNotNull(struct_object, position);
|
||||
}
|
||||
gasm_->StructSet(struct_object, field_value, struct_type, field_index);
|
||||
}
|
||||
@ -5880,7 +5868,7 @@ Node* WasmGraphBuilder::ArrayGet(Node* array_object,
|
||||
CheckForNull null_check, bool is_signed,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
array_object = AssertNotNull(array_object, wasm::kWasmArrayRef, position);
|
||||
array_object = AssertNotNull(array_object, position);
|
||||
}
|
||||
BoundsCheckArray(array_object, index, position);
|
||||
return gasm_->ArrayGet(array_object, index, type, is_signed);
|
||||
@ -5891,7 +5879,7 @@ void WasmGraphBuilder::ArraySet(Node* array_object, const wasm::ArrayType* type,
|
||||
CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
array_object = AssertNotNull(array_object, wasm::kWasmArrayRef, position);
|
||||
array_object = AssertNotNull(array_object, position);
|
||||
}
|
||||
BoundsCheckArray(array_object, index, position);
|
||||
gasm_->ArraySet(array_object, index, value, type);
|
||||
@ -5900,7 +5888,7 @@ void WasmGraphBuilder::ArraySet(Node* array_object, const wasm::ArrayType* type,
|
||||
Node* WasmGraphBuilder::ArrayLen(Node* array_object, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
array_object = AssertNotNull(array_object, wasm::kWasmArrayRef, position);
|
||||
array_object = AssertNotNull(array_object, position);
|
||||
}
|
||||
return gasm_->ArrayLength(array_object);
|
||||
}
|
||||
@ -5913,10 +5901,10 @@ void WasmGraphBuilder::ArrayCopy(Node* dst_array, Node* dst_index,
|
||||
Node* length,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (dst_null_check == kWithNullCheck) {
|
||||
dst_array = AssertNotNull(dst_array, wasm::kWasmArrayRef, position);
|
||||
dst_array = AssertNotNull(dst_array, position);
|
||||
}
|
||||
if (src_null_check == kWithNullCheck) {
|
||||
src_array = AssertNotNull(src_array, wasm::kWasmArrayRef, position);
|
||||
src_array = AssertNotNull(src_array, position);
|
||||
}
|
||||
BoundsCheckArrayCopy(dst_array, dst_index, length, position);
|
||||
BoundsCheckArrayCopy(src_array, src_index, length, position);
|
||||
@ -5988,7 +5976,7 @@ Node* WasmGraphBuilder::StringConst(uint32_t index) {
|
||||
Node* WasmGraphBuilder::StringMeasureUtf8(Node* string, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringMeasureUtf8,
|
||||
Operator::kEliminatable, string);
|
||||
@ -5997,7 +5985,7 @@ Node* WasmGraphBuilder::StringMeasureUtf8(Node* string, CheckForNull null_check,
|
||||
Node* WasmGraphBuilder::StringMeasureWtf8(Node* string, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringMeasureWtf8,
|
||||
Operator::kEliminatable, string);
|
||||
@ -6007,7 +5995,7 @@ Node* WasmGraphBuilder::StringMeasureWtf16(Node* string,
|
||||
CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->LoadImmutableFromObject(
|
||||
MachineType::Int32(), string,
|
||||
@ -6020,7 +6008,7 @@ Node* WasmGraphBuilder::StringEncodeWtf8(uint32_t memory,
|
||||
Node* offset,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringEncodeWtf8,
|
||||
Operator::kNoDeopt | Operator::kNoThrow, string,
|
||||
@ -6033,10 +6021,10 @@ Node* WasmGraphBuilder::StringEncodeWtf8Array(
|
||||
Node* array, CheckForNull array_null_check, Node* start,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (string_null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
if (array_null_check == kWithNullCheck) {
|
||||
array = AssertNotNull(array, wasm::kWasmArrayRef, position);
|
||||
array = AssertNotNull(array, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringEncodeWtf8Array,
|
||||
Operator::kNoDeopt | Operator::kNoThrow, string,
|
||||
@ -6048,7 +6036,7 @@ Node* WasmGraphBuilder::StringEncodeWtf16(uint32_t memory, Node* string,
|
||||
CheckForNull null_check, Node* offset,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringEncodeWtf16,
|
||||
Operator::kNoDeopt | Operator::kNoThrow, string,
|
||||
@ -6058,7 +6046,7 @@ Node* WasmGraphBuilder::StringEncodeWtf16(uint32_t memory, Node* string,
|
||||
Node* WasmGraphBuilder::StringAsWtf16(Node* string, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->StringAsWtf16(string);
|
||||
}
|
||||
@ -6068,10 +6056,10 @@ Node* WasmGraphBuilder::StringEncodeWtf16Array(
|
||||
CheckForNull array_null_check, Node* start,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (string_null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
if (array_null_check == kWithNullCheck) {
|
||||
array = AssertNotNull(array, wasm::kWasmArrayRef, position);
|
||||
array = AssertNotNull(array, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringEncodeWtf16Array,
|
||||
Operator::kNoDeopt | Operator::kNoThrow, string,
|
||||
@ -6081,12 +6069,8 @@ Node* WasmGraphBuilder::StringEncodeWtf16Array(
|
||||
Node* WasmGraphBuilder::StringConcat(Node* head, CheckForNull head_null_check,
|
||||
Node* tail, CheckForNull tail_null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (head_null_check == kWithNullCheck) {
|
||||
head = AssertNotNull(head, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (tail_null_check == kWithNullCheck) {
|
||||
tail = AssertNotNull(tail, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (head_null_check == kWithNullCheck) head = AssertNotNull(head, position);
|
||||
if (tail_null_check == kWithNullCheck) tail = AssertNotNull(tail, position);
|
||||
return gasm_->CallBuiltin(
|
||||
Builtin::kStringAdd_CheckNone, Operator::kNoDeopt | Operator::kNoThrow,
|
||||
head, tail,
|
||||
@ -6100,12 +6084,10 @@ Node* WasmGraphBuilder::StringEqual(Node* a, CheckForNull a_null_check, Node* b,
|
||||
// Covers "identical string pointer" and "both are null" cases.
|
||||
gasm_->GotoIf(gasm_->TaggedEqual(a, b), &done, Int32Constant(1));
|
||||
if (a_null_check == kWithNullCheck) {
|
||||
gasm_->GotoIf(gasm_->IsNull(a, wasm::kWasmStringRef), &done,
|
||||
Int32Constant(0));
|
||||
gasm_->GotoIf(gasm_->IsNull(a), &done, Int32Constant(0));
|
||||
}
|
||||
if (b_null_check == kWithNullCheck) {
|
||||
gasm_->GotoIf(gasm_->IsNull(b, wasm::kWasmStringRef), &done,
|
||||
Int32Constant(0));
|
||||
gasm_->GotoIf(gasm_->IsNull(b), &done, Int32Constant(0));
|
||||
}
|
||||
gasm_->Goto(&done, gasm_->CallBuiltin(Builtin::kWasmStringEqual,
|
||||
Operator::kEliminatable, a, b));
|
||||
@ -6115,9 +6097,7 @@ Node* WasmGraphBuilder::StringEqual(Node* a, CheckForNull a_null_check, Node* b,
|
||||
|
||||
Node* WasmGraphBuilder::StringIsUSVSequence(Node* str, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
str = AssertNotNull(str, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) str = AssertNotNull(str, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringIsUSVSequence,
|
||||
Operator::kEliminatable, str);
|
||||
@ -6125,9 +6105,7 @@ Node* WasmGraphBuilder::StringIsUSVSequence(Node* str, CheckForNull null_check,
|
||||
|
||||
Node* WasmGraphBuilder::StringAsWtf8(Node* str, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
str = AssertNotNull(str, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) str = AssertNotNull(str, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringAsWtf8, Operator::kEliminatable,
|
||||
str);
|
||||
@ -6137,9 +6115,7 @@ Node* WasmGraphBuilder::StringViewWtf8Advance(Node* view,
|
||||
CheckForNull null_check,
|
||||
Node* pos, Node* bytes,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
view = AssertNotNull(view, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) view = AssertNotNull(view, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewWtf8Advance,
|
||||
Operator::kEliminatable, view, pos, bytes);
|
||||
@ -6150,7 +6126,7 @@ void WasmGraphBuilder::StringViewWtf8Encode(
|
||||
CheckForNull null_check, Node* addr, Node* pos, Node* bytes,
|
||||
Node** next_pos, Node** bytes_written, wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
view = AssertNotNull(view, wasm::kWasmStringRef, position);
|
||||
view = AssertNotNull(view, position);
|
||||
}
|
||||
Node* pair =
|
||||
gasm_->CallBuiltin(Builtin::kWasmStringViewWtf8Encode,
|
||||
@ -6165,7 +6141,7 @@ Node* WasmGraphBuilder::StringViewWtf8Slice(Node* view, CheckForNull null_check,
|
||||
Node* pos, Node* bytes,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
view = AssertNotNull(view, wasm::kWasmStringRef, position);
|
||||
view = AssertNotNull(view, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewWtf8Slice,
|
||||
Operator::kEliminatable, view, pos, bytes);
|
||||
@ -6175,7 +6151,7 @@ Node* WasmGraphBuilder::StringViewWtf16GetCodeUnit(
|
||||
Node* string, CheckForNull null_check, Node* offset,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
Node* prepare = gasm_->StringPrepareForGetCodeunit(string);
|
||||
Node* base = gasm_->Projection(0, prepare);
|
||||
@ -6235,7 +6211,7 @@ Node* WasmGraphBuilder::StringViewWtf16Encode(uint32_t memory, Node* string,
|
||||
Node* codeunits,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewWtf16Encode,
|
||||
Operator::kNoDeopt | Operator::kNoThrow, offset,
|
||||
@ -6248,7 +6224,7 @@ Node* WasmGraphBuilder::StringViewWtf16Slice(Node* string,
|
||||
Node* start, Node* end,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewWtf16Slice,
|
||||
Operator::kEliminatable, string, start, end);
|
||||
@ -6256,9 +6232,7 @@ Node* WasmGraphBuilder::StringViewWtf16Slice(Node* string,
|
||||
|
||||
Node* WasmGraphBuilder::StringAsIter(Node* str, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
str = AssertNotNull(str, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) str = AssertNotNull(str, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringAsIter, Operator::kEliminatable,
|
||||
str);
|
||||
@ -6266,9 +6240,7 @@ Node* WasmGraphBuilder::StringAsIter(Node* str, CheckForNull null_check,
|
||||
|
||||
Node* WasmGraphBuilder::StringViewIterNext(Node* view, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
view = AssertNotNull(view, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) view = AssertNotNull(view, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewIterNext,
|
||||
Operator::kEliminatable, view);
|
||||
@ -6278,9 +6250,7 @@ Node* WasmGraphBuilder::StringViewIterAdvance(Node* view,
|
||||
CheckForNull null_check,
|
||||
Node* codepoints,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
view = AssertNotNull(view, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) view = AssertNotNull(view, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewIterAdvance,
|
||||
Operator::kEliminatable, view, codepoints);
|
||||
@ -6290,9 +6260,7 @@ Node* WasmGraphBuilder::StringViewIterRewind(Node* view,
|
||||
CheckForNull null_check,
|
||||
Node* codepoints,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
view = AssertNotNull(view, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) view = AssertNotNull(view, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewIterRewind,
|
||||
Operator::kEliminatable, view, codepoints);
|
||||
@ -6301,9 +6269,7 @@ Node* WasmGraphBuilder::StringViewIterRewind(Node* view,
|
||||
Node* WasmGraphBuilder::StringViewIterSlice(Node* view, CheckForNull null_check,
|
||||
Node* codepoints,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
view = AssertNotNull(view, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) view = AssertNotNull(view, position);
|
||||
|
||||
return gasm_->CallBuiltin(Builtin::kWasmStringViewIterSlice,
|
||||
Operator::kEliminatable, view, codepoints);
|
||||
@ -6312,12 +6278,8 @@ Node* WasmGraphBuilder::StringViewIterSlice(Node* view, CheckForNull null_check,
|
||||
Node* WasmGraphBuilder::StringCompare(Node* lhs, CheckForNull null_check_lhs,
|
||||
Node* rhs, CheckForNull null_check_rhs,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check_lhs == kWithNullCheck) {
|
||||
lhs = AssertNotNull(lhs, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check_rhs == kWithNullCheck) {
|
||||
rhs = AssertNotNull(rhs, wasm::kWasmStringRef, position);
|
||||
}
|
||||
if (null_check_lhs == kWithNullCheck) lhs = AssertNotNull(lhs, position);
|
||||
if (null_check_rhs == kWithNullCheck) rhs = AssertNotNull(rhs, position);
|
||||
return gasm_->BuildChangeSmiToInt32(gasm_->CallBuiltin(
|
||||
Builtin::kWasmStringCompare, Operator::kEliminatable, lhs, rhs));
|
||||
}
|
||||
@ -6330,7 +6292,7 @@ Node* WasmGraphBuilder::StringFromCodePoint(Node* code_point) {
|
||||
Node* WasmGraphBuilder::StringHash(Node* string, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
string = AssertNotNull(string, wasm::kWasmStringRef, position);
|
||||
string = AssertNotNull(string, position);
|
||||
}
|
||||
|
||||
auto runtime_label = gasm_->MakeLabel();
|
||||
@ -6379,9 +6341,7 @@ Node* WasmGraphBuilder::I31New(Node* input) {
|
||||
|
||||
Node* WasmGraphBuilder::I31GetS(Node* input, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
input = AssertNotNull(input, wasm::kWasmI31Ref, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) input = AssertNotNull(input, position);
|
||||
if constexpr (SmiValuesAre31Bits()) {
|
||||
input = gasm_->BuildTruncateIntPtrToInt32(input);
|
||||
return gasm_->Word32SarShiftOutZeros(input,
|
||||
@ -6396,9 +6356,7 @@ Node* WasmGraphBuilder::I31GetS(Node* input, CheckForNull null_check,
|
||||
|
||||
Node* WasmGraphBuilder::I31GetU(Node* input, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position) {
|
||||
if (null_check == kWithNullCheck) {
|
||||
input = AssertNotNull(input, wasm::kWasmI31Ref, position);
|
||||
}
|
||||
if (null_check == kWithNullCheck) input = AssertNotNull(input, position);
|
||||
if constexpr (SmiValuesAre31Bits()) {
|
||||
input = gasm_->BuildTruncateIntPtrToInt32(input);
|
||||
return gasm_->Word32Shr(input, gasm_->BuildSmiShiftBitsConstant32());
|
||||
@ -6635,80 +6593,63 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
case wasm::kF64:
|
||||
return BuildChangeFloat64ToNumber(node);
|
||||
case wasm::kRef:
|
||||
switch (type.heap_representation()) {
|
||||
case wasm::HeapType::kEq:
|
||||
case wasm::HeapType::kI31:
|
||||
case wasm::HeapType::kStruct:
|
||||
case wasm::HeapType::kArray:
|
||||
case wasm::HeapType::kAny:
|
||||
case wasm::HeapType::kExtern:
|
||||
case wasm::HeapType::kString:
|
||||
case wasm::HeapType::kNone:
|
||||
case wasm::HeapType::kNoFunc:
|
||||
case wasm::HeapType::kNoExtern:
|
||||
return node;
|
||||
case wasm::HeapType::kBottom:
|
||||
case wasm::HeapType::kStringViewWtf8:
|
||||
case wasm::HeapType::kStringViewWtf16:
|
||||
case wasm::HeapType::kStringViewIter:
|
||||
UNREACHABLE();
|
||||
case wasm::HeapType::kFunc:
|
||||
default:
|
||||
if (type.heap_representation() == wasm::HeapType::kFunc ||
|
||||
module_->has_signature(type.ref_index())) {
|
||||
// Typed function. Extract the external function.
|
||||
return gasm_->LoadFromObject(
|
||||
MachineType::TaggedPointer(), node,
|
||||
wasm::ObjectAccess::ToTagged(
|
||||
WasmInternalFunction::kExternalOffset));
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
case wasm::kRefNull:
|
||||
switch (type.heap_representation()) {
|
||||
case wasm::HeapType::kExtern:
|
||||
case wasm::HeapType::kNoExtern:
|
||||
return node;
|
||||
case wasm::HeapType::kNone:
|
||||
case wasm::HeapType::kNoFunc:
|
||||
return LOAD_ROOT(NullValue, null_value);
|
||||
case wasm::HeapType::kEq:
|
||||
case wasm::HeapType::kStruct:
|
||||
case wasm::HeapType::kArray:
|
||||
case wasm::HeapType::kString:
|
||||
case wasm::HeapType::kI31:
|
||||
case wasm::HeapType::kAny: {
|
||||
auto done = gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
gasm_->GotoIfNot(IsNull(node, type), &done, node);
|
||||
gasm_->Goto(&done, LOAD_ROOT(NullValue, null_value));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
}
|
||||
case wasm::HeapType::kFunc:
|
||||
default: {
|
||||
if (type == wasm::kWasmFuncRef ||
|
||||
module_->has_signature(type.ref_index())) {
|
||||
case wasm::HeapType::kFunc: {
|
||||
if (type.kind() == wasm::kRefNull) {
|
||||
auto done =
|
||||
gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
auto null_label = gasm_->MakeLabel();
|
||||
gasm_->GotoIf(IsNull(node, type), &null_label);
|
||||
// Null gets passed as-is.
|
||||
gasm_->GotoIf(IsNull(node), &done, node);
|
||||
gasm_->Goto(&done,
|
||||
gasm_->LoadFromObject(
|
||||
MachineType::TaggedPointer(), node,
|
||||
wasm::ObjectAccess::ToTagged(
|
||||
WasmInternalFunction::kExternalOffset)));
|
||||
gasm_->Bind(&null_label);
|
||||
gasm_->Goto(&done, LOAD_ROOT(NullValue, null_value));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
} else {
|
||||
auto done =
|
||||
gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
gasm_->GotoIfNot(IsNull(node, type), &done, node);
|
||||
gasm_->Goto(&done, LOAD_ROOT(NullValue, null_value));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
return gasm_->LoadFromObject(
|
||||
MachineType::TaggedPointer(), node,
|
||||
wasm::ObjectAccess::ToTagged(
|
||||
WasmInternalFunction::kExternalOffset));
|
||||
}
|
||||
}
|
||||
case wasm::HeapType::kEq:
|
||||
case wasm::HeapType::kStruct:
|
||||
case wasm::HeapType::kArray:
|
||||
case wasm::HeapType::kString:
|
||||
case wasm::HeapType::kExtern:
|
||||
case wasm::HeapType::kAny:
|
||||
case wasm::HeapType::kNone:
|
||||
case wasm::HeapType::kNoFunc:
|
||||
case wasm::HeapType::kNoExtern:
|
||||
case wasm::HeapType::kI31:
|
||||
return node;
|
||||
default: {
|
||||
DCHECK(type.has_index());
|
||||
if (module_->has_signature(type.ref_index())) {
|
||||
// Typed function. Extract the external function.
|
||||
if (type.kind() == wasm::kRefNull) {
|
||||
auto done =
|
||||
gasm_->MakeLabel(MachineRepresentation::kTaggedPointer);
|
||||
// Null gets passed as-is.
|
||||
gasm_->GotoIf(IsNull(node), &done, node);
|
||||
gasm_->Goto(&done,
|
||||
gasm_->LoadFromObject(
|
||||
MachineType::TaggedPointer(), node,
|
||||
wasm::ObjectAccess::ToTagged(
|
||||
WasmInternalFunction::kExternalOffset)));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
} else {
|
||||
return gasm_->LoadFromObject(
|
||||
MachineType::TaggedPointer(), node,
|
||||
wasm::ObjectAccess::ToTagged(
|
||||
WasmInternalFunction::kExternalOffset));
|
||||
}
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6748,10 +6689,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
auto done = gasm_->MakeLabel(MachineRepresentation::kTagged);
|
||||
auto type_error = gasm_->MakeLabel();
|
||||
gasm_->GotoIf(IsSmi(input), &type_error, BranchHint::kFalse);
|
||||
if (type.is_nullable()) {
|
||||
gasm_->GotoIf(IsNull(input, wasm::kWasmExternRef), &done,
|
||||
LOAD_ROOT(WasmNull, wasm_null));
|
||||
}
|
||||
if (type.is_nullable()) gasm_->GotoIf(IsNull(input), &done, input);
|
||||
Node* map = gasm_->LoadMap(input);
|
||||
Node* instance_type = gasm_->LoadInstanceType(map);
|
||||
Node* check = gasm_->Uint32LessThan(
|
||||
@ -6772,14 +6710,15 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
|
||||
case wasm::kRef:
|
||||
case wasm::kRefNull: {
|
||||
switch (type.heap_representation()) {
|
||||
// TODO(7748): Add more fast paths?
|
||||
// Fast paths for extern and string.
|
||||
// TODO(7748): Add more/all fast paths?
|
||||
case wasm::HeapType::kExtern:
|
||||
case wasm::HeapType::kNoExtern:
|
||||
return input;
|
||||
case wasm::HeapType::kString:
|
||||
return BuildCheckString(input, js_context, type);
|
||||
case wasm::HeapType::kNone:
|
||||
case wasm::HeapType::kNoFunc:
|
||||
case wasm::HeapType::kNoExtern:
|
||||
case wasm::HeapType::kI31:
|
||||
case wasm::HeapType::kAny:
|
||||
case wasm::HeapType::kFunc:
|
||||
|
@ -253,10 +253,10 @@ class WasmGraphBuilder {
|
||||
Node* tnode, Node* fnode);
|
||||
Node* CreateOrMergeIntoEffectPhi(Node* merge, Node* tnode, Node* fnode);
|
||||
Node* EffectPhi(unsigned count, Node** effects_and_control);
|
||||
Node* RefNull(wasm::ValueType type);
|
||||
Node* RefNull();
|
||||
Node* RefFunc(uint32_t function_index);
|
||||
Node* AssertNotNull(
|
||||
Node* object, wasm::ValueType type, wasm::WasmCodePosition position,
|
||||
Node* object, wasm::WasmCodePosition position,
|
||||
wasm::TrapReason reason = wasm::TrapReason::kTrapNullDereference);
|
||||
Node* TraceInstruction(uint32_t mark_id);
|
||||
Node* Int32Constant(int32_t value);
|
||||
@ -266,9 +266,7 @@ class WasmGraphBuilder {
|
||||
Node* Simd128Constant(const uint8_t value[16]);
|
||||
Node* Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
|
||||
wasm::WasmCodePosition position = wasm::kNoCodePosition);
|
||||
// The {type} argument is only required for null-checking operations.
|
||||
Node* Unop(wasm::WasmOpcode opcode, Node* input,
|
||||
wasm::ValueType type = wasm::kWasmBottom,
|
||||
wasm::WasmCodePosition position = wasm::kNoCodePosition);
|
||||
Node* MemoryGrow(Node* input);
|
||||
Node* Throw(uint32_t tag_index, const wasm::WasmTag* tag,
|
||||
@ -354,8 +352,7 @@ class WasmGraphBuilder {
|
||||
Node** failure_control,
|
||||
bool is_last_case);
|
||||
|
||||
void BrOnNull(Node* ref_object, wasm::ValueType type, Node** non_null_node,
|
||||
Node** null_node);
|
||||
void BrOnNull(Node* ref_object, Node** non_null_node, Node** null_node);
|
||||
|
||||
Node* Invert(Node* node);
|
||||
|
||||
@ -603,7 +600,7 @@ class WasmGraphBuilder {
|
||||
Node* StringFromCodePoint(Node* code_point);
|
||||
Node* StringHash(Node* string, CheckForNull null_check,
|
||||
wasm::WasmCodePosition position);
|
||||
Node* IsNull(Node* object, wasm::ValueType type);
|
||||
Node* IsNull(Node* object);
|
||||
Node* TypeGuard(Node* value, wasm::ValueType type);
|
||||
|
||||
bool has_simd() const { return has_simd_; }
|
||||
|
@ -96,19 +96,12 @@ Node* WasmGCLowering::RootNode(RootIndex index) {
|
||||
IsolateData::root_slot_offset(index));
|
||||
}
|
||||
|
||||
Node* WasmGCLowering::Null(wasm::ValueType type) {
|
||||
return wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_)
|
||||
? RootNode(RootIndex::kNullValue)
|
||||
: RootNode(RootIndex::kWasmNull);
|
||||
}
|
||||
Node* WasmGCLowering::Null() { return RootNode(RootIndex::kNullValue); }
|
||||
|
||||
Node* WasmGCLowering::IsNull(Node* object, wasm::ValueType type) {
|
||||
Tagged_t static_null =
|
||||
wasm::GetWasmEngine()->compressed_wasm_null_value_or_zero();
|
||||
Node* null_value = !wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_) &&
|
||||
static_null != 0
|
||||
? gasm_.UintPtrConstant(static_null)
|
||||
: Null(type);
|
||||
Node* WasmGCLowering::IsNull(Node* object) {
|
||||
Tagged_t static_null = wasm::GetWasmEngine()->compressed_null_value_or_zero();
|
||||
Node* null_value =
|
||||
static_null != 0 ? gasm_.UintPtrConstant(static_null) : Null();
|
||||
return gasm_.TaggedEqual(object, null_value);
|
||||
}
|
||||
|
||||
@ -138,8 +131,8 @@ Reduction WasmGCLowering::ReduceWasmTypeCheck(Node* node) {
|
||||
// being a wasm object and return 0 (failure).
|
||||
if (object_can_be_null && (!is_cast_from_any || config.to.is_nullable())) {
|
||||
const int kResult = config.to.is_nullable() ? 1 : 0;
|
||||
gasm_.GotoIf(IsNull(object, wasm::kWasmAnyRef), &end_label,
|
||||
BranchHint::kFalse, gasm_.Int32Constant(kResult));
|
||||
gasm_.GotoIf(IsNull(object), &end_label, BranchHint::kFalse,
|
||||
gasm_.Int32Constant(kResult));
|
||||
}
|
||||
|
||||
if (object_can_be_i31) {
|
||||
@ -216,7 +209,7 @@ Reduction WasmGCLowering::ReduceWasmTypeCast(Node* node) {
|
||||
// failure. In that case the instance type check will identify null as not
|
||||
// being a wasm object and trap.
|
||||
if (object_can_be_null && (!is_cast_from_any || config.to.is_nullable())) {
|
||||
Node* is_null = IsNull(object, wasm::kWasmAnyRef);
|
||||
Node* is_null = IsNull(object);
|
||||
if (config.to.is_nullable()) {
|
||||
gasm_.GotoIf(is_null, &end_label, BranchHint::kFalse);
|
||||
} else if (!v8_flags.experimental_wasm_skip_null_checks) {
|
||||
@ -283,9 +276,8 @@ Reduction WasmGCLowering::ReduceAssertNotNull(Node* node) {
|
||||
Node* control = NodeProperties::GetControlInput(node);
|
||||
Node* object = NodeProperties::GetValueInput(node, 0);
|
||||
gasm_.InitializeEffectControl(effect, control);
|
||||
auto op_parameter = OpParameter<AssertNotNullParameters>(node->op());
|
||||
if (!v8_flags.experimental_wasm_skip_null_checks) {
|
||||
gasm_.TrapIf(IsNull(object, op_parameter.type), op_parameter.trap_id);
|
||||
gasm_.TrapIf(IsNull(object), TrapIdOf(node->op()));
|
||||
}
|
||||
|
||||
ReplaceWithValue(node, object, gasm_.effect(), gasm_.control());
|
||||
@ -295,23 +287,19 @@ Reduction WasmGCLowering::ReduceAssertNotNull(Node* node) {
|
||||
|
||||
Reduction WasmGCLowering::ReduceNull(Node* node) {
|
||||
DCHECK_EQ(node->opcode(), IrOpcode::kNull);
|
||||
auto type = OpParameter<wasm::ValueType>(node->op());
|
||||
return Replace(Null(type));
|
||||
return Replace(Null());
|
||||
}
|
||||
|
||||
Reduction WasmGCLowering::ReduceIsNull(Node* node) {
|
||||
DCHECK_EQ(node->opcode(), IrOpcode::kIsNull);
|
||||
Node* object = NodeProperties::GetValueInput(node, 0);
|
||||
auto type = OpParameter<wasm::ValueType>(node->op());
|
||||
return Replace(IsNull(object, type));
|
||||
return Replace(IsNull(object));
|
||||
}
|
||||
|
||||
Reduction WasmGCLowering::ReduceIsNotNull(Node* node) {
|
||||
DCHECK_EQ(node->opcode(), IrOpcode::kIsNotNull);
|
||||
Node* object = NodeProperties::GetValueInput(node, 0);
|
||||
auto type = OpParameter<wasm::ValueType>(node->op());
|
||||
return Replace(
|
||||
gasm_.Word32Equal(IsNull(object, type), gasm_.Int32Constant(0)));
|
||||
return Replace(gasm_.Word32Equal(IsNull(object), gasm_.Int32Constant(0)));
|
||||
}
|
||||
|
||||
Reduction WasmGCLowering::ReduceRttCanon(Node* node) {
|
||||
@ -340,18 +328,13 @@ Reduction WasmGCLowering::ReduceWasmExternInternalize(Node* node) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
// TODO(7748): WasmExternExternalize is a no-op. Consider removing it.
|
||||
Reduction WasmGCLowering::ReduceWasmExternExternalize(Node* node) {
|
||||
DCHECK_EQ(node->opcode(), IrOpcode::kWasmExternExternalize);
|
||||
Node* object = node->InputAt(0);
|
||||
gasm_.InitializeEffectControl(NodeProperties::GetEffectInput(node),
|
||||
NodeProperties::GetControlInput(node));
|
||||
auto label = gasm_.MakeLabel(MachineRepresentation::kTagged);
|
||||
gasm_.GotoIfNot(IsNull(object, wasm::kWasmAnyRef), &label, object);
|
||||
gasm_.Goto(&label, Null(wasm::kWasmExternRef));
|
||||
gasm_.Bind(&label);
|
||||
ReplaceWithValue(node, label.PhiAt(0), gasm_.effect(), gasm_.control());
|
||||
Node* object = NodeProperties::GetValueInput(node, 0);
|
||||
ReplaceWithValue(node, object);
|
||||
node->Kill();
|
||||
return Replace(label.PhiAt(0));
|
||||
return Replace(object);
|
||||
}
|
||||
|
||||
Reduction WasmGCLowering::ReduceWasmStructGet(Node* node) {
|
||||
|
@ -49,8 +49,8 @@ class WasmGCLowering final : public AdvancedReducer {
|
||||
Reduction ReduceStringPrepareForGetCodeunit(Node* node);
|
||||
Node* IsolateRoot();
|
||||
Node* RootNode(RootIndex index);
|
||||
Node* Null(wasm::ValueType type);
|
||||
Node* IsNull(Node* object, wasm::ValueType type);
|
||||
Node* Null();
|
||||
Node* IsNull(Node* object);
|
||||
Node* BuildLoadExternalPointerFromObject(Node* object, int offset,
|
||||
ExternalPointerTag tag);
|
||||
WasmGraphAssembler gasm_;
|
||||
|
@ -301,9 +301,9 @@ Reduction WasmGCOperatorReducer::ReduceWasmTypeCast(Node* node) {
|
||||
return Changed(node);
|
||||
} else {
|
||||
gasm_.InitializeEffectControl(effect, control);
|
||||
return Replace(SetType(gasm_.AssertNotNull(object, object_type.type,
|
||||
TrapId::kTrapIllegalCast),
|
||||
object_type.type.AsNonNull()));
|
||||
return Replace(
|
||||
SetType(gasm_.AssertNotNull(object, TrapId::kTrapIllegalCast),
|
||||
object_type.type.AsNonNull()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,12 +314,11 @@ Reduction WasmGCOperatorReducer::ReduceWasmTypeCast(Node* node) {
|
||||
// A cast between unrelated types can only succeed if the argument is null.
|
||||
// Otherwise, it always fails.
|
||||
Node* non_trapping_condition = object_type.type.is_nullable() && to_nullable
|
||||
? gasm_.IsNull(object, object_type.type)
|
||||
? gasm_.IsNull(object)
|
||||
: gasm_.Int32Constant(0);
|
||||
gasm_.TrapUnless(SetType(non_trapping_condition, wasm::kWasmI32),
|
||||
TrapId::kTrapIllegalCast);
|
||||
Node* null_node = SetType(gasm_.Null(object_type.type),
|
||||
wasm::ToNullSentinel(object_type));
|
||||
Node* null_node = SetType(gasm_.Null(), wasm::ToNullSentinel(object_type));
|
||||
ReplaceWithValue(node, null_node, gasm_.effect(), gasm_.control());
|
||||
node->Kill();
|
||||
return Replace(null_node);
|
||||
@ -361,7 +360,7 @@ Reduction WasmGCOperatorReducer::ReduceWasmTypeCheck(Node* node) {
|
||||
// Type cast will fail only on null.
|
||||
gasm_.InitializeEffectControl(effect, control);
|
||||
Node* condition = SetType(object_type.type.is_nullable() && !null_succeeds
|
||||
? gasm_.IsNotNull(object, object_type.type)
|
||||
? gasm_.IsNotNull(object)
|
||||
: gasm_.Int32Constant(1),
|
||||
wasm::kWasmI32);
|
||||
ReplaceWithValue(node, condition);
|
||||
@ -378,8 +377,7 @@ Reduction WasmGCOperatorReducer::ReduceWasmTypeCheck(Node* node) {
|
||||
if (null_succeeds && object_type.type.is_nullable()) {
|
||||
// The cast only succeeds in case of null.
|
||||
gasm_.InitializeEffectControl(effect, control);
|
||||
condition =
|
||||
SetType(gasm_.IsNull(object, object_type.type), wasm::kWasmI32);
|
||||
condition = SetType(gasm_.IsNull(object), wasm::kWasmI32);
|
||||
} else {
|
||||
// The cast never succeeds.
|
||||
condition = SetType(gasm_.Int32Constant(0), wasm::kWasmI32);
|
||||
|
@ -375,23 +375,21 @@ Node* WasmGraphAssembler::WasmTypeCast(Node* object, Node* rtt,
|
||||
effect(), control()));
|
||||
}
|
||||
|
||||
Node* WasmGraphAssembler::Null(wasm::ValueType type) {
|
||||
return AddNode(graph()->NewNode(simplified_.Null(type)));
|
||||
Node* WasmGraphAssembler::Null() {
|
||||
return AddNode(graph()->NewNode(simplified_.Null()));
|
||||
}
|
||||
|
||||
Node* WasmGraphAssembler::IsNull(Node* object, wasm::ValueType type) {
|
||||
return AddNode(graph()->NewNode(simplified_.IsNull(type), object, control()));
|
||||
Node* WasmGraphAssembler::IsNull(Node* object) {
|
||||
return AddNode(graph()->NewNode(simplified_.IsNull(), object, control()));
|
||||
}
|
||||
|
||||
Node* WasmGraphAssembler::IsNotNull(Node* object, wasm::ValueType type) {
|
||||
return AddNode(
|
||||
graph()->NewNode(simplified_.IsNotNull(type), object, control()));
|
||||
Node* WasmGraphAssembler::IsNotNull(Node* object) {
|
||||
return AddNode(graph()->NewNode(simplified_.IsNotNull(), object, control()));
|
||||
}
|
||||
|
||||
Node* WasmGraphAssembler::AssertNotNull(Node* object, wasm::ValueType type,
|
||||
TrapId trap_id) {
|
||||
return AddNode(graph()->NewNode(simplified_.AssertNotNull(type, trap_id),
|
||||
object, effect(), control()));
|
||||
Node* WasmGraphAssembler::AssertNotNull(Node* object, TrapId trap_id) {
|
||||
return AddNode(graph()->NewNode(simplified_.AssertNotNull(trap_id), object,
|
||||
effect(), control()));
|
||||
}
|
||||
|
||||
Node* WasmGraphAssembler::WasmExternInternalize(Node* object) {
|
||||
|
@ -246,13 +246,13 @@ class WasmGraphAssembler : public GraphAssembler {
|
||||
|
||||
Node* WasmTypeCast(Node* object, Node* rtt, WasmTypeCheckConfig config);
|
||||
|
||||
Node* Null(wasm::ValueType type);
|
||||
Node* Null();
|
||||
|
||||
Node* IsNull(Node* object, wasm::ValueType type);
|
||||
Node* IsNull(Node* object);
|
||||
|
||||
Node* IsNotNull(Node* object, wasm::ValueType type);
|
||||
Node* IsNotNull(Node* object);
|
||||
|
||||
Node* AssertNotNull(Node* object, wasm::ValueType type, TrapId trap_id);
|
||||
Node* AssertNotNull(Node* object, TrapId trap_id);
|
||||
|
||||
Node* WasmExternInternalize(Node* object);
|
||||
|
||||
|
@ -948,10 +948,6 @@ Handle<WasmValueObject> WasmValueObject::New(
|
||||
isolate);
|
||||
}
|
||||
t = GetRefTypeName(isolate, value.type(), module_object);
|
||||
} else if (ref->IsWasmNull()) {
|
||||
// TODO(manoskouk): Is this value correct?
|
||||
v = isolate->factory()->null_value();
|
||||
t = GetRefTypeName(isolate, value.type(), module_object);
|
||||
} else if (ref->IsJSFunction() || ref->IsSmi() || ref->IsNull() ||
|
||||
ref->IsString() ||
|
||||
value.type().is_reference_to(wasm::HeapType::kExtern) ||
|
||||
|
@ -70,8 +70,7 @@ namespace internal {
|
||||
IF_WASM(V, WasmSuspenderObject) \
|
||||
IF_WASM(V, WasmResumeData) \
|
||||
IF_WASM(V, WasmTypeInfo) \
|
||||
IF_WASM(V, WasmContinuationObject) \
|
||||
IF_WASM(V, WasmNull)
|
||||
IF_WASM(V, WasmContinuationObject)
|
||||
|
||||
#define FORWARD_DECLARE(TypeName) class TypeName;
|
||||
TYPED_VISITOR_ID_LIST(FORWARD_DECLARE)
|
||||
|
@ -274,8 +274,6 @@ class ReadOnlySpace : public BaseSpace {
|
||||
|
||||
size_t capacity_;
|
||||
const size_t area_size_;
|
||||
|
||||
friend class Heap;
|
||||
};
|
||||
|
||||
class SharedReadOnlySpace : public ReadOnlySpace {
|
||||
|
@ -588,7 +588,6 @@ bool Heap::CreateInitialReadOnlyMaps() {
|
||||
wasm_type_info)
|
||||
IF_WASM(ALLOCATE_MAP, WASM_CONTINUATION_OBJECT_TYPE,
|
||||
WasmContinuationObject::kSize, wasm_continuation_object)
|
||||
IF_WASM(ALLOCATE_MAP, WASM_NULL_TYPE, kVariableSizeSentinel, wasm_null);
|
||||
|
||||
ALLOCATE_MAP(WEAK_CELL_TYPE, WeakCell::kSize, weak_cell)
|
||||
}
|
||||
@ -985,53 +984,6 @@ void Heap::CreateInitialReadOnlyObjects() {
|
||||
Handle<ScopeInfo> shadow_realm_scope_info =
|
||||
ScopeInfo::CreateForShadowRealmNativeContext(isolate());
|
||||
set_shadow_realm_scope_info(*shadow_realm_scope_info);
|
||||
|
||||
// Initialize the wasm null_value.
|
||||
|
||||
#ifdef V8_ENABLE_WEBASSEMBLY
|
||||
// Allocate the wasm-null object. It is a regular V8 heap object contained in
|
||||
// a V8 page. It is large enough so that its payload (other than its map word)
|
||||
// can be mprotected on OS page granularity.
|
||||
// We adjust the layout such that we have a filler object in the current OS
|
||||
// page, and the wasm-null map word at the end of the current OS page. The
|
||||
// payload then is contained on a separate OS page which can be protected.
|
||||
|
||||
// Ensure all of the following lands on the same V8 page.
|
||||
constexpr int kOffsetAfterMapWord = HeapObject::kMapOffset + kTaggedSize;
|
||||
constexpr size_t kLargestPossibleOSPageSize = 64 * KB;
|
||||
static_assert(kLargestPossibleOSPageSize >= kMinimumOSPageSize);
|
||||
read_only_space_->EnsureSpaceForAllocation(
|
||||
kLargestPossibleOSPageSize + WasmNull::kSize - kOffsetAfterMapWord);
|
||||
Address next_page =
|
||||
RoundUp(read_only_space_->top(), kLargestPossibleOSPageSize);
|
||||
CHECK_EQ(kOffsetAfterMapWord % kObjectAlignment, 0);
|
||||
|
||||
// Add some filler to end up right before an OS page boundary.
|
||||
{
|
||||
int filler_size = static_cast<int>(next_page - read_only_space_->top() -
|
||||
kOffsetAfterMapWord);
|
||||
HeapObject filler =
|
||||
allocator()->AllocateRawWith<HeapAllocator::kRetryOrFail>(
|
||||
filler_size, AllocationType::kReadOnly, AllocationOrigin::kRuntime,
|
||||
AllocationAlignment::kTaggedAligned);
|
||||
CreateFillerObjectAt(filler.address(), filler_size,
|
||||
ClearFreedMemoryMode::kClearFreedMemory);
|
||||
CHECK_EQ(read_only_space_->top() + kOffsetAfterMapWord, next_page);
|
||||
}
|
||||
|
||||
// Finally, allocate the wasm-null object.
|
||||
{
|
||||
HeapObject obj;
|
||||
CHECK(AllocateRaw(WasmNull::kSize, AllocationType::kReadOnly).To(&obj));
|
||||
obj.set_map_after_allocation(roots.wasm_null_map(), SKIP_WRITE_BARRIER);
|
||||
set_wasm_null(WasmNull::cast(obj));
|
||||
|
||||
CHECK_EQ(read_only_space_->top() % kLargestPossibleOSPageSize, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// We prefer to fit all of read-only space in one page.
|
||||
CHECK_EQ(read_only_space_->pages().size(), 1);
|
||||
}
|
||||
|
||||
void Heap::CreateInitialMutableObjects() {
|
||||
|
@ -142,9 +142,6 @@ bool RootToBoolean(RootIndex index) {
|
||||
case RootIndex::kHoleNanValue:
|
||||
case RootIndex::kMinusZeroValue:
|
||||
case RootIndex::kempty_string:
|
||||
#ifdef V8_ENABLE_WEBASSEMBLY
|
||||
case RootIndex::kWasmNull:
|
||||
#endif
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
@ -411,8 +411,6 @@ VisitorId Map::GetVisitorId(Map map) {
|
||||
return kVisitWasmCapiFunctionData;
|
||||
case WASM_SUSPENDER_OBJECT_TYPE:
|
||||
return kVisitWasmSuspenderObject;
|
||||
case WASM_NULL_TYPE:
|
||||
return kVisitWasmNull;
|
||||
#endif // V8_ENABLE_WEBASSEMBLY
|
||||
|
||||
#define MAKE_TQ_CASE(TYPE, Name) \
|
||||
|
@ -30,8 +30,7 @@ enum InstanceType : uint16_t;
|
||||
V(CoverageInfo) \
|
||||
V(DataObject) \
|
||||
V(FeedbackMetadata) \
|
||||
V(FixedDoubleArray) \
|
||||
IF_WASM(V, WasmNull)
|
||||
V(FixedDoubleArray)
|
||||
|
||||
#define POINTER_VISITOR_ID_LIST(V) \
|
||||
V(AccessorInfo) \
|
||||
|
@ -280,7 +280,6 @@ class ZoneForwardList;
|
||||
IF_WASM(V, WasmValueObject) \
|
||||
IF_WASM(V, WasmSuspenderObject) \
|
||||
IF_WASM(V, WasmContinuationObject) \
|
||||
IF_WASM(V, WasmNull) \
|
||||
V(WeakFixedArray) \
|
||||
V(WeakArrayList) \
|
||||
V(WeakCell) \
|
||||
|
@ -881,19 +881,6 @@ class WasmStruct::BodyDescriptor final : public BodyDescriptorBase {
|
||||
}
|
||||
};
|
||||
|
||||
class WasmNull::BodyDescriptor final : public BodyDescriptorBase {
|
||||
public:
|
||||
static bool IsValidSlot(Map map, HeapObject obj, int offset) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
template <typename ObjectVisitor>
|
||||
static inline void IterateBody(Map map, HeapObject obj, int object_size,
|
||||
ObjectVisitor* v) {}
|
||||
|
||||
static inline int SizeOf(Map map, HeapObject obj) { return WasmNull::kSize; }
|
||||
};
|
||||
|
||||
#endif // V8_ENABLE_WEBASSEMBLY
|
||||
|
||||
class ExternalOneByteString::BodyDescriptor final : public BodyDescriptorBase {
|
||||
@ -1319,8 +1306,6 @@ auto BodyDescriptorApply(InstanceType type, Args&&... args) {
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
case WASM_INSTANCE_OBJECT_TYPE:
|
||||
return CALL_APPLY(WasmInstanceObject);
|
||||
case WASM_NULL_TYPE:
|
||||
return CALL_APPLY(WasmNull);
|
||||
#endif // V8_ENABLE_WEBASSEMBLY
|
||||
case JS_WEAK_MAP_TYPE:
|
||||
case JS_WEAK_SET_TYPE:
|
||||
|
@ -651,9 +651,6 @@ bool Object::BooleanValue(IsolateT* isolate) {
|
||||
DCHECK(IsHeapObject());
|
||||
if (IsBoolean()) return IsTrue(isolate);
|
||||
if (IsNullOrUndefined(isolate)) return false;
|
||||
#ifdef V8_ENABLE_WEBASSEMBLY
|
||||
if (IsWasmNull()) return false;
|
||||
#endif
|
||||
if (IsUndetectable()) return false; // Undetectable object is false.
|
||||
if (IsString()) return String::cast(*this).length() != 0;
|
||||
if (IsHeapNumber()) return DoubleToBoolean(HeapNumber::cast(*this).value());
|
||||
@ -2295,9 +2292,6 @@ int HeapObject::SizeFromMap(Map map) const {
|
||||
if (instance_type == WASM_ARRAY_TYPE) {
|
||||
return WasmArray::SizeFor(map, WasmArray::unchecked_cast(*this).length());
|
||||
}
|
||||
if (instance_type == WASM_NULL_TYPE) {
|
||||
return WasmNull::kSize;
|
||||
}
|
||||
#endif // V8_ENABLE_WEBASSEMBLY
|
||||
DCHECK_EQ(instance_type, EMBEDDER_DATA_ARRAY_TYPE);
|
||||
return EmbedderDataArray::SizeFor(
|
||||
|
@ -27,10 +27,6 @@
|
||||
#include "src/roots/roots.h"
|
||||
#include "src/roots/static-roots.h"
|
||||
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#endif
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
|
@ -139,7 +139,6 @@ class Symbol;
|
||||
IF_WASM(V, Map, wasm_resume_data_map, WasmResumeDataMap) \
|
||||
IF_WASM(V, Map, wasm_type_info_map, WasmTypeInfoMap) \
|
||||
IF_WASM(V, Map, wasm_continuation_object_map, WasmContinuationObjectMap) \
|
||||
IF_WASM(V, Map, wasm_null_map, WasmNullMap) \
|
||||
V(Map, weak_fixed_array_map, WeakFixedArrayMap) \
|
||||
V(Map, weak_array_list_map, WeakArrayListMap) \
|
||||
V(Map, ephemeron_hash_table_map, EphemeronHashTableMap) \
|
||||
@ -226,8 +225,7 @@ class Symbol;
|
||||
V(ScopeInfo, shadow_realm_scope_info, ShadowRealmScopeInfo) \
|
||||
V(RegisteredSymbolTable, empty_symbol_table, EmptySymbolTable) \
|
||||
/* Hash seed */ \
|
||||
V(ByteArray, hash_seed, HashSeed) \
|
||||
IF_WASM(V, WasmNull, wasm_null, WasmNull)
|
||||
V(ByteArray, hash_seed, HashSeed)
|
||||
|
||||
// Mutable roots that are known to be immortal immovable, for which we can
|
||||
// safely skip write barriers.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -951,7 +951,7 @@ RUNTIME_FUNCTION(Runtime_WasmStringNewWtf8) {
|
||||
if (utf8_variant == unibrow::Utf8Variant::kUtf8NoTrap) {
|
||||
DCHECK(!isolate->has_pending_exception());
|
||||
if (result_string.is_null()) {
|
||||
return *isolate->factory()->wasm_null();
|
||||
return *isolate->factory()->null_value();
|
||||
}
|
||||
return *result_string.ToHandleChecked();
|
||||
}
|
||||
@ -976,7 +976,7 @@ RUNTIME_FUNCTION(Runtime_WasmStringNewWtf8Array) {
|
||||
if (utf8_variant == unibrow::Utf8Variant::kUtf8NoTrap) {
|
||||
DCHECK(!isolate->has_pending_exception());
|
||||
if (result_string.is_null()) {
|
||||
return *isolate->factory()->wasm_null();
|
||||
return *isolate->factory()->null_value();
|
||||
}
|
||||
return *result_string.ToHandleChecked();
|
||||
}
|
||||
|
@ -923,22 +923,14 @@ class LiftoffCompiler {
|
||||
|
||||
// Initialize all reference type locals with ref.null.
|
||||
if (has_refs) {
|
||||
LiftoffRegList pinned;
|
||||
Register null_ref_reg =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned).gp());
|
||||
Register wasm_null_ref_reg =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned).gp());
|
||||
LoadNullValue(null_ref_reg, pinned, kWasmExternRef);
|
||||
LoadNullValue(wasm_null_ref_reg, pinned, kWasmAnyRef);
|
||||
Register null_ref_reg = __ GetUnusedRegister(kGpReg, {}).gp();
|
||||
LoadNullValue(null_ref_reg, {});
|
||||
for (uint32_t local_index = num_params; local_index < __ num_locals();
|
||||
++local_index) {
|
||||
ValueType type = decoder->local_types_[local_index];
|
||||
if (type.is_reference()) {
|
||||
ValueKind kind = __ local_kind(local_index);
|
||||
if (is_reference(kind)) {
|
||||
__ Spill(__ cache_state()->stack_state[local_index].offset(),
|
||||
IsSubtypeOf(type, kWasmExternRef, decoder->module_)
|
||||
? LiftoffRegister(null_ref_reg)
|
||||
: LiftoffRegister(wasm_null_ref_reg),
|
||||
type.kind());
|
||||
LiftoffRegister(null_ref_reg), kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1713,11 +1705,11 @@ class LiftoffCompiler {
|
||||
__ PushRegister(dst_kind, dst);
|
||||
}
|
||||
|
||||
void EmitIsNull(WasmOpcode opcode, ValueType type) {
|
||||
void EmitIsNull(WasmOpcode opcode) {
|
||||
LiftoffRegList pinned;
|
||||
LiftoffRegister ref = pinned.set(__ PopToRegister());
|
||||
LiftoffRegister null = __ GetUnusedRegister(kGpReg, pinned);
|
||||
LoadNullValueForCompare(null.gp(), pinned, type);
|
||||
LoadNullValueForCompare(null.gp(), pinned);
|
||||
// Prefer to overwrite one of the input registers with the result
|
||||
// of the comparison.
|
||||
LiftoffRegister dst = __ GetUnusedRegister(kGpReg, {ref, null}, {});
|
||||
@ -1862,7 +1854,7 @@ class LiftoffCompiler {
|
||||
// We abuse ref.as_non_null, which isn't otherwise used in this switch, as
|
||||
// a sentinel for the negation of ref.is_null.
|
||||
case kExprRefAsNonNull:
|
||||
return EmitIsNull(opcode, value.type);
|
||||
return EmitIsNull(opcode);
|
||||
case kExprExternInternalize: {
|
||||
LiftoffAssembler::VarState input_state =
|
||||
__ cache_state()->stack_state.back();
|
||||
@ -1873,22 +1865,9 @@ class LiftoffCompiler {
|
||||
__ PushRegister(kRef, LiftoffRegister(kReturnRegister0));
|
||||
return;
|
||||
}
|
||||
case kExprExternExternalize: {
|
||||
LiftoffRegList pinned;
|
||||
LiftoffRegister ref = pinned.set(__ PopToRegister(pinned));
|
||||
LiftoffRegister null = __ GetUnusedRegister(kGpReg, pinned);
|
||||
LoadNullValueForCompare(null.gp(), pinned, kWasmAnyRef);
|
||||
Label label;
|
||||
{
|
||||
FREEZE_STATE(frozen);
|
||||
__ emit_cond_jump(kNotEqual, &label, kRefNull, ref.gp(), null.gp(),
|
||||
frozen);
|
||||
LoadNullValue(ref.gp(), pinned, kWasmExternRef);
|
||||
__ bind(&label);
|
||||
}
|
||||
__ PushRegister(kRefNull, ref);
|
||||
case kExprExternExternalize:
|
||||
// This is a no-op.
|
||||
return;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -2315,7 +2294,7 @@ class LiftoffCompiler {
|
||||
|
||||
void RefNull(FullDecoder* decoder, ValueType type, Value*) {
|
||||
LiftoffRegister null = __ GetUnusedRegister(kGpReg, {});
|
||||
LoadNullValue(null.gp(), {}, type);
|
||||
LoadNullValue(null.gp(), {});
|
||||
__ PushRegister(type.kind(), null);
|
||||
}
|
||||
|
||||
@ -2684,7 +2663,7 @@ class LiftoffCompiler {
|
||||
Label* trap_label =
|
||||
AddOutOfLineTrap(decoder, WasmCode::kThrowWasmTrapIllegalCast);
|
||||
LiftoffRegister null = __ GetUnusedRegister(kGpReg, pinned);
|
||||
LoadNullValueForCompare(null.gp(), pinned, arg.type);
|
||||
LoadNullValueForCompare(null.gp(), pinned);
|
||||
{
|
||||
FREEZE_STATE(trapping);
|
||||
__ emit_cond_jump(cond, trap_label, kRefNull, obj.gp(), null.gp(),
|
||||
@ -3601,7 +3580,7 @@ class LiftoffCompiler {
|
||||
Register tmp = NeedsTierupCheck(decoder, depth)
|
||||
? pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp()
|
||||
: no_reg;
|
||||
LoadNullValueForCompare(null, pinned, ref_object.type);
|
||||
LoadNullValueForCompare(null, pinned);
|
||||
{
|
||||
FREEZE_STATE(frozen);
|
||||
__ emit_cond_jump(kNotEqual, &cont_false, ref_object.type.kind(),
|
||||
@ -3631,7 +3610,7 @@ class LiftoffCompiler {
|
||||
Register tmp = NeedsTierupCheck(decoder, depth)
|
||||
? pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp()
|
||||
: no_reg;
|
||||
LoadNullValueForCompare(null, pinned, ref_object.type);
|
||||
LoadNullValueForCompare(null, pinned);
|
||||
{
|
||||
FREEZE_STATE(frozen);
|
||||
__ emit_cond_jump(kEqual, &cont_false, ref_object.type.kind(), ref.gp(),
|
||||
@ -5559,19 +5538,16 @@ class LiftoffCompiler {
|
||||
for (uint32_t i = imm.struct_type->field_count(); i > 0;) {
|
||||
i--;
|
||||
int offset = StructFieldOffset(imm.struct_type, i);
|
||||
ValueType field_type = imm.struct_type->field(i);
|
||||
ValueKind field_kind = imm.struct_type->field(i).kind();
|
||||
LiftoffRegister value = pinned.set(
|
||||
initial_values_on_stack
|
||||
? __ PopToRegister(pinned)
|
||||
: __ GetUnusedRegister(reg_class_for(field_type.kind()), pinned));
|
||||
: __ GetUnusedRegister(reg_class_for(field_kind), pinned));
|
||||
if (!initial_values_on_stack) {
|
||||
if (!CheckSupportedType(decoder, field_type.kind(), "default value")) {
|
||||
return;
|
||||
}
|
||||
SetDefaultValue(value, field_type, pinned);
|
||||
if (!CheckSupportedType(decoder, field_kind, "default value")) return;
|
||||
SetDefaultValue(value, field_kind, pinned);
|
||||
}
|
||||
StoreObjectField(obj.gp(), no_reg, offset, value, pinned,
|
||||
field_type.kind());
|
||||
StoreObjectField(obj.gp(), no_reg, offset, value, pinned, field_kind);
|
||||
pinned.clear(value);
|
||||
}
|
||||
// If this assert fails then initialization of padding field might be
|
||||
@ -5632,8 +5608,7 @@ class LiftoffCompiler {
|
||||
__ emit_i32_cond_jumpi(kUnsignedGreaterThan, trap_label, length.gp(),
|
||||
WasmArray::MaxLength(imm.array_type), trapping);
|
||||
}
|
||||
ValueType elem_type = imm.array_type->element_type();
|
||||
ValueKind elem_kind = elem_type.kind();
|
||||
ValueKind elem_kind = imm.array_type->element_type().kind();
|
||||
int elem_size = value_kind_size(elem_kind);
|
||||
// Allocate the array.
|
||||
{
|
||||
@ -5661,7 +5636,7 @@ class LiftoffCompiler {
|
||||
__ PopToFixedRegister(value);
|
||||
} else {
|
||||
if (!CheckSupportedType(decoder, elem_kind, "default value")) return;
|
||||
SetDefaultValue(value, elem_type, pinned);
|
||||
SetDefaultValue(value, elem_kind, pinned);
|
||||
}
|
||||
// Initialize the array's elements.
|
||||
LiftoffRegister offset = pinned.set(__ GetUnusedRegister(kGpReg, pinned));
|
||||
@ -6019,9 +5994,7 @@ class LiftoffCompiler {
|
||||
Register scratch_null =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
LiftoffRegister result = pinned.set(__ GetUnusedRegister(kGpReg, pinned));
|
||||
if (obj.type.is_nullable()) {
|
||||
LoadNullValueForCompare(scratch_null, pinned, obj.type);
|
||||
}
|
||||
if (obj.type.is_nullable()) LoadNullValueForCompare(scratch_null, pinned);
|
||||
|
||||
{
|
||||
FREEZE_STATE(frozen);
|
||||
@ -6055,7 +6028,7 @@ class LiftoffCompiler {
|
||||
case HeapType::kNoExtern:
|
||||
case HeapType::kNoFunc:
|
||||
DCHECK(null_succeeds);
|
||||
return EmitIsNull(kExprRefIsNull, obj.type);
|
||||
return EmitIsNull(kExprRefIsNull);
|
||||
case HeapType::kAny:
|
||||
// Any may never need a cast as it is either implicitly convertible or
|
||||
// never convertible for any given type.
|
||||
@ -6079,9 +6052,7 @@ class LiftoffCompiler {
|
||||
Register scratch_null =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
Register scratch2 = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
if (obj.type.is_nullable()) {
|
||||
LoadNullValueForCompare(scratch_null, pinned, obj.type);
|
||||
}
|
||||
if (obj.type.is_nullable()) LoadNullValueForCompare(scratch_null, pinned);
|
||||
|
||||
{
|
||||
FREEZE_STATE(frozen);
|
||||
@ -6132,9 +6103,7 @@ class LiftoffCompiler {
|
||||
Register scratch_null =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
Register scratch2 = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
if (obj.type.is_nullable()) {
|
||||
LoadNullValue(scratch_null, pinned, kWasmAnyRef);
|
||||
}
|
||||
if (obj.type.is_nullable()) LoadNullValue(scratch_null, pinned);
|
||||
FREEZE_STATE(frozen);
|
||||
|
||||
NullSucceeds null_handling = null_succeeds ? kNullSucceeds : kNullFails;
|
||||
@ -6162,9 +6131,7 @@ class LiftoffCompiler {
|
||||
Register scratch_null =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
Register scratch2 = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
if (obj.type.is_nullable()) {
|
||||
LoadNullValue(scratch_null, pinned, kWasmAnyRef);
|
||||
}
|
||||
if (obj.type.is_nullable()) LoadNullValue(scratch_null, pinned);
|
||||
FREEZE_STATE(frozen);
|
||||
|
||||
NullSucceeds null_handling = null_succeeds ? kNullSucceeds : kNullFails;
|
||||
@ -6252,7 +6219,7 @@ class LiftoffCompiler {
|
||||
|
||||
enum PopOrPeek { kPop, kPeek };
|
||||
|
||||
void Initialize(TypeCheck& check, PopOrPeek pop_or_peek, ValueType type) {
|
||||
void Initialize(TypeCheck& check, PopOrPeek pop_or_peek) {
|
||||
LiftoffRegList pinned;
|
||||
if (pop_or_peek == kPop) {
|
||||
check.obj_reg = pinned.set(__ PopToRegister(pinned)).gp();
|
||||
@ -6262,7 +6229,7 @@ class LiftoffCompiler {
|
||||
check.tmp1 = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
check.tmp2 = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
|
||||
if (check.obj_type.is_nullable()) {
|
||||
LoadNullValue(check.null_reg(), pinned, type);
|
||||
LoadNullValue(check.null_reg(), pinned);
|
||||
}
|
||||
}
|
||||
void LoadInstanceType(TypeCheck& check, const FreezeCacheState& frozen,
|
||||
@ -6322,7 +6289,7 @@ class LiftoffCompiler {
|
||||
void AbstractTypeCheck(const Value& object, bool null_succeeds) {
|
||||
Label match, no_match, done;
|
||||
TypeCheck check(object.type, &no_match, null_succeeds);
|
||||
Initialize(check, kPop, object.type);
|
||||
Initialize(check, kPop);
|
||||
LiftoffRegister result(check.tmp1);
|
||||
{
|
||||
FREEZE_STATE(frozen);
|
||||
@ -6373,7 +6340,7 @@ class LiftoffCompiler {
|
||||
Label* trap_label =
|
||||
AddOutOfLineTrap(decoder, WasmCode::kThrowWasmTrapIllegalCast);
|
||||
TypeCheck check(object.type, trap_label, null_succeeds);
|
||||
Initialize(check, kPeek, object.type);
|
||||
Initialize(check, kPeek);
|
||||
FREEZE_STATE(frozen);
|
||||
|
||||
if (null_succeeds && check.obj_type.is_nullable()) {
|
||||
@ -6418,7 +6385,7 @@ class LiftoffCompiler {
|
||||
|
||||
Label no_match, match;
|
||||
TypeCheck check(object.type, &no_match, null_succeeds);
|
||||
Initialize(check, kPeek, object.type);
|
||||
Initialize(check, kPeek);
|
||||
FREEZE_STATE(frozen);
|
||||
|
||||
if (null_succeeds && check.obj_type.is_nullable()) {
|
||||
@ -6443,7 +6410,7 @@ class LiftoffCompiler {
|
||||
|
||||
Label no_match, end;
|
||||
TypeCheck check(object.type, &no_match, null_succeeds);
|
||||
Initialize(check, kPeek, object.type);
|
||||
Initialize(check, kPeek);
|
||||
FREEZE_STATE(frozen);
|
||||
|
||||
if (null_succeeds && check.obj_type.is_nullable()) {
|
||||
@ -6877,7 +6844,7 @@ class LiftoffCompiler {
|
||||
LiftoffRegister null = pinned.set(__ GetUnusedRegister(kGpReg, pinned));
|
||||
bool check_for_null = a.type.is_nullable() || b.type.is_nullable();
|
||||
if (check_for_null) {
|
||||
LoadNullValueForCompare(null.gp(), pinned, kWasmStringRef);
|
||||
LoadNullValueForCompare(null.gp(), pinned);
|
||||
}
|
||||
|
||||
FREEZE_STATE(frozen);
|
||||
@ -7791,30 +7758,25 @@ class LiftoffCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
void LoadNullValue(Register null, LiftoffRegList pinned, ValueType type) {
|
||||
__ LoadFullPointer(
|
||||
null, kRootRegister,
|
||||
type == kWasmExternRef || type == kWasmNullExternRef
|
||||
? IsolateData::root_slot_offset(RootIndex::kNullValue)
|
||||
: IsolateData::root_slot_offset(RootIndex::kWasmNull));
|
||||
void LoadNullValue(Register null, LiftoffRegList pinned) {
|
||||
__ LoadFullPointer(null, kRootRegister,
|
||||
IsolateData::root_slot_offset(RootIndex::kNullValue));
|
||||
}
|
||||
|
||||
// Stores the null value representation in the passed register.
|
||||
// If pointer compression is active, only the compressed tagged pointer
|
||||
// will be stored. Any operations with this register therefore must
|
||||
// not compare this against 64 bits using quadword instructions.
|
||||
void LoadNullValueForCompare(Register null, LiftoffRegList pinned,
|
||||
ValueType type) {
|
||||
void LoadNullValueForCompare(Register null, LiftoffRegList pinned) {
|
||||
Tagged_t static_null =
|
||||
wasm::GetWasmEngine()->compressed_wasm_null_value_or_zero();
|
||||
if (type != kWasmExternRef && type != kWasmNullExternRef &&
|
||||
static_null != 0) {
|
||||
wasm::GetWasmEngine()->compressed_null_value_or_zero();
|
||||
if (static_null != 0) {
|
||||
// static_null is only set for builds with pointer compression.
|
||||
DCHECK_LE(static_null, std::numeric_limits<uint32_t>::max());
|
||||
__ LoadConstant(LiftoffRegister(null),
|
||||
WasmValue(static_cast<uint32_t>(static_null)));
|
||||
} else {
|
||||
LoadNullValue(null, pinned, type);
|
||||
LoadNullValue(null, pinned);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7832,7 +7794,7 @@ class LiftoffCompiler {
|
||||
Label* trap_label =
|
||||
AddOutOfLineTrap(decoder, WasmCode::kThrowWasmTrapNullDereference);
|
||||
LiftoffRegister null = __ GetUnusedRegister(kGpReg, pinned);
|
||||
LoadNullValueForCompare(null.gp(), pinned, type);
|
||||
LoadNullValueForCompare(null.gp(), pinned);
|
||||
FREEZE_STATE(trapping);
|
||||
__ emit_cond_jump(kEqual, trap_label, kRefNull, object, null.gp(),
|
||||
trapping);
|
||||
@ -7881,10 +7843,10 @@ class LiftoffCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
void SetDefaultValue(LiftoffRegister reg, ValueType type,
|
||||
void SetDefaultValue(LiftoffRegister reg, ValueKind kind,
|
||||
LiftoffRegList pinned) {
|
||||
DCHECK(is_defaultable(type.kind()));
|
||||
switch (type.kind()) {
|
||||
DCHECK(is_defaultable(kind));
|
||||
switch (kind) {
|
||||
case kI8:
|
||||
case kI16:
|
||||
case kI32:
|
||||
@ -7899,7 +7861,7 @@ class LiftoffCompiler {
|
||||
DCHECK(CpuFeatures::SupportsWasmSimd128());
|
||||
return __ emit_s128_xor(reg, reg, reg);
|
||||
case kRefNull:
|
||||
return LoadNullValue(reg.gp(), pinned, type);
|
||||
return LoadNullValue(reg.gp(), pinned);
|
||||
case kRtt:
|
||||
case kVoid:
|
||||
case kBottom:
|
||||
|
@ -1884,9 +1884,6 @@ auto Global::get() const -> Val {
|
||||
handle(i::Handle<i::WasmInternalFunction>::cast(result)->external(),
|
||||
v8_global->GetIsolate());
|
||||
}
|
||||
if (result->IsWasmNull()) {
|
||||
result = v8_global->GetIsolate()->factory()->null_value();
|
||||
}
|
||||
return Val(V8RefValueToWasm(store, result));
|
||||
}
|
||||
case i::wasm::kS128:
|
||||
@ -2026,9 +2023,6 @@ auto Table::get(size_t index) const -> own<Ref> {
|
||||
result = handle(
|
||||
i::Handle<i::WasmInternalFunction>::cast(result)->external(), isolate);
|
||||
}
|
||||
if (result->IsWasmNull()) {
|
||||
result = isolate->factory()->null_value();
|
||||
}
|
||||
DCHECK(result->IsNull(isolate) || result->IsJSReceiver());
|
||||
return V8RefValueToWasm(impl(this)->store(), result);
|
||||
}
|
||||
|
@ -106,11 +106,7 @@ void ConstantExpressionInterface::BinOp(FullDecoder* decoder, WasmOpcode opcode,
|
||||
void ConstantExpressionInterface::RefNull(FullDecoder* decoder, ValueType type,
|
||||
Value* result) {
|
||||
if (!generate_value()) return;
|
||||
result->runtime_value =
|
||||
WasmValue(type == kWasmExternRef || type == kWasmNullExternRef
|
||||
? Handle<Object>::cast(isolate_->factory()->null_value())
|
||||
: Handle<Object>::cast(isolate_->factory()->wasm_null()),
|
||||
type);
|
||||
result->runtime_value = WasmValue(isolate_->factory()->null_value(), type);
|
||||
}
|
||||
|
||||
void ConstantExpressionInterface::RefFunc(FullDecoder* decoder,
|
||||
|
@ -35,11 +35,8 @@ ValueOrError EvaluateConstantExpression(Zone* zone, ConstantExpression expr,
|
||||
case ConstantExpression::kI32Const:
|
||||
return WasmValue(expr.i32_value());
|
||||
case ConstantExpression::kRefNull:
|
||||
return WasmValue(
|
||||
expected == kWasmExternRef || expected == kWasmNullExternRef
|
||||
? Handle<Object>::cast(isolate->factory()->null_value())
|
||||
: Handle<Object>::cast(isolate->factory()->wasm_null()),
|
||||
ValueType::RefNull(expr.repr()));
|
||||
return WasmValue(isolate->factory()->null_value(),
|
||||
ValueType::RefNull(expr.repr()));
|
||||
case ConstantExpression::kRefFunc: {
|
||||
uint32_t index = expr.index();
|
||||
Handle<Object> value =
|
||||
|
@ -233,7 +233,7 @@ class WasmGraphBuildingInterface {
|
||||
DCHECK(type.is_reference());
|
||||
// TODO(jkummerow): Consider using "the hole" instead, to make any
|
||||
// illegal uses more obvious.
|
||||
node = builder_->SetType(builder_->RefNull(type), type);
|
||||
node = builder_->SetType(builder_->RefNull(), type);
|
||||
} else {
|
||||
node = builder_->SetType(builder_->DefaultValue(type), type);
|
||||
}
|
||||
@ -444,8 +444,8 @@ class WasmGraphBuildingInterface {
|
||||
|
||||
void UnOp(FullDecoder* decoder, WasmOpcode opcode, const Value& value,
|
||||
Value* result) {
|
||||
SetAndTypeNode(result, builder_->Unop(opcode, value.node, value.type,
|
||||
decoder->position()));
|
||||
SetAndTypeNode(result,
|
||||
builder_->Unop(opcode, value.node, decoder->position()));
|
||||
}
|
||||
|
||||
void BinOp(FullDecoder* decoder, WasmOpcode opcode, const Value& lhs,
|
||||
@ -481,7 +481,7 @@ class WasmGraphBuildingInterface {
|
||||
}
|
||||
|
||||
void RefNull(FullDecoder* decoder, ValueType type, Value* result) {
|
||||
SetAndTypeNode(result, builder_->RefNull(type));
|
||||
SetAndTypeNode(result, builder_->RefNull());
|
||||
}
|
||||
|
||||
void RefFunc(FullDecoder* decoder, uint32_t function_index, Value* result) {
|
||||
@ -489,8 +489,7 @@ class WasmGraphBuildingInterface {
|
||||
}
|
||||
|
||||
void RefAsNonNull(FullDecoder* decoder, const Value& arg, Value* result) {
|
||||
TFNode* cast_node =
|
||||
builder_->AssertNotNull(arg.node, arg.type, decoder->position());
|
||||
TFNode* cast_node = builder_->AssertNotNull(arg.node, decoder->position());
|
||||
SetAndTypeNode(result, cast_node);
|
||||
}
|
||||
|
||||
@ -540,16 +539,15 @@ class WasmGraphBuildingInterface {
|
||||
void AssertNullTypecheck(FullDecoder* decoder, const Value& obj,
|
||||
Value* result) {
|
||||
builder_->TrapIfFalse(wasm::TrapReason::kTrapIllegalCast,
|
||||
builder_->IsNull(obj.node, obj.type),
|
||||
decoder->position());
|
||||
builder_->IsNull(obj.node), decoder->position());
|
||||
Forward(decoder, obj, result);
|
||||
}
|
||||
|
||||
void AssertNotNullTypecheck(FullDecoder* decoder, const Value& obj,
|
||||
Value* result) {
|
||||
SetAndTypeNode(
|
||||
result, builder_->AssertNotNull(obj.node, obj.type, decoder->position(),
|
||||
TrapReason::kTrapIllegalCast));
|
||||
SetAndTypeNode(result,
|
||||
builder_->AssertNotNull(obj.node, decoder->position(),
|
||||
TrapReason::kTrapIllegalCast));
|
||||
}
|
||||
|
||||
void NopForTestingUnsupportedInLiftoff(FullDecoder* decoder) {}
|
||||
@ -917,7 +915,7 @@ class WasmGraphBuildingInterface {
|
||||
SsaEnv* false_env = ssa_env_;
|
||||
SsaEnv* true_env = Split(decoder->zone(), false_env);
|
||||
false_env->SetNotMerged();
|
||||
builder_->BrOnNull(ref_object.node, ref_object.type, &true_env->control,
|
||||
builder_->BrOnNull(ref_object.node, &true_env->control,
|
||||
&false_env->control);
|
||||
builder_->SetControl(false_env->control);
|
||||
{
|
||||
@ -936,7 +934,7 @@ class WasmGraphBuildingInterface {
|
||||
SsaEnv* false_env = ssa_env_;
|
||||
SsaEnv* true_env = Split(decoder->zone(), false_env);
|
||||
false_env->SetNotMerged();
|
||||
builder_->BrOnNull(ref_object.node, ref_object.type, &false_env->control,
|
||||
builder_->BrOnNull(ref_object.node, &false_env->control,
|
||||
&true_env->control);
|
||||
builder_->SetControl(false_env->control);
|
||||
ScopedSsaEnv scoped_env(this, true_env);
|
||||
|
@ -680,9 +680,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
|
||||
Handle<WasmTableObject> table_obj = WasmTableObject::New(
|
||||
isolate_, instance, table.type, table.initial_size,
|
||||
table.has_maximum_size, table.maximum_size, nullptr,
|
||||
IsSubtypeOf(table.type, kWasmExternRef, module_)
|
||||
? Handle<Object>::cast(isolate_->factory()->null_value())
|
||||
: Handle<Object>::cast(isolate_->factory()->wasm_null()));
|
||||
isolate_->factory()->null_value());
|
||||
tables->set(i, *table_obj);
|
||||
}
|
||||
instance->set_tables(*tables);
|
||||
@ -1969,7 +1967,7 @@ V8_INLINE void SetFunctionTablePlaceholder(Isolate* isolate,
|
||||
V8_INLINE void SetFunctionTableNullEntry(Isolate* isolate,
|
||||
Handle<WasmTableObject> table_object,
|
||||
uint32_t entry_index) {
|
||||
table_object->entries().set(entry_index, *isolate->factory()->wasm_null());
|
||||
table_object->entries().set(entry_index, *isolate->factory()->null_value());
|
||||
WasmTableObject::ClearDispatchTables(isolate, table_object, entry_index);
|
||||
}
|
||||
} // namespace
|
||||
|
@ -1041,8 +1041,8 @@ void WasmEngine::AddIsolate(Isolate* isolate) {
|
||||
#if defined(V8_COMPRESS_POINTERS)
|
||||
// The null value is not accessible on mksnapshot runs.
|
||||
if (isolate->snapshot_available()) {
|
||||
wasm_null_tagged_compressed_ = V8HeapCompressionScheme::CompressTagged(
|
||||
isolate->factory()->wasm_null()->ptr());
|
||||
null_tagged_compressed_ = V8HeapCompressionScheme::CompressTagged(
|
||||
isolate->factory()->null_value()->ptr());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -371,8 +371,8 @@ class V8_EXPORT_PRIVATE WasmEngine {
|
||||
|
||||
// Returns either the compressed tagged pointer representing a null value or
|
||||
// 0 if pointer compression is not available.
|
||||
Tagged_t compressed_wasm_null_value_or_zero() const {
|
||||
return wasm_null_tagged_compressed_;
|
||||
Tagged_t compressed_null_value_or_zero() const {
|
||||
return null_tagged_compressed_;
|
||||
}
|
||||
|
||||
// Call on process start and exit.
|
||||
@ -411,7 +411,7 @@ class V8_EXPORT_PRIVATE WasmEngine {
|
||||
std::atomic<int> next_compilation_id_{0};
|
||||
|
||||
// Compressed tagged pointer to null value.
|
||||
std::atomic<Tagged_t> wasm_null_tagged_compressed_{0};
|
||||
std::atomic<Tagged_t> null_tagged_compressed_{0};
|
||||
|
||||
TypeCanonicalizer type_canonicalizer_;
|
||||
|
||||
|
@ -1135,13 +1135,15 @@ bool GetInitialOrMinimumProperty(v8::Isolate* isolate, ErrorThrower* thrower,
|
||||
namespace {
|
||||
i::Handle<i::Object> DefaultReferenceValue(i::Isolate* isolate,
|
||||
i::wasm::ValueType type) {
|
||||
DCHECK(type.is_object_reference());
|
||||
// Use undefined for JS type (externref) but null for wasm types as wasm does
|
||||
// not know undefined.
|
||||
if (type.heap_representation() == i::wasm::HeapType::kExtern) {
|
||||
return isolate->factory()->undefined_value();
|
||||
if (type.is_reference()) {
|
||||
// Use undefined for JS type (externref) but null for wasm types as wasm
|
||||
// does not know undefined.
|
||||
if (type.heap_representation() == i::wasm::HeapType::kExtern) {
|
||||
return isolate->factory()->undefined_value();
|
||||
}
|
||||
return isolate->factory()->null_value();
|
||||
}
|
||||
return isolate->factory()->wasm_null();
|
||||
UNREACHABLE();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -2333,13 +2335,6 @@ void WebAssemblyTableSet(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
i::Handle<i::Object> element;
|
||||
if (args.Length() >= 2) {
|
||||
element = Utils::OpenHandle(*args[1]);
|
||||
const char* error_message;
|
||||
if (!i::WasmTableObject::JSToWasmElement(i_isolate, table_object, element,
|
||||
&error_message)
|
||||
.ToHandle(&element)) {
|
||||
thrower.TypeError("Argument 1 is invalid for table: %s", error_message);
|
||||
return;
|
||||
}
|
||||
} else if (table_object->type().is_defaultable()) {
|
||||
element = DefaultReferenceValue(i_isolate, table_object->type());
|
||||
} else {
|
||||
@ -2348,6 +2343,14 @@ void WebAssemblyTableSet(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* error_message;
|
||||
if (!i::WasmTableObject::JSToWasmElement(i_isolate, table_object, element,
|
||||
&error_message)
|
||||
.ToHandle(&element)) {
|
||||
thrower.TypeError("Argument 1 is invalid for table: %s", error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
i::WasmTableObject::Set(i_isolate, table_object, index, element);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ TQ_OBJECT_CONSTRUCTORS_IMPL(WasmArray)
|
||||
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmContinuationObject)
|
||||
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmSuspenderObject)
|
||||
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmResumeData)
|
||||
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmNull)
|
||||
|
||||
CAST_ACCESSOR(WasmInstanceObject)
|
||||
|
||||
|
@ -280,9 +280,9 @@ void WasmTableObject::SetFunctionTableEntry(Isolate* isolate,
|
||||
Handle<FixedArray> entries,
|
||||
int entry_index,
|
||||
Handle<Object> entry) {
|
||||
if (entry->IsWasmNull(isolate)) {
|
||||
if (entry->IsNull(isolate)) {
|
||||
ClearDispatchTables(isolate, table, entry_index); // Degenerate case.
|
||||
entries->set(entry_index, ReadOnlyRoots(isolate).wasm_null());
|
||||
entries->set(entry_index, ReadOnlyRoots(isolate).null_value());
|
||||
return;
|
||||
}
|
||||
Handle<Object> external =
|
||||
@ -362,7 +362,7 @@ Handle<Object> WasmTableObject::Get(Isolate* isolate,
|
||||
|
||||
Handle<Object> entry(entries->get(entry_index), isolate);
|
||||
|
||||
if (entry->IsWasmNull(isolate)) {
|
||||
if (entry->IsNull(isolate)) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -598,7 +598,7 @@ void WasmTableObject::GetFunctionTableEntry(
|
||||
*is_valid = true;
|
||||
Handle<Object> element(table->entries().get(entry_index), isolate);
|
||||
|
||||
*is_null = element->IsWasmNull(isolate);
|
||||
*is_null = element->IsNull(isolate);
|
||||
if (*is_null) return;
|
||||
|
||||
if (element->IsWasmInternalFunction()) {
|
||||
@ -2249,10 +2249,7 @@ MaybeHandle<Object> JSToWasmObject(Isolate* isolate, Handle<Object> value,
|
||||
*error_message = "stringview_iter has no JS representation";
|
||||
return {};
|
||||
default:
|
||||
bool is_extern_subtype =
|
||||
expected_canonical.heap_representation() == HeapType::kExtern ||
|
||||
expected_canonical.heap_representation() == HeapType::kNoExtern;
|
||||
return is_extern_subtype ? value : isolate->factory()->wasm_null();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2428,15 +2425,15 @@ MaybeHandle<Object> WasmToJSObject(Isolate* isolate, Handle<Object> value,
|
||||
case i::wasm::HeapType::kArray:
|
||||
case i::wasm::HeapType::kEq:
|
||||
case i::wasm::HeapType::kAny:
|
||||
return value->IsWasmNull() ? isolate->factory()->null_value() : value;
|
||||
return value;
|
||||
case i::wasm::HeapType::kFunc: {
|
||||
if (value->IsWasmNull()) {
|
||||
return isolate->factory()->null_value();
|
||||
} else {
|
||||
if (!value->IsNull()) {
|
||||
DCHECK(value->IsWasmInternalFunction());
|
||||
return handle(
|
||||
i::Handle<i::WasmInternalFunction>::cast(value)->external(),
|
||||
isolate);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
case i::wasm::HeapType::kStringViewWtf8:
|
||||
@ -2451,9 +2448,7 @@ MaybeHandle<Object> WasmToJSObject(Isolate* isolate, Handle<Object> value,
|
||||
case i::wasm::HeapType::kBottom:
|
||||
UNREACHABLE();
|
||||
default:
|
||||
if (value->IsWasmNull()) {
|
||||
return isolate->factory()->null_value();
|
||||
} else if (value->IsWasmInternalFunction()) {
|
||||
if (value->IsWasmInternalFunction()) {
|
||||
return handle(
|
||||
i::Handle<i::WasmInternalFunction>::cast(value)->external(),
|
||||
isolate);
|
||||
|
@ -1063,20 +1063,6 @@ class WasmSuspenderObject
|
||||
TQ_OBJECT_CONSTRUCTORS(WasmSuspenderObject)
|
||||
};
|
||||
|
||||
class WasmNull : public TorqueGeneratedWasmNull<WasmNull, HeapObject> {
|
||||
public:
|
||||
// TODO(manoskouk): Make it smaller if able and needed.
|
||||
static constexpr int kSize = 64 * KB + kTaggedSize;
|
||||
// Payload should be a multiple of page size.
|
||||
static_assert((kSize - kTaggedSize) % kMinimumOSPageSize == 0);
|
||||
// Any wasm struct offset should fit in the object.
|
||||
static_assert(kSize >= WasmStruct::kHeaderSize +
|
||||
wasm::kV8MaxWasmStructFields * kSimd128Size);
|
||||
class BodyDescriptor;
|
||||
|
||||
TQ_OBJECT_CONSTRUCTORS(WasmNull)
|
||||
};
|
||||
|
||||
#undef DECL_OPTIONAL_ACCESSORS
|
||||
|
||||
namespace wasm {
|
||||
|
@ -220,8 +220,3 @@ class WasmStringViewIter extends HeapObject {
|
||||
string: String;
|
||||
offset: uint32; // Index into string.
|
||||
}
|
||||
|
||||
extern class WasmNull extends HeapObject {}
|
||||
|
||||
extern macro WasmNullConstant(): WasmNull;
|
||||
const kWasmNull: WasmNull = WasmNullConstant();
|
||||
|
@ -386,7 +386,7 @@ WASM_COMPILED_EXEC_TEST(WasmRefAsNonNullSkipCheck) {
|
||||
tester.CompileModule();
|
||||
Handle<Object> result = tester.GetResultObject(kFunc).ToHandleChecked();
|
||||
// Without null checks, ref.as_non_null can actually return null.
|
||||
CHECK(result->IsWasmNull());
|
||||
CHECK(result->IsNull());
|
||||
}
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmBrOnNull) {
|
||||
@ -1145,7 +1145,7 @@ WASM_COMPILED_EXEC_TEST(WasmArrayCopy) {
|
||||
{
|
||||
Handle<Object> result5 =
|
||||
tester.GetResultObject(kCopyRef, 5).ToHandleChecked();
|
||||
CHECK(result5->IsWasmNull());
|
||||
CHECK(result5->IsNull());
|
||||
for (int i = 6; i <= 9; i++) {
|
||||
Handle<Object> res =
|
||||
tester.GetResultObject(kCopyRef, i).ToHandleChecked();
|
||||
@ -1156,7 +1156,7 @@ WASM_COMPILED_EXEC_TEST(WasmArrayCopy) {
|
||||
}
|
||||
CHECK(tester.GetResultObject(kCopyRefOverlapping, 6)
|
||||
.ToHandleChecked()
|
||||
->IsWasmNull());
|
||||
->IsNull());
|
||||
Handle<Object> res0 =
|
||||
tester.GetResultObject(kCopyRefOverlapping, 0).ToHandleChecked();
|
||||
CHECK(res0->IsWasmArray());
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "src/wasm/wasm-import-wrapper-cache.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
#include "src/wasm/wasm-opcodes.h"
|
||||
#include "src/wasm/wasm-subtyping.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -242,12 +241,10 @@ void TestingModuleBuilder::AddIndirectFunctionTable(
|
||||
|
||||
WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize(
|
||||
instance_object(), table_index, table_size);
|
||||
Handle<WasmTableObject> table_obj = WasmTableObject::New(
|
||||
isolate_, instance, table.type, table.initial_size,
|
||||
table.has_maximum_size, table.maximum_size, nullptr,
|
||||
IsSubtypeOf(table.type, kWasmExternRef, test_module_.get())
|
||||
? Handle<Object>::cast(isolate_->factory()->null_value())
|
||||
: Handle<Object>::cast(isolate_->factory()->wasm_null()));
|
||||
Handle<WasmTableObject> table_obj =
|
||||
WasmTableObject::New(isolate_, instance, table.type, table.initial_size,
|
||||
table.has_maximum_size, table.maximum_size, nullptr,
|
||||
isolate_->factory()->null_value());
|
||||
|
||||
WasmTableObject::AddDispatchTable(isolate_, table_obj, instance_object_,
|
||||
table_index);
|
||||
|
@ -25,7 +25,7 @@ function testGrowInternalExternRefTable(table_index) {
|
||||
const initial_size = 5;
|
||||
// Add 10 tables, we only test one.
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
builder.addTable(kWasmExternRef, initial_size);
|
||||
builder.addTable(kWasmExternRef, initial_size).index;
|
||||
}
|
||||
builder.addFunction('grow', kSig_i_ri)
|
||||
.addBody([kExprLocalGet, 0,
|
||||
|
@ -178,19 +178,18 @@ INSTANCE_TYPES = {
|
||||
267: "WASM_API_FUNCTION_REF_TYPE",
|
||||
268: "WASM_CONTINUATION_OBJECT_TYPE",
|
||||
269: "WASM_INTERNAL_FUNCTION_TYPE",
|
||||
270: "WASM_NULL_TYPE",
|
||||
271: "WASM_RESUME_DATA_TYPE",
|
||||
272: "WASM_STRING_VIEW_ITER_TYPE",
|
||||
273: "WASM_TYPE_INFO_TYPE",
|
||||
274: "WEAK_ARRAY_LIST_TYPE",
|
||||
275: "WEAK_CELL_TYPE",
|
||||
276: "WASM_ARRAY_TYPE",
|
||||
277: "WASM_STRUCT_TYPE",
|
||||
278: "JS_PROXY_TYPE",
|
||||
270: "WASM_RESUME_DATA_TYPE",
|
||||
271: "WASM_STRING_VIEW_ITER_TYPE",
|
||||
272: "WASM_TYPE_INFO_TYPE",
|
||||
273: "WEAK_ARRAY_LIST_TYPE",
|
||||
274: "WEAK_CELL_TYPE",
|
||||
275: "WASM_ARRAY_TYPE",
|
||||
276: "WASM_STRUCT_TYPE",
|
||||
277: "JS_PROXY_TYPE",
|
||||
1057: "JS_OBJECT_TYPE",
|
||||
279: "JS_GLOBAL_OBJECT_TYPE",
|
||||
280: "JS_GLOBAL_PROXY_TYPE",
|
||||
281: "JS_MODULE_NAMESPACE_TYPE",
|
||||
278: "JS_GLOBAL_OBJECT_TYPE",
|
||||
279: "JS_GLOBAL_PROXY_TYPE",
|
||||
280: "JS_MODULE_NAMESPACE_TYPE",
|
||||
1040: "JS_SPECIAL_API_OBJECT_TYPE",
|
||||
1041: "JS_PRIMITIVE_WRAPPER_TYPE",
|
||||
1058: "JS_API_OBJECT_TYPE",
|
||||
@ -298,7 +297,7 @@ KNOWN_MAPS = {
|
||||
("read_only_space", 0x02141): (255, "MetaMap"),
|
||||
("read_only_space", 0x02169): (175, "FixedArrayMap"),
|
||||
("read_only_space", 0x02191): (240, "WeakFixedArrayMap"),
|
||||
("read_only_space", 0x021b9): (274, "WeakArrayListMap"),
|
||||
("read_only_space", 0x021b9): (273, "WeakArrayListMap"),
|
||||
("read_only_space", 0x021e1): (175, "FixedCOWArrayMap"),
|
||||
("read_only_space", 0x02209): (236, "DescriptorArrayMap"),
|
||||
("read_only_space", 0x02231): (131, "UndefinedMap"),
|
||||
@ -430,7 +429,7 @@ KNOWN_MAPS = {
|
||||
("read_only_space", 0x0366d): (235, "AbstractInternalClassSubclass2Map"),
|
||||
("read_only_space", 0x03695): (230, "ExportedSubClass2Map"),
|
||||
("read_only_space", 0x036bd): (265, "SortStateMap"),
|
||||
("read_only_space", 0x036e5): (272, "WasmStringViewIterMap"),
|
||||
("read_only_space", 0x036e5): (271, "WasmStringViewIterMap"),
|
||||
("read_only_space", 0x0370d): (194, "SloppyArgumentsElementsMap"),
|
||||
("read_only_space", 0x03735): (237, "StrongDescriptorArrayMap"),
|
||||
("read_only_space", 0x0375d): (200, "TurboshaftWord32SetTypeMap"),
|
||||
@ -478,11 +477,10 @@ KNOWN_MAPS = {
|
||||
("read_only_space", 0x03df5): (226, "WasmExportedFunctionDataMap"),
|
||||
("read_only_space", 0x03e1d): (269, "WasmInternalFunctionMap"),
|
||||
("read_only_space", 0x03e45): (227, "WasmJSFunctionDataMap"),
|
||||
("read_only_space", 0x03e6d): (271, "WasmResumeDataMap"),
|
||||
("read_only_space", 0x03e95): (273, "WasmTypeInfoMap"),
|
||||
("read_only_space", 0x03e6d): (270, "WasmResumeDataMap"),
|
||||
("read_only_space", 0x03e95): (272, "WasmTypeInfoMap"),
|
||||
("read_only_space", 0x03ebd): (268, "WasmContinuationObjectMap"),
|
||||
("read_only_space", 0x03ee5): (270, "WasmNullMap"),
|
||||
("read_only_space", 0x03f0d): (275, "WeakCellMap"),
|
||||
("read_only_space", 0x03ee5): (274, "WeakCellMap"),
|
||||
("old_space", 0x043bd): (2118, "ExternalMap"),
|
||||
("old_space", 0x043e5): (2122, "JSMessageObjectMap"),
|
||||
}
|
||||
@ -498,49 +496,48 @@ KNOWN_OBJECTS = {
|
||||
("read_only_space", 0x02a99): "EmptyEnumCache",
|
||||
("read_only_space", 0x02aa5): "EmptyDescriptorArray",
|
||||
("read_only_space", 0x03875): "InvalidPrototypeValidityCell",
|
||||
("read_only_space", 0x03f35): "EmptyArrayList",
|
||||
("read_only_space", 0x03f41): "EmptyScopeInfo",
|
||||
("read_only_space", 0x03f51): "EmptyObjectBoilerplateDescription",
|
||||
("read_only_space", 0x03f5d): "EmptyArrayBoilerplateDescription",
|
||||
("read_only_space", 0x03f69): "TrueValue",
|
||||
("read_only_space", 0x03f85): "FalseValue",
|
||||
("read_only_space", 0x03fa1): "EmptyByteArray",
|
||||
("read_only_space", 0x03fa9): "EmptyPropertyArray",
|
||||
("read_only_space", 0x03fb1): "EmptyClosureFeedbackCellArray",
|
||||
("read_only_space", 0x03fb9): "NoOpInterceptorInfo",
|
||||
("read_only_space", 0x03fe1): "MinusZeroValue",
|
||||
("read_only_space", 0x03fed): "NanValue",
|
||||
("read_only_space", 0x03ff9): "HoleNanValue",
|
||||
("read_only_space", 0x04005): "InfinityValue",
|
||||
("read_only_space", 0x04011): "MinusInfinityValue",
|
||||
("read_only_space", 0x0401d): "MaxSafeInteger",
|
||||
("read_only_space", 0x04029): "MaxUInt32",
|
||||
("read_only_space", 0x04035): "SmiMinValue",
|
||||
("read_only_space", 0x04041): "SmiMaxValuePlusOne",
|
||||
("read_only_space", 0x0404d): "HashSeed",
|
||||
("read_only_space", 0x0405d): "SingleCharacterStringTable",
|
||||
("read_only_space", 0x05465): "empty_string",
|
||||
("read_only_space", 0x07b5d): "UninitializedValue",
|
||||
("read_only_space", 0x07b95): "ArgumentsMarker",
|
||||
("read_only_space", 0x07bcd): "TerminationException",
|
||||
("read_only_space", 0x07c0d): "Exception",
|
||||
("read_only_space", 0x07c29): "OptimizedOut",
|
||||
("read_only_space", 0x07c61): "StaleRegister",
|
||||
("read_only_space", 0x07c99): "SelfReferenceMarker",
|
||||
("read_only_space", 0x07cd9): "BasicBlockCountersMarker",
|
||||
("read_only_space", 0x081f1): "EmptyPropertyDictionary",
|
||||
("read_only_space", 0x08219): "EmptySymbolTable",
|
||||
("read_only_space", 0x08235): "EmptySlowElementDictionary",
|
||||
("read_only_space", 0x08259): "EmptyOrderedHashMap",
|
||||
("read_only_space", 0x0826d): "EmptyOrderedHashSet",
|
||||
("read_only_space", 0x08281): "EmptyOrderedPropertyDictionary",
|
||||
("read_only_space", 0x082a5): "EmptySwissPropertyDictionary",
|
||||
("read_only_space", 0x082c5): "EmptyFeedbackMetadata",
|
||||
("read_only_space", 0x082d1): "GlobalThisBindingScopeInfo",
|
||||
("read_only_space", 0x082f1): "EmptyFunctionScopeInfo",
|
||||
("read_only_space", 0x08315): "NativeScopeInfo",
|
||||
("read_only_space", 0x0832d): "ShadowRealmScopeInfo",
|
||||
("read_only_space", 0x0fffd): "WasmNull",
|
||||
("read_only_space", 0x03f0d): "EmptyArrayList",
|
||||
("read_only_space", 0x03f19): "EmptyScopeInfo",
|
||||
("read_only_space", 0x03f29): "EmptyObjectBoilerplateDescription",
|
||||
("read_only_space", 0x03f35): "EmptyArrayBoilerplateDescription",
|
||||
("read_only_space", 0x03f41): "TrueValue",
|
||||
("read_only_space", 0x03f5d): "FalseValue",
|
||||
("read_only_space", 0x03f79): "EmptyByteArray",
|
||||
("read_only_space", 0x03f81): "EmptyPropertyArray",
|
||||
("read_only_space", 0x03f89): "EmptyClosureFeedbackCellArray",
|
||||
("read_only_space", 0x03f91): "NoOpInterceptorInfo",
|
||||
("read_only_space", 0x03fb9): "MinusZeroValue",
|
||||
("read_only_space", 0x03fc5): "NanValue",
|
||||
("read_only_space", 0x03fd1): "HoleNanValue",
|
||||
("read_only_space", 0x03fdd): "InfinityValue",
|
||||
("read_only_space", 0x03fe9): "MinusInfinityValue",
|
||||
("read_only_space", 0x03ff5): "MaxSafeInteger",
|
||||
("read_only_space", 0x04001): "MaxUInt32",
|
||||
("read_only_space", 0x0400d): "SmiMinValue",
|
||||
("read_only_space", 0x04019): "SmiMaxValuePlusOne",
|
||||
("read_only_space", 0x04025): "HashSeed",
|
||||
("read_only_space", 0x04035): "SingleCharacterStringTable",
|
||||
("read_only_space", 0x0543d): "empty_string",
|
||||
("read_only_space", 0x07b35): "UninitializedValue",
|
||||
("read_only_space", 0x07b6d): "ArgumentsMarker",
|
||||
("read_only_space", 0x07ba5): "TerminationException",
|
||||
("read_only_space", 0x07be5): "Exception",
|
||||
("read_only_space", 0x07c01): "OptimizedOut",
|
||||
("read_only_space", 0x07c39): "StaleRegister",
|
||||
("read_only_space", 0x07c71): "SelfReferenceMarker",
|
||||
("read_only_space", 0x07cb1): "BasicBlockCountersMarker",
|
||||
("read_only_space", 0x081c9): "EmptyPropertyDictionary",
|
||||
("read_only_space", 0x081f1): "EmptySymbolTable",
|
||||
("read_only_space", 0x0820d): "EmptySlowElementDictionary",
|
||||
("read_only_space", 0x08231): "EmptyOrderedHashMap",
|
||||
("read_only_space", 0x08245): "EmptyOrderedHashSet",
|
||||
("read_only_space", 0x08259): "EmptyOrderedPropertyDictionary",
|
||||
("read_only_space", 0x0827d): "EmptySwissPropertyDictionary",
|
||||
("read_only_space", 0x0829d): "EmptyFeedbackMetadata",
|
||||
("read_only_space", 0x082a9): "GlobalThisBindingScopeInfo",
|
||||
("read_only_space", 0x082c9): "EmptyFunctionScopeInfo",
|
||||
("read_only_space", 0x082ed): "NativeScopeInfo",
|
||||
("read_only_space", 0x08305): "ShadowRealmScopeInfo",
|
||||
("old_space", 0x0426d): "ArgumentsIteratorAccessor",
|
||||
("old_space", 0x04285): "ArrayLengthAccessor",
|
||||
("old_space", 0x0429d): "BoundFunctionLengthAccessor",
|
||||
|
Loading…
Reference in New Issue
Block a user