Commit 015632a0 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

[handles] Simplify global handle state machine

Remove PENDING state as handles were always immediately transitioned
into FREE or NEAR_DEATH state.

Bug: v8:12672
Change-Id: I9a9d40b573e862282d41d7a4a3f9c8c8ed21b9e4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3599473Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80119}
parent 9135859a
...@@ -406,7 +406,6 @@ class Internals { ...@@ -406,7 +406,6 @@ class Internals {
static const int kNodeFlagsOffset = 1 * kApiSystemPointerSize + 3; static const int kNodeFlagsOffset = 1 * kApiSystemPointerSize + 3;
static const int kNodeStateMask = 0x7; static const int kNodeStateMask = 0x7;
static const int kNodeStateIsWeakValue = 2; static const int kNodeStateIsWeakValue = 2;
static const int kNodeStateIsPendingValue = 3;
static const int kFirstNonstringType = 0x80; static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83; static const int kOddballType = 0x83;
......
This diff is collapsed.
...@@ -143,14 +143,18 @@ class V8_EXPORT_PRIVATE GlobalHandles final { ...@@ -143,14 +143,18 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
// Iterates over strong and dependent handles. See the note above. // Iterates over strong and dependent handles. See the note above.
void IterateYoungStrongAndDependentRoots(RootVisitor* v); void IterateYoungStrongAndDependentRoots(RootVisitor* v);
// Iterates over weak independent or unmodified handles. // Processes all young weak objects. Weak objects for which
// See the note above. // `should_reset_handle()` returns true are reset and others are passed to the
void IterateYoungWeakObjectsForPhantomHandles( // visitor `v`.
RootVisitor* v, WeakSlotCallbackWithHeap should_reset_handle); void ProcessWeakYoungObjects(RootVisitor* v,
WeakSlotCallbackWithHeap should_reset_handle);
// Identify unmodified objects that are in weak state and marks them
// unmodified // Computes whether young weak objects should be considered roots for young
void IdentifyWeakUnmodifiedObjects(WeakSlotCallback is_unmodified); // generation garbage collections or just be treated weakly. Per default
// objects are considered as roots. Objects are treated not as root when both
// - `is_unmodified()` returns true;
// - the `EmbedderRootsHandler` also does not consider them as roots;
void ComputeWeaknessForYoungObjects(WeakSlotCallback is_unmodified);
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
...@@ -205,6 +209,13 @@ class V8_EXPORT_PRIVATE GlobalHandles final { ...@@ -205,6 +209,13 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
void ApplyPersistentHandleVisitor(v8::PersistentHandleVisitor* visitor, void ApplyPersistentHandleVisitor(v8::PersistentHandleVisitor* visitor,
Node* node); Node* node);
// Clears a weak `node` for which `should_reset_node()` returns true.
//
// Returns false if a node is weak and alive which requires further
// processing, and true in all other cases (e.g. also strong nodes).
bool ResetWeakNodeIfDead(Node* node,
WeakSlotCallbackWithHeap should_reset_node);
Isolate* const isolate_; Isolate* const isolate_;
bool is_marking_ = false; bool is_marking_ = false;
......
...@@ -5805,7 +5805,7 @@ void MinorMarkCompactCollector::MarkRootSetInParallel( ...@@ -5805,7 +5805,7 @@ void MinorMarkCompactCollector::MarkRootSetInParallel(
// Seed the root set (roots + old->new set). // Seed the root set (roots + old->new set).
{ {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_SEED); TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_SEED);
isolate()->global_handles()->IdentifyWeakUnmodifiedObjects( isolate()->global_handles()->ComputeWeaknessForYoungObjects(
&JSObject::IsUnmodifiedApiObject); &JSObject::IsUnmodifiedApiObject);
// MinorMC treats all weak roots except for global handles as strong. // MinorMC treats all weak roots except for global handles as strong.
// That is why we don't set skip_weak = true here and instead visit // That is why we don't set skip_weak = true here and instead visit
...@@ -5859,7 +5859,7 @@ void MinorMarkCompactCollector::MarkLiveObjects() { ...@@ -5859,7 +5859,7 @@ void MinorMarkCompactCollector::MarkLiveObjects() {
{ {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_GLOBAL_HANDLES); TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_GLOBAL_HANDLES);
isolate()->global_handles()->IterateYoungWeakObjectsForPhantomHandles( isolate()->global_handles()->ProcessWeakYoungObjects(
&root_visitor, &IsUnmarkedObjectForYoungGeneration); &root_visitor, &IsUnmarkedObjectForYoungGeneration);
DrainMarkingWorklist(); DrainMarkingWorklist();
} }
......
...@@ -322,7 +322,7 @@ void ScavengerCollector::CollectGarbage() { ...@@ -322,7 +322,7 @@ void ScavengerCollector::CollectGarbage() {
TRACE_GC( TRACE_GC(
heap_->tracer(), heap_->tracer(),
GCTracer::Scope::SCAVENGER_SCAVENGE_WEAK_GLOBAL_HANDLES_IDENTIFY); GCTracer::Scope::SCAVENGER_SCAVENGE_WEAK_GLOBAL_HANDLES_IDENTIFY);
isolate_->global_handles()->IdentifyWeakUnmodifiedObjects( isolate_->global_handles()->ComputeWeaknessForYoungObjects(
&JSObject::IsUnmodifiedApiObject); &JSObject::IsUnmodifiedApiObject);
} }
{ {
...@@ -366,7 +366,7 @@ void ScavengerCollector::CollectGarbage() { ...@@ -366,7 +366,7 @@ void ScavengerCollector::CollectGarbage() {
// Scavenge weak global handles. // Scavenge weak global handles.
TRACE_GC(heap_->tracer(), TRACE_GC(heap_->tracer(),
GCTracer::Scope::SCAVENGER_SCAVENGE_WEAK_GLOBAL_HANDLES_PROCESS); GCTracer::Scope::SCAVENGER_SCAVENGE_WEAK_GLOBAL_HANDLES_PROCESS);
isolate_->global_handles()->IterateYoungWeakObjectsForPhantomHandles( isolate_->global_handles()->ProcessWeakYoungObjects(
&root_scavenge_visitor, &IsUnscavengedHeapObjectSlot); &root_scavenge_visitor, &IsUnscavengedHeapObjectSlot);
DCHECK(copied_list.IsEmpty()); DCHECK(copied_list.IsEmpty());
DCHECK(promotion_list.IsEmpty()); DCHECK(promotion_list.IsEmpty());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment