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 deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 15
#define V8_MINOR_VERSION 6
#define V8_BUILD_NUMBER 75
#define V8_PATCH_LEVEL 50
#define V8_PATCH_LEVEL 60

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
26 changes: 12 additions & 14 deletions deps/v8/src/baseline/baseline-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1882,27 +1882,25 @@ void BaselineCompiler::VisitIntrinsicAsyncFunctionResolve(

void BaselineCompiler::VisitIntrinsicGeneratorYieldResult(
interpreter::RegisterList args) {
Register value = WriteBarrierDescriptor::ValueRegister();
Register generator = WriteBarrierDescriptor::ObjectRegister();
DCHECK(!AreAliased(value, generator, kInterpreterAccumulatorRegister));
DCHECK(!AreAliased(generator, kInterpreterAccumulatorRegister));

Label allocate, done;

__ LoadRegister(generator, args[1]); // generator

// Check whether the generator user asked to skip result allocation
// (yielded_value_ == TheHole).
// Check whether the caller asked to skip result allocation
// (resume_mode_ == kNextTrySkipAlloc).
__ LoadTaggedField(kInterpreterAccumulatorRegister, generator,
offsetof(JSGeneratorObject, yielded_value_));
__ JumpIfNotRoot(kInterpreterAccumulatorRegister, RootIndex::kTheHoleValue,
&allocate);

// Skip allocation: store value into yielded_value_.
__ LoadRegister(value, args[0]); // value
__ StoreTaggedFieldWithWriteBarrier(
generator, offsetof(JSGeneratorObject, yielded_value_), value);

__ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kTheHoleValue);
offsetof(JSGeneratorObject, resume_mode_));
__ JumpIfSmi(kNotEqual, kInterpreterAccumulatorRegister,
Smi::FromInt(JSGeneratorObject::kNextTrySkipAlloc), &allocate);

// Skip allocation: ack handshake and return bare value.
__ StoreTaggedSignedField(generator,
offsetof(JSGeneratorObject, resume_mode_),
Smi::FromInt(JSGeneratorObject::kNextAllocSkipped));
__ LoadRegister(kInterpreterAccumulatorRegister, args[0]); // value
__ Jump(&done);

