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

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 bool force_marking, bool force_completion) {
897 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking || 898 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking ||
898 !FLAG_incremental_marking_steps || 899 !FLAG_incremental_marking_steps ||
899 (state_ != SWEEPING && state_ != MARKING)) { 900 (state_ != SWEEPING && state_ != MARKING)) {
900 return; 901 return;
901 } 902 }
902 903
903 allocated_ += allocated_bytes; 904 allocated_ += allocated_bytes;
904 905
905 if (!force_marking && allocated_ < kAllocatedThreshold && 906 if (!force_marking && allocated_ < kAllocatedThreshold &&
906 write_barriers_invoked_since_last_step_ < 907 write_barriers_invoked_since_last_step_ <
(...skipping 29 matching lines...) Expand all
936 if (heap_->mark_compact_collector()->sweeping_in_progress() && 937 if (heap_->mark_compact_collector()->sweeping_in_progress() &&
937 heap_->mark_compact_collector()->IsSweepingCompleted()) { 938 heap_->mark_compact_collector()->IsSweepingCompleted()) {
938 heap_->mark_compact_collector()->EnsureSweepingCompleted(); 939 heap_->mark_compact_collector()->EnsureSweepingCompleted();
939 } 940 }
940 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { 941 if (!heap_->mark_compact_collector()->sweeping_in_progress()) {
941 bytes_scanned_ = 0; 942 bytes_scanned_ = 0;
942 StartMarking(PREVENT_COMPACTION); 943 StartMarking(PREVENT_COMPACTION);
943 } 944 }
944 } else if (state_ == MARKING) { 945 } else if (state_ == MARKING) {
945 bytes_processed = ProcessMarkingDeque(bytes_to_process); 946 bytes_processed = ProcessMarkingDeque(bytes_to_process);
946 if (marking_deque_.IsEmpty()) MarkingComplete(action); 947 IncrementIdleMarkingDelayCounter();
Erik Corry Chromium.org 2014/10/06 14:56:47 If we increment this every time we do a step, then
Hannes Payer (out of office) 2014/10/07 13:41:11 Uff, good catch. We should just increment the coun
948 if (marking_deque_.IsEmpty() &&
949 (force_completion || IsIdleMarkingDelayCounterLimitReached())) {
950 MarkingComplete(action);
951 }
947 } 952 }
948 953
949 steps_count_++; 954 steps_count_++;
950 955
951 // Speed up marking if we are marking too slow or if we are almost done 956 // Speed up marking if we are marking too slow or if we are almost done
952 // with marking. 957 // with marking.
953 SpeedUp(); 958 SpeedUp();
954 959
955 double end = base::OS::TimeCurrentMillis(); 960 double end = base::OS::TimeCurrentMillis();
956 double duration = (end - start); 961 double duration = (end - start);
(...skipping 14 matching lines...) Expand all
971 bytes_rescanned_ = 0; 976 bytes_rescanned_ = 0;
972 marking_speed_ = kInitialMarkingSpeed; 977 marking_speed_ = kInitialMarkingSpeed;
973 bytes_scanned_ = 0; 978 bytes_scanned_ = 0;
974 write_barriers_invoked_since_last_step_ = 0; 979 write_barriers_invoked_since_last_step_ = 0;
975 } 980 }
976 981
977 982
978 int64_t IncrementalMarking::SpaceLeftInOldSpace() { 983 int64_t IncrementalMarking::SpaceLeftInOldSpace() {
979 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); 984 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects();
980 } 985 }
986
987
988 bool IncrementalMarking::IsIdleMarkingDelayCounterLimitReached() {
989 return idle_marking_delay_counter_ >= kMaxIdleMarkingDelayCounter;
990 }
991
992
993 void IncrementalMarking::IncrementIdleMarkingDelayCounter() {
994 idle_marking_delay_counter_++;
995 }
996
997
998 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
999 idle_marking_delay_counter_ = 0;
1000 }
981 } 1001 }
982 } // namespace v8::internal 1002 } // namespace v8::internal
OLDNEW
« src/heap/heap.cc ('K') | « src/heap/incremental-marking.h ('k') | src/heap/mark-compact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698