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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 static const intptr_t kActivationThreshold = 8 * MB; | 404 static const intptr_t kActivationThreshold = 8 * MB; |
405 #else | 405 #else |
406 // TODO(gc) consider setting this to some low level so that some | 406 // TODO(gc) consider setting this to some low level so that some |
407 // debug tests run with incremental marking and some without. | 407 // debug tests run with incremental marking and some without. |
408 static const intptr_t kActivationThreshold = 0; | 408 static const intptr_t kActivationThreshold = 0; |
409 #endif | 409 #endif |
410 // Only start incremental marking in a safe state: 1) when incremental | 410 // Only start incremental marking in a safe state: 1) when incremental |
411 // marking is turned on, 2) when we are currently not in a GC, and | 411 // marking is turned on, 2) when we are currently not in a GC, and |
412 // 3) when we are currently not serializing or deserializing the heap. | 412 // 3) when we are currently not serializing or deserializing the heap. |
413 // Don't switch on for very small heaps. | 413 // Don't switch on for very small heaps. |
414 return FLAG_incremental_marking && FLAG_incremental_marking_steps && | 414 return FLAG_incremental_marking && heap_->gc_state() == Heap::NOT_IN_GC && |
415 heap_->gc_state() == Heap::NOT_IN_GC && | |
416 heap_->deserialization_complete() && | 415 heap_->deserialization_complete() && |
417 !heap_->isolate()->serializer_enabled() && | 416 !heap_->isolate()->serializer_enabled() && |
418 heap_->PromotedSpaceSizeOfObjects() > kActivationThreshold; | 417 heap_->PromotedSpaceSizeOfObjects() > kActivationThreshold; |
419 } | 418 } |
420 | 419 |
421 | 420 |
422 void IncrementalMarking::ActivateGeneratedStub(Code* stub) { | 421 void IncrementalMarking::ActivateGeneratedStub(Code* stub) { |
423 DCHECK(RecordWriteStub::GetMode(stub) == RecordWriteStub::STORE_BUFFER_ONLY); | 422 DCHECK(RecordWriteStub::GetMode(stub) == RecordWriteStub::STORE_BUFFER_ONLY); |
424 | 423 |
425 if (!IsMarking()) { | 424 if (!IsMarking()) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 470 |
472 | 471 |
473 void IncrementalMarking::Start(int mark_compact_flags, | 472 void IncrementalMarking::Start(int mark_compact_flags, |
474 const GCCallbackFlags gc_callback_flags, | 473 const GCCallbackFlags gc_callback_flags, |
475 const char* reason) { | 474 const char* reason) { |
476 if (FLAG_trace_incremental_marking) { | 475 if (FLAG_trace_incremental_marking) { |
477 PrintF("[IncrementalMarking] Start (%s)\n", | 476 PrintF("[IncrementalMarking] Start (%s)\n", |
478 (reason == nullptr) ? "unknown reason" : reason); | 477 (reason == nullptr) ? "unknown reason" : reason); |
479 } | 478 } |
480 DCHECK(FLAG_incremental_marking); | 479 DCHECK(FLAG_incremental_marking); |
481 DCHECK(FLAG_incremental_marking_steps); | |
482 DCHECK(state_ == STOPPED); | 480 DCHECK(state_ == STOPPED); |
483 DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); | 481 DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); |
484 DCHECK(!heap_->isolate()->serializer_enabled()); | 482 DCHECK(!heap_->isolate()->serializer_enabled()); |
485 | 483 |
486 ResetStepCounters(); | 484 ResetStepCounters(); |
487 | 485 |
488 gc_callback_flags_ = gc_callback_flags; | 486 gc_callback_flags_ = gc_callback_flags; |
489 was_activated_ = true; | 487 was_activated_ = true; |
490 | 488 |
491 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { | 489 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 } | 903 } |
906 } | 904 } |
907 } | 905 } |
908 | 906 |
909 | 907 |
910 intptr_t IncrementalMarking::Step(intptr_t allocated_bytes, | 908 intptr_t IncrementalMarking::Step(intptr_t allocated_bytes, |
911 CompletionAction action, | 909 CompletionAction action, |
912 ForceMarkingAction marking, | 910 ForceMarkingAction marking, |
913 ForceCompletionAction completion) { | 911 ForceCompletionAction completion) { |
914 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking || | 912 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking || |
915 !FLAG_incremental_marking_steps || | |
916 (state_ != SWEEPING && state_ != MARKING)) { | 913 (state_ != SWEEPING && state_ != MARKING)) { |
917 return 0; | 914 return 0; |
918 } | 915 } |
919 | 916 |
920 allocated_ += allocated_bytes; | 917 allocated_ += allocated_bytes; |
921 | 918 |
922 if (marking == DO_NOT_FORCE_MARKING && allocated_ < kAllocatedThreshold && | 919 if (marking == DO_NOT_FORCE_MARKING && allocated_ < kAllocatedThreshold && |
923 write_barriers_invoked_since_last_step_ < | 920 write_barriers_invoked_since_last_step_ < |
924 kWriteBarriersInvokedThreshold) { | 921 kWriteBarriersInvokedThreshold) { |
925 return 0; | 922 return 0; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1022 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
1026 idle_marking_delay_counter_++; | 1023 idle_marking_delay_counter_++; |
1027 } | 1024 } |
1028 | 1025 |
1029 | 1026 |
1030 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1027 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1031 idle_marking_delay_counter_ = 0; | 1028 idle_marking_delay_counter_ = 0; |
1032 } | 1029 } |
1033 } // namespace internal | 1030 } // namespace internal |
1034 } // namespace v8 | 1031 } // namespace v8 |
OLD | NEW |