Chromium Code Reviews| Index: src/incremental-marking.cc |
| diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc |
| index 2cee9810d21227f48202d5056036ca6559e4f389..394aad0a00f59955924ccb7a3a45a33827455d09 100644 |
| --- a/src/incremental-marking.cc |
| +++ b/src/incremental-marking.cc |
| @@ -57,7 +57,20 @@ void IncrementalMarking::TearDown() { |
| void IncrementalMarking::RecordWriteFromCode(HeapObject* obj, |
| Object* value, |
| Isolate* isolate) { |
| - isolate->heap()->incremental_marking()->RecordWrite(obj, value); |
| + ASSERT(obj->IsHeapObject()); |
| + |
| + IncrementalMarking* marking = isolate->heap()->incremental_marking(); |
| + ASSERT(!marking->is_compacting_); |
| + marking->RecordWrite(obj, NULL, value); |
| +} |
| + |
| + |
| +void IncrementalMarking::RecordWriteForEvacuationFromCode(HeapObject* obj, |
| + Object** slot, |
| + Isolate* isolate) { |
| + IncrementalMarking* marking = isolate->heap()->incremental_marking(); |
| + ASSERT(marking->is_compacting_); |
| + marking->RecordWrite(obj, slot, *slot); |
| } |
| @@ -70,22 +83,24 @@ class IncrementalMarkingMarkingVisitor : public ObjectVisitor { |
| } |
| void VisitPointer(Object** p) { |
| - MarkObjectByPointer(p); |
| + MarkObjectByPointer(p, p); |
| } |
| void VisitPointers(Object** start, Object** end) { |
| - for (Object** p = start; p < end; p++) MarkObjectByPointer(p); |
| + for (Object** p = start; p < end; p++) MarkObjectByPointer(start, p); |
| } |
| private: |
| // Mark object pointed to by p. |
| - INLINE(void MarkObjectByPointer(Object** p)) { |
| + INLINE(void MarkObjectByPointer(Object** anchor, Object** p)) { |
| Object* obj = *p; |
| // Since we can be sure that the object is not tagged as a failure we can |
| // inline a slightly more efficient tag check here than IsHeapObject() would |
| // produce. |
| if (obj->NonFailureIsHeapObject()) { |
| HeapObject* heap_object = HeapObject::cast(obj); |
| + |
| + heap_->mark_compact_collector()->RecordSlot(anchor, p, obj); |
| MarkBit mark_bit = Marking::MarkBitFrom(heap_object); |
| if (mark_bit.data_only()) { |
| incremental_marking_->MarkBlackOrKeepGrey(mark_bit); |
| @@ -279,14 +294,15 @@ bool IncrementalMarking::WorthActivating() { |
| static const intptr_t kActivationThreshold = 0; |
| #endif |
| - // TODO(gc) ISOLATES MERGE |
| return FLAG_incremental_marking && |
| heap_->PromotedSpaceSize() > kActivationThreshold; |
| } |
| -static void PatchIncrementalMarkingRecordWriteStubs(bool enable) { |
| - NumberDictionary* stubs = HEAP->code_stubs(); |
| +static void PatchIncrementalMarkingRecordWriteStubs(Heap* heap, |
| + bool incremental, |
| + bool compacting) { |
| + NumberDictionary* stubs = heap->code_stubs(); |
| int capacity = stubs->Capacity(); |
| for (int i = 0; i < capacity; i++) { |
| @@ -298,7 +314,7 @@ static void PatchIncrementalMarkingRecordWriteStubs(bool enable) { |
| CodeStub::RecordWrite) { |
| Object* e = stubs->ValueAt(i); |
| if (e->IsCode()) { |
| - RecordWriteStub::Patch(Code::cast(e), enable); |
| + RecordWriteStub::Patch(Code::cast(e), incremental, compacting); |
| } |
| } |
| } |
| @@ -345,9 +361,14 @@ void IncrementalMarking::StartMarking() { |
| PrintF("[IncrementalMarking] Start marking\n"); |
| } |
| + is_compacting_ = !FLAG_never_compact && |
| + heap_->mark_compact_collector()->StartCompaction(); |
| + |
| state_ = MARKING; |
| - PatchIncrementalMarkingRecordWriteStubs(true); |
| + PatchIncrementalMarkingRecordWriteStubs(heap_, |
| + true, |
|
Erik Corry
2011/07/04 11:04:11
This constant deserves a comment or an enum type.
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
|
| + is_compacting_); |
| EnsureMarkingDequeIsCommitted(); |
| @@ -398,6 +419,7 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { |
| while (current != limit) { |
| HeapObject* obj = array[current]; |
| + ASSERT(obj->IsHeapObject()); |
| current = ((current + 1) & mask); |
| if (heap_->InNewSpace(obj)) { |
| MapWord map_word = obj->map_word(); |
| @@ -465,21 +487,27 @@ void IncrementalMarking::Abort() { |
| IncrementalMarking::set_should_hurry(false); |
| ResetStepCounters(); |
| if (IsMarking()) { |
| - PatchIncrementalMarkingRecordWriteStubs(false); |
| + PatchIncrementalMarkingRecordWriteStubs(heap_, |
| + false, |
|
Erik Corry
2011/07/04 11:04:11
These constants deserve comments or enum types.
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
|
| + false); |
| DeactivateIncrementalWriteBarrier(); |
| } |
| heap_->isolate()->stack_guard()->Continue(GC_REQUEST); |
| state_ = STOPPED; |
| + is_compacting_ = false; |
| } |
| void IncrementalMarking::Finalize() { |
| Hurry(); |
| state_ = STOPPED; |
| + is_compacting_ = false; |
| heap_->new_space()->LowerInlineAllocationLimit(0); |
| IncrementalMarking::set_should_hurry(false); |
| ResetStepCounters(); |
| - PatchIncrementalMarkingRecordWriteStubs(false); |
| + PatchIncrementalMarkingRecordWriteStubs(heap_, |
| + false, |
|
Erik Corry
2011/07/04 11:04:11
& here
Vyacheslav Egorov (Chromium)
2011/08/05 12:50:28
Done.
|
| + false); |
| DeactivateIncrementalWriteBarrier(); |
| ASSERT(marking_deque_.IsEmpty()); |
| heap_->isolate()->stack_guard()->Continue(GC_REQUEST); |
| @@ -497,8 +525,7 @@ void IncrementalMarking::MarkingComplete() { |
| if (FLAG_trace_incremental_marking) { |
| PrintF("[IncrementalMarking] Complete (normal).\n"); |
| } |
| - // TODO(gc) ISOLATES |
| - ISOLATE->stack_guard()->RequestGC(); |
| + heap_->isolate()->stack_guard()->RequestGC(); |
| } |