Revision: 13835
Author:   [email protected]
Date:     Wed Mar  6 02:49:34 2013
Log:      Track Hydrogen statistics on a per-Isolate basis

This is basically the same fix as the one for --trace-hydrogen, but now for
--hydrogen-stats. Removed a few train wrecks on the way.

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

Modified:
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/hydrogen-instructions.cc
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/hydrogen.h
 /branches/bleeding_edge/src/isolate.cc
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/lithium-allocator.h
 /branches/bleeding_edge/src/lithium.h

=======================================
--- /branches/bleeding_edge/src/compiler.cc     Tue Mar  5 23:25:46 2013
+++ /branches/bleeding_edge/src/compiler.cc     Wed Mar  6 02:49:34 2013
@@ -234,9 +234,9 @@
            compilation_time);
   }
   if (FLAG_hydrogen_stats) {
- HStatistics::Instance()->IncrementSubtotals(time_taken_to_create_graph_,
-                                                time_taken_to_optimize_,
-                                                time_taken_to_codegen_);
+ isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_create_graph_, + time_taken_to_optimize_, + time_taken_to_codegen_);
   }
 }

=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Mar 5 06:11:56 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.cc Wed Mar 6 02:49:34 2013
@@ -78,7 +78,7 @@

 Isolate* HValue::isolate() const {
   ASSERT(block() != NULL);
-  return block()->graph()->isolate();
+  return block()->isolate();
 }


=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Tue Mar  5 23:25:46 2013
+++ /branches/bleeding_edge/src/hydrogen.cc     Wed Mar  6 02:49:34 2013
@@ -73,6 +73,11 @@
       is_deoptimizing_(false),
       dominates_loop_successors_(false),
       is_osr_entry_(false) { }
+
+
+Isolate* HBasicBlock::isolate() const {
+  return graph_->isolate();
+}


 void HBasicBlock::AttachLoopInformation() {
@@ -829,8 +834,8 @@

 HGraph* HGraphBuilder::CreateGraph() {
   graph_ = new(zone()) HGraph(info_);
-  if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info_);
-  HPhase phase("H_Block building", graph()->isolate());
+  if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_);
+  HPhase phase("H_Block building", isolate());
   set_current_block(graph()->entry_block());
   if (!BuildGraph()) return NULL;
   return graph_;
@@ -1001,7 +1006,7 @@
       AddInstruction(new(zone) HLoadElements(object, mapcheck));
   if (is_store && (fast_elements || fast_smi_only_elements)) {
     HCheckMaps* check_cow_map = new(zone) HCheckMaps(
-        elements, graph()->isolate()->factory()->fixed_array_map(), zone);
+        elements, isolate()->factory()->fixed_array_map(), zone);
     check_cow_map->ClearGVNFlag(kDependsOnElementsKind);
     AddInstruction(check_cow_map);
   }
@@ -1066,16 +1071,14 @@
   HValue* elements =
       AddInstruction(new(zone) HAllocate(context, total_size,
                                          HType::JSArray(), flags));
-  Isolate* isolate = graph()->isolate();

-  Factory* factory = isolate->factory();
+  Factory* factory = isolate()->factory();
   Handle<Map> map = IsFastDoubleElementsKind(kind)
       ? factory->fixed_double_array_map()
       : factory->fixed_array_map();
   BuildStoreMap(elements, map, BailoutId::StubEntry());

-  Handle<String> fixed_array_length_field_name =
-      isolate->factory()->length_field_string();
+ Handle<String> fixed_array_length_field_name = factory->length_field_string();
   HInstruction* store_length =
       new(zone) HStoreNamedField(elements, fixed_array_length_field_name,
capacity, true, FixedArray::kLengthOffset);
@@ -1090,8 +1093,7 @@
                                            HValue* map,
                                            BailoutId id) {
   Zone* zone = this->zone();
-  Isolate* isolate = graph()->isolate();
-  Factory* factory = isolate->factory();
+  Factory* factory = isolate()->factory();
   Handle<String> map_field_name = factory->map_field_string();
   HInstruction* store_map =
       new(zone) HStoreNamedField(object, map_field_name, map,
@@ -9380,7 +9382,7 @@
     return HandleLiteralCompareTypeof(expr, typeof_expr, check);
   }
   HValue* sub_expr = NULL;
-  Factory* f = graph()->isolate()->factory();
+  Factory* f = isolate()->factory();
if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) {
     return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);
   }
@@ -10511,7 +10513,7 @@


 void HTracer::TraceLithium(const char* name, LChunk* chunk) {
-  AllowHandleDereference allow_handle_deref(chunk->graph()->isolate());
+  AllowHandleDereference allow_handle_deref(chunk->isolate());
   Trace(name, chunk->graph(), chunk);
 }

@@ -10810,12 +10812,12 @@


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


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


@@ -10843,7 +10845,7 @@
   if (FLAG_hydrogen_stats) {
     int64_t ticks = OS::Ticks() - start_ticks_;
     unsigned size = Zone::allocation_size_ - start_allocation_size_;
-    HStatistics::Instance()->SaveTiming(name_, ticks, size);
+    isolate_->GetHStatistics()->SaveTiming(name_, ticks, size);
   }

   // Produce trace output if flag is set so that the first letter of the
