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

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

Issue 2472043002: Revert of [heap] Invoke incremental marking step before allocation. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/heap/incremental-marking.h" 5 #include "src/heap/incremental-marking.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/compilation-cache.h" 8 #include "src/compilation-cache.h"
9 #include "src/conversions.h" 9 #include "src/conversions.h"
10 #include "src/heap/gc-idle-time-handler.h" 10 #include "src/heap/gc-idle-time-handler.h"
(...skipping 14 matching lines...) Expand all
25 initial_old_generation_size_(0), 25 initial_old_generation_size_(0),
26 bytes_marked_ahead_of_schedule_(0), 26 bytes_marked_ahead_of_schedule_(0),
27 unscanned_bytes_of_large_object_(0), 27 unscanned_bytes_of_large_object_(0),
28 idle_marking_delay_counter_(0), 28 idle_marking_delay_counter_(0),
29 incremental_marking_finalization_rounds_(0), 29 incremental_marking_finalization_rounds_(0),
30 is_compacting_(false), 30 is_compacting_(false),
31 should_hurry_(false), 31 should_hurry_(false),
32 was_activated_(false), 32 was_activated_(false),
33 black_allocation_(false), 33 black_allocation_(false),
34 finalize_marking_completed_(false), 34 finalize_marking_completed_(false),
35 request_type_(NONE) {} 35 request_type_(NONE),
36 new_generation_observer_(*this, kAllocatedThreshold),
37 old_generation_observer_(*this, kAllocatedThreshold) {}
36 38
37 bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) { 39 bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) {
38 HeapObject* value_heap_obj = HeapObject::cast(value); 40 HeapObject* value_heap_obj = HeapObject::cast(value);
39 MarkBit value_bit = ObjectMarking::MarkBitFrom(value_heap_obj); 41 MarkBit value_bit = ObjectMarking::MarkBitFrom(value_heap_obj);
40 DCHECK(!Marking::IsImpossible(value_bit)); 42 DCHECK(!Marking::IsImpossible(value_bit));
41 43
42 MarkBit obj_bit = ObjectMarking::MarkBitFrom(obj); 44 MarkBit obj_bit = ObjectMarking::MarkBitFrom(obj);
43 DCHECK(!Marking::IsImpossible(obj_bit)); 45 DCHECK(!Marking::IsImpossible(obj_bit));
44 bool is_black = Marking::IsBlack(obj_bit); 46 bool is_black = Marking::IsBlack(obj_bit);
45 47
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { 482 if (!heap_->mark_compact_collector()->sweeping_in_progress()) {
481 StartMarking(); 483 StartMarking();
482 } else { 484 } else {
483 if (FLAG_trace_incremental_marking) { 485 if (FLAG_trace_incremental_marking) {
484 heap()->isolate()->PrintWithTimestamp( 486 heap()->isolate()->PrintWithTimestamp(
485 "[IncrementalMarking] Start sweeping.\n"); 487 "[IncrementalMarking] Start sweeping.\n");
486 } 488 }
487 state_ = SWEEPING; 489 state_ = SWEEPING;
488 } 490 }
489 491
492 SpaceIterator it(heap_);
493 while (it.has_next()) {
494 Space* space = it.next();
495 if (space == heap_->new_space()) {
496 space->AddAllocationObserver(&new_generation_observer_);
497 } else {
498 space->AddAllocationObserver(&old_generation_observer_);
499 }
500 }
501
490 incremental_marking_job()->Start(heap_); 502 incremental_marking_job()->Start(heap_);
491 } 503 }
492 504
493 505
494 void IncrementalMarking::StartMarking() { 506 void IncrementalMarking::StartMarking() {
495 if (heap_->isolate()->serializer_enabled()) { 507 if (heap_->isolate()->serializer_enabled()) {
496 // Black allocation currently starts when we start incremental marking, 508 // Black allocation currently starts when we start incremental marking,
497 // but we cannot enable black allocation while deserializing. Hence, we 509 // but we cannot enable black allocation while deserializing. Hence, we
498 // have to delay the start of incremental marking in that case. 510 // have to delay the start of incremental marking in that case.
499 if (FLAG_trace_incremental_marking) { 511 if (FLAG_trace_incremental_marking) {
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 static_cast<int>(heap()->PromotedSpaceSizeOfObjects() / MB); 950 static_cast<int>(heap()->PromotedSpaceSizeOfObjects() / MB);
939 int old_generation_limit_mb = 951 int old_generation_limit_mb =
940 static_cast<int>(heap()->old_generation_allocation_limit() / MB); 952 static_cast<int>(heap()->old_generation_allocation_limit() / MB);
941 heap()->isolate()->PrintWithTimestamp( 953 heap()->isolate()->PrintWithTimestamp(
942 "[IncrementalMarking] Stopping: old generation %dMB, limit %dMB, " 954 "[IncrementalMarking] Stopping: old generation %dMB, limit %dMB, "
943 "overshoot %dMB\n", 955 "overshoot %dMB\n",
944 old_generation_size_mb, old_generation_limit_mb, 956 old_generation_size_mb, old_generation_limit_mb,
945 Max(0, old_generation_size_mb - old_generation_limit_mb)); 957 Max(0, old_generation_size_mb - old_generation_limit_mb));
946 } 958 }
947 959
960 SpaceIterator it(heap_);
961 while (it.has_next()) {
962 Space* space = it.next();
963 if (space == heap_->new_space()) {
964 space->RemoveAllocationObserver(&new_generation_observer_);
965 } else {
966 space->RemoveAllocationObserver(&old_generation_observer_);
967 }
968 }
969
948 IncrementalMarking::set_should_hurry(false); 970 IncrementalMarking::set_should_hurry(false);
949 if (IsMarking()) { 971 if (IsMarking()) {
950 PatchIncrementalMarkingRecordWriteStubs(heap_, 972 PatchIncrementalMarkingRecordWriteStubs(heap_,
951 RecordWriteStub::STORE_BUFFER_ONLY); 973 RecordWriteStub::STORE_BUFFER_ONLY);
952 DeactivateIncrementalWriteBarrier(); 974 DeactivateIncrementalWriteBarrier();
953 } 975 }
954 heap_->isolate()->stack_guard()->ClearGC(); 976 heap_->isolate()->stack_guard()->ClearGC();
955 state_ = STOPPED; 977 state_ = STOPPED;
956 is_compacting_ = false; 978 is_compacting_ = false;
957 FinishBlackAllocation(); 979 FinishBlackAllocation();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 double factor = Min(time_passed_ms / kRampUpIntervalMs, 1.0); 1078 double factor = Min(time_passed_ms / kRampUpIntervalMs, 1.0);
1057 return static_cast<size_t>(factor * step_size); 1079 return static_cast<size_t>(factor * step_size);
1058 } 1080 }
1059 1081
1060 void IncrementalMarking::AdvanceIncrementalMarkingOnAllocation() { 1082 void IncrementalMarking::AdvanceIncrementalMarkingOnAllocation() {
1061 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking || 1083 if (heap_->gc_state() != Heap::NOT_IN_GC || !FLAG_incremental_marking ||
1062 (state_ != SWEEPING && state_ != MARKING)) { 1084 (state_ != SWEEPING && state_ != MARKING)) {
1063 return; 1085 return;
1064 } 1086 }
1065 1087
1066 size_t bytes_to_process = StepSizeToKeepUpWithAllocations(); 1088 size_t bytes_to_process =
1089 StepSizeToKeepUpWithAllocations() + StepSizeToMakeProgress();
1067 1090
1068 if (bytes_to_process < IncrementalMarking::kAllocatedThreshold) { 1091 if (bytes_to_process >= IncrementalMarking::kAllocatedThreshold) {
1069 return; 1092 // The first step after Scavenge will see many allocated bytes.
1093 // Cap the step size to distribute the marking work more uniformly.
1094 size_t max_step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
1095 kMaxStepSizeInMs,
1096 heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
1097 bytes_to_process = Min(bytes_to_process, max_step_size);
1098
1099 size_t bytes_processed = 0;
1100 if (bytes_marked_ahead_of_schedule_ >= bytes_to_process) {
1101 // Steps performed in tasks have put us ahead of schedule.
1102 // We skip processing of marking dequeue here and thus
1103 // shift marking time from inside V8 to standalone tasks.
1104 bytes_marked_ahead_of_schedule_ -= bytes_to_process;
1105 bytes_processed = bytes_to_process;
1106 } else {
1107 bytes_processed = Step(bytes_to_process, GC_VIA_STACK_GUARD,
1108 FORCE_COMPLETION, StepOrigin::kV8);
1109 }
1110 bytes_allocated_ -= Min(bytes_allocated_, bytes_processed);
1070 } 1111 }
1071
1072 bytes_to_process += StepSizeToMakeProgress();
1073
1074 // The first step after Scavenge will see many allocated bytes.
1075 // Cap the step size to distribute the marking work more uniformly.
1076 size_t max_step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
1077 kMaxStepSizeInMs,
1078 heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
1079 bytes_to_process = Min(bytes_to_process, max_step_size);
1080
1081 size_t bytes_processed = 0;
1082 if (bytes_marked_ahead_of_schedule_ >= bytes_to_process) {
1083 // Steps performed in tasks have put us ahead of schedule.
1084 // We skip processing of marking dequeue here and thus
1085 // shift marking time from inside V8 to standalone tasks.
1086 bytes_marked_ahead_of_schedule_ -= bytes_to_process;
1087 bytes_processed = bytes_to_process;
1088 } else {
1089 bytes_processed = Step(bytes_to_process, GC_VIA_STACK_GUARD,
1090 FORCE_COMPLETION, StepOrigin::kV8);
1091 }
1092 bytes_allocated_ -= Min(bytes_allocated_, bytes_processed);
1093 } 1112 }
1094 1113
1095 size_t IncrementalMarking::Step(size_t bytes_to_process, 1114 size_t IncrementalMarking::Step(size_t bytes_to_process,
1096 CompletionAction action, 1115 CompletionAction action,
1097 ForceCompletionAction completion, 1116 ForceCompletionAction completion,
1098 StepOrigin step_origin) { 1117 StepOrigin step_origin) {
1099 HistogramTimerScope incremental_marking_scope( 1118 HistogramTimerScope incremental_marking_scope(
1100 heap_->isolate()->counters()->gc_incremental_marking()); 1119 heap_->isolate()->counters()->gc_incremental_marking());
1101 TRACE_EVENT0("v8", "V8.GCIncrementalMarking"); 1120 TRACE_EVENT0("v8", "V8.GCIncrementalMarking");
1102 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL); 1121 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 idle_marking_delay_counter_++; 1192 idle_marking_delay_counter_++;
1174 } 1193 }
1175 1194
1176 1195
1177 void IncrementalMarking::ClearIdleMarkingDelayCounter() { 1196 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
1178 idle_marking_delay_counter_ = 0; 1197 idle_marking_delay_counter_ = 0;
1179 } 1198 }
1180 1199
1181 } // namespace internal 1200 } // namespace internal
1182 } // namespace v8 1201 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698