| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/heap/incremental-marking.h" | 7 #include "src/heap/incremental-marking.h" |
| 8 | 8 |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 ActivateIncrementalWriteBarrier(heap_->new_space()); | 414 ActivateIncrementalWriteBarrier(heap_->new_space()); |
| 415 | 415 |
| 416 LargePage* lop = heap_->lo_space()->first_page(); | 416 LargePage* lop = heap_->lo_space()->first_page(); |
| 417 while (lop->is_valid()) { | 417 while (lop->is_valid()) { |
| 418 SetOldSpacePageFlags(lop, true, is_compacting_); | 418 SetOldSpacePageFlags(lop, true, is_compacting_); |
| 419 lop = lop->next_page(); | 419 lop = lop->next_page(); |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 | 423 |
| 424 bool IncrementalMarking::ShouldActivate() { |
| 425 return WorthActivating() && heap_->NextGCIsLikelyToBeFull(); |
| 426 } |
| 427 |
| 428 |
| 424 bool IncrementalMarking::WorthActivating() { | 429 bool IncrementalMarking::WorthActivating() { |
| 425 #ifndef DEBUG | 430 #ifndef DEBUG |
| 426 static const intptr_t kActivationThreshold = 8 * MB; | 431 static const intptr_t kActivationThreshold = 8 * MB; |
| 427 #else | 432 #else |
| 428 // TODO(gc) consider setting this to some low level so that some | 433 // TODO(gc) consider setting this to some low level so that some |
| 429 // debug tests run with incremental marking and some without. | 434 // debug tests run with incremental marking and some without. |
| 430 static const intptr_t kActivationThreshold = 0; | 435 static const intptr_t kActivationThreshold = 0; |
| 431 #endif | 436 #endif |
| 432 // Only start incremental marking in a safe state: 1) when incremental | 437 // Only start incremental marking in a safe state: 1) when incremental |
| 433 // marking is turned on, 2) when we are currently not in a GC, and | 438 // marking is turned on, 2) when we are currently not in a GC, and |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 if (FLAG_trace_incremental_marking) { | 809 if (FLAG_trace_incremental_marking) { |
| 805 PrintF("[IncrementalMarking] Complete (normal).\n"); | 810 PrintF("[IncrementalMarking] Complete (normal).\n"); |
| 806 } | 811 } |
| 807 if (action == GC_VIA_STACK_GUARD) { | 812 if (action == GC_VIA_STACK_GUARD) { |
| 808 heap_->isolate()->stack_guard()->RequestGC(); | 813 heap_->isolate()->stack_guard()->RequestGC(); |
| 809 } | 814 } |
| 810 } | 815 } |
| 811 | 816 |
| 812 | 817 |
| 813 void IncrementalMarking::OldSpaceStep(intptr_t allocated) { | 818 void IncrementalMarking::OldSpaceStep(intptr_t allocated) { |
| 814 if (IsStopped() && WorthActivating() && heap_->NextGCIsLikelyToBeFull()) { | 819 if (IsStopped() && ShouldActivate()) { |
| 815 // TODO(hpayer): Let's play safe for now, but compaction should be | 820 // TODO(hpayer): Let's play safe for now, but compaction should be |
| 816 // in principle possible. | 821 // in principle possible. |
| 817 Start(PREVENT_COMPACTION); | 822 Start(PREVENT_COMPACTION); |
| 818 } else { | 823 } else { |
| 819 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); | 824 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); |
| 820 } | 825 } |
| 821 } | 826 } |
| 822 | 827 |
| 823 | 828 |
| 824 void IncrementalMarking::SpeedUp() { | 829 void IncrementalMarking::SpeedUp() { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 bytes_scanned_ = 0; | 973 bytes_scanned_ = 0; |
| 969 write_barriers_invoked_since_last_step_ = 0; | 974 write_barriers_invoked_since_last_step_ = 0; |
| 970 } | 975 } |
| 971 | 976 |
| 972 | 977 |
| 973 int64_t IncrementalMarking::SpaceLeftInOldSpace() { | 978 int64_t IncrementalMarking::SpaceLeftInOldSpace() { |
| 974 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); | 979 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); |
| 975 } | 980 } |
| 976 } | 981 } |
| 977 } // namespace v8::internal | 982 } // namespace v8::internal |
| OLD | NEW |