OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 if (FLAG_trace_incremental_marking) { | 403 if (FLAG_trace_incremental_marking) { |
404 PrintF("[IncrementalMarking] Start\n"); | 404 PrintF("[IncrementalMarking] Start\n"); |
405 } | 405 } |
406 ASSERT(FLAG_incremental_marking); | 406 ASSERT(FLAG_incremental_marking); |
407 ASSERT(state_ == STOPPED); | 407 ASSERT(state_ == STOPPED); |
408 | 408 |
409 ResetStepCounters(); | 409 ResetStepCounters(); |
410 | 410 |
411 if (heap_->old_pointer_space()->IsSweepingComplete() && | 411 if (heap_->old_pointer_space()->IsSweepingComplete() && |
412 heap_->old_data_space()->IsSweepingComplete()) { | 412 heap_->old_data_space()->IsSweepingComplete()) { |
413 StartMarking(); | 413 StartMarking(ALLOW_COMPACTION); |
414 } else { | 414 } else { |
415 if (FLAG_trace_incremental_marking) { | 415 if (FLAG_trace_incremental_marking) { |
416 PrintF("[IncrementalMarking] Start sweeping.\n"); | 416 PrintF("[IncrementalMarking] Start sweeping.\n"); |
417 } | 417 } |
418 state_ = SWEEPING; | 418 state_ = SWEEPING; |
419 } | 419 } |
420 | 420 |
421 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold); | 421 heap_->new_space()->LowerInlineAllocationLimit(kAllocatedThreshold); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 static void MarkObjectGreyDoNotEnqueue(Object* obj) { | 425 static void MarkObjectGreyDoNotEnqueue(Object* obj) { |
426 if (obj->IsHeapObject()) { | 426 if (obj->IsHeapObject()) { |
427 HeapObject* heap_obj = HeapObject::cast(obj); | 427 HeapObject* heap_obj = HeapObject::cast(obj); |
428 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); | 428 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); |
429 if (Marking::IsBlack(mark_bit)) { | 429 if (Marking::IsBlack(mark_bit)) { |
430 MemoryChunk::IncrementLiveBytes(heap_obj->address(), | 430 MemoryChunk::IncrementLiveBytes(heap_obj->address(), |
431 -heap_obj->Size()); | 431 -heap_obj->Size()); |
432 } | 432 } |
433 Marking::AnyToGrey(mark_bit); | 433 Marking::AnyToGrey(mark_bit); |
434 } | 434 } |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 void IncrementalMarking::StartMarking() { | 438 void IncrementalMarking::StartMarking(CompactionFlag flag) { |
439 if (FLAG_trace_incremental_marking) { | 439 if (FLAG_trace_incremental_marking) { |
440 PrintF("[IncrementalMarking] Start marking\n"); | 440 PrintF("[IncrementalMarking] Start marking\n"); |
441 } | 441 } |
442 | 442 |
443 is_compacting_ = !FLAG_never_compact && | 443 is_compacting_ = !FLAG_never_compact && (flag == ALLOW_COMPACTION) && |
444 heap_->mark_compact_collector()->StartCompaction(); | 444 heap_->mark_compact_collector()->StartCompaction(); |
445 | 445 |
446 state_ = MARKING; | 446 state_ = MARKING; |
447 | 447 |
448 RecordWriteStub::Mode mode = is_compacting_ ? | 448 RecordWriteStub::Mode mode = is_compacting_ ? |
449 RecordWriteStub::INCREMENTAL_COMPACTION : RecordWriteStub::INCREMENTAL; | 449 RecordWriteStub::INCREMENTAL_COMPACTION : RecordWriteStub::INCREMENTAL; |
450 | 450 |
451 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); | 451 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); |
452 | 452 |
453 EnsureMarkingDequeIsCommitted(); | 453 EnsureMarkingDequeIsCommitted(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 689 |
690 double start = 0; | 690 double start = 0; |
691 | 691 |
692 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { | 692 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { |
693 start = OS::TimeCurrentMillis(); | 693 start = OS::TimeCurrentMillis(); |
694 } | 694 } |
695 | 695 |
696 if (state_ == SWEEPING) { | 696 if (state_ == SWEEPING) { |
697 if (heap_->old_pointer_space()->AdvanceSweeper(bytes_to_process) && | 697 if (heap_->old_pointer_space()->AdvanceSweeper(bytes_to_process) && |
698 heap_->old_data_space()->AdvanceSweeper(bytes_to_process)) { | 698 heap_->old_data_space()->AdvanceSweeper(bytes_to_process)) { |
699 StartMarking(); | 699 StartMarking(PREVENT_COMPACTION); |
700 } | 700 } |
701 } else if (state_ == MARKING) { | 701 } else if (state_ == MARKING) { |
702 Map* filler_map = heap_->one_pointer_filler_map(); | 702 Map* filler_map = heap_->one_pointer_filler_map(); |
703 Map* global_context_map = heap_->global_context_map(); | 703 Map* global_context_map = heap_->global_context_map(); |
704 IncrementalMarkingMarkingVisitor marking_visitor(heap_, this); | 704 IncrementalMarkingMarkingVisitor marking_visitor(heap_, this); |
705 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) { | 705 while (!marking_deque_.IsEmpty() && bytes_to_process > 0) { |
706 HeapObject* obj = marking_deque_.Pop(); | 706 HeapObject* obj = marking_deque_.Pop(); |
707 | 707 |
708 // Explicitly skip one word fillers. Incremental markbit patterns are | 708 // Explicitly skip one word fillers. Incremental markbit patterns are |
709 // correct only for objects that occupy at least two words. | 709 // correct only for objects that occupy at least two words. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 bytes_rescanned_ = 0; | 802 bytes_rescanned_ = 0; |
803 allocation_marking_factor_ = kInitialAllocationMarkingFactor; | 803 allocation_marking_factor_ = kInitialAllocationMarkingFactor; |
804 } | 804 } |
805 | 805 |
806 | 806 |
807 int64_t IncrementalMarking::SpaceLeftInOldSpace() { | 807 int64_t IncrementalMarking::SpaceLeftInOldSpace() { |
808 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize(); | 808 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize(); |
809 } | 809 } |
810 | 810 |
811 } } // namespace v8::internal | 811 } } // namespace v8::internal |
OLD | NEW |