| 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 25 matching lines...) Expand all Loading... |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 | 38 |
| 39 IncrementalMarking::IncrementalMarking(Heap* heap) | 39 IncrementalMarking::IncrementalMarking(Heap* heap) |
| 40 : heap_(heap), | 40 : heap_(heap), |
| 41 state_(STOPPED), | 41 state_(STOPPED), |
| 42 marking_deque_memory_(NULL), | 42 marking_deque_memory_(NULL), |
| 43 steps_count_(0), | 43 steps_count_(0), |
| 44 steps_took_(0), | 44 steps_took_(0), |
| 45 longest_step_(0.0), | 45 longest_step_(0.0), |
| 46 old_generation_space_available_at_start_of_incremental_(0), |
| 47 old_generation_space_used_at_start_of_incremental_(0), |
| 46 steps_count_since_last_gc_(0), | 48 steps_count_since_last_gc_(0), |
| 47 steps_took_since_last_gc_(0), | 49 steps_took_since_last_gc_(0), |
| 48 should_hurry_(false), | 50 should_hurry_(false), |
| 49 allocation_marking_factor_(0), | 51 allocation_marking_factor_(0), |
| 50 allocated_(0) { | 52 allocated_(0) { |
| 51 } | 53 } |
| 52 | 54 |
| 53 | 55 |
| 54 void IncrementalMarking::TearDown() { | 56 void IncrementalMarking::TearDown() { |
| 55 delete marking_deque_memory_; | 57 delete marking_deque_memory_; |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 } | 578 } |
| 577 } | 579 } |
| 578 if (marking_deque_.IsEmpty()) MarkingComplete(); | 580 if (marking_deque_.IsEmpty()) MarkingComplete(); |
| 579 } | 581 } |
| 580 | 582 |
| 581 allocated_ = 0; | 583 allocated_ = 0; |
| 582 | 584 |
| 583 steps_count_++; | 585 steps_count_++; |
| 584 steps_count_since_last_gc_++; | 586 steps_count_since_last_gc_++; |
| 585 | 587 |
| 586 if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0) { | 588 bool speed_up = false; |
| 589 |
| 590 if (old_generation_space_available_at_start_of_incremental_ < 10 * MB || |
| 591 SpaceLeftInOldSpace() < |
| 592 old_generation_space_available_at_start_of_incremental_ >> 1) { |
| 593 // Half of the space that was available is gone while we were |
| 594 // incrementally marking. |
| 595 speed_up = true; |
| 596 old_generation_space_available_at_start_of_incremental_ = |
| 597 SpaceLeftInOldSpace(); |
| 598 } |
| 599 |
| 600 if (heap_->PromotedTotalSize() > |
| 601 old_generation_space_used_at_start_of_incremental_ << 1) { |
| 602 // Size of old space doubled while we were incrementally marking. |
| 603 speed_up = true; |
| 604 old_generation_space_used_at_start_of_incremental_ = |
| 605 heap_->PromotedTotalSize(); |
| 606 } |
| 607 |
| 608 if ((steps_count_ % kAllocationMarkingFactorSpeedupInterval) == 0 && |
| 609 allocation_marking_factor_ < kMaxAllocationMarkingFactor) { |
| 610 speed_up = true; |
| 611 } |
| 612 |
| 613 if (speed_up && 0) { |
| 587 allocation_marking_factor_ += kAllocationMarkingFactorSpeedup; | 614 allocation_marking_factor_ += kAllocationMarkingFactorSpeedup; |
| 588 allocation_marking_factor_ = | 615 allocation_marking_factor_ = |
| 589 static_cast<int>(allocation_marking_factor_ * 1.3); | 616 static_cast<int>(allocation_marking_factor_ * 1.3); |
| 590 if (FLAG_trace_gc) { | 617 if (FLAG_trace_gc) { |
| 591 PrintF("Marking speed increased to %d\n", allocation_marking_factor_); | 618 PrintF("Marking speed increased to %d\n", allocation_marking_factor_); |
| 592 } | 619 } |
| 593 } | 620 } |
| 594 | 621 |
| 595 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { | 622 if (FLAG_trace_incremental_marking || FLAG_trace_gc) { |
| 596 double end = OS::TimeCurrentMillis(); | 623 double end = OS::TimeCurrentMillis(); |
| 597 double delta = (end - start); | 624 double delta = (end - start); |
| 598 longest_step_ = Max(longest_step_, delta); | 625 longest_step_ = Max(longest_step_, delta); |
| 599 steps_took_ += delta; | 626 steps_took_ += delta; |
| 600 steps_took_since_last_gc_ += delta; | 627 steps_took_since_last_gc_ += delta; |
| 601 } | 628 } |
| 602 } | 629 } |
| 603 | 630 |
| 604 | 631 |
| 632 void IncrementalMarking::ResetStepCounters() { |
| 633 steps_count_ = 0; |
| 634 steps_took_ = 0; |
| 635 longest_step_ = 0.0; |
| 636 old_generation_space_available_at_start_of_incremental_ = |
| 637 SpaceLeftInOldSpace(); |
| 638 old_generation_space_used_at_start_of_incremental_ = |
| 639 heap_->PromotedTotalSize(); |
| 640 steps_count_since_last_gc_ = 0; |
| 641 steps_took_since_last_gc_ = 0; |
| 642 bytes_rescanned_ = 0; |
| 643 allocation_marking_factor_ = kInitialAllocationMarkingFactor; |
| 644 } |
| 645 |
| 646 |
| 647 int64_t IncrementalMarking::SpaceLeftInOldSpace() { |
| 648 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSize(); |
| 649 } |
| 650 |
| 605 } } // namespace v8::internal | 651 } } // namespace v8::internal |
| OLD | NEW |