Reviewers: danno,

Description:
Move phase_zone from CompilationInfo to CompilationPhase.

Each CompilationPhase has its own zone, used for phase local
allocations. The zone of CompilationInfo should only be used
for non phase local allocations.

[email protected]
BUG=

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

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

Affected files:
  M src/compiler.h
  M src/compiler.cc
  M src/hydrogen.h
  M src/hydrogen.cc
  M src/lithium-allocator.h
  M src/lithium.h


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 895c31c63c41da3df4496ef73645f3b0ff3f9bf0..3da686aad11b6a5a6bf1ff3b571f1fce323beb39 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -54,55 +54,50 @@ namespace internal {


 CompilationInfo::CompilationInfo(Handle<Script> script,
-                                 Zone* zone,
-                                 Zone* phase_zone)
+                                 Zone* zone)
     : flags_(LanguageModeField::encode(CLASSIC_MODE)),
       script_(script),
       osr_ast_id_(BailoutId::None()) {
-  Initialize(script->GetIsolate(), BASE, zone, phase_zone);
+  Initialize(script->GetIsolate(), BASE, zone);
 }


 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
-                                 Zone* zone,
-                                 Zone* phase_zone)
+                                 Zone* zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
       shared_info_(shared_info),
       script_(Handle<Script>(Script::cast(shared_info->script()))),
       osr_ast_id_(BailoutId::None()) {
-  Initialize(script_->GetIsolate(), BASE, zone, phase_zone);
+  Initialize(script_->GetIsolate(), BASE, zone);
 }


 CompilationInfo::CompilationInfo(Handle<JSFunction> closure,
-                                 Zone* zone,
-                                 Zone* phase_zone)
+                                 Zone* zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
       closure_(closure),
       shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
       script_(Handle<Script>(Script::cast(shared_info_->script()))),
       context_(closure->context()),
       osr_ast_id_(BailoutId::None()) {
-  Initialize(script_->GetIsolate(), BASE, zone, phase_zone);
+  Initialize(script_->GetIsolate(), BASE, zone);
 }


 CompilationInfo::CompilationInfo(HydrogenCodeStub* stub,
                                  Isolate* isolate,
-                                 Zone* zone,
-                                 Zone* phase_zone)
+                                 Zone* zone)
     : flags_(LanguageModeField::encode(CLASSIC_MODE) |
              IsLazy::encode(true)),
       osr_ast_id_(BailoutId::None()) {
-  Initialize(isolate, STUB, zone, phase_zone);
+  Initialize(isolate, STUB, zone);
   code_stub_ = stub;
 }


 void CompilationInfo::Initialize(Isolate* isolate,
                                  Mode mode,
-                                 Zone* zone,
-                                 Zone* phase_zone) {
+                                 Zone* zone) {
   isolate_ = isolate;
   function_ = NULL;
   scope_ = NULL;
@@ -110,7 +105,6 @@ void CompilationInfo::Initialize(Isolate* isolate,
   extension_ = NULL;
   pre_parse_data_ = NULL;
   zone_ = zone;
-  phase_zone_ = phase_zone;
   deferred_handles_ = NULL;
   code_stub_ = NULL;
   prologue_offset_ = kPrologueOffsetNotSet;
@@ -1228,12 +1222,10 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
 }


-CompilationPhase::CompilationPhase(const char* name,
-                                   Isolate* isolate,
-                                   Zone* zone)
-    : name_(name), isolate_(isolate), zone_(zone) {
+CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info)
+    : name_(name), info_(info), zone_(info->isolate()) {
   if (FLAG_hydrogen_stats) {
-    start_allocation_size_ = zone->allocation_size();
+    info_zone_start_allocation_size_ = info->zone()->allocation_size();
     start_ticks_ = OS::Ticks();
   }
 }
@@ -1241,9 +1233,10 @@ CompilationPhase::CompilationPhase(const char* name,

 CompilationPhase::~CompilationPhase() {
   if (FLAG_hydrogen_stats) {
-    unsigned size = zone()->allocation_size() - start_allocation_size_;
+    unsigned size = zone()->allocation_size();
+ size += info_->zone()->allocation_size() - info_zone_start_allocation_size_;
     int64_t ticks = OS::Ticks() - start_ticks_;
-    isolate_->GetHStatistics()->SaveTiming(name_, ticks, size);
+    isolate()->GetHStatistics()->SaveTiming(name_, ticks, size);
   }
 }

Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index 2f47dceba3d673306d785dde400e9d40c5c9ac6a..390a1d8d1abe47e79d040643bc2389af5b218470 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -57,7 +57,7 @@ struct OffsetRange {
 // is constructed based on the resources available at compile-time.
 class CompilationInfo {
  public:
- CompilationInfo(Handle<JSFunction> closure, Zone* zone, Zone* phase_zone);
+  CompilationInfo(Handle<JSFunction> closure, Zone* zone);
   virtual ~CompilationInfo();

   Isolate* isolate() {
@@ -65,7 +65,6 @@ class CompilationInfo {
     return isolate_;
   }
   Zone* zone() { return zone_; }
-  Zone* phase_zone() { return phase_zone_; }
   bool is_lazy() const { return IsLazy::decode(flags_); }
   bool is_eval() const { return IsEval::decode(flags_); }
   bool is_global() const { return IsGlobal::decode(flags_); }
@@ -303,15 +302,12 @@ class CompilationInfo {

  protected:
   CompilationInfo(Handle<Script> script,
-                  Zone* zone,
-                  Zone* phase_zone);
+                  Zone* zone);
   CompilationInfo(Handle<SharedFunctionInfo> shared_info,
-                  Zone* zone,
-                  Zone* phase_zone);
+                  Zone* zone);
   CompilationInfo(HydrogenCodeStub* stub,
                   Isolate* isolate,
-                  Zone* zone,
-                  Zone* phase_zone);
+                  Zone* zone);

  private:
   Isolate* isolate_;
@@ -329,7 +325,7 @@ class CompilationInfo {
     DEPENDENCY_CHANGE_ABORT
   };

- void Initialize(Isolate* isolate, Mode mode, Zone* zone, Zone* phase_zone);
+  void Initialize(Isolate* isolate, Mode mode, Zone* zone);

   void SetMode(Mode mode) {
     ASSERT(V8::UseCrankshaft());
@@ -403,9 +399,6 @@ class CompilationInfo {
   // The zone from which the compilation pipeline working on this
   // CompilationInfo allocates.
   Zone* zone_;
-  // The phase zone where allocations local to a specific phase are
-  // performed; be aware that this zone is cleared after each phase
-  Zone* phase_zone_;

   DeferredHandles* deferred_handles_;

@@ -440,21 +433,17 @@ class CompilationInfo {
 class CompilationInfoWithZone: public CompilationInfo {
  public:
   explicit CompilationInfoWithZone(Handle<Script> script)
-      : CompilationInfo(script, &zone_, &phase_zone_),
-        zone_(script->GetIsolate()),
-        phase_zone_(script->GetIsolate()) {}
+      : CompilationInfo(script, &zone_),
+        zone_(script->GetIsolate()) {}
   explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
-      : CompilationInfo(shared_info, &zone_, &phase_zone_),
-        zone_(shared_info->GetIsolate()),
-        phase_zone_(shared_info->GetIsolate()) {}
+      : CompilationInfo(shared_info, &zone_),
+        zone_(shared_info->GetIsolate()) {}
   explicit CompilationInfoWithZone(Handle<JSFunction> closure)
-      : CompilationInfo(closure, &zone_, &phase_zone_),
-        zone_(closure->GetIsolate()),
-        phase_zone_(closure->GetIsolate()) {}
+      : CompilationInfo(closure, &zone_),
+        zone_(closure->GetIsolate()) {}
   CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
-      : CompilationInfo(stub, isolate, &zone_, &phase_zone_),
-        zone_(isolate),
-        phase_zone_(isolate) {}
+      : CompilationInfo(stub, isolate, &zone_),
+        zone_(isolate) {}

   // Virtual destructor because a CompilationInfoWithZone has to exit the
   // zone scope and get rid of dependent maps even when the destructor is
@@ -465,7 +454,6 @@ class CompilationInfoWithZone: public CompilationInfo {

  private:
   Zone zone_;
-  Zone phase_zone_;
 };


@@ -631,21 +619,21 @@ class Compiler : public AllStatic {

 class CompilationPhase BASE_EMBEDDED {
  public:
-  CompilationPhase(const char* name, Isolate* isolate, Zone* zone);
+  CompilationPhase(const char* name, CompilationInfo* info);
   ~CompilationPhase();

  protected:
   bool ShouldProduceTraceOutput() const;

   const char* name() const { return name_; }
-  Isolate* isolate() const { return isolate_; }
-  Zone* zone() const { return zone_; }
+  Isolate* isolate() const { return info_->isolate(); }
+  Zone* zone() { return &zone_; }

  private:
   const char* name_;
-  Isolate* isolate_;
-  Zone* zone_;
-  unsigned start_allocation_size_;
+  CompilationInfo* info_;
+  Zone zone_;
+  unsigned info_zone_start_allocation_size_;
   int64_t start_ticks_;

   DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index e96b51cd7420d3c5313fb3c6d32ae12b8b0797aa..10d78bc964ce72e0f3de10883f9ef266456ea21c 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_);
-  CompilationPhase phase("H_Block building", isolate(), zone());
+  CompilationPhase phase("H_Block building", info_);
   set_current_block(graph()->entry_block());
   if (!BuildGraph()) return NULL;
   graph()->FinalizeUniqueValueIds();
@@ -2384,7 +2384,7 @@ class PostorderProcessor : public ZoneObject {


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

   ZoneList<HBasicBlock*> reverse_result(8, zone());
@@ -7932,7 +7932,7 @@ bool HOptimizedGraphBuilder::TryInline(CallKind call_kind,
   }

   // Parse and allocate variables.
- CompilationInfo target_info(target, zone(), current_info()->phase_zone());
+  CompilationInfo target_info(target, zone());
   Handle<SharedFunctionInfo> target_shared(target->shared());
   if (!Parser::Parse(&target_info) || !Scope::Analyze(&target_info)) {
     if (target_info.isolate()->has_pending_exception()) {
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index f9aaf68ea2a26a0fc29431022726d249f6d30b07..a88b67f01bbabed8dc02861ca4cab949cadea902 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -1958,7 +1958,7 @@ class HStatistics: public Malloced {
 class HPhase : public CompilationPhase {
  public:
   HPhase(const char* name, HGraph* graph)
-      : CompilationPhase(name, graph->isolate(), graph->zone()),
+      : CompilationPhase(name, graph->info()),
         graph_(graph) { }
   ~HPhase();

Index: src/lithium-allocator.h
diff --git a/src/lithium-allocator.h b/src/lithium-allocator.h
index ce9101d17663a2aa598d97e58a2151c7cf048a04..3f1ce90eb8006e0c313b8199de90580d6a456a14 100644
--- a/src/lithium-allocator.h
+++ b/src/lithium-allocator.h
@@ -648,7 +648,7 @@ class LAllocator BASE_EMBEDDED {
 class LAllocatorPhase : public CompilationPhase {
  public:
   LAllocatorPhase(const char* name, LAllocator* allocator)
-      : CompilationPhase(name, allocator->isolate(), allocator->zone()),
+      : CompilationPhase(name, allocator->graph()->info()),
         allocator_(allocator) { }
   ~LAllocatorPhase();

Index: src/lithium.h
diff --git a/src/lithium.h b/src/lithium.h
index 1f31b9091589bbb717842e00a608b7dc78fe742a..1e0784eb98da891e9cde48919d91706cce13ac39 100644
--- a/src/lithium.h
+++ b/src/lithium.h
@@ -762,7 +762,7 @@ enum NumberUntagDMode {
 class LPhase : public CompilationPhase {
  public:
   LPhase(const char* name, LChunk* chunk)
-      : CompilationPhase(name, chunk->isolate(), chunk->zone()),
+      : CompilationPhase(name, chunk->info()),
         chunk_(chunk) { }
   ~LPhase();



--
--
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