Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.39',
'v8_embedder_string': '-node.56',

##### V8 defaults for Node.js #####

Expand Down
1 change: 1 addition & 0 deletions deps/v8/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Sander Mathijs van Veen <sander@leaningtech.com>
Sandro Santilli <strk@keybit.net>
Sanjoy Das <sanjoy@playingwithpointers.com>
Sam James <sam@gentoo.org>
Sébastien Doeraene <sjrdoeraene@gmail.com>
Seo Sanghyeon <sanxiyn@gmail.com>
Shawn Anastasio <shawnanastasio@gmail.com>
Shawn Presser <shawnpresser@gmail.com>
Expand Down
7 changes: 6 additions & 1 deletion deps/v8/src/builtins/wasm.tq
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,12 @@ builtin WasmThrow(tag: Object, values: FixedArray): JSAny {
}

builtin WasmRethrow(exception: Object): JSAny {
if (exception == Null) tail ThrowWasmTrapRethrowNull();
dcheck(exception != kWasmNull);
tail runtime::WasmReThrow(LoadContextFromFrame(), exception);
}

builtin WasmThrowRef(exception: Object): JSAny {
if (exception == kWasmNull) tail ThrowWasmTrapRethrowNull();
tail runtime::WasmReThrow(LoadContextFromFrame(), exception);
}

Expand Down
20 changes: 9 additions & 11 deletions deps/v8/src/compiler/turboshaft/wasm-lowering-reducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class WasmLoweringReducer : public Next {
#if V8_STATIC_ROOTS_BOOL
// TODO(14616): Extend this for shared types.
const bool is_wasm_null =
!wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_) &&
!wasm::IsSubtypeOf(type, wasm::kWasmExnRef, module_);
!wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_);
OpIndex null_value =
__ UintPtrConstant(is_wasm_null ? StaticReadOnlyRoot::kWasmNull
: StaticReadOnlyRoot::kNullValue);
Expand All @@ -68,8 +67,7 @@ class WasmLoweringReducer : public Next {
// (3) the object might be a JS object.
if (null_check_strategy_ == NullCheckStrategy::kExplicit ||
wasm::IsSubtypeOf(wasm::kWasmI31Ref.AsNonNull(), type, module_) ||
wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_) ||
wasm::IsSubtypeOf(type, wasm::kWasmExnRef, module_)) {
wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_)) {
__ TrapIf(__ IsNull(object, type), OpIndex::Invalid(), trap_id);
} else {
// Otherwise, load the word after the map word.
Expand Down Expand Up @@ -556,7 +554,8 @@ class WasmLoweringReducer : public Next {
// The none-types only perform a null check. They need no control flow.
if (to_rep == wasm::HeapType::kNone ||
to_rep == wasm::HeapType::kNoExtern ||
to_rep == wasm::HeapType::kNoFunc) {
to_rep == wasm::HeapType::kNoFunc ||
to_rep == wasm::HeapType::kNoExn) {
result = __ IsNull(object, config.from);
break;
}
Expand Down Expand Up @@ -628,7 +627,8 @@ class WasmLoweringReducer : public Next {
// The none-types only perform a null check.
if (to_rep == wasm::HeapType::kNone ||
to_rep == wasm::HeapType::kNoExtern ||
to_rep == wasm::HeapType::kNoFunc) {
to_rep == wasm::HeapType::kNoFunc ||
to_rep == wasm::HeapType::kNoExn) {
__ TrapIfNot(__ IsNull(object, config.from), OpIndex::Invalid(),
TrapId::kTrapIllegalCast);
break;
Expand Down Expand Up @@ -917,11 +917,9 @@ class WasmLoweringReducer : public Next {

OpIndex Null(wasm::ValueType type) {
OpIndex roots = __ LoadRootRegister();
RootIndex index =
wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_) ||
wasm::IsSubtypeOf(type, wasm::kWasmExnRef, module_)
? RootIndex::kNullValue
: RootIndex::kWasmNull;
RootIndex index = wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_)
? RootIndex::kNullValue
: RootIndex::kWasmNull;
// We load WasmNull as a pointer here and not as a TaggedPointer because
// WasmNull is stored uncompressed in the IsolateData, and a load of a
// TaggedPointer loads compressed pointers. We do not bitcast the WasmNull
Expand Down
17 changes: 11 additions & 6 deletions deps/v8/src/compiler/wasm-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,8 @@ Node* WasmGraphBuilder::EffectPhi(unsigned count, Node** effects_and_control) {
Node* WasmGraphBuilder::RefNull(wasm::ValueType type) {
// We immediately lower null in wrappers, as they do not go through a lowering
// phase.
// TODO(thibaudm): Can we use wasm null for exnref?
return parameter_mode_ == kInstanceParameterMode ? gasm_->Null(type)
: (type == wasm::kWasmExternRef || type == wasm::kWasmNullExternRef ||
type == wasm::kWasmExnRef || type == wasm::kWasmNullExnRef)
: (type == wasm::kWasmExternRef || type == wasm::kWasmNullExternRef)
? LOAD_ROOT(NullValue, null_value)
: LOAD_ROOT(WasmNull, wasm_null);
}
Expand Down Expand Up @@ -2372,6 +2370,14 @@ Node* WasmGraphBuilder::Rethrow(Node* except_obj) {
Builtin::kWasmRethrow, Operator::kNoProperties, except_obj);
}

Node* WasmGraphBuilder::ThrowRef(Node* except_obj) {
// TODO(v8:8091): Currently the message of the original exception is not being
// preserved when rethrown to the console. The pending message will need to be
// saved when caught and restored here while being rethrown.
return gasm_->CallBuiltinThroughJumptable(
Builtin::kWasmThrowRef, Operator::kNoProperties, except_obj);
}

Node* WasmGraphBuilder::IsExceptionTagUndefined(Node* tag) {
return gasm_->TaggedEqual(tag, UndefinedValue());
}
Expand Down Expand Up @@ -7325,6 +7331,8 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
// TODO(14034): Add more fast paths?
case wasm::HeapType::kExtern:
case wasm::HeapType::kNoExtern:
case wasm::HeapType::kExn:
case wasm::HeapType::kNoExn:
if (type.kind() == wasm::kRef) {
Node* null_value = gasm_->LoadImmutable(
MachineType::Pointer(), gasm_->LoadRootRegister(),
Expand All @@ -7345,9 +7353,6 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
return input;
case wasm::HeapType::kString:
return BuildCheckString(input, js_context, type);
case wasm::HeapType::kExn:
case wasm::HeapType::kNoExn:
return input;
case wasm::HeapType::kNone:
case wasm::HeapType::kNoFunc:
case wasm::HeapType::kI31:
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/compiler/wasm-compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class WasmGraphBuilder {
const base::Vector<Node*> values,
wasm::WasmCodePosition position);
Node* Rethrow(Node* except_obj);
Node* ThrowRef(Node* except_obj);
Node* IsExceptionTagUndefined(Node* tag);
Node* LoadJSTag();
Node* ExceptionTagEqual(Node* caught_tag, Node* expected_tag);
Expand Down
14 changes: 5 additions & 9 deletions deps/v8/src/compiler/wasm-gc-lowering.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ Reduction WasmGCLowering::Reduce(Node* node) {
}

Node* WasmGCLowering::Null(wasm::ValueType type) {
// TODO(thibaudm): Can we use wasm null for exnref?
RootIndex index = wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_) ||
wasm::IsSubtypeOf(type, wasm::kWasmExnRef, module_)
RootIndex index = wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_)
? RootIndex::kNullValue
: RootIndex::kWasmNull;
return gasm_.LoadImmutable(MachineType::Pointer(), gasm_.LoadRootRegister(),
Expand All @@ -108,8 +106,7 @@ Node* WasmGCLowering::IsNull(Node* object, wasm::ValueType type) {
#if V8_STATIC_ROOTS_BOOL
// TODO(14616): Extend this for shared types.
const bool is_wasm_null =
!wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_) &&
!wasm::IsSubtypeOf(type, wasm::kWasmExnRef, module_);
!wasm::IsSubtypeOf(type, wasm::kWasmExternRef, module_);
Node* null_value =
gasm_.UintPtrConstant(is_wasm_null ? StaticReadOnlyRoot::kWasmNull
: StaticReadOnlyRoot::kNullValue);
Expand Down Expand Up @@ -224,7 +221,7 @@ Reduction WasmGCLowering::ReduceWasmTypeCheckAbstract(Node* node) {
// The none-types only perform a null check. They need no control flow.
if (to_rep == wasm::HeapType::kNone ||
to_rep == wasm::HeapType::kNoExtern ||
to_rep == wasm::HeapType::kNoFunc) {
to_rep == wasm::HeapType::kNoFunc || to_rep == wasm::HeapType::kNoExn) {
result = IsNull(object, config.from);
break;
}
Expand Down Expand Up @@ -398,7 +395,7 @@ Reduction WasmGCLowering::ReduceWasmTypeCastAbstract(Node* node) {
// The none-types only perform a null check.
if (to_rep == wasm::HeapType::kNone ||
to_rep == wasm::HeapType::kNoExtern ||
to_rep == wasm::HeapType::kNoFunc) {
to_rep == wasm::HeapType::kNoFunc || to_rep == wasm::HeapType::kNoExn) {
gasm_.TrapUnless(IsNull(object, config.from), TrapId::kTrapIllegalCast);
UpdateSourcePosition(gasm_.effect(), node);
break;
Expand Down Expand Up @@ -488,8 +485,7 @@ Reduction WasmGCLowering::ReduceAssertNotNull(Node* node) {
if (null_check_strategy_ == NullCheckStrategy::kExplicit ||
wasm::IsSubtypeOf(wasm::kWasmI31Ref.AsNonNull(), op_parameter.type,
module_) ||
wasm::IsSubtypeOf(op_parameter.type, wasm::kWasmExternRef, module_) ||
wasm::IsSubtypeOf(op_parameter.type, wasm::kWasmExnRef, module_)) {
wasm::IsSubtypeOf(op_parameter.type, wasm::kWasmExternRef, module_)) {
gasm_.TrapIf(IsNull(object, op_parameter.type), op_parameter.trap_id);
UpdateSourcePosition(gasm_.effect(), node);
} else {
Expand Down
14 changes: 10 additions & 4 deletions deps/v8/src/runtime/runtime-wasm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,18 @@ RUNTIME_FUNCTION(Runtime_WasmThrow) {
ClearThreadInWasmScope clear_wasm_flag(isolate);
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
isolate->set_context(GetNativeContextFromWasmInstanceOnStackTop(isolate));
Tagged<Context> context = GetNativeContextFromWasmInstanceOnStackTop(isolate);
isolate->set_context(context);
Handle<WasmExceptionTag> tag(WasmExceptionTag::cast(args[0]), isolate);
Handle<FixedArray> values(FixedArray::cast(args[1]), isolate);
Handle<WasmExceptionPackage> exception =
WasmExceptionPackage::New(isolate, tag, values);
return isolate->Throw(*exception);
auto js_tag = WasmTagObject::cast(context->wasm_js_tag());
if (*tag == js_tag->tag()) {
return isolate->Throw(values->get(0));
} else {
Handle<WasmExceptionPackage> exception =
WasmExceptionPackage::New(isolate, tag, values);
return isolate->Throw(*exception);
}
}

RUNTIME_FUNCTION(Runtime_WasmReThrow) {
Expand Down
11 changes: 6 additions & 5 deletions deps/v8/src/wasm/baseline/liftoff-assembler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,13 @@ void LiftoffAssembler::DropExceptionValueAtOffset(int offset) {
slot != end; ++slot) {
*slot = *(slot + 1);
stack_offset = NextSpillOffset(slot->kind(), stack_offset);
// Padding could allow us to exit early.
if (slot->offset() == stack_offset) break;
if (slot->is_stack()) {
MoveStackValue(stack_offset, slot->offset(), slot->kind());
// Padding could cause some spill offsets to remain the same.
if (slot->offset() != stack_offset) {
if (slot->is_stack()) {
MoveStackValue(stack_offset, slot->offset(), slot->kind());
}
slot->set_offset(stack_offset);
}
slot->set_offset(stack_offset);
}
cache_state_.stack_state.pop_back();
}
Expand Down
Loading
Loading