Commit 1c5fafe8 authored by dcarney@chromium.org's avatar dcarney@chromium.org

[turbofan] use ZonePool in most places in the compiler pipeline a temp zone is used.

R=jarin@chromium.org, bmeurer@chromium.org

BUG=

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24779 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 26420587
...@@ -17,8 +17,9 @@ namespace v8 { ...@@ -17,8 +17,9 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
AstGraphBuilder::AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph) AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info,
: StructuredGraphBuilder(jsgraph->graph(), jsgraph->common()), JSGraph* jsgraph)
: StructuredGraphBuilder(local_zone, jsgraph->graph(), jsgraph->common()),
info_(info), info_(info),
jsgraph_(jsgraph), jsgraph_(jsgraph),
globals_(0, info->zone()), globals_(0, info->zone()),
......
...@@ -25,7 +25,7 @@ class Graph; ...@@ -25,7 +25,7 @@ class Graph;
// of function inlining. // of function inlining.
class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor { class AstGraphBuilder : public StructuredGraphBuilder, public AstVisitor {
public: public:
AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph); AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph);
// Creates a graph by visiting the entire AST. // Creates a graph by visiting the entire AST.
bool CreateGraph(); bool CreateGraph();
......
...@@ -21,16 +21,17 @@ enum VisitState { kUnvisited, kOnStack, kRevisit, kVisited }; ...@@ -21,16 +21,17 @@ enum VisitState { kUnvisited, kOnStack, kRevisit, kVisited };
class ControlReducerImpl { class ControlReducerImpl {
public: public:
ControlReducerImpl(JSGraph* jsgraph, CommonOperatorBuilder* common) ControlReducerImpl(Zone* zone, JSGraph* jsgraph,
: zone_(jsgraph->zone()->isolate()), CommonOperatorBuilder* common)
: zone_(zone),
jsgraph_(jsgraph), jsgraph_(jsgraph),
common_(common), common_(common),
state_(jsgraph->graph()->NodeCount(), kUnvisited, &zone_), state_(jsgraph->graph()->NodeCount(), kUnvisited, zone_),
stack_(&zone_), stack_(zone_),
revisit_(&zone_), revisit_(zone_),
dead_(NULL) {} dead_(NULL) {}
Zone zone_; Zone* zone_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
CommonOperatorBuilder* common_; CommonOperatorBuilder* common_;
ZoneVector<VisitState> state_; ZoneVector<VisitState> state_;
...@@ -40,7 +41,7 @@ class ControlReducerImpl { ...@@ -40,7 +41,7 @@ class ControlReducerImpl {
void Trim() { void Trim() {
// Mark all nodes reachable from end. // Mark all nodes reachable from end.
NodeVector nodes(&zone_); NodeVector nodes(zone_);
state_.assign(jsgraph_->graph()->NodeCount(), kUnvisited); state_.assign(jsgraph_->graph()->NodeCount(), kUnvisited);
Push(jsgraph_->graph()->end()); Push(jsgraph_->graph()->end());
while (!stack_.empty()) { while (!stack_.empty()) {
...@@ -104,17 +105,17 @@ class ControlReducerImpl { ...@@ -104,17 +105,17 @@ class ControlReducerImpl {
} }
}; };
void ControlReducer::ReduceGraph(JSGraph* jsgraph, void ControlReducer::ReduceGraph(Zone* zone, JSGraph* jsgraph,
CommonOperatorBuilder* common) { CommonOperatorBuilder* common) {
ControlReducerImpl impl(jsgraph, NULL); ControlReducerImpl impl(zone, jsgraph, NULL);
// Only trim the graph for now. Control reduction can reduce non-terminating // Only trim the graph for now. Control reduction can reduce non-terminating
// loops to graphs that are unschedulable at the moment. // loops to graphs that are unschedulable at the moment.
impl.Trim(); impl.Trim();
} }
void ControlReducer::TrimGraph(JSGraph* jsgraph) { void ControlReducer::TrimGraph(Zone* zone, JSGraph* jsgraph) {
ControlReducerImpl impl(jsgraph, NULL); ControlReducerImpl impl(zone, jsgraph, NULL);
impl.Trim(); impl.Trim();
} }
} }
......
...@@ -15,10 +15,11 @@ class CommonOperatorBuilder; ...@@ -15,10 +15,11 @@ class CommonOperatorBuilder;
class ControlReducer { class ControlReducer {
public: public:
// Perform branch folding and dead code elimination on the graph. // Perform branch folding and dead code elimination on the graph.
static void ReduceGraph(JSGraph* graph, CommonOperatorBuilder* builder); static void ReduceGraph(Zone* zone, JSGraph* graph,
CommonOperatorBuilder* builder);
// Trim nodes in the graph that are not reachable from end. // Trim nodes in the graph that are not reachable from end.
static void TrimGraph(JSGraph* graph); static void TrimGraph(Zone* zone, JSGraph* graph);
}; };
} }
} }
......
...@@ -19,12 +19,12 @@ namespace internal { ...@@ -19,12 +19,12 @@ namespace internal {
namespace compiler { namespace compiler {
StructuredGraphBuilder::StructuredGraphBuilder(Graph* graph, StructuredGraphBuilder::StructuredGraphBuilder(Zone* local_zone, Graph* graph,
CommonOperatorBuilder* common) CommonOperatorBuilder* common)
: GraphBuilder(graph), : GraphBuilder(graph),
common_(common), common_(common),
environment_(NULL), environment_(NULL),
local_zone_(isolate()), local_zone_(local_zone),
current_context_(NULL), current_context_(NULL),
exit_control_(NULL) {} exit_control_(NULL) {}
......
...@@ -79,7 +79,8 @@ class GraphBuilder { ...@@ -79,7 +79,8 @@ class GraphBuilder {
// StubGraphBuilder). // StubGraphBuilder).
class StructuredGraphBuilder : public GraphBuilder { class StructuredGraphBuilder : public GraphBuilder {
public: public:
StructuredGraphBuilder(Graph* graph, CommonOperatorBuilder* common); StructuredGraphBuilder(Zone* zone, Graph* graph,
CommonOperatorBuilder* common);
virtual ~StructuredGraphBuilder() {} virtual ~StructuredGraphBuilder() {}
// Creates a new Phi node having {count} input values. // Creates a new Phi node having {count} input values.
...@@ -123,7 +124,7 @@ class StructuredGraphBuilder : public GraphBuilder { ...@@ -123,7 +124,7 @@ class StructuredGraphBuilder : public GraphBuilder {
Node* dead_control(); Node* dead_control();
Zone* graph_zone() const { return graph()->zone(); } Zone* graph_zone() const { return graph()->zone(); }
Zone* local_zone() { return &local_zone_; } Zone* local_zone() const { return local_zone_; }
Isolate* isolate() const { return graph_zone()->isolate(); } Isolate* isolate() const { return graph_zone()->isolate(); }
CommonOperatorBuilder* common() const { return common_; } CommonOperatorBuilder* common() const { return common_; }
...@@ -145,7 +146,7 @@ class StructuredGraphBuilder : public GraphBuilder { ...@@ -145,7 +146,7 @@ class StructuredGraphBuilder : public GraphBuilder {
Environment* environment_; Environment* environment_;
// Zone local to the builder for data not leaking into the graph. // Zone local to the builder for data not leaking into the graph.
Zone local_zone_; Zone* local_zone_;
// Node representing the control dependency for dead code. // Node representing the control dependency for dead code.
SetOncePointer<Node> dead_control_; SetOncePointer<Node> dead_control_;
......
...@@ -13,12 +13,12 @@ namespace v8 { ...@@ -13,12 +13,12 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
InstructionSelector::InstructionSelector(Linkage* linkage, InstructionSelector::InstructionSelector(Zone* local_zone, Linkage* linkage,
InstructionSequence* sequence, InstructionSequence* sequence,
Schedule* schedule, Schedule* schedule,
SourcePositionTable* source_positions, SourcePositionTable* source_positions,
Features features) Features features)
: zone_(sequence->isolate()), : zone_(local_zone),
linkage_(linkage), linkage_(linkage),
sequence_(sequence), sequence_(sequence),
source_positions_(source_positions), source_positions_(source_positions),
......
...@@ -25,8 +25,9 @@ class InstructionSelector FINAL { ...@@ -25,8 +25,9 @@ class InstructionSelector FINAL {
// Forward declarations. // Forward declarations.
class Features; class Features;
InstructionSelector(Linkage* linkage, InstructionSequence* sequence, InstructionSelector(Zone* local_zone, Linkage* linkage,
Schedule* schedule, SourcePositionTable* source_positions, InstructionSequence* sequence, Schedule* schedule,
SourcePositionTable* source_positions,
Features features = SupportedFeatures()); Features features = SupportedFeatures());
// Visit code for the entire graph with the included schedule. // Visit code for the entire graph with the included schedule.
...@@ -187,11 +188,11 @@ class InstructionSelector FINAL { ...@@ -187,11 +188,11 @@ class InstructionSelector FINAL {
Linkage* linkage() const { return linkage_; } Linkage* linkage() const { return linkage_; }
InstructionSequence* sequence() const { return sequence_; } InstructionSequence* sequence() const { return sequence_; }
Zone* instruction_zone() const { return sequence()->zone(); } Zone* instruction_zone() const { return sequence()->zone(); }
Zone* zone() { return &zone_; } Zone* zone() const { return zone_; }
// =========================================================================== // ===========================================================================
Zone zone_; Zone* const zone_;
Linkage* const linkage_; Linkage* const linkage_;
InstructionSequence* const sequence_; InstructionSequence* const sequence_;
SourcePositionTable* const source_positions_; SourcePositionTable* const source_positions_;
......
...@@ -409,7 +409,7 @@ void JSInliner::TryInlineJSCall(Node* call_node) { ...@@ -409,7 +409,7 @@ void JSInliner::TryInlineJSCall(Node* call_node) {
JSGraph jsgraph(&graph, jsgraph_->common(), jsgraph_->javascript(), JSGraph jsgraph(&graph, jsgraph_->common(), jsgraph_->javascript(),
jsgraph_->machine()); jsgraph_->machine());
AstGraphBuilder graph_builder(&info, &jsgraph); AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph);
graph_builder.CreateGraph(); graph_builder.CreateGraph();
Inlinee::UnifyReturn(&jsgraph); Inlinee::UnifyReturn(&jsgraph);
......
...@@ -16,8 +16,8 @@ class JSCallFunctionAccessor; ...@@ -16,8 +16,8 @@ class JSCallFunctionAccessor;
class JSInliner { class JSInliner {
public: public:
JSInliner(CompilationInfo* info, JSGraph* jsgraph) JSInliner(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph)
: info_(info), jsgraph_(jsgraph) {} : local_zone_(local_zone), info_(info), jsgraph_(jsgraph) {}
void Inline(); void Inline();
void TryInlineJSCall(Node* node); void TryInlineJSCall(Node* node);
...@@ -25,6 +25,7 @@ class JSInliner { ...@@ -25,6 +25,7 @@ class JSInliner {
private: private:
friend class InlinerVisitor; friend class InlinerVisitor;
Zone* local_zone_;
CompilationInfo* info_; CompilationInfo* info_;
JSGraph* jsgraph_; JSGraph* jsgraph_;
......
...@@ -178,9 +178,11 @@ void Pipeline::PrintAllocator(const char* phase, ...@@ -178,9 +178,11 @@ void Pipeline::PrintAllocator(const char* phase,
class AstGraphBuilderWithPositions : public AstGraphBuilder { class AstGraphBuilderWithPositions : public AstGraphBuilder {
public: public:
explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph, explicit AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
JSGraph* jsgraph,
SourcePositionTable* source_positions) SourcePositionTable* source_positions)
: AstGraphBuilder(info, jsgraph), source_positions_(source_positions) {} : AstGraphBuilder(local_zone, info, jsgraph),
source_positions_(source_positions) {}
bool CreateGraph() { bool CreateGraph() {
SourcePositionTable::Scope pos(source_positions_, SourcePositionTable::Scope pos(source_positions_,
...@@ -253,8 +255,9 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -253,8 +255,9 @@ Handle<Code> Pipeline::GenerateCode() {
{ {
PhaseStats graph_builder_stats(info(), &zone_pool, PhaseStats::CREATE_GRAPH, PhaseStats graph_builder_stats(info(), &zone_pool, PhaseStats::CREATE_GRAPH,
"graph builder"); "graph builder");
AstGraphBuilderWithPositions graph_builder(info(), &jsgraph, ZonePool::Scope zone_scope(&zone_pool);
&source_positions); AstGraphBuilderWithPositions graph_builder(zone_scope.zone(), info(),
&jsgraph, &source_positions);
graph_builder.CreateGraph(); graph_builder.CreateGraph();
context_node = graph_builder.GetFunctionContext(); context_node = graph_builder.GetFunctionContext();
} }
...@@ -284,7 +287,8 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -284,7 +287,8 @@ Handle<Code> Pipeline::GenerateCode() {
if (info()->is_inlining_enabled()) { if (info()->is_inlining_enabled()) {
SourcePositionTable::Scope pos(&source_positions, SourcePositionTable::Scope pos(&source_positions,
SourcePosition::Unknown()); SourcePosition::Unknown());
JSInliner inliner(info(), &jsgraph); ZonePool::Scope zone_scope(&zone_pool);
JSInliner inliner(zone_scope.zone(), info(), &jsgraph);
inliner.Inline(); inliner.Inline();
VerifyAndPrintGraph(&graph, "Inlined", true); VerifyAndPrintGraph(&graph, "Inlined", true);
} }
...@@ -367,7 +371,8 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -367,7 +371,8 @@ Handle<Code> Pipeline::GenerateCode() {
SourcePosition::Unknown()); SourcePosition::Unknown());
PhaseStats control_reducer_stats( PhaseStats control_reducer_stats(
info(), &zone_pool, PhaseStats::CREATE_GRAPH, "control reduction"); info(), &zone_pool, PhaseStats::CREATE_GRAPH, "control reduction");
ControlReducer::ReduceGraph(&jsgraph, &common); ZonePool::Scope zone_scope(&zone_pool);
ControlReducer::ReduceGraph(zone_scope.zone(), &jsgraph, &common);
VerifyAndPrintGraph(&graph, "Control reduced"); VerifyAndPrintGraph(&graph, "Control reduced");
} }
...@@ -398,7 +403,8 @@ Handle<Code> Pipeline::GenerateCode() { ...@@ -398,7 +403,8 @@ Handle<Code> Pipeline::GenerateCode() {
PhaseStats codegen_stats(info(), &zone_pool, PhaseStats::CODEGEN, PhaseStats codegen_stats(info(), &zone_pool, PhaseStats::CODEGEN,
"codegen"); "codegen");
Linkage linkage(info()); Linkage linkage(info());
code = GenerateCode(&linkage, &graph, schedule, &source_positions); code =
GenerateCode(&zone_pool, &linkage, &graph, schedule, &source_positions);
info()->SetCode(code); info()->SetCode(code);
} }
...@@ -430,17 +436,18 @@ Schedule* Pipeline::ComputeSchedule(ZonePool* zone_pool, Graph* graph) { ...@@ -430,17 +436,18 @@ Schedule* Pipeline::ComputeSchedule(ZonePool* zone_pool, Graph* graph) {
Handle<Code> Pipeline::GenerateCodeForMachineGraph(Linkage* linkage, Handle<Code> Pipeline::GenerateCodeForMachineGraph(Linkage* linkage,
Graph* graph, Graph* graph,
Schedule* schedule) { Schedule* schedule) {
ZonePool zone_pool(isolate());
CHECK(SupportedBackend()); CHECK(SupportedBackend());
if (schedule == NULL) { if (schedule == NULL) {
// TODO(rossberg): Should this really be untyped? // TODO(rossberg): Should this really be untyped?
VerifyAndPrintGraph(graph, "Machine", true); VerifyAndPrintGraph(graph, "Machine", true);
ZonePool zone_pool(isolate());
schedule = ComputeSchedule(&zone_pool, graph); schedule = ComputeSchedule(&zone_pool, graph);
} }
TraceSchedule(schedule); TraceSchedule(schedule);
SourcePositionTable source_positions(graph); SourcePositionTable source_positions(graph);
Handle<Code> code = GenerateCode(linkage, graph, schedule, &source_positions); Handle<Code> code =
GenerateCode(&zone_pool, linkage, graph, schedule, &source_positions);
#if ENABLE_DISASSEMBLER #if ENABLE_DISASSEMBLER
if (!code.is_null() && FLAG_print_opt_code) { if (!code.is_null() && FLAG_print_opt_code) {
CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
...@@ -452,8 +459,8 @@ Handle<Code> Pipeline::GenerateCodeForMachineGraph(Linkage* linkage, ...@@ -452,8 +459,8 @@ Handle<Code> Pipeline::GenerateCodeForMachineGraph(Linkage* linkage,
} }
Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, Handle<Code> Pipeline::GenerateCode(ZonePool* zone_pool, Linkage* linkage,
Schedule* schedule, Graph* graph, Schedule* schedule,
SourcePositionTable* source_positions) { SourcePositionTable* source_positions) {
DCHECK_NOT_NULL(graph); DCHECK_NOT_NULL(graph);
DCHECK_NOT_NULL(linkage); DCHECK_NOT_NULL(linkage);
...@@ -470,8 +477,9 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, ...@@ -470,8 +477,9 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph,
// Select and schedule instructions covering the scheduled graph. // Select and schedule instructions covering the scheduled graph.
{ {
InstructionSelector selector(linkage, &sequence, schedule, ZonePool::Scope zone_scope(zone_pool);
source_positions); InstructionSelector selector(zone_scope.zone(), linkage, &sequence,
schedule, source_positions);
selector.SelectInstructions(); selector.SelectInstructions();
} }
...@@ -491,8 +499,10 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph, ...@@ -491,8 +499,10 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph,
linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues); linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues);
return Handle<Code>::null(); return Handle<Code>::null();
} }
RegisterAllocator allocator(&frame, linkage->info(), &sequence); ZonePool::Scope zone_scope(zone_pool);
if (!allocator.Allocate()) { RegisterAllocator allocator(zone_scope.zone(), &frame, linkage->info(),
&sequence);
if (!allocator.Allocate(zone_pool)) {
linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc); linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
return Handle<Code>::null(); return Handle<Code>::null();
} }
......
...@@ -61,7 +61,8 @@ class Pipeline { ...@@ -61,7 +61,8 @@ class Pipeline {
void PrintAllocator(const char* phase, const RegisterAllocator* allocator); void PrintAllocator(const char* phase, const RegisterAllocator* allocator);
void VerifyAndPrintGraph(Graph* graph, const char* phase, void VerifyAndPrintGraph(Graph* graph, const char* phase,
bool untyped = false); bool untyped = false);
Handle<Code> GenerateCode(Linkage* linkage, Graph* graph, Schedule* schedule, Handle<Code> GenerateCode(ZonePool* zone_pool, Linkage* linkage, Graph* graph,
Schedule* schedule,
SourcePositionTable* source_positions); SourcePositionTable* source_positions);
}; };
} }
......
...@@ -499,9 +499,11 @@ LifetimePosition LiveRange::FirstIntersection(LiveRange* other) { ...@@ -499,9 +499,11 @@ LifetimePosition LiveRange::FirstIntersection(LiveRange* other) {
} }
RegisterAllocator::RegisterAllocator(Frame* frame, CompilationInfo* info, RegisterAllocator::RegisterAllocator(Zone* local_zone, Frame* frame,
CompilationInfo* info,
InstructionSequence* code) InstructionSequence* code)
: zone_(code->isolate()), : zone_(local_zone),
zone_pool_(NULL),
frame_(frame), frame_(frame),
info_(info), info_(info),
code_(code), code_(code),
...@@ -1094,7 +1096,9 @@ void RegisterAllocator::ResolvePhis(const InstructionBlock* block) { ...@@ -1094,7 +1096,9 @@ void RegisterAllocator::ResolvePhis(const InstructionBlock* block) {
} }
bool RegisterAllocator::Allocate() { bool RegisterAllocator::Allocate(ZonePool* zone_pool) {
DCHECK_EQ(NULL, zone_pool_);
zone_pool_ = zone_pool;
assigned_registers_ = new (code_zone()) assigned_registers_ = new (code_zone())
BitVector(Register::NumAllocatableRegisters(), code_zone()); BitVector(Register::NumAllocatableRegisters(), code_zone());
assigned_double_registers_ = new (code_zone()) assigned_double_registers_ = new (code_zone())
...@@ -1116,6 +1120,46 @@ bool RegisterAllocator::Allocate() { ...@@ -1116,6 +1120,46 @@ bool RegisterAllocator::Allocate() {
} }
class RegisterAllocatorPhase : public CompilationPhase {
public:
RegisterAllocatorPhase(const char* name, RegisterAllocator* allocator)
: CompilationPhase(name, allocator->info()),
allocator_(allocator),
allocator_zone_start_allocation_size_(0),
stats_(NULL) {
if (FLAG_turbo_stats) {
allocator_zone_start_allocation_size_ =
allocator->info()->zone()->allocation_size();
if (allocator->zone_pool() != NULL) {
stats_ = new ZonePool::StatsScope(allocator->zone_pool());
}
}
}
~RegisterAllocatorPhase() {
if (FLAG_turbo_stats) {
unsigned size = allocator_->info()->zone()->allocation_size() -
allocator_zone_start_allocation_size_;
if (stats_ != NULL) {
size += static_cast<unsigned>(stats_->GetMaxAllocatedBytes());
}
isolate()->GetTStatistics()->SaveTiming(name(), base::TimeDelta(), size);
}
delete stats_;
#ifdef DEBUG
if (allocator_ != NULL) allocator_->Verify();
#endif
}
private:
RegisterAllocator* allocator_;
unsigned allocator_zone_start_allocation_size_;
ZonePool::StatsScope* stats_;
DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorPhase);
};
void RegisterAllocator::MeetRegisterConstraints() { void RegisterAllocator::MeetRegisterConstraints() {
RegisterAllocatorPhase phase("L_Register constraints", this); RegisterAllocatorPhase phase("L_Register constraints", this);
for (int i = 0; i < code()->InstructionBlockCount(); ++i) { for (int i = 0; i < code()->InstructionBlockCount(); ++i) {
...@@ -2205,27 +2249,6 @@ void RegisterAllocator::SetLiveRangeAssignedRegister(LiveRange* range, ...@@ -2205,27 +2249,6 @@ void RegisterAllocator::SetLiveRangeAssignedRegister(LiveRange* range,
range->set_assigned_register(reg, code_zone()); range->set_assigned_register(reg, code_zone());
} }
RegisterAllocatorPhase::RegisterAllocatorPhase(const char* name,
RegisterAllocator* allocator)
: CompilationPhase(name, allocator->info()), allocator_(allocator) {
if (FLAG_turbo_stats) {
allocator_zone_start_allocation_size_ =
allocator->zone()->allocation_size();
}
}
RegisterAllocatorPhase::~RegisterAllocatorPhase() {
if (FLAG_turbo_stats) {
unsigned size = allocator_->zone()->allocation_size() -
allocator_zone_start_allocation_size_;
isolate()->GetTStatistics()->SaveTiming(name(), base::TimeDelta(), size);
}
#ifdef DEBUG
if (allocator_ != NULL) allocator_->Verify();
#endif
}
} }
} }
} // namespace v8::internal::compiler } // namespace v8::internal::compiler
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/allocation.h" #include "src/allocation.h"
#include "src/compiler/instruction.h" #include "src/compiler/instruction.h"
#include "src/compiler/zone-pool.h"
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/zone.h" #include "src/zone.h"
...@@ -318,8 +319,8 @@ class LiveRange : public ZoneObject { ...@@ -318,8 +319,8 @@ class LiveRange : public ZoneObject {
class RegisterAllocator BASE_EMBEDDED { class RegisterAllocator BASE_EMBEDDED {
public: public:
// TODO(dcarney): remove info // TODO(dcarney): remove info
explicit RegisterAllocator(Frame* frame, CompilationInfo* info, explicit RegisterAllocator(Zone* local_zone, Frame* frame,
InstructionSequence* code); CompilationInfo* info, InstructionSequence* code);
static void TraceAlloc(const char* msg, ...); static void TraceAlloc(const char* msg, ...);
...@@ -330,7 +331,8 @@ class RegisterAllocator BASE_EMBEDDED { ...@@ -330,7 +331,8 @@ class RegisterAllocator BASE_EMBEDDED {
// Returns the register kind required by the given virtual register. // Returns the register kind required by the given virtual register.
RegisterKind RequiredRegisterKind(int virtual_register) const; RegisterKind RequiredRegisterKind(int virtual_register) const;
bool Allocate(); // TODO(dcarney): fix compilation phase stats to not require this.
bool Allocate(ZonePool* zone_pool = NULL);
const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; } const ZoneList<LiveRange*>* live_ranges() const { return &live_ranges_; }
const Vector<LiveRange*>* fixed_live_ranges() const { const Vector<LiveRange*>* fixed_live_ranges() const {
...@@ -342,13 +344,14 @@ class RegisterAllocator BASE_EMBEDDED { ...@@ -342,13 +344,14 @@ class RegisterAllocator BASE_EMBEDDED {
CompilationInfo* info() const { return info_; } CompilationInfo* info() const { return info_; }
inline InstructionSequence* code() const { return code_; } inline InstructionSequence* code() const { return code_; }
ZonePool* zone_pool() const { return zone_pool_; }
// This zone is for datastructures only needed during register allocation. // This zone is for datastructures only needed during register allocation.
inline Zone* zone() { return &zone_; } inline Zone* zone() const { return zone_; }
// This zone is for InstructionOperands and moves that live beyond register // This zone is for InstructionOperands and moves that live beyond register
// allocation. // allocation.
inline Zone* code_zone() { return code()->zone(); } inline Zone* code_zone() const { return code()->zone(); }
int GetVirtualRegister() { int GetVirtualRegister() {
int vreg = code()->NextVirtualRegister(); int vreg = code()->NextVirtualRegister();
...@@ -497,7 +500,9 @@ class RegisterAllocator BASE_EMBEDDED { ...@@ -497,7 +500,9 @@ class RegisterAllocator BASE_EMBEDDED {
Frame* frame() const { return frame_; } Frame* frame() const { return frame_; }
Zone zone_; Zone* const zone_;
// TODO(dcarney): remove this.
ZonePool* zone_pool_;
Frame* const frame_; Frame* const frame_;
CompilationInfo* const info_; CompilationInfo* const info_;
InstructionSequence* const code_; InstructionSequence* const code_;
...@@ -535,18 +540,6 @@ class RegisterAllocator BASE_EMBEDDED { ...@@ -535,18 +540,6 @@ class RegisterAllocator BASE_EMBEDDED {
DISALLOW_COPY_AND_ASSIGN(RegisterAllocator); DISALLOW_COPY_AND_ASSIGN(RegisterAllocator);
}; };
class RegisterAllocatorPhase : public CompilationPhase {
public:
RegisterAllocatorPhase(const char* name, RegisterAllocator* allocator);
~RegisterAllocatorPhase();
private:
RegisterAllocator* allocator_;
unsigned allocator_zone_start_allocation_size_;
DISALLOW_COPY_AND_ASSIGN(RegisterAllocatorPhase);
};
} }
} }
} // namespace v8::internal::compiler } // namespace v8::internal::compiler
......
...@@ -70,7 +70,8 @@ class DeoptCodegenTester { ...@@ -70,7 +70,8 @@ class DeoptCodegenTester {
code = new v8::internal::compiler::InstructionSequence(scope_->main_zone(), code = new v8::internal::compiler::InstructionSequence(scope_->main_zone(),
graph, schedule); graph, schedule);
SourcePositionTable source_positions(graph); SourcePositionTable source_positions(graph);
InstructionSelector selector(linkage, code, schedule, &source_positions); InstructionSelector selector(scope_->main_zone(), linkage, code, schedule,
&source_positions);
selector.SelectInstructions(); selector.SelectInstructions();
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
...@@ -79,7 +80,7 @@ class DeoptCodegenTester { ...@@ -79,7 +80,7 @@ class DeoptCodegenTester {
} }
Frame frame; Frame frame;
RegisterAllocator allocator(&frame, &info, code); RegisterAllocator allocator(scope_->main_zone(), &frame, &info, code);
CHECK(allocator.Allocate()); CHECK(allocator.Allocate());
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
......
...@@ -37,7 +37,7 @@ class CTrimTester : HandleAndZoneScope { ...@@ -37,7 +37,7 @@ class CTrimTester : HandleAndZoneScope {
Node* one; Node* one;
Node* half; Node* half;
void Trim() { ControlReducer::TrimGraph(&jsgraph); } void Trim() { ControlReducer::TrimGraph(main_zone(), &jsgraph); }
}; };
......
...@@ -40,7 +40,7 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( ...@@ -40,7 +40,7 @@ InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build(
Linkage linkage(&info, call_descriptor()); Linkage linkage(&info, call_descriptor());
InstructionSequence sequence(test_->zone(), graph(), schedule); InstructionSequence sequence(test_->zone(), graph(), schedule);
SourcePositionTable source_position_table(graph()); SourcePositionTable source_position_table(graph());
InstructionSelector selector(&linkage, &sequence, schedule, InstructionSelector selector(test_->zone(), &linkage, &sequence, schedule,
&source_position_table, features); &source_position_table, features);
selector.SelectInstructions(); selector.SelectInstructions();
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
......
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