=======================================
--- /branches/bleeding_edge/src/hydrogen.h      Tue Mar  5 23:25:46 2013
+++ /branches/bleeding_edge/src/hydrogen.h      Wed Mar  6 02:49:34 2013
@@ -61,6 +61,7 @@
   int block_id() const { return block_id_; }
   void set_block_id(int id) { block_id_ = id; }
   HGraph* graph() const { return graph_; }
+  Isolate* isolate() const;
   const ZoneList<HPhi*>* phis() const { return &phis_; }
   HInstruction* first() const { return first_; }
   HInstruction* last() const { return last_; }
@@ -870,7 +871,8 @@
     return current_block()->last_environment();
   }
   Zone* zone() const { return info_->zone(); }
-  HGraph* graph() { return graph_; }
+  HGraph* graph() const { return graph_; }
+  Isolate* isolate() const { return graph_->isolate(); }

   HGraph* CreateGraph();

@@ -1534,16 +1536,20 @@

 class HStatistics: public Malloced {
  public:
+  HStatistics()
+      : timing_(5),
+        names_(5),
+        sizes_(5),
+        create_graph_(0),
+        optimize_graph_(0),
+        generate_code_(0),
+        total_size_(0),
+        full_code_gen_(0),
+        source_size_(0) { }
+
   void Initialize(CompilationInfo* info);
   void Print();
   void SaveTiming(const char* name, int64_t ticks, unsigned size);
-  static HStatistics* Instance() {
-    static SetOncePointer<HStatistics> instance;
-    if (!instance.is_set()) {
-      instance.set(new HStatistics());
-    }
-    return instance.get();
-  }

   void IncrementSubtotals(int64_t create_graph,
                           int64_t optimize_graph,
@@ -1554,17 +1560,6 @@
   }

  private:
-  HStatistics()
-      : timing_(5),
-        names_(5),
-        sizes_(5),
-        create_graph_(0),
-        optimize_graph_(0),
-        generate_code_(0),
-        total_size_(0),
-        full_code_gen_(0),
-        source_size_(0) { }
-
   List<int64_t> timing_;
   List<const char*> names_;
   List<unsigned> sizes_;
@@ -1589,10 +1584,10 @@

  private:
   void Init(Isolate* isolate,
-             const char* name,
-             HGraph* graph,
-             LChunk* chunk,
-             LAllocator* allocator);
+            const char* name,
+            HGraph* graph,
+            LChunk* chunk,
+            LAllocator* allocator);

   Isolate* isolate_;
   const char* name_;
=======================================
--- /branches/bleeding_edge/src/isolate.cc      Tue Mar  5 23:25:46 2013
+++ /branches/bleeding_edge/src/isolate.cc      Wed Mar  6 02:49:34 2013
@@ -1792,7 +1792,7 @@
       delete[] marking_thread_;
     }

-    if (FLAG_hydrogen_stats) HStatistics::Instance()->Print();
+    if (FLAG_hydrogen_stats) GetHStatistics()->Print();

     // We must stop the logger before we tear down other components.
     logger_->EnsureTickerStopped();
@@ -2316,6 +2316,12 @@
     deferred->previous_->next_ = deferred->next_;
   }
 }
+
+
+HStatistics* Isolate::GetHStatistics() {
+  if (hstatistics() == NULL) set_hstatistics(new HStatistics());
+  return hstatistics();
+}


 HTracer* Isolate::GetHTracer() {
=======================================
--- /branches/bleeding_edge/src/isolate.h       Tue Mar  5 23:25:46 2013
+++ /branches/bleeding_edge/src/isolate.h       Wed Mar  6 02:49:34 2013
@@ -68,6 +68,7 @@
 class FunctionInfoListener;
 class HandleScopeImplementer;
 class HeapProfiler;
+class HStatistics;
 class HTracer;
 class InlineRuntimeFunctionsTable;
 class NoAllocationStringAllocator;
@@ -373,6 +374,7 @@
V(CpuProfiler*, cpu_profiler, NULL) \ V(HeapProfiler*, heap_profiler, NULL) \ V(bool, observer_delivery_pending, false) \ + V(HStatistics*, hstatistics, NULL) \ V(HTracer*, htracer, NULL) \
   ISOLATE_DEBUGGER_INIT_LIST(V)

@@ -1102,6 +1104,7 @@
     return sweeper_thread_;
   }

+  HStatistics* GetHStatistics();
   HTracer* GetHTracer();

  private:
=======================================
--- /branches/bleeding_edge/src/lithium-allocator.h     Mon Feb  4 04:01:59 2013
+++ /branches/bleeding_edge/src/lithium-allocator.h     Wed Mar  6 02:49:34 2013
@@ -423,6 +423,7 @@

   LPlatformChunk* chunk() const { return chunk_; }
   HGraph* graph() const { return graph_; }
+  Isolate* isolate() const { return graph_->isolate(); }
   Zone* zone() const { return zone_; }

   int GetVirtualRegister() {
=======================================
--- /branches/bleeding_edge/src/lithium.h       Thu Feb 14 05:48:20 2013
+++ /branches/bleeding_edge/src/lithium.h       Wed Mar  6 02:49:34 2013
@@ -663,6 +663,7 @@
   int spill_slot_count() const { return spill_slot_count_; }
   CompilationInfo* info() const { return info_; }
   HGraph* graph() const { return graph_; }
+  Isolate* isolate() const { return graph_->isolate(); }
const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
   void AddGapMove(int index, LOperand* from, LOperand* to);
   LGap* GetGapAt(int index) const;

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