Reviewers: Yang,

Description:
Make Zone::allocation_size work with parallel zones.

[email protected]

Please review this at https://codereview.chromium.org/16858018/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/compiler.cc
  M src/hydrogen.h
  M src/hydrogen.cc
  M src/zone.h
  M src/zone.cc


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 7b0b92152931dc3da1e9036cc585b631de054c5c..cfdec8ffb9915b45dce9439c8c1880c52d17ce61 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -367,7 +367,7 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() {
   // performance of the hydrogen-based compiler.
bool should_recompile = !info()->shared_info()->has_deoptimization_support();
   if (should_recompile || FLAG_hydrogen_stats) {
-    HPhase phase(HPhase::kFullCodeGen, isolate());
+    HPhase phase(HPhase::kFullCodeGen, isolate(), info()->zone());
     CompilationInfoWithZone unoptimized(info()->shared_info());
     // Note that we use the same AST that we will use for generating the
     // optimized code.
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index f9adf49b8ff2920b22553400f554f963d39fa6ab..16aa5e8acc22f31c3dc6488f01e99b58cdd1bc7c 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -963,7 +963,7 @@ void HGraphBuilder::LoopBuilder::EndBody() {
 HGraph* HGraphBuilder::CreateGraph() {
   graph_ = new(zone()) HGraph(info_);
   if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_);
-  HPhase phase("H_Block building", isolate());
+  HPhase phase("H_Block building", isolate(), zone());
   set_current_block(graph()->entry_block());
   if (!BuildGraph()) return NULL;
   graph()->FinalizeUniqueValueIds();
@@ -2384,7 +2384,7 @@ class PostorderProcessor : public ZoneObject {


 void HGraph::OrderBlocks() {
-  HPhase phase("H_Block ordering", isolate());
+  HPhase phase("H_Block ordering", isolate(), zone());
   BitVector visited(blocks_.length(), zone());

   ZoneList<HBasicBlock*> reverse_result(8, zone());
@@ -11575,33 +11575,35 @@ void HStatistics::SaveTiming(const char* name, int64_t ticks, unsigned size) {
 const char* const HPhase::kFullCodeGen = "Full code generator";


-HPhase::HPhase(const char* name, Isolate* isolate) {
-  Init(isolate, name, NULL, NULL, NULL);
+HPhase::HPhase(const char* name, Isolate* isolate, Zone* zone) {
+  Init(isolate, name, zone, NULL, NULL, NULL);
 }


 HPhase::HPhase(const char* name, HGraph* graph) {
-  Init(graph->isolate(), name, graph, NULL, NULL);
+  Init(graph->isolate(), name, graph->zone(), graph, NULL, NULL);
 }


 HPhase::HPhase(const char* name, LChunk* chunk) {
-  Init(chunk->isolate(), name, NULL, chunk, NULL);
+  Init(chunk->isolate(), name, chunk->zone(), NULL, chunk, NULL);
 }


 HPhase::HPhase(const char* name, LAllocator* allocator) {
-  Init(allocator->isolate(), name, NULL, NULL, allocator);
+ Init(allocator->isolate(), name, allocator->zone(), NULL, NULL, allocator);
 }


 void HPhase::Init(Isolate* isolate,
                   const char* name,
+                  Zone* zone,
                   HGraph* graph,
                   LChunk* chunk,
                   LAllocator* allocator) {
   isolate_ = isolate;
   name_ = name;
+  zone_ = zone;
   graph_ = graph;
   chunk_ = chunk;
   allocator_ = allocator;
@@ -11610,7 +11612,7 @@ void HPhase::Init(Isolate* isolate,
   }
   if (FLAG_hydrogen_stats) {
     start_ticks_ = OS::Ticks();
-    start_allocation_size_ = Zone::allocation_size_;
+    start_allocation_size_ = zone_->allocation_size();
   }
 }

@@ -11618,7 +11620,7 @@ void HPhase::Init(Isolate* isolate,
 HPhase::~HPhase() {
   if (FLAG_hydrogen_stats) {
     int64_t ticks = OS::Ticks() - start_ticks_;
-    unsigned size = Zone::allocation_size_ - start_allocation_size_;
+    unsigned size = zone_->allocation_size() - start_allocation_size_;
     isolate_->GetHStatistics()->SaveTiming(name_, ticks, size);
   }

Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 73b905a7f9c837758073c4c16a08c7950de6d21c..aa360594c30910387d2e8314379c6a97349cfcec 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -1935,7 +1935,7 @@ class HPhase BASE_EMBEDDED {
  public:
   static const char* const kFullCodeGen;

-  HPhase(const char* name, Isolate* isolate);
+  HPhase(const char* name, Isolate* isolate, Zone* zone);
   HPhase(const char* name, HGraph* graph);
   HPhase(const char* name, LChunk* chunk);
   HPhase(const char* name, LAllocator* allocator);
@@ -1944,12 +1944,14 @@ class HPhase BASE_EMBEDDED {
  private:
   void Init(Isolate* isolate,
             const char* name,
+            Zone* zone,
             HGraph* graph,
             LChunk* chunk,
             LAllocator* allocator);

   Isolate* isolate_;
   const char* name_;
+  Zone* zone_;
   HGraph* graph_;
   LChunk* chunk_;
   LAllocator* allocator_;
Index: src/zone.cc
diff --git a/src/zone.cc b/src/zone.cc
index 51b8113a0d912e78b67213145c07664bad4d8d0c..d3f1c6fce52d0b00e9feb86c0c253b5564937c51 100644
--- a/src/zone.cc
+++ b/src/zone.cc
@@ -69,6 +69,7 @@ class Segment {

 Zone::Zone(Isolate* isolate)
     : zone_excess_limit_(256 * MB),
+      allocation_size_(0),
       segment_bytes_allocated_(0),
       position_(0),
       limit_(0),
@@ -76,7 +77,7 @@ Zone::Zone(Isolate* isolate)
       segment_head_(NULL),
       isolate_(isolate) {
 }
-unsigned Zone::allocation_size_ = 0;
+

 ZoneScope::~ZoneScope() {
   if (ShouldDeleteOnExit()) zone_->DeleteAll();
Index: src/zone.h
diff --git a/src/zone.h b/src/zone.h
index 01e887e779d70377db2c8a80e653e94b53d7f2e9..6d94754e4b47b3212dee5ec215cf186d9e2bcef6 100644
--- a/src/zone.h
+++ b/src/zone.h
@@ -86,9 +86,9 @@ class Zone {

   inline void adjust_segment_bytes_allocated(int delta);

-  inline Isolate* isolate() { return isolate_; }
+  inline unsigned allocation_size() { return allocation_size_; }

-  static unsigned allocation_size_;
+  inline Isolate* isolate() { return isolate_; }

  private:
   friend class Isolate;
@@ -111,6 +111,9 @@ class Zone {
   // Report zone excess when allocation exceeds this limit.
   int zone_excess_limit_;

+  // The number of bytes allocated in this zone so far.
+  unsigned allocation_size_;
+
   // The number of bytes allocated in segments.  Note that this number
   // includes memory allocated from the OS but not yet allocated from
   // the zone.


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to