Skip to content
Closed
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.17',
'v8_embedder_string': '-node.21',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to correct the number after 573171d was cherry-picked incorrectly.


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

Expand Down
46 changes: 27 additions & 19 deletions deps/v8/src/interpreter/bytecode-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4688,6 +4688,22 @@ void BytecodeGenerator::BuildHoleCheckForVariableAssignment(Variable* variable,
}
}

void BytecodeGenerator::AddDisposableValue(VariableMode mode) {
if (mode == VariableMode::kUsing) {
RegisterList args = register_allocator()->NewRegisterList(2);
builder()
->MoveRegister(current_disposables_stack(), args[0])
.StoreAccumulatorInRegister(args[1])
.CallRuntime(Runtime::kAddDisposableValue, args);
} else if (mode == VariableMode::kAwaitUsing) {
RegisterList args = register_allocator()->NewRegisterList(2);
builder()
->MoveRegister(current_disposables_stack(), args[0])
.StoreAccumulatorInRegister(args[1])
.CallRuntime(Runtime::kAddAsyncDisposableValue, args);
}
}

void BytecodeGenerator::BuildVariableAssignment(
Variable* variable, Token::Value op, HoleCheckMode hole_check_mode,
LookupHoistingMode lookup_hoisting_mode) {
Expand Down Expand Up @@ -4727,19 +4743,7 @@ void BytecodeGenerator::BuildVariableAssignment(
// elide subsequent checks.
RememberHoleCheckInCurrentBlock(variable);
}
if (mode == VariableMode::kUsing) {
RegisterList args = register_allocator()->NewRegisterList(2);
builder()
->MoveRegister(current_disposables_stack(), args[0])
.StoreAccumulatorInRegister(args[1])
.CallRuntime(Runtime::kAddDisposableValue, args);
} else if (mode == VariableMode::kAwaitUsing) {
RegisterList args = register_allocator()->NewRegisterList(2);
builder()
->MoveRegister(current_disposables_stack(), args[0])
.StoreAccumulatorInRegister(args[1])
.CallRuntime(Runtime::kAddAsyncDisposableValue, args);
}
AddDisposableValue(mode);
}
builder()->StoreAccumulatorInRegister(destination);
} else if (variable->throw_on_const_assignment(language_mode()) &&
Expand Down Expand Up @@ -4780,12 +4784,16 @@ void BytecodeGenerator::BuildVariableAssignment(
builder()->LoadAccumulatorWithRegister(value_temp);
}

if (mode != VariableMode::kConst || op == Token::kInit) {
if (op == Token::kInit &&
variable->HasHoleCheckUseInSameClosureScope()) {
// After initializing a variable it won't be the hole anymore, so
// elide subsequent checks.
RememberHoleCheckInCurrentBlock(variable);
if ((mode != VariableMode::kConst && mode != VariableMode::kUsing &&
mode != VariableMode::kAwaitUsing) ||
op == Token::kInit) {
if (op == Token::kInit) {
if (variable->HasHoleCheckUseInSameClosureScope()) {
// After initializing a variable it won't be the hole anymore, so
// elide subsequent checks.
RememberHoleCheckInCurrentBlock(variable);
}
AddDisposableValue(mode);
}
builder()->StoreContextSlot(context_reg, variable, depth);
} else if (variable->throw_on_const_assignment(language_mode())) {
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/interpreter/bytecode-generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {

Variable* GetPotentialVariableInAccumulator();

void AddDisposableValue(VariableMode mode);
void BuildVariableLoad(Variable* variable, HoleCheckMode hole_check_mode,
TypeofMode typeof_mode = TypeofMode::kNotInside);
void BuildVariableLoadForAccumulatorValue(
Expand Down
24 changes: 24 additions & 0 deletions deps/v8/test/mjsunit/harmony/regress/regress-409478039.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2025 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --js-staging

var log = [];
class Test {
[Symbol.dispose]() {
log.push(42);
}

f() {
log.push(43);
}
}

{
using listener = new Test();
g = () => listener;
}
g().f();

assertEquals(log, [42, 43]);
Loading