Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index 87028bda35406f673b37cebda80d4a0a2bb7cf89..575afaaf0b2c74513585952c1315f41d07a0eaa3 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -1224,4 +1224,32 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
info)); |
} |
+ |
+CompilationPhase::CompilationPhase(const char* name, |
+ Isolate* isolate, |
+ Zone* zone) |
+ : name_(name), isolate_(isolate), zone_scope_(zone, DELETE_ON_EXIT) { |
+ if (FLAG_hydrogen_stats) { |
+ start_allocation_size_ = zone->allocation_size(); |
+ start_ticks_ = OS::Ticks(); |
+ } |
+} |
+ |
+ |
+CompilationPhase::~CompilationPhase() { |
+ if (FLAG_hydrogen_stats) { |
+ unsigned size = zone()->allocation_size() - start_allocation_size_; |
+ int64_t ticks = OS::Ticks() - start_ticks_; |
+ isolate_->GetHStatistics()->SaveTiming(name_, ticks, size); |
+ } |
+} |
+ |
+ |
+bool CompilationPhase::ShouldProduceTraceOutput() const { |
+ // Produce trace output if flag is set so that the first letter of the |
+ // phase name matches the command line parameter FLAG_trace_phase. |
+ return (FLAG_trace_hydrogen && |
+ OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
+} |
+ |
} } // namespace v8::internal |