__ Bind(&allocate);
Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/builtins/builtins-generator-gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ void GeneratorBuiltinsAssembler::InnerResume(
case JSGeneratorObject::kRethrow:
// Currently only async generators use this mode.
UNREACHABLE();
case JSGeneratorObject::kNextTrySkipAlloc:
case JSGeneratorObject::kNextAllocSkipped:
// Handshake states only set by optimized callers or the generator body.
UNREACHABLE();
}
args->PopAndReturn(builtin_result);
}
Expand Down
8 changes: 2 additions & 6 deletions deps/v8/src/builtins/generator.tq
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ transitioning javascript builtin GeneratorPrototypeNextLazyDeoptContinuation(
js-implicit context: NativeContext, receiver: JSAny)(generator: JSAny,
exception: JSAny|TheHole, result: JSAny): JSAny {
const gen = UnsafeCast<JSGeneratorObject>(generator);
const yieldedValue = gen.yielded_value;
gen.yielded_value = Undefined;

// Exception path: close the generator and rethrow.
typeswitch (exception) {
Expand All @@ -36,15 +34,13 @@ transitioning javascript builtin GeneratorPrototypeNextLazyDeoptContinuation(
// continuation is now kGeneratorExecuting; close it and wrap the result.
// Otherwise (yielded), return the result as-is.
if (gen.continuation == SmiConstant(kGeneratorExecuting)) {
dcheck(result != TheHole);
gen.continuation = SmiConstant(kGeneratorClosed);
return AllocateJSIteratorResult(result, True);
}

// Allocating the iterator result object was skipped; allocate it here.
if (result == TheHole) {
const val = (yieldedValue == TheHole) ? Undefined : yieldedValue;
return AllocateJSIteratorResult(val, False);
if (gen.resume_mode == SmiConstant(kGeneratorResumeModeNextAllocSkipped)) {
return AllocateJSIteratorResult(result, False);
}

return result;
Expand Down
51 changes: 36 additions & 15 deletions deps/v8/src/codegen/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,11 @@ class ConstantPoolPointerForwarder {
}
}

bool HasScopeInfoToUpdate(Tagged<ScopeInfo> scope_info) const {
return scope_infos_to_update_.find(scope_info->UniqueIdInScript()) !=
scope_infos_to_update_.end();
}

void UpdateStandaloneScopeInfo(Tagged<ScopeInfo> scope_info) {
if (!scope_info->HasOuterScopeInfo()) return;

Expand Down Expand Up @@ -2354,6 +2359,23 @@ void VerifyCodeMerge(Isolate* isolate, DirectHandle<Script> script) {
// * All constant pool SFI entries point to an SFI referring to the old
// script (i.e. references were updated correctly).
std::unordered_map<int, Tagged<ScopeInfo>> scope_infos;
auto verify_scope_info = [&](Tagged<ScopeInfo> scope_info) {
while (true) {
auto it = scope_infos.find(scope_info->UniqueIdInScript());
if (it != scope_infos.end()) {
if (it->second != scope_info) {
isolate->PushParamsAndDie("duplicate scope info unique id",
reinterpret_cast<void*>(it->second.ptr()),
reinterpret_cast<void*>(scope_info.ptr()));
UNREACHABLE();
}
break;
}
scope_infos[scope_info->UniqueIdInScript()] = scope_info;
if (!scope_info->HasOuterScopeInfo()) break;
scope_info = scope_info->OuterScopeInfo();
}
};
uint32_t script_infos_len = script->infos()->ulength().value();
for (uint32_t info_idx = 0; info_idx < script_infos_len; info_idx++) {
Tagged<ScopeInfo> scope_info;
Expand All @@ -2377,6 +2399,8 @@ void VerifyCodeMerge(Isolate* isolate, DirectHandle<Script> script) {
int id = inner_sfi->function_literal_id(kRelaxedLoad);
CHECK_EQ(MakeWeak(inner_sfi), script->infos()->get(id));
CHECK_EQ(inner_sfi->script(), *script);
} else if (Is<ScopeInfo>(entry)) {
verify_scope_info(Cast<ScopeInfo>(entry));
}
}
}
Expand All @@ -2391,21 +2415,7 @@ void VerifyCodeMerge(Isolate* isolate, DirectHandle<Script> script) {
} else {
scope_info = Cast<ScopeInfo>(info);
}
while (true) {
auto it = scope_infos.find(scope_info->UniqueIdInScript());
if (it != scope_infos.end()) {
if (it->second != scope_info) {
isolate->PushParamsAndDie("duplicate scope info unique id",
reinterpret_cast<void*>(it->second.ptr()),
reinterpret_cast<void*>(scope_info.ptr()));
UNREACHABLE();
}
break;
}
scope_infos[scope_info->UniqueIdInScript()] = scope_info;
if (!scope_info->HasOuterScopeInfo()) break;
scope_info = scope_info->OuterScopeInfo();
}
verify_scope_info(scope_info);
}
}
} // namespace
Expand Down Expand Up @@ -2553,6 +2563,9 @@ void BackgroundMergeTask::BeginMergeInBackground(
for (DirectHandle<SharedFunctionInfo> new_sfi : used_new_sfis_) {
forwarder.UpdateScopeInfo(*new_sfi);
}
for (DirectHandle<ScopeInfo> new_scope : used_new_scope_infos_) {
forwarder.UpdateStandaloneScopeInfo(*new_scope);
}
for (const auto& new_compiled_data : new_compiled_data_for_cached_sfis_) {
// It's possible that new_compiled_data.cached_sfi had
// scope_info()->IsEmpty() while an inner function has scope info if the
Expand Down Expand Up @@ -2659,6 +2672,14 @@ Handle<SharedFunctionInfo> BackgroundMergeTask::CompleteMergeInForeground(
compiled_data_it++;
}
} else if (!maybe_old_info.IsWeak()) {
// Standalone eval ScopeInfos are only recorded for scopes within their
// owning closure, so if the slot in old_script was cleared, the ScopeInfo
// itself cannot still be alive in old_script.
DCHECK_IMPLIES(
maybe_new_info.IsWeak() &&
Is<ScopeInfo>(maybe_new_info.GetHeapObjectAssumeWeak()),
!forwarder.HasScopeInfoToUpdate(
Cast<ScopeInfo>(maybe_new_info.GetHeapObjectAssumeWeak())));
old_script->infos()->set(i, maybe_new_info, kReleaseStore);
}
}
Expand Down
34 changes: 19 additions & 15 deletions deps/v8/src/common/assert-scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,25 @@ class V8_NODISCARD PerThreadAssertScope

// Per-isolate assert scopes.

#define PER_ISOLATE_DCHECK_TYPE(V, enable) \
/* Scope to document where we do not expect javascript execution. */ \
/* Scope to introduce an exception to DisallowJavascriptExecution. */ \
V(AllowJavascriptExecution, DisallowJavascriptExecution, \
javascript_execution_assert, enable) \
/* Scope to document where we do not expect deoptimization. */ \
/* Scope to introduce an exception to DisallowDeoptimization. */ \
V(AllowDeoptimization, DisallowDeoptimization, deoptimization_assert, \
enable) \
/* Scope to document where we do not expect deoptimization. */ \
/* Scope to introduce an exception to DisallowDeoptimization. */ \
V(AllowCompilation, DisallowCompilation, compilation_assert, enable) \
/* Scope to document where we do not expect exceptions. */ \
/* Scope to introduce an exception to DisallowExceptions. */ \
V(AllowExceptions, DisallowExceptions, no_exception_assert, enable)
#define PER_ISOLATE_DCHECK_TYPE(V, enable) \
/* Scope to document where we do not expect javascript execution. */ \
/* Scope to introduce an exception to DisallowJavascriptExecution. */ \
V(AllowJavascriptExecution, DisallowJavascriptExecution, \
javascript_execution_assert, enable) \
/* Scope to document where we do not expect deoptimization. */ \
/* Scope to introduce an exception to DisallowDeoptimization. */ \
V(AllowDeoptimization, DisallowDeoptimization, deoptimization_assert, \
enable) \
/* Scope to document where we do not expect deoptimization. */ \
/* Scope to introduce an exception to DisallowDeoptimization. */ \
V(AllowCompilation, DisallowCompilation, compilation_assert, enable) \
/* Scope to document where we do not expect exceptions. */ \
/* Scope to introduce an exception to DisallowExceptions. */ \
V(AllowExceptions, DisallowExceptions, no_exception_assert, enable) \
/* Scope to document where we do not expect JS object modifications. */ \
/* Scope to introduce an exception to DisallowJSObjectModification. */ \
V(AllowJSObjectModification, DisallowJSObjectModification, \
js_object_modification_assert, enable)

#define PER_ISOLATE_CHECK_TYPE(V, enable) \
/* Scope in which javascript execution leads to exception being thrown. */ \
Expand Down
5 changes: 3 additions & 2 deletions deps/v8/src/compiler/backend/register-allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4406,8 +4406,9 @@ void LinearScanAllocator::AllocateBlockedReg(LiveRange* current,
InstructionBlock* deferred_block =
code()->GetInstructionBlock(current->Start().ToInstructionIndex());
new_end =
std::min(new_end, LifetimePosition::GapFromInstructionIndex(
LastDeferredInstructionIndex(deferred_block)));
std::min(new_end, LifetimePosition::InstructionFromInstructionIndex(
LastDeferredInstructionIndex(deferred_block))
.NextFullStart());
}

// We couldn't spill until the next register use. Split before the register
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/compiler/escape-analysis-reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ void EscapeAnalysisReducer::Finalize() {
NodeProperties::SetType(load, Type::None());
NodeProperties::SetType(dead_value, Type::None());
NodeProperties::ReplaceUses(load, dead_value, load);
NodeProperties::ReplaceValueInput(dead_value, load, 0);
continue;
}

Expand Down
10 changes: 8 additions & 2 deletions deps/v8/src/compiler/simplified-operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1167,9 +1167,12 @@ struct SimplifiedOperatorGlobalCache final {
DEOPTIMIZE_REASON_LIST(CHECK_IF)
#undef CHECK_IF

// Looking up a string key can internalize it in place into a ThinString,
// so Operator::kNoWrite (and thus Operator::kEliminatable) does not hold.
struct FindOrderedHashMapEntryOperator final : public Operator {
FindOrderedHashMapEntryOperator()
: Operator(IrOpcode::kFindOrderedHashMapEntry, Operator::kEliminatable,
: Operator(IrOpcode::kFindOrderedHashMapEntry,
Operator::kNoThrow | Operator::kNoDeopt,
"FindOrderedHashMapEntry", 2, 1, 1, 1, 1, 0) {}
};
FindOrderedHashMapEntryOperator kFindOrderedHashMapEntry;
Expand All @@ -1183,9 +1186,12 @@ struct SimplifiedOperatorGlobalCache final {
FindOrderedHashMapEntryForInt32KeyOperator
kFindOrderedHashMapEntryForInt32Key;

// Looking up a string key can internalize it in place into a ThinString,
// so Operator::kNoWrite (and thus Operator::kEliminatable) does not hold.
struct FindOrderedHashSetEntryOperator final : public Operator {
FindOrderedHashSetEntryOperator()
: Operator(IrOpcode::kFindOrderedHashSetEntry, Operator::kEliminatable,
: Operator(IrOpcode::kFindOrderedHashSetEntry,
Operator::kNoThrow | Operator::kNoDeopt,
"FindOrderedHashSetEntry", 2, 1, 1, 1, 1, 0) {}
};
FindOrderedHashSetEntryOperator kFindOrderedHashSetEntry;
Expand Down
12 changes: 8 additions & 4 deletions deps/v8/src/compiler/turboshaft/builtin-call-descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,19 @@ struct builtin : CallDescriptorBuilder {
static constexpr auto kFunction = B;
struct Arguments : ArgumentsBase {
ARG(V<Object>, table)
ARG(V<Smi>, key)
ARG(V<Object>, key)
};
using returns_t = std::tuple<V<Smi>>;

static constexpr bool kCanTriggerLazyDeopt = false;
static constexpr bool kNeedsContext = true;
static constexpr Operator::Properties kProperties = Operator::kEliminatable;
static constexpr OpEffects kEffects =
base_effects.AssumesConsistentHeap().CanReadMemory().CanAllocate();
static constexpr Operator::Properties kProperties =
Operator::kNoThrow | Operator::kNoDeopt;
// Looking up a string key can internalize it in place into a ThinString.
static constexpr OpEffects kEffects = base_effects.AssumesConsistentHeap()
.CanReadMemory()
.CanWriteHeapMemory()
.CanAllocate();
};
using FindOrderedHashMapEntry =
FindOrderedHashEntry<Builtin::kFindOrderedHashMapEntry>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ void LateLoadEliminationAnalyzer::ProcessBlock(const Block& block,
break;

case Opcode::kCatchBlockBegin:
// Throwing an exception can have arbitrary side effects (e.g., via
// debugger pause-on-exception), even when the throwing operation itself
// does not have `can_write` effects on its non-throwing path.
memory_.InvalidateMaybeAliasing();
break;

case Opcode::kRetain:
case Opcode::kDidntThrow:
case Opcode::kCheckException:
Expand Down
20 changes: 18 additions & 2 deletions deps/v8/src/compiler/turboshaft/operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -7478,8 +7478,22 @@ struct FindOrderedHashEntryOp
};
Kind kind;

static constexpr OpEffects effects =
OpEffects().CanDependOnChecks().CanReadMemory().CanAllocate();
OpEffects Effects() const {
switch (kind) {
case Kind::kFindOrderedHashMapEntry:
case Kind::kFindOrderedHashSetEntry:
// Looking up a string key can internalize it in place into a
// ThinString, overwriting its payload (e.g., ConsString::first_).
return OpEffects()
.CanDependOnChecks()
.CanReadMemory()
.CanWriteHeapMemory()
.CanAllocate();
case Kind::kFindOrderedHashMapEntryForInt32Key:
return OpEffects().CanDependOnChecks().CanReadMemory();
}
UNREACHABLE();
}
base::Vector<const RegisterRepresentation> outputs_rep() const {
switch (kind) {
case Kind::kFindOrderedHashMapEntry:
Expand Down Expand Up @@ -11092,6 +11106,8 @@ inline OpEffects Operation::Effects() const {
return Cast<StoreOp>().Effects();
case Opcode::kCall:
return Cast<CallOp>().Effects();
case Opcode::kFindOrderedHashEntry:
return Cast<FindOrderedHashEntryOp>().Effects();
case Opcode::kDidntThrow:
return Cast<DidntThrowOp>().Effects();
case Opcode::kTaggedBitcast:
Expand Down
Loading
Loading