Commit 8377ce95 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[crankshaft] Move CompilationPhase into separate file.

The CompilationPhase helper class is only used in Crankshaft and is not
suitable for use in other compilers. This factors is out into a separate
file and moves it into the "crankshaft" directory.

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/1758773002

Cr-Commit-Position: refs/heads/master@{#34441}
parent 56eca6d3
......@@ -913,6 +913,8 @@ source_set("v8_base") {
"src/conversions.h",
"src/counters.cc",
"src/counters.h",
"src/crankshaft/compilation-phase.cc",
"src/crankshaft/compilation-phase.h",
"src/crankshaft/hydrogen-alias-analysis.h",
"src/crankshaft/hydrogen-bce.cc",
"src/crankshaft/hydrogen-bce.h",
......
......@@ -1857,41 +1857,12 @@ MaybeHandle<Code> Compiler::GetConcurrentlyOptimizedCode(
}
CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info)
: name_(name), info_(info) {
if (FLAG_hydrogen_stats) {
info_zone_start_allocation_size_ = info->zone()->allocation_size();
timer_.Start();
}
}
CompilationPhase::~CompilationPhase() {
if (FLAG_hydrogen_stats) {
size_t size = zone()->allocation_size();
size += info_->zone()->allocation_size() - info_zone_start_allocation_size_;
isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size);
}
}
bool CompilationPhase::ShouldProduceTraceOutput() const {
// Trace if the appropriate trace flag is set and the phase name's first
// character is in the FLAG_trace_phase command line parameter.
AllowHandleDereference allow_deref;
bool tracing_on = info()->IsStub()
? FLAG_trace_hydrogen_stubs
: (FLAG_trace_hydrogen &&
info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
return (tracing_on &&
base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
}
#if DEBUG
void CompilationInfo::PrintAstForTesting() {
PrintF("--- Source from AST ---\n%s\n",
PrettyPrinter(isolate()).PrintProgram(literal()));
}
#endif
} // namespace internal
} // namespace v8
......@@ -664,30 +664,6 @@ class Compiler : public AllStatic {
OptimizedCompileJob* job);
};
class CompilationPhase BASE_EMBEDDED {
public:
CompilationPhase(const char* name, CompilationInfo* info);
~CompilationPhase();
protected:
bool ShouldProduceTraceOutput() const;
const char* name() const { return name_; }
CompilationInfo* info() const { return info_; }
Isolate* isolate() const { return info()->isolate(); }
Zone* zone() { return &zone_; }
private:
const char* name_;
CompilationInfo* info_;
Zone zone_;
size_t info_zone_start_allocation_size_;
base::ElapsedTimer timer_;
DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
};
} // namespace internal
} // namespace v8
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/crankshaft/compilation-phase.h"
#include "src/crankshaft/hydrogen.h"
#include "src/isolate.h"
namespace v8 {
namespace internal {
CompilationPhase::CompilationPhase(const char* name, CompilationInfo* info)
: name_(name), info_(info) {
if (FLAG_hydrogen_stats) {
info_zone_start_allocation_size_ = info->zone()->allocation_size();
timer_.Start();
}
}
CompilationPhase::~CompilationPhase() {
if (FLAG_hydrogen_stats) {
size_t size = zone()->allocation_size();
size += info_->zone()->allocation_size() - info_zone_start_allocation_size_;
isolate()->GetHStatistics()->SaveTiming(name_, timer_.Elapsed(), size);
}
}
bool CompilationPhase::ShouldProduceTraceOutput() const {
// Trace if the appropriate trace flag is set and the phase name's first
// character is in the FLAG_trace_phase command line parameter.
AllowHandleDereference allow_deref;
bool tracing_on =
info()->IsStub()
? FLAG_trace_hydrogen_stubs
: (FLAG_trace_hydrogen &&
info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
return (tracing_on &&
base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) !=
NULL);
}
} // namespace internal
} // namespace v8
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_CRANKSHAFT_COMPILATION_PHASE_H_
#define V8_CRANKSHAFT_COMPILATION_PHASE_H_
#include "src/allocation.h"
#include "src/compiler.h"
#include "src/zone.h"
namespace v8 {
namespace internal {
class CompilationPhase BASE_EMBEDDED {
public:
CompilationPhase(const char* name, CompilationInfo* info);
~CompilationPhase();
protected:
bool ShouldProduceTraceOutput() const;
const char* name() const { return name_; }
CompilationInfo* info() const { return info_; }
Isolate* isolate() const { return info()->isolate(); }
Zone* zone() { return &zone_; }
private:
const char* name_;
CompilationInfo* info_;
Zone zone_;
size_t info_zone_start_allocation_size_;
base::ElapsedTimer timer_;
DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
};
} // namespace internal
} // namespace v8
#endif // V8_CRANKSHAFT_COMPILATION_PHASE_H_
......@@ -11,6 +11,7 @@
#include "src/ast/scopes.h"
#include "src/bailout-reason.h"
#include "src/compiler.h"
#include "src/crankshaft/compilation-phase.h"
#include "src/crankshaft/hydrogen-instructions.h"
#include "src/zone.h"
......
......@@ -6,6 +6,7 @@
#define V8_CRANKSHAFT_LITHIUM_ALLOCATOR_H_
#include "src/allocation.h"
#include "src/crankshaft/compilation-phase.h"
#include "src/crankshaft/lithium.h"
#include "src/zone.h"
......
......@@ -9,6 +9,7 @@
#include "src/allocation.h"
#include "src/bailout-reason.h"
#include "src/crankshaft/compilation-phase.h"
#include "src/crankshaft/hydrogen.h"
#include "src/safepoint-table.h"
#include "src/zone-allocator.h"
......
......@@ -731,6 +731,8 @@
'../../src/conversions.h',
'../../src/counters.cc',
'../../src/counters.h',
'../../src/crankshaft/compilation-phase.cc',
'../../src/crankshaft/compilation-phase.h',
'../../src/crankshaft/hydrogen-alias-analysis.h',
'../../src/crankshaft/hydrogen-bce.cc',
'../../src/crankshaft/hydrogen-bce.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment