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

Side by Side Diff: src/heap/gc-tracer.cc

Issue 754023003: Make GCTracer not reentrant. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/gc-tracer.h ('k') | src/heap/heap.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 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/heap/gc-tracer.h" 7 #include "src/heap/gc-tracer.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 GCTracer::GCTracer(Heap* heap) 87 GCTracer::GCTracer(Heap* heap)
88 : heap_(heap), 88 : heap_(heap),
89 cumulative_incremental_marking_steps_(0), 89 cumulative_incremental_marking_steps_(0),
90 cumulative_incremental_marking_bytes_(0), 90 cumulative_incremental_marking_bytes_(0),
91 cumulative_incremental_marking_duration_(0.0), 91 cumulative_incremental_marking_duration_(0.0),
92 cumulative_pure_incremental_marking_duration_(0.0), 92 cumulative_pure_incremental_marking_duration_(0.0),
93 longest_incremental_marking_step_(0.0), 93 longest_incremental_marking_step_(0.0),
94 cumulative_marking_duration_(0.0), 94 cumulative_marking_duration_(0.0),
95 cumulative_sweeping_duration_(0.0), 95 cumulative_sweeping_duration_(0.0),
96 new_space_top_after_gc_(0) { 96 new_space_top_after_gc_(0),
97 start_counter_(0) {
97 current_ = Event(Event::START, NULL, NULL); 98 current_ = Event(Event::START, NULL, NULL);
98 current_.end_time = base::OS::TimeCurrentMillis(); 99 current_.end_time = base::OS::TimeCurrentMillis();
99 previous_ = previous_mark_compactor_event_ = current_; 100 previous_ = previous_mark_compactor_event_ = current_;
100 } 101 }
101 102
102 103
103 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, 104 void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
104 const char* collector_reason) { 105 const char* collector_reason) {
106 start_counter_++;
107 if (start_counter_ != 1) return;
108
105 previous_ = current_; 109 previous_ = current_;
106 double start_time = base::OS::TimeCurrentMillis(); 110 double start_time = base::OS::TimeCurrentMillis();
107 if (new_space_top_after_gc_ != 0) { 111 if (new_space_top_after_gc_ != 0) {
108 AddNewSpaceAllocationTime( 112 AddNewSpaceAllocationTime(
109 start_time - previous_.end_time, 113 start_time - previous_.end_time,
110 reinterpret_cast<intptr_t>((heap_->new_space()->top()) - 114 reinterpret_cast<intptr_t>((heap_->new_space()->top()) -
111 new_space_top_after_gc_)); 115 new_space_top_after_gc_));
112 } 116 }
113 if (current_.type == Event::MARK_COMPACTOR) 117 if (current_.type == Event::MARK_COMPACTOR)
114 previous_mark_compactor_event_ = current_; 118 previous_mark_compactor_event_ = current_;
(...skipping 20 matching lines...) Expand all
135 current_.cumulative_pure_incremental_marking_duration = 139 current_.cumulative_pure_incremental_marking_duration =
136 cumulative_pure_incremental_marking_duration_; 140 cumulative_pure_incremental_marking_duration_;
137 current_.longest_incremental_marking_step = longest_incremental_marking_step_; 141 current_.longest_incremental_marking_step = longest_incremental_marking_step_;
138 142
139 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { 143 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) {
140 current_.scopes[i] = 0; 144 current_.scopes[i] = 0;
141 } 145 }
142 } 146 }
143 147
144 148
145 void GCTracer::Stop() { 149 void GCTracer::Stop(GarbageCollector collector) {
150 start_counter_--;
151 if (start_counter_ != 0) {
152 if (FLAG_trace_gc) {
153 PrintF("[Finished reentrant %s during %s.]\n",
154 collector == SCAVENGER ? "Scavenge" : "Mark-sweep",
155 current_.TypeName(false));
156 }
157 return;
158 }
159
160 DCHECK(start_counter_ >= 0);
161 DCHECK(
162 (collector == SCAVENGER && current_.type == Event::SCAVENGER) ||
163 (collector == MARK_COMPACTOR && current_.type == Event::MARK_COMPACTOR));
164
146 current_.end_time = base::OS::TimeCurrentMillis(); 165 current_.end_time = base::OS::TimeCurrentMillis();
147 current_.end_object_size = heap_->SizeOfObjects(); 166 current_.end_object_size = heap_->SizeOfObjects();
148 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); 167 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size();
149 current_.end_holes_size = CountTotalHolesSize(heap_); 168 current_.end_holes_size = CountTotalHolesSize(heap_);
150 new_space_top_after_gc_ = 169 new_space_top_after_gc_ =
151 reinterpret_cast<intptr_t>(heap_->new_space()->top()); 170 reinterpret_cast<intptr_t>(heap_->new_space()->top());
152 171
153 if (current_.type == Event::SCAVENGER) { 172 if (current_.type == Event::SCAVENGER) {
154 current_.incremental_marking_steps = 173 current_.incremental_marking_steps =
155 current_.cumulative_incremental_marking_steps - 174 current_.cumulative_incremental_marking_steps -
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 context_disposal_events_.begin(); 517 context_disposal_events_.begin();
499 while (iter != context_disposal_events_.end()) { 518 while (iter != context_disposal_events_.end()) {
500 end = iter->time_; 519 end = iter->time_;
501 ++iter; 520 ++iter;
502 } 521 }
503 522
504 return (begin - end) / context_disposal_events_.size(); 523 return (begin - end) / context_disposal_events_.size();
505 } 524 }
506 } 525 }
507 } // namespace v8::internal 526 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/gc-tracer.h ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698