Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index a08e3a3d9f60f4eb4ba33799b826f023f14a12f2..0c5eecc97d405437d8568fe955ecaeb57c799e65 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -771,8 +771,7 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, |
| isolate_->counters()->objs_since_last_young()->Set(0); |
| - if (collector == MARK_COMPACTOR) { |
| - DisableAssertNoAllocation allow_allocation; |
| + { DisableAssertNoAllocation allow_allocation; |
| GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
| next_gc_likely_to_collect_more = |
| isolate_->global_handles()->PostGarbageCollectionProcessing(); |
|
Vitaly Repeshko
2011/05/16 13:42:11
This can invoke callbacks for pending dependent ha
Vyacheslav Egorov (Chromium)
2011/05/16 14:15:46
Yes it can and I am failing to see how it is a pro
Vitaly Repeshko
2011/05/16 14:31:22
If I'm right about the prologue/epilogue callbacks
Vyacheslav Egorov (Chromium)
2011/05/16 14:55:34
We should not mark those handles that depend on pr
Vitaly Repeshko
2011/05/16 15:04:03
Right, but please not that there can be _dependent
Vyacheslav Egorov (Chromium)
2011/05/16 15:19:58
Argh. This is true. If those callbacks rely on bei
|
| @@ -935,6 +934,12 @@ void Heap::CheckNewSpaceExpansionCriteria() { |
| } |
| +static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { |
| + return heap->InNewSpace(*p) && |
| + !HeapObject::cast(*p)->map_word().IsForwardingAddress(); |
| +} |
| + |
| + |
| void Heap::Scavenge() { |
| #ifdef DEBUG |
| if (FLAG_enable_slow_asserts) VerifyNonPointerSpacePointers(); |
| @@ -1029,6 +1034,11 @@ void Heap::Scavenge() { |
| scavenge_visitor.VisitPointer(BitCast<Object**>(&global_contexts_list_)); |
| new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
| + isolate_->global_handles()->IdentifyWeakIndependentHandles( |
|
Vitaly Repeshko
2011/05/16 13:42:11
Scanning the linked list of handles was really slo
Vyacheslav Egorov (Chromium)
2011/05/16 14:15:46
If there are two weak handles that point to the sa
Vitaly Repeshko
2011/05/16 14:31:22
Ahh, this is annoying. Can we at least inline the
Vyacheslav Egorov (Chromium)
2011/05/16 14:55:34
To inline identify callback we need to move Identi
Vitaly Repeshko
2011/05/16 21:40:37
I do remember seeing scavenge time increase when I
Vyacheslav Egorov (Chromium)
2011/05/17 11:55:31
Very neat! But unfortunately will not work for pro
|
| + &IsUnscavengedHeapObject); |
| + isolate_->global_handles()->IterateWeakIndependentRoots(&scavenge_visitor); |
| + new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
| + |
| UpdateNewSpaceReferencesInExternalStringTable( |
| &UpdateNewSpaceReferenceInExternalStringTableEntry); |
| @@ -4492,7 +4502,8 @@ void Heap::IterateRoots(ObjectVisitor* v, VisitMode mode) { |
| void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) { |
| v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex])); |
| v->Synchronize("symbol_table"); |
| - if (mode != VISIT_ALL_IN_SCAVENGE) { |
| + if (mode != VISIT_ALL_IN_SCAVENGE && |
| + mode != VISIT_ALL_IN_SWEEP_NEWSPACE) { |
| // Scavenge collections have special processing for this. |
| external_string_table_.Iterate(v); |
| } |
| @@ -4528,16 +4539,26 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { |
| // Iterate over the builtin code objects and code stubs in the |
| // heap. Note that it is not necessary to iterate over code objects |
| // on scavenge collections. |
| - if (mode != VISIT_ALL_IN_SCAVENGE) { |
| + if (mode != VISIT_ALL_IN_SCAVENGE && |
| + mode != VISIT_ALL_IN_SWEEP_NEWSPACE) { |
| isolate_->builtins()->IterateBuiltins(v); |
| } |
| v->Synchronize("builtins"); |
| // Iterate over global handles. |
| - if (mode == VISIT_ONLY_STRONG) { |
| - isolate_->global_handles()->IterateStrongRoots(v); |
| - } else { |
| - isolate_->global_handles()->IterateAllRoots(v); |
| + switch (mode) { |
| + case VISIT_ONLY_STRONG: |
| + isolate_->global_handles()->IterateStrongRoots(v); |
| + break; |
| + case VISIT_ALL_IN_SCAVENGE: |
| + isolate_->global_handles()->IterateStrongAndDependentRoots(v); |
| + break; |
| + case VISIT_ALL_IN_SWEEP_NEWSPACE: |
| + case VISIT_ALL: |
| + isolate_->global_handles()->IterateAllRoots(v); |
| + break; |
| + default: |
|
Vitaly Repeshko
2011/05/16 13:42:11
Gcc should be able to statically catch an unhanded
Vyacheslav Egorov (Chromium)
2011/05/16 14:15:46
Ok.
|
| + UNREACHABLE(); |
| } |
| v->Synchronize("globalhandles"); |