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

Side by Side Diff: src/heap/gc-idle-time-handler.cc

Issue 492763002: Move idle notification handling to GCIdleTimeHandler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Casts Created 6 years, 4 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
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/gc-tracer.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/gc-idle-time-handler.h" 5 #include "src/heap/gc-idle-time-handler.h"
6 #include "src/heap/gc-tracer.h"
7 #include "src/utils.h"
6 8
7 namespace v8 { 9 namespace v8 {
8 namespace internal { 10 namespace internal {
9 11
10
11 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9; 12 const double GCIdleTimeHandler::kConservativeTimeRatio = 0.9;
13 const size_t GCIdleTimeHandler::kMaxMarkCompactTimeInMs = 1000000;
12 14
13 15
14 size_t GCIdleTimeHandler::EstimateMarkingStepSize( 16 size_t GCIdleTimeHandler::EstimateMarkingStepSize(
15 size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) { 17 size_t idle_time_in_ms, size_t marking_speed_in_bytes_per_ms) {
16 DCHECK(idle_time_in_ms > 0); 18 DCHECK(idle_time_in_ms > 0);
17 19
18 if (marking_speed_in_bytes_per_ms == 0) { 20 if (marking_speed_in_bytes_per_ms == 0) {
19 marking_speed_in_bytes_per_ms = 21 marking_speed_in_bytes_per_ms = kInitialConservativeMarkingSpeed;
20 GCIdleTimeHandler::kInitialConservativeMarkingSpeed;
21 } 22 }
22 23
23 size_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms; 24 size_t marking_step_size = marking_speed_in_bytes_per_ms * idle_time_in_ms;
24 if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) { 25 if (marking_step_size / marking_speed_in_bytes_per_ms != idle_time_in_ms) {
25 // In the case of an overflow we return maximum marking step size. 26 // In the case of an overflow we return maximum marking step size.
26 return GCIdleTimeHandler::kMaximumMarkingStepSize; 27 return kMaximumMarkingStepSize;
27 } 28 }
28 29
29 if (marking_step_size > kMaximumMarkingStepSize) 30 if (marking_step_size > kMaximumMarkingStepSize)
30 return kMaximumMarkingStepSize; 31 return kMaximumMarkingStepSize;
31 32
32 return static_cast<size_t>(marking_step_size * 33 return static_cast<size_t>(marking_step_size *
33 GCIdleTimeHandler::kConservativeTimeRatio); 34 GCIdleTimeHandler::kConservativeTimeRatio);
34 } 35 }
36
37
38 size_t GCIdleTimeHandler::EstimateMarkCompactTime(
39 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) {
40 if (mark_compact_speed_in_bytes_per_ms == 0) {
41 mark_compact_speed_in_bytes_per_ms = kInitialConservativeMarkCompactSpeed;
42 }
43 size_t result = size_of_objects / mark_compact_speed_in_bytes_per_ms;
44 return Min(result, kMaxMarkCompactTimeInMs);
45 }
46
47
48 GCIdleTimeAction GCIdleTimeHandler::Compute(int idle_time_in_ms,
49 int contexts_disposed,
50 size_t size_of_objects,
51 bool incremental_marking_stopped,
52 GCTracer* gc_tracer) {
53 if (IsIdleRoundFinished()) {
54 if (EnoughGarbageSinceLastIdleRound() || contexts_disposed > 0) {
55 StartIdleRound();
56 } else {
57 return GCIdleTimeAction::Nothing();
58 }
59 }
60 if (incremental_marking_stopped) {
61 size_t speed =
62 static_cast<size_t>(gc_tracer->MarkCompactSpeedInBytesPerMillisecond());
63 if (idle_time_in_ms >=
64 static_cast<int>(EstimateMarkCompactTime(size_of_objects, speed))) {
65 // If there are no more than two GCs left in this idle round and we are
66 // allowed to do a full GC, then make those GCs full in order to compact
67 // the code space.
68 // TODO(ulan): Once we enable code compaction for incremental marking, we
69 // can get rid of this special case and always start incremental marking.
70 int remaining_mark_sweeps =
71 kMaxMarkCompactsInIdleRound - mark_compacts_since_idle_round_started_;
72 if (contexts_disposed > 0 || remaining_mark_sweeps <= 2) {
73 return GCIdleTimeAction::FullGC();
74 }
75 }
76 }
77 intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond();
78 size_t step_size =
79 static_cast<size_t>(EstimateMarkingStepSize(idle_time_in_ms, speed));
80 return GCIdleTimeAction::IncrementalMarking(step_size);
35 } 81 }
36 } 82 }
83 }
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.h ('k') | src/heap/gc-tracer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698