Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: src/heap/incremental-marking.cc

Issue 629903003: Check if there is still time before finalizing an incremental collection. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "src/conversions.h" 11 #include "src/conversions.h"
12 #include "src/heap/objects-visiting.h" 12 #include "src/heap/objects-visiting.h"
13 #include "src/heap/objects-visiting-inl.h" 13 #include "src/heap/objects-visiting-inl.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 18
19 IncrementalMarking::IncrementalMarking(Heap* heap) 19 IncrementalMarking::IncrementalMarking(Heap* heap)
20 : heap_(heap), 20 : heap_(heap),
21 state_(STOPPED), 21 state_(STOPPED),
22 marking_deque_memory_(NULL), 22 marking_deque_memory_(NULL),
23 marking_deque_memory_committed_(false), 23 marking_deque_memory_committed_(false),
24 steps_count_(0), 24 steps_count_(0),
25 old_generation_space_available_at_start_of_incremental_(0), 25 old_generation_space_available_at_start_of_incremental_(0),
26 old_generation_space_used_at_start_of_incremental_(0), 26 old_generation_space_used_at_start_of_incremental_(0),
27 should_hurry_(false), 27 should_hurry_(false),
28 marking_speed_(0), 28 marking_speed_(0),
29 allocated_(0), 29 allocated_(0),
30 idle_marking_delay_counter_(0),
30 no_marking_scope_depth_(0), 31 no_marking_scope_depth_(0),
31 unscanned_bytes_of_large_object_(0) {} 32 unscanned_bytes_of_large_object_(0) {}
32 33
33 34
34 void IncrementalMarking::TearDown() { delete marking_deque_memory_; } 35 void IncrementalMarking::TearDown() { delete marking_deque_memory_; }
35 36
36 37
37 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, 38 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot,
38 Object* value) { 39 Object* value) {
39 if (BaseRecordWrite(obj, slot, value) && slot != NULL) { 40 if (BaseRecordWrite(obj, slot, value) && slot != NULL) {
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 Min(kMaxMarkingSpeed, static_cast<intptr_t>(marking_speed_ * 1.3))); 887 Min(kMaxMarkingSpeed, static_cast<intptr_t>(marking_speed_ * 1.3)));
887 if (FLAG_trace_gc) { 888 if (FLAG_trace_gc) {
888 PrintPID("Marking speed increased to %d\n", marking_speed_); 889 PrintPID("Marking speed increased to %d\n", marking_speed_);
889 } 890 }
890 } 891 }
891 } 892 }
892 } 893 }
893 894
894 895
895 void IncrementalMarking::Step(intptr_t allocated_bytes, CompletionAction action, 896 void IncrementalMarking::Step(intptr_t allocated_bytes, CompletionAction action,
896 bool force_marking) { 897 ForceMarkingAction marking,
898 ForceCompletionAction completion) {
897 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking || 899 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking ||
898 !FLAG_incremental_marking_steps || 900 !FLAG_incremental_marking_steps ||
899 (state_ != SWEEPING && state_ != MARKING)) { 901 (state_ != SWEEPING && state_ != MARKING)) {
900 return; 902 return;
901 } 903 }
902 904
903 allocated_ += allocated_bytes; 905 allocated_ += allocated_bytes;
904 906
905 if (!force_marking && allocated_ < kAllocatedThreshold && 907 if (marking == DO_NOT_FORCE_MARKING && allocated_ < kAllocatedThreshold &&
906 write_barriers_invoked_since_last_step_ < 908 write_barriers_invoked_since_last_step_ <
907 kWriteBarriersInvokedThreshold) { 909 kWriteBarriersInvokedThreshold) {
908 return; 910 return;
909 } 911 }
910 912
911 if (state_ == MARKING && no_marking_scope_depth_ > 0) return; 913 if (state_ == MARKING && no_marking_scope_depth_ > 0) return;
912 914
913 { 915 {
914 HistogramTimerScope incremental_marking_scope( 916 HistogramTimerScope incremental_marking_scope(
915 heap_->isolate()->counters()->gc_incremental_marking()); 917 heap_->isolate()->counters()->gc_incremental_marking());
(...skipping 20 matching lines...) Expand all
936 if (heap_->mark_compact_collector()->sweeping_in_progress() && 938 if (heap_->mark_compact_collector()->sweeping_in_progress() &&
937 heap_->mark_compact_collector()->IsSweepingCompleted()) { 939 heap_->mark_compact_collector()->IsSweepingCompleted()) {
938 heap_->mark_compact_collector()->EnsureSweepingCompleted(); 940 heap_->mark_compact_collector()->EnsureSweepingCompleted();
939 } 941 }
940 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { 942 if (!heap_->mark_compact_collector()->sweeping_in_progress()) {
941 bytes_scanned_ = 0; 943 bytes_scanned_ = 0;
942 StartMarking(PREVENT_COMPACTION); 944 StartMarking(PREVENT_COMPACTION);
943 } 945 }
944 } else if (state_ == MARKING) { 946 } else if (state_ == MARKING) {
945 bytes_processed = ProcessMarkingDeque(bytes_to_process); 947 bytes_processed = ProcessMarkingDeque(bytes_to_process);
946 if (marking_deque_.IsEmpty()) MarkingComplete(action); 948 if (marking_deque_.IsEmpty()) {
949 if (completion == FORCE_COMPLETION ||
950 IsIdleMarkingDelayCounterLimitReached()) {
951 MarkingComplete(action);
952 } else {
953 IncrementIdleMarkingDelayCounter();
954 }
955 }
947 } 956 }
948 957
949 steps_count_++; 958 steps_count_++;
950 959
951 // Speed up marking if we are marking too slow or if we are almost done 960 // Speed up marking if we are marking too slow or if we are almost done
952 // with marking. 961 // with marking.
953 SpeedUp(); 962 SpeedUp();
954 963
955 double end = base::OS::TimeCurrentMillis(); 964 double end = base::OS::TimeCurrentMillis();
956 double duration = (end - start); 965 double duration = (end - start);
(...skipping 14 matching lines...) Expand all
971 bytes_rescanned_ = 0; 980 bytes_rescanned_ = 0;
972 marking_speed_ = kInitialMarkingSpeed; 981 marking_speed_ = kInitialMarkingSpeed;
973 bytes_scanned_ = 0; 982 bytes_scanned_ = 0;
974 write_barriers_invoked_since_last_step_ = 0; 983 write_barriers_invoked_since_last_step_ = 0;
975 } 984 }
976 985
977 986
978 int64_t IncrementalMarking::SpaceLeftInOldSpace() { 987 int64_t IncrementalMarking::SpaceLeftInOldSpace() {
979 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); 988 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects();
980 } 989 }
990
991
992 bool IncrementalMarking::IsIdleMarkingDelayCounterLimitReached() {
993 return idle_marking_delay_counter_ >= kMaxIdleMarkingDelayCounter;
994 }
995
996
997 void IncrementalMarking::IncrementIdleMarkingDelayCounter() {
998 idle_marking_delay_counter_++;
999 }
1000
1001
1002 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
1003 idle_marking_delay_counter_ = 0;
1004 }
981 } 1005 }
982 } // namespace v8::internal 1006 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698