| Index: src/incremental-marking.cc
|
| diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc
|
| index a5c4ce111ffab26204527f4427cf13d24a6f83d5..ef29a3b7984f3bc5a67990d69d19f3ac2950a553 100644
|
| --- a/src/incremental-marking.cc
|
| +++ b/src/incremental-marking.cc
|
| @@ -163,6 +163,18 @@ static void PatchIncrementalMarkingRecordWriteStubs(bool enable) {
|
| }
|
| }
|
|
|
| +static VirtualMemory* marking_stack_memory = NULL;
|
| +
|
| +static void EnsureMarkingStackIsCommitted() {
|
| + if (marking_stack_memory == NULL) {
|
| + marking_stack_memory = new VirtualMemory(4*MB);
|
| + marking_stack_memory->Commit(
|
| + reinterpret_cast<Address>(marking_stack_memory->address()),
|
| + marking_stack_memory->size(),
|
| + false); // Not executable.
|
| + }
|
| +}
|
| +
|
|
|
| void IncrementalMarking::Start() {
|
| if (FLAG_trace_incremental_marking) {
|
| @@ -174,18 +186,19 @@ void IncrementalMarking::Start() {
|
|
|
| PatchIncrementalMarkingRecordWriteStubs(true);
|
|
|
| - Heap::EnsureFromSpaceIsCommitted();
|
| + // Heap::EnsureFromSpaceIsCommitted();
|
| + EnsureMarkingStackIsCommitted();
|
|
|
| // Initialize marking stack.
|
| - marking_stack_.Initialize(Heap::new_space()->FromSpaceLow(),
|
| - Heap::new_space()->FromSpaceHigh());
|
| + Address addr = static_cast<Address>(marking_stack_memory->address());
|
| + marking_stack_.Initialize(addr,
|
| + addr + marking_stack_memory->size());
|
|
|
| // Clear markbits.
|
| - Address new_space_bottom = Heap::new_space()->bottom();
|
| - uintptr_t new_space_size =
|
| - RoundUp(Heap::new_space()->top() - new_space_bottom, 32 * kPointerSize);
|
| -
|
| - Marking::ClearRange(new_space_bottom, new_space_size);
|
| + Address new_space_low = Heap::new_space()->ToSpaceLow();
|
| + Address new_space_high = Heap::new_space()->ToSpaceHigh();
|
| + Marking::ClearRange(new_space_low,
|
| + static_cast<int>(new_space_high - new_space_low));
|
|
|
| ClearMarkbits();
|
|
|
| @@ -204,6 +217,42 @@ void IncrementalMarking::Start() {
|
| }
|
|
|
|
|
| +void IncrementalMarking::PrepareForScavenge() {
|
| + if (IsStopped()) return;
|
| +
|
| + Address new_space_low = Heap::new_space()->FromSpaceLow();
|
| + Address new_space_high = Heap::new_space()->FromSpaceHigh();
|
| + Marking::ClearRange(new_space_low,
|
| + static_cast<int>(new_space_high - new_space_low));
|
| +}
|
| +
|
| +
|
| +void IncrementalMarking::UpdateMarkingStackAfterScavenge() {
|
| + if (IsStopped()) return;
|
| +
|
| + HeapObject** current = marking_stack_.low();
|
| + HeapObject** top = marking_stack_.top();
|
| + HeapObject** new_top = current;
|
| +
|
| + while (current < top) {
|
| + HeapObject* obj = *current++;
|
| + if (Heap::InNewSpace(obj)) {
|
| + MapWord map_word = obj->map_word();
|
| + if (map_word.IsForwardingAddress()) {
|
| + HeapObject* dest = map_word.ToForwardingAddress();
|
| + MarkWhiteObjectGrey(dest, Marking::MarkBitFrom(dest));
|
| + *new_top++ = dest;
|
| + ASSERT(Color(obj) == Color(dest));
|
| + }
|
| + } else {
|
| + *new_top++ = obj;
|
| + }
|
| + }
|
| +
|
| + marking_stack_.set_top(new_top);
|
| +}
|
| +
|
| +
|
| void IncrementalMarking::Hurry() {
|
| if (state() == MARKING) {
|
| double start = 0.0;
|
| @@ -254,17 +303,12 @@ void IncrementalMarking::MarkingComplete() {
|
|
|
|
|
| void IncrementalMarking::Step(intptr_t allocated_bytes) {
|
| - if (state_ == MARKING) {
|
| + if (state_ == MARKING && Heap::gc_state() == Heap::NOT_IN_GC) {
|
| allocated += allocated_bytes;
|
|
|
| if (allocated >= kAllocatedThreshold) {
|
| intptr_t bytes_to_process = allocated * kAllocationMarkingFactor;
|
| int count = 0;
|
| - double start = 0;
|
| - if (FLAG_trace_incremental_marking) {
|
| - PrintF("[IncrementalMarking] Marking %d bytes\n", bytes_to_process);
|
| - start = OS::TimeCurrentMillis();
|
| - }
|
|
|
| Map* filler_map = Heap::one_pointer_filler_map();
|
| while (!marking_stack_.is_empty() && bytes_to_process > 0) {
|
| @@ -285,12 +329,6 @@ void IncrementalMarking::Step(intptr_t allocated_bytes) {
|
| }
|
| count++;
|
| }
|
| - if (FLAG_trace_incremental_marking) {
|
| - double end = OS::TimeCurrentMillis();
|
| - PrintF("[IncrementalMarking] %d objects marked, spent %d ms\n",
|
| - count,
|
| - static_cast<int>(end - start));
|
| - }
|
| allocated = 0;
|
| if (marking_stack_.is_empty()) MarkingComplete();
|
| }
|
|
|