Commit c4368765 authored by hpayer's avatar hpayer Committed by Commit bot

Make GCTracer not reentrant.

BUG=

Review URL: https://codereview.chromium.org/754023003

Cr-Commit-Position: refs/heads/master@{#25524}
parent 2bd931e6
...@@ -93,7 +93,8 @@ GCTracer::GCTracer(Heap* heap) ...@@ -93,7 +93,8 @@ GCTracer::GCTracer(Heap* heap)
longest_incremental_marking_step_(0.0), longest_incremental_marking_step_(0.0),
cumulative_marking_duration_(0.0), cumulative_marking_duration_(0.0),
cumulative_sweeping_duration_(0.0), cumulative_sweeping_duration_(0.0),
new_space_top_after_gc_(0) { new_space_top_after_gc_(0),
start_counter_(0) {
current_ = Event(Event::START, NULL, NULL); current_ = Event(Event::START, NULL, NULL);
current_.end_time = base::OS::TimeCurrentMillis(); current_.end_time = base::OS::TimeCurrentMillis();
previous_ = previous_mark_compactor_event_ = current_; previous_ = previous_mark_compactor_event_ = current_;
...@@ -102,6 +103,9 @@ GCTracer::GCTracer(Heap* heap) ...@@ -102,6 +103,9 @@ GCTracer::GCTracer(Heap* heap)
void GCTracer::Start(GarbageCollector collector, const char* gc_reason, void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
const char* collector_reason) { const char* collector_reason) {
start_counter_++;
if (start_counter_ != 1) return;
previous_ = current_; previous_ = current_;
double start_time = base::OS::TimeCurrentMillis(); double start_time = base::OS::TimeCurrentMillis();
if (new_space_top_after_gc_ != 0) { if (new_space_top_after_gc_ != 0) {
...@@ -142,7 +146,22 @@ void GCTracer::Start(GarbageCollector collector, const char* gc_reason, ...@@ -142,7 +146,22 @@ void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
} }
void GCTracer::Stop() { void GCTracer::Stop(GarbageCollector collector) {
start_counter_--;
if (start_counter_ != 0) {
if (FLAG_trace_gc) {
PrintF("[Finished reentrant %s during %s.]\n",
collector == SCAVENGER ? "Scavenge" : "Mark-sweep",
current_.TypeName(false));
}
return;
}
DCHECK(start_counter_ >= 0);
DCHECK(
(collector == SCAVENGER && current_.type == Event::SCAVENGER) ||
(collector == MARK_COMPACTOR && current_.type == Event::MARK_COMPACTOR));
current_.end_time = base::OS::TimeCurrentMillis(); current_.end_time = base::OS::TimeCurrentMillis();
current_.end_object_size = heap_->SizeOfObjects(); current_.end_object_size = heap_->SizeOfObjects();
current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); current_.end_memory_size = heap_->isolate()->memory_allocator()->Size();
......
...@@ -264,7 +264,7 @@ class GCTracer { ...@@ -264,7 +264,7 @@ class GCTracer {
const char* collector_reason); const char* collector_reason);
// Stop collecting data and print results. // Stop collecting data and print results.
void Stop(); void Stop(GarbageCollector collector);
// Log an allocation throughput event. // Log an allocation throughput event.
void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes); void AddNewSpaceAllocationTime(double duration, intptr_t allocation_in_bytes);
...@@ -419,6 +419,9 @@ class GCTracer { ...@@ -419,6 +419,9 @@ class GCTracer {
// collection. // collection.
intptr_t new_space_top_after_gc_; intptr_t new_space_top_after_gc_;
// Counts how many tracers were started without stopping.
int start_counter_;
DISALLOW_COPY_AND_ASSIGN(GCTracer); DISALLOW_COPY_AND_ASSIGN(GCTracer);
}; };
} }
......
...@@ -844,7 +844,7 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason, ...@@ -844,7 +844,7 @@ bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason,
} }
GarbageCollectionEpilogue(); GarbageCollectionEpilogue();
tracer()->Stop(); tracer()->Stop(collector);
} }
// Start incremental marking for the next cycle. The heap snapshot // Start incremental marking for the next cycle. The heap snapshot
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment