Revision: 15294
Author:   [email protected]
Date:     Mon Jun 24 06:37:46 2013
Log:      Add phase zone to CompilationInfo and use it in GVN pass.

The phase_zone of CompilationInfo is intended for local allocations that
are freed at the end of the phase.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/17573003
http://code.google.com/p/v8/source/detail?r=15294

Modified:
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/compiler.h
 /branches/bleeding_edge/src/hydrogen-gvn.cc
 /branches/bleeding_edge/src/hydrogen-gvn.h
 /branches/bleeding_edge/src/hydrogen.cc

=======================================
--- /branches/bleeding_edge/src/compiler.cc     Mon Jun 24 06:25:44 2013
+++ /branches/bleeding_edge/src/compiler.cc     Mon Jun 24 06:37:46 2013
@@ -53,46 +53,56 @@
 namespace internal {


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


 CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
-                                 Zone* zone)
+                                 Zone* zone,
+                                 Zone* phase_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);
+  Initialize(script_->GetIsolate(), BASE, zone, phase_zone);
 }


-CompilationInfo::CompilationInfo(Handle<JSFunction> closure, Zone* zone)
+CompilationInfo::CompilationInfo(Handle<JSFunction> closure,
+                                 Zone* zone,
+                                 Zone* phase_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);
+  Initialize(script_->GetIsolate(), BASE, zone, phase_zone);
 }


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


-void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) {
+void CompilationInfo::Initialize(Isolate* isolate,
+                                 Mode mode,
+                                 Zone* zone,
+                                 Zone* phase_zone) {
   isolate_ = isolate;
   function_ = NULL;
   scope_ = NULL;
@@ -100,6 +110,7 @@
   extension_ = NULL;
   pre_parse_data_ = NULL;
   zone_ = zone;
+  phase_zone_ = phase_zone;
   deferred_handles_ = NULL;
   code_stub_ = NULL;
   prologue_offset_ = kPrologueOffsetNotSet;
=======================================
--- /branches/bleeding_edge/src/compiler.h      Wed Jun 12 02:43:22 2013
+++ /branches/bleeding_edge/src/compiler.h      Mon Jun 24 06:37:46 2013
@@ -57,7 +57,7 @@
 // is constructed based on the resources available at compile-time.
 class CompilationInfo {
  public:
-  CompilationInfo(Handle<JSFunction> closure, Zone* zone);
+ CompilationInfo(Handle<JSFunction> closure, Zone* zone, Zone* phase_zone);
   virtual ~CompilationInfo();

   Isolate* isolate() {
@@ -65,6 +65,7 @@
     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_); }
@@ -300,9 +301,16 @@
   }

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

  private:
   Isolate* isolate_;
@@ -320,7 +328,7 @@
     DEPENDENT_MAP_ABORT
   };

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

   void SetMode(Mode mode) {
     ASSERT(V8::UseCrankshaft());
@@ -394,6 +402,9 @@
   // 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_;

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

   // Virtual destructor because a CompilationInfoWithZone has to exit the
   // zone scope and get rid of dependent maps even when the destructor is
@@ -454,6 +469,7 @@
  private:
   Zone zone_;
   ZoneScope zone_scope_;
+  Zone phase_zone_;
 };


=======================================
--- /branches/bleeding_edge/src/hydrogen-gvn.cc Mon Jun  3 08:32:22 2013
+++ /branches/bleeding_edge/src/hydrogen-gvn.cc Mon Jun 24 06:37:46 2013
@@ -365,14 +365,16 @@
       : graph_(graph),
         info_(info),
         removed_side_effects_(false),
-        block_side_effects_(graph->blocks()->length(), graph->zone()),
-        loop_side_effects_(graph->blocks()->length(), graph->zone()),
-        visited_on_paths_(graph->zone(), graph->blocks()->length()) {
+        phase_zone_(info->phase_zone()),
+        phase_zone_scope_(phase_zone_, DELETE_ON_EXIT),
+        block_side_effects_(graph->blocks()->length(), phase_zone_),
+        loop_side_effects_(graph->blocks()->length(), phase_zone_),
+        visited_on_paths_(phase_zone_, graph->blocks()->length()) {
     ASSERT(!AllowHandleAllocation::IsAllowed());
     block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
-                                 graph_->zone());
+                                 phase_zone_);
     loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
-                                graph_->zone());
+                                phase_zone_);
   }

 bool HGlobalValueNumberer::Analyze() {
@@ -756,9 +758,9 @@
 // GvnBasicBlockState instances.
 void HGlobalValueNumberer::AnalyzeGraph() {
   HBasicBlock* entry_block = graph_->entry_block();
-  HValueMap* entry_map = new(zone()) HValueMap(zone());
+  HValueMap* entry_map = new(phase_zone()) HValueMap(phase_zone());
   GvnBasicBlockState* current =
-      GvnBasicBlockState::CreateEntry(zone(), entry_block, entry_map);
+ GvnBasicBlockState::CreateEntry(phase_zone(), entry_block, entry_map);

   while (current != NULL) {
     HBasicBlock* block = current->block();
@@ -800,7 +802,7 @@
           if (instr->HasSideEffects()) removed_side_effects_ = true;
           instr->DeleteAndReplaceWith(other);
         } else {
-          map->Add(instr, zone());
+          map->Add(instr, phase_zone());
         }
       }
       if (instr->IsLinked() &&
@@ -826,7 +828,8 @@

     HBasicBlock* dominator_block;
     GvnBasicBlockState* next =
- current->next_in_dominator_tree_traversal(zone(), &dominator_block);
+        current->next_in_dominator_tree_traversal(phase_zone(),
+                                                  &dominator_block);

     if (next != NULL) {
       HBasicBlock* dominated = next->block();
=======================================
--- /branches/bleeding_edge/src/hydrogen-gvn.h  Mon May 27 05:45:46 2013
+++ /branches/bleeding_edge/src/hydrogen-gvn.h  Mon Jun 24 06:37:46 2013
@@ -100,12 +100,15 @@

   HGraph* graph() { return graph_; }
   CompilationInfo* info() { return info_; }
-  Zone* zone() const { return graph_->zone(); }
+  Zone* phase_zone() const { return info_->phase_zone(); }

   HGraph* graph_;
   CompilationInfo* info_;
   bool removed_side_effects_;

+  Zone* phase_zone_;
+  ZoneScope phase_zone_scope_;
+
   // A map of block IDs to their side effects.
   ZoneList<GVNFlagSet> block_side_effects_;

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Mon Jun 24 06:25:44 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Mon Jun 24 06:37:46 2013
@@ -7938,7 +7938,7 @@
   }

   // Parse and allocate variables.
-  CompilationInfo target_info(target, zone());
+ CompilationInfo target_info(target, zone(), current_info()->phase_zone());
   Handle<SharedFunctionInfo> target_shared(target->shared());
   if (!Parser::Parse(&target_info) || !Scope::Analyze(&target_info)) {
     if (target_info.isolate()->has_pending_exception()) {

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