Collect phantom callback data only once during gc. For scavenges, just consider the young handles referenced by young generation.
BUG= Review URL: https://codereview.chromium.org/885553005 Cr-Commit-Position: refs/heads/master@{#26344}
This commit is contained in:
parent
f1ba8d8f86
commit
9b60e89482
@ -573,7 +573,7 @@ void GlobalHandles::MakePhantom(Object** location, void* parameter,
|
||||
}
|
||||
|
||||
|
||||
void GlobalHandles::CollectPhantomCallbackData() {
|
||||
void GlobalHandles::CollectAllPhantomCallbackData() {
|
||||
for (NodeIterator it(this); !it.done(); it.Advance()) {
|
||||
Node* node = it.node();
|
||||
node->CollectPhantomCallbackData(isolate(), &pending_phantom_callbacks_);
|
||||
@ -581,6 +581,15 @@ void GlobalHandles::CollectPhantomCallbackData() {
|
||||
}
|
||||
|
||||
|
||||
void GlobalHandles::CollectYoungPhantomCallbackData() {
|
||||
for (int i = 0; i < new_space_nodes_.length(); ++i) {
|
||||
Node* node = new_space_nodes_[i];
|
||||
DCHECK(node->is_in_new_space_list());
|
||||
node->CollectPhantomCallbackData(isolate(), &pending_phantom_callbacks_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void* GlobalHandles::ClearWeakness(Object** location) {
|
||||
return Node::FromLocation(location)->ClearWeakness();
|
||||
}
|
||||
|
@ -165,7 +165,11 @@ class GlobalHandles {
|
||||
|
||||
// Collect up data for the weak handle callbacks after GC has completed, but
|
||||
// before memory is reclaimed.
|
||||
void CollectPhantomCallbackData();
|
||||
void CollectAllPhantomCallbackData();
|
||||
|
||||
// Collect up data for the weak handle callbacks referenced by young
|
||||
// generation after GC has completed, but before memory is reclaimed.
|
||||
void CollectYoungPhantomCallbackData();
|
||||
|
||||
// Clear the weakness of a global handle.
|
||||
static void* ClearWeakness(Object** location);
|
||||
|
@ -1599,6 +1599,11 @@ void Heap::Scavenge() {
|
||||
ScavengeWeakObjectRetainer weak_object_retainer(this);
|
||||
ProcessYoungWeakReferences(&weak_object_retainer);
|
||||
|
||||
// Collects callback info for handles referenced by young generation that are
|
||||
// pending (about to be collected) and either phantom or internal-fields.
|
||||
// Releases the global handles. See also PostGarbageCollectionProcessing.
|
||||
isolate()->global_handles()->CollectYoungPhantomCallbackData();
|
||||
|
||||
DCHECK(new_space_front == new_space_.top());
|
||||
|
||||
// Set age mark.
|
||||
@ -1688,20 +1693,12 @@ void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) {
|
||||
ProcessArrayBuffers(retainer);
|
||||
ProcessNativeContexts(retainer);
|
||||
ProcessAllocationSites(retainer);
|
||||
// Collects callback info for handles that are pending (about to be
|
||||
// collected) and either phantom or internal-fields. Releases the global
|
||||
// handles. See also PostGarbageCollectionProcessing.
|
||||
isolate()->global_handles()->CollectPhantomCallbackData();
|
||||
}
|
||||
|
||||
|
||||
void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) {
|
||||
ProcessArrayBuffers(retainer);
|
||||
ProcessNativeContexts(retainer);
|
||||
// Collects callback info for handles that are pending (about to be
|
||||
// collected) and either phantom or internal-fields. Releases the global
|
||||
// handles. See also PostGarbageCollectionProcessing.
|
||||
isolate()->global_handles()->CollectPhantomCallbackData();
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,8 +309,6 @@ void MarkCompactCollector::CollectGarbage() {
|
||||
|
||||
heap_->set_encountered_weak_cells(Smi::FromInt(0));
|
||||
|
||||
isolate()->global_handles()->CollectPhantomCallbackData();
|
||||
|
||||
#ifdef VERIFY_HEAP
|
||||
if (FLAG_verify_heap) {
|
||||
VerifyMarking(heap_);
|
||||
@ -3548,6 +3546,11 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
|
||||
EvacuationWeakObjectRetainer evacuation_object_retainer;
|
||||
heap()->ProcessAllWeakReferences(&evacuation_object_retainer);
|
||||
|
||||
// Collects callback info for handles that are pending (about to be
|
||||
// collected) and either phantom or internal-fields. Releases the global
|
||||
// handles. See also PostGarbageCollectionProcessing.
|
||||
isolate()->global_handles()->CollectAllPhantomCallbackData();
|
||||
|
||||
// Visit invalidated code (we ignored all slots on it) and clear mark-bits
|
||||
// under it.
|
||||
ProcessInvalidatedCode(&updating_visitor);
|
||||
|
Loading…
Reference in New Issue
Block a user