[heap] Hide GCTracer inside the heap component.
authormstarzinger <mstarzinger@chromium.org>
Thu, 20 Aug 2015 15:47:59 +0000 (08:47 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 20 Aug 2015 15:48:12 +0000 (15:48 +0000)
This prevents leakage of the gc-tracer.h declarations inside of the
heap and prevents it from being exposed to the world. Protects private
state from being inadvertently mocked with.

R=mlippautz@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30276}

src/heap/heap.cc
src/heap/heap.h
src/heap/incremental-marking.cc
src/heap/mark-compact.cc
src/heap/memory-reducer.cc
test/cctest/test-gc-tracer.cc
test/cctest/test-heap.cc

index 1586a00..467a220 100644 (file)
@@ -18,6 +18,7 @@
 #include "src/deoptimizer.h"
 #include "src/global-handles.h"
 #include "src/heap/gc-idle-time-handler.h"
+#include "src/heap/gc-tracer.h"
 #include "src/heap/incremental-marking.h"
 #include "src/heap/mark-compact-inl.h"
 #include "src/heap/mark-compact.h"
@@ -97,7 +98,7 @@ Heap::Heap()
       inline_allocation_disabled_(false),
       store_buffer_rebuilder_(store_buffer()),
       total_regexp_code_generated_(0),
-      tracer_(this),
+      tracer_(nullptr),
       high_survival_rate_period_length_(0),
       promoted_objects_size_(0),
       promotion_ratio_(0),
@@ -5806,6 +5807,7 @@ bool Heap::SetUp() {
     deferred_counters_[i] = 0;
   }
 
+  tracer_ = new GCTracer(this);
 
   LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
   LOG(isolate_, IntPtrTEvent("heap-available", Available()));
@@ -5878,8 +5880,9 @@ void Heap::TearDown() {
     PrintF("total_gc_time=%.1f ", total_gc_time_ms_);
     PrintF("min_in_mutator=%.1f ", get_min_in_mutator());
     PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", get_max_alive_after_gc());
-    PrintF("total_marking_time=%.1f ", tracer_.cumulative_marking_duration());
-    PrintF("total_sweeping_time=%.1f ", tracer_.cumulative_sweeping_duration());
+    PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration());
+    PrintF("total_sweeping_time=%.1f ",
+           tracer()->cumulative_sweeping_duration());
     PrintF("\n\n");
   }
 
@@ -5914,6 +5917,9 @@ void Heap::TearDown() {
 
   mark_compact_collector()->TearDown();
 
+  delete tracer_;
+  tracer_ = nullptr;
+
   new_space_.TearDown();
 
   if (old_space_ != NULL) {
index a4268e5..6791ecf 100644 (file)
@@ -12,7 +12,6 @@
 #include "src/assert-scope.h"
 #include "src/globals.h"
 #include "src/heap/gc-idle-time-handler.h"
-#include "src/heap/gc-tracer.h"
 #include "src/heap/incremental-marking.h"
 #include "src/heap/mark-compact.h"
 #include "src/heap/memory-reducer.h"
@@ -1344,7 +1343,7 @@ class Heap {
 
   void ClearNormalizedMapCaches();
 
-  GCTracer* tracer() { return &tracer_; }
+  GCTracer* tracer() { return tracer_; }
 
   // Returns the size of objects residing in non new spaces.
   intptr_t PromotedSpaceSizeOfObjects();
@@ -2098,7 +2097,7 @@ class Heap {
 
   int deferred_counters_[v8::Isolate::kUseCounterFeatureCount];
 
-  GCTracer tracer_;
+  GCTracer* tracer_;
 
   // Creates and installs the full-sized number string cache.
   int FullSizeNumberStringCacheLength();
index 544ee74..c7b3eac 100644 (file)
@@ -7,6 +7,7 @@
 #include "src/code-stubs.h"
 #include "src/compilation-cache.h"
 #include "src/conversions.h"
+#include "src/heap/gc-tracer.h"
 #include "src/heap/mark-compact-inl.h"
 #include "src/heap/objects-visiting.h"
 #include "src/heap/objects-visiting-inl.h"
index ab00782..de37ecb 100644 (file)
@@ -14,6 +14,7 @@
 #include "src/frames-inl.h"
 #include "src/gdb-jit.h"
 #include "src/global-handles.h"
+#include "src/heap/gc-tracer.h"
 #include "src/heap/incremental-marking.h"
 #include "src/heap/mark-compact-inl.h"
 #include "src/heap/objects-visiting.h"
index 3f2862d..f3c1473 100644 (file)
@@ -5,6 +5,7 @@
 #include "src/heap/memory-reducer.h"
 
 #include "src/flags.h"
+#include "src/heap/gc-tracer.h"
 #include "src/heap/heap.h"
 #include "src/objects-inl.h"  // TODO(mstarzinger): Temporary cycle breaker!
 #include "src/utils.h"
index 190644d..1289ec5 100644 (file)
@@ -28,8 +28,7 @@
 #include <stdlib.h>
 #include <utility>
 
-#include "src/v8.h"
-
+#include "src/heap/gc-tracer.h"
 #include "test/cctest/cctest.h"
 
 using namespace v8::internal;
index 1c09752..e5533b6 100644 (file)
 #include <stdlib.h>
 #include <utility>
 
-#include "src/v8.h"
-
 #include "src/compilation-cache.h"
 #include "src/context-measure.h"
 #include "src/deoptimizer.h"
 #include "src/execution.h"
 #include "src/factory.h"
 #include "src/global-handles.h"
+#include "src/heap/gc-tracer.h"
 #include "src/ic/ic.h"
 #include "src/macro-assembler.h"
 #include "src/snapshot/snapshot.h"