LPlatformChunk* LChunkBuilder::Build() {
ASSERT(is_unused());
chunk_ = new(zone()) LPlatformChunk(info(), graph());
- HPhase phase("L_Building chunk", chunk_);
+ LPhase phase("L_Building chunk", chunk_);
status_ = BUILDING;
const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
for (int i = 0; i < blocks->length(); i++) {
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
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
};
+class CompilationPhase BASE_EMBEDDED {
+ public:
+ CompilationPhase(const char* name, Isolate* isolate, Zone* zone);
+ ~CompilationPhase();
+
+ protected:
+ bool ShouldProduceTraceOutput() const;
+
+ const char* name() const { return name_; }
+ Isolate* isolate() const { return isolate_; }
+ Zone* zone() const { return zone_scope_.zone(); }
+
+ private:
+ const char* name_;
+ Isolate* isolate_;
+ ZoneScope zone_scope_;
+ unsigned start_allocation_size_;
+ int64_t start_ticks_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompilationPhase);
+};
+
+
} } // namespace v8::internal
#endif // V8_COMPILER_H_
HGraph* HGraphBuilder::CreateGraph() {
graph_ = new(zone()) HGraph(info_);
if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_);
- HPhase phase("H_Block building", isolate(), zone());
+ CompilationPhase phase("H_Block building", isolate(), zone());
set_current_block(graph()->entry_block());
if (!BuildGraph()) return NULL;
graph()->FinalizeUniqueValueIds();
void HGraph::OrderBlocks() {
- HPhase phase("H_Block ordering", isolate(), zone());
+ CompilationPhase phase("H_Block ordering", isolate(), zone());
BitVector visited(blocks_.length(), zone());
ZoneList<HBasicBlock*> reverse_result(8, zone());
}
-HPhase::HPhase(const char* name, Isolate* isolate, Zone* zone) {
- Init(isolate, name, zone, NULL, NULL, NULL);
-}
-
-
-HPhase::HPhase(const char* name, HGraph* graph) {
- Init(graph->isolate(), name, graph->zone(), graph, NULL, NULL);
-}
-
-
-HPhase::HPhase(const char* name, LChunk* chunk) {
- Init(chunk->isolate(), name, chunk->zone(), NULL, chunk, NULL);
-}
-
-
-HPhase::HPhase(const char* name, LAllocator* allocator) {
- Init(allocator->isolate(), name, allocator->zone(), NULL, NULL, allocator);
-}
-
-
-void HPhase::Init(Isolate* isolate,
- const char* name,
- Zone* zone,
- HGraph* graph,
- LChunk* chunk,
- LAllocator* allocator) {
- isolate_ = isolate;
- name_ = name;
- zone_ = zone;
- graph_ = graph;
- chunk_ = chunk;
- allocator_ = allocator;
- if (allocator != NULL && chunk_ == NULL) {
- chunk_ = allocator->chunk();
- }
- if (FLAG_hydrogen_stats) {
- start_ticks_ = OS::Ticks();
- start_allocation_size_ = zone_->allocation_size();
- }
-}
-
-
HPhase::~HPhase() {
- if (FLAG_hydrogen_stats) {
- int64_t ticks = OS::Ticks() - start_ticks_;
- unsigned size = zone_->allocation_size() - start_allocation_size_;
- isolate_->GetHStatistics()->SaveTiming(name_, ticks, size);
- }
-
- // Produce trace output if flag is set so that the first letter of the
- // phase name matches the command line parameter FLAG_trace_phase.
- if (FLAG_trace_hydrogen &&
- OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL) {
- if (graph_ != NULL) {
- isolate_->GetHTracer()->TraceHydrogen(name_, graph_);
- }
- if (chunk_ != NULL) {
- isolate_->GetHTracer()->TraceLithium(name_, chunk_);
- }
- if (allocator_ != NULL) {
- isolate_->GetHTracer()->TraceLiveRanges(name_, allocator_);
- }
+ if (ShouldProduceTraceOutput()) {
+ isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
}
#ifdef DEBUG
- if (graph_ != NULL) graph_->Verify(false); // No full verify.
- if (allocator_ != NULL) allocator_->Verify();
+ graph_->Verify(false); // No full verify.
#endif
}
};
-class HPhase BASE_EMBEDDED {
+class HPhase : public CompilationPhase {
public:
- HPhase(const char* name, Isolate* isolate, Zone* zone);
- HPhase(const char* name, HGraph* graph);
- HPhase(const char* name, LChunk* chunk);
- HPhase(const char* name, LAllocator* allocator);
+ HPhase(const char* name, HGraph* graph)
+ : CompilationPhase(name, graph->isolate(), graph->zone()),
+ graph_(graph) { }
~HPhase();
private:
- void Init(Isolate* isolate,
- const char* name,
- Zone* zone,
- HGraph* graph,
- LChunk* chunk,
- LAllocator* allocator);
-
- Isolate* isolate_;
- const char* name_;
- Zone* zone_;
HGraph* graph_;
- LChunk* chunk_;
- LAllocator* allocator_;
- int64_t start_ticks_;
- unsigned start_allocation_size_;
+
+ DISALLOW_COPY_AND_ASSIGN(HPhase);
};
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
LPlatformChunk* LChunkBuilder::Build() {
ASSERT(is_unused());
chunk_ = new(zone()) LPlatformChunk(info(), graph());
- HPhase phase("L_Building chunk", chunk_);
+ LPhase phase("L_Building chunk", chunk_);
status_ = BUILDING;
// Reserve the first spill slot for the state of dynamic alignment.
void LAllocator::MeetRegisterConstraints() {
- HPhase phase("L_Register constraints", chunk_);
+ LAllocatorPhase phase("L_Register constraints", this);
first_artificial_register_ = next_virtual_register_;
const ZoneList<HBasicBlock*>* blocks = graph_->blocks();
for (int i = 0; i < blocks->length(); ++i) {
void LAllocator::ResolvePhis() {
- HPhase phase("L_Resolve phis", chunk_);
+ LAllocatorPhase phase("L_Resolve phis", this);
// Process the blocks in reverse order.
const ZoneList<HBasicBlock*>* blocks = graph_->blocks();
void LAllocator::ConnectRanges() {
- HPhase phase("L_Connect ranges", this);
+ LAllocatorPhase phase("L_Connect ranges", this);
for (int i = 0; i < live_ranges()->length(); ++i) {
LiveRange* first_range = live_ranges()->at(i);
if (first_range == NULL || first_range->parent() != NULL) continue;
void LAllocator::ResolveControlFlow() {
- HPhase phase("L_Resolve control flow", this);
+ LAllocatorPhase phase("L_Resolve control flow", this);
const ZoneList<HBasicBlock*>* blocks = graph_->blocks();
for (int block_id = 1; block_id < blocks->length(); ++block_id) {
HBasicBlock* block = blocks->at(block_id);
void LAllocator::BuildLiveRanges() {
- HPhase phase("L_Build live ranges", this);
+ LAllocatorPhase phase("L_Build live ranges", this);
InitializeLivenessAnalysis();
// Process the blocks in reverse order.
const ZoneList<HBasicBlock*>* blocks = graph_->blocks();
void LAllocator::PopulatePointerMaps() {
- HPhase phase("L_Populate pointer maps", this);
+ LAllocatorPhase phase("L_Populate pointer maps", this);
const ZoneList<LPointerMap*>* pointer_maps = chunk_->pointer_maps();
ASSERT(SafePointsAreInOrder());
void LAllocator::AllocateGeneralRegisters() {
- HPhase phase("L_Allocate general registers", this);
+ LAllocatorPhase phase("L_Allocate general registers", this);
num_registers_ = Register::NumAllocatableRegisters();
AllocateRegisters();
}
void LAllocator::AllocateDoubleRegisters() {
- HPhase phase("L_Allocate double registers", this);
+ LAllocatorPhase phase("L_Allocate double registers", this);
num_registers_ = DoubleRegister::NumAllocatableRegisters();
mode_ = DOUBLE_REGISTERS;
AllocateRegisters();
#endif
+LAllocatorPhase::~LAllocatorPhase() {
+ if (ShouldProduceTraceOutput()) {
+ isolate()->GetHTracer()->TraceLithium(name(), allocator_->chunk());
+ isolate()->GetHTracer()->TraceLiveRanges(name(), allocator_);
+ }
+
+#ifdef DEBUG
+ if (allocator_ != NULL) allocator_->Verify();
+#endif
+}
+
+
} } // namespace v8::internal
};
+class LAllocatorPhase : public CompilationPhase {
+ public:
+ LAllocatorPhase(const char* name, LAllocator* allocator)
+ : CompilationPhase(name, allocator->isolate(), allocator->zone()),
+ allocator_(allocator) { }
+ ~LAllocatorPhase();
+
+ private:
+ LAllocator* allocator_;
+
+ DISALLOW_COPY_AND_ASSIGN(LAllocatorPhase);
+};
+
+
} } // namespace v8::internal
#endif // V8_LITHIUM_ALLOCATOR_H_
}
void LChunk::MarkEmptyBlocks() {
- HPhase phase("L_Mark empty blocks", this);
+ LPhase phase("L_Mark empty blocks", this);
for (int i = 0; i < graph()->blocks()->length(); ++i) {
HBasicBlock* block = graph()->blocks()->at(i);
int first = block->first_instruction_index();
}
+LPhase::~LPhase() {
+ if (ShouldProduceTraceOutput()) {
+ isolate()->GetHTracer()->TraceLithium(name(), chunk_);
+ }
+}
+
+
} } // namespace v8::internal
};
+class LPhase : public CompilationPhase {
+ public:
+ LPhase(const char* name, LChunk* chunk)
+ : CompilationPhase(name, chunk->isolate(), chunk->zone()),
+ chunk_(chunk) { }
+ ~LPhase();
+
+ private:
+ LChunk* chunk_;
+
+ DISALLOW_COPY_AND_ASSIGN(LPhase);
+};
+
+
} } // namespace v8::internal
#endif // V8_LITHIUM_H_
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
LPlatformChunk* LChunkBuilder::Build() {
ASSERT(is_unused());
chunk_ = new(zone()) LPlatformChunk(info(), graph());
- HPhase phase("L_Building chunk", chunk_);
+ LPhase phase("L_Building chunk", chunk_);
status_ = BUILDING;
const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
for (int i = 0; i < blocks->length(); i++) {
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
LPlatformChunk* LChunkBuilder::Build() {
ASSERT(is_unused());
chunk_ = new(zone()) LPlatformChunk(info(), graph());
- HPhase phase("L_Building chunk", chunk_);
+ LPhase phase("L_Building chunk", chunk_);
status_ = BUILDING;
const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
for (int i = 0; i < blocks->length(); i++) {
virtual ~ZoneScope();
+ Zone* zone() const { return zone_; }
+
inline bool ShouldDeleteOnExit();
// For ZoneScopes that do not delete on exit by default, call this