Home | History | Annotate | Download | only in crankshaft
      1 // Copyright 2016 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "src/crankshaft/compilation-phase.h"
      6 
      7 #include "src/crankshaft/hydrogen.h"
      8 #include "src/isolate.h"
      9 #include "src/objects-inl.h"
     10 
     11 namespace v8 {
     12 namespace internal {
     13 
     14 CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info)
     15     : name_(name), info_(info), zone_(info->isolate()->allocator(), ZONE_NAME) {
     16   if (FLAG_hydrogen_stats) {
     17     info_zone_start_allocation_size_ = info->zone()->allocation_size();
     18     timer_.Start();
     19   }
     20 }
     21 
     22 CompilationPhase::~CompilationPhase() {
     23   if (FLAG_hydrogen_stats) {
     24     size_t size = zone()->allocation_size();
     25     size += info_->zone()->allocation_size() - info_zone_start_allocation_size_;
     26     isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size);
     27   }
     28 }
     29 
     30 bool CompilationPhase::ShouldProduceTraceOutput() const {
     31   // Trace if the appropriate trace flag is set and the phase name's first
     32   // character is in the FLAG_trace_phase command line parameter.
     33   AllowHandleDereference allow_deref;
     34   bool tracing_on =
     35       info()->IsStub()
     36           ? FLAG_trace_hydrogen_stubs
     37           : (FLAG_trace_hydrogen &&
     38              info()->shared_info()->PassesFilter(FLAG_trace_hydrogen_filter));
     39   return (tracing_on &&
     40           base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) !=
     41               NULL);
     42 }
     43 
     44 }  // namespace internal
     45 }  // namespace v8
     46