Commit 682d5369 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

Revert "Revert "Revert "[global-handles] Remove dead code"""

This reverts commit c836a95e.

Reason for revert: I don't think this was related.

Original change's description:
> Revert "Revert "[global-handles] Remove dead code""
> 
> This reverts commit 58020872.
> 
> Reason for revert: Turned out to be a bot issue, reverting the revert. 
> 
> Original change's description:
> > Revert "[global-handles] Remove dead code"
> > 
> > This reverts commit e2890c19.
> > 
> > Reason for revert: Looks like this CL causes slowdown on multiple builders, Check tests timeout and raise exceptions on the bot. Possible it is a bot issue as well, see tracking bug - https://bugs.chromium.org/p/chromium/issues/detail?id=720606
> > 
> > Original change's description:
> > > [global-handles] Remove dead code
> > > 
> > > Bug: chromium:720477
> > > Change-Id: I090168c575c41b7038af5dfba6cd8973d1154c51
> > > Reviewed-on: https://chromium-review.googlesource.com/501790
> > > Reviewed-by: Hannes Payer <hpayer@chromium.org>
> > > Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> > > Cr-Commit-Position: refs/heads/master@{#45241}
> > 
> > TBR=hpayer@chromium.org,mlippautz@chromium.org,jochen@chromium.org
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > Bug: chromium:720477
> > 
> > Change-Id: I92f40d8c4dbfdb5208b3068648612e8c5b97fb20
> > Reviewed-on: https://chromium-review.googlesource.com/502029
> > Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
> > Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#45243}
> 
> TBR=hpayer@chromium.org,gdeepti@chromium.org,mlippautz@chromium.org,jochen@chromium.org,v8-reviews@googlegroups.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> Bug: chromium:720477
> 
> Change-Id: I70e190e0c27074228a8128aa849e5a419af915e8
> Reviewed-on: https://chromium-review.googlesource.com/502030
> Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
> Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#45244}

TBR=hpayer@chromium.org,gdeepti@chromium.org,mlippautz@chromium.org,jochen@chromium.org,v8-reviews@googlegroups.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Bug: chromium:720477

Change-Id: If3e4abea51d87546e25076b906a4c91e5ccf947b
Reviewed-on: https://chromium-review.googlesource.com/503007Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45246}
parent 57ed8ba3
......@@ -647,6 +647,19 @@ void GlobalHandles::IterateNewSpaceStrongAndDependentRoots(RootVisitor* v) {
}
}
void GlobalHandles::IdentifyNewSpaceWeakIndependentHandles(
WeakSlotCallbackWithHeap f) {
for (int i = 0; i < new_space_nodes_.length(); ++i) {
Node* node = new_space_nodes_[i];
DCHECK(node->is_in_new_space_list());
if (node->is_independent() && node->IsWeak() &&
f(isolate_->heap(), node->location())) {
node->MarkPending();
}
}
}
void GlobalHandles::IterateNewSpaceWeakIndependentRoots(RootVisitor* v) {
for (int i = 0; i < new_space_nodes_.length(); ++i) {
Node* node = new_space_nodes_[i];
......@@ -690,6 +703,7 @@ void GlobalHandles::MarkNewSpaceWeakUnmodifiedObjectsPending(
}
}
template <GlobalHandles::IterationMode mode>
void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots(RootVisitor* v) {
for (int i = 0; i < new_space_nodes_.length(); ++i) {
Node* node = new_space_nodes_[i];
......@@ -698,18 +712,36 @@ void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots(RootVisitor* v) {
node->IsWeakRetainer()) {
// Pending weak phantom handles die immediately. Everything else survives.
if (node->IsPendingPhantomResetHandle()) {
node->ResetPhantomHandle();
++number_of_phantom_handle_resets_;
if (mode == IterationMode::HANDLE_PHANTOM_NODES ||
mode == IterationMode::HANDLE_PHANTOM_NODES_VISIT_OTHERS) {
node->ResetPhantomHandle();
++number_of_phantom_handle_resets_;
}
} else if (node->IsPendingPhantomCallback()) {
node->CollectPhantomCallbackData(isolate(),
&pending_phantom_callbacks_);
if (mode == IterationMode::HANDLE_PHANTOM_NODES ||
mode == IterationMode::HANDLE_PHANTOM_NODES_VISIT_OTHERS) {
node->CollectPhantomCallbackData(isolate(),
&pending_phantom_callbacks_);
}
} else {
v->VisitRootPointer(Root::kGlobalHandles, node->location());
if (mode == IterationMode::VISIT_OTHERS ||
mode == IterationMode::HANDLE_PHANTOM_NODES_VISIT_OTHERS) {
v->VisitRootPointer(Root::kGlobalHandles, node->location());
}
}
}
}
}
template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots<
GlobalHandles::HANDLE_PHANTOM_NODES>(RootVisitor* v);
template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots<
GlobalHandles::VISIT_OTHERS>(RootVisitor* v);
template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots<
GlobalHandles::HANDLE_PHANTOM_NODES_VISIT_OTHERS>(RootVisitor* v);
void GlobalHandles::InvokeSecondPassPhantomCallbacks(
List<PendingPhantomCallback>* callbacks, Isolate* isolate) {
while (callbacks->length() != 0) {
......@@ -957,6 +989,30 @@ void GlobalHandles::IterateWeakRootsInNewSpaceWithClassIds(
}
}
int GlobalHandles::NumberOfWeakHandles() {
int count = 0;
for (NodeIterator it(this); !it.done(); it.Advance()) {
if (it.node()->IsWeakRetainer()) {
count++;
}
}
return count;
}
int GlobalHandles::NumberOfGlobalObjectWeakHandles() {
int count = 0;
for (NodeIterator it(this); !it.done(); it.Advance()) {
if (it.node()->IsWeakRetainer() &&
it.node()->object()->IsJSGlobalObject()) {
count++;
}
}
return count;
}
void GlobalHandles::RecordStats(HeapStats* stats) {
*stats->global_handle_count = 0;
*stats->weak_global_handle_count = 0;
......@@ -1016,7 +1072,9 @@ void GlobalHandles::Print() {
#endif
void GlobalHandles::TearDown() {}
void GlobalHandles::TearDown() {
// TODO(1428): invoke weak callbacks.
}
EternalHandles::EternalHandles() : size_(0) {
for (unsigned i = 0; i < arraysize(singleton_handles_); i++) {
......
......@@ -43,6 +43,12 @@ enum WeaknessType {
class GlobalHandles {
public:
enum IterationMode {
HANDLE_PHANTOM_NODES_VISIT_OTHERS,
VISIT_OTHERS,
HANDLE_PHANTOM_NODES
};
~GlobalHandles();
// Creates a new global handle that is alive until Destroy is called.
......@@ -79,6 +85,13 @@ class GlobalHandles {
void RecordStats(HeapStats* stats);
// Returns the current number of weak handles.
int NumberOfWeakHandles();
// Returns the current number of weak handles to global objects.
// These handles are also included in NumberOfWeakHandles().
int NumberOfGlobalObjectWeakHandles();
// Returns the current number of handles to global objects.
int global_handles_count() const {
return number_of_global_handles_;
......@@ -143,6 +156,10 @@ class GlobalHandles {
// Iterates over strong and dependent handles. See the node above.
void IterateNewSpaceStrongAndDependentRoots(RootVisitor* v);
// Finds weak independent or partially independent handles satisfying
// the callback predicate and marks them as pending. See the note above.
void IdentifyNewSpaceWeakIndependentHandles(WeakSlotCallbackWithHeap f);
// Iterates over weak independent or partially independent handles.
// See the note above.
void IterateNewSpaceWeakIndependentRoots(RootVisitor* v);
......@@ -154,6 +171,7 @@ class GlobalHandles {
// Iterates over weak independent or unmodified handles.
// See the note above.
template <IterationMode mode>
void IterateNewSpaceWeakUnmodifiedRoots(RootVisitor* v);
// Identify unmodified objects that are in weak state and marks them
......
......@@ -1781,8 +1781,11 @@ void Heap::Scavenge() {
isolate()->global_handles()->MarkNewSpaceWeakUnmodifiedObjectsPending(
&IsUnscavengedHeapObject);
isolate()->global_handles()->IterateNewSpaceWeakUnmodifiedRoots(
&root_scavenge_visitor);
isolate()
->global_handles()
->IterateNewSpaceWeakUnmodifiedRoots<
GlobalHandles::HANDLE_PHANTOM_NODES_VISIT_OTHERS>(
&root_scavenge_visitor);
new_space_front = DoScavenge(new_space_front);
UpdateNewSpaceReferencesInExternalStringTable(
......
......@@ -2547,8 +2547,10 @@ void MinorMarkCompactCollector::MarkLiveObjects() {
TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_GLOBAL_HANDLES);
isolate()->global_handles()->MarkNewSpaceWeakUnmodifiedObjectsPending(
&IsUnmarkedObjectForYoungGeneration);
isolate()->global_handles()->IterateNewSpaceWeakUnmodifiedRoots(
&root_visitor);
isolate()
->global_handles()
->IterateNewSpaceWeakUnmodifiedRoots<
GlobalHandles::HANDLE_PHANTOM_NODES_VISIT_OTHERS>(&root_visitor);
ProcessMarkingDeque();
}
......
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