Revision: 15321
Author: [email protected]
Date: Tue Jun 25 05:22:26 2013
Log: Split HPhase for Lithium and Hydrogen using common
CompilationPhase base.
Add new base class CompilationPhase, which is the base for both HPhase,
LPhase and LAllocatorPhase. HPhase is now for Hydrogen passes only, LPhase
is for Lithium passes and LAllocatorPhase is for LAllocator phases.
[email protected]
BUG=
Review URL: https://codereview.chromium.org/17572011
http://code.google.com/p/v8/source/detail?r=15321
Modified:
/branches/bleeding_edge/src/arm/lithium-arm.cc
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/src/compiler.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-ia32.cc
/branches/bleeding_edge/src/lithium-allocator.cc
/branches/bleeding_edge/src/lithium-allocator.h
/branches/bleeding_edge/src/lithium.cc
/branches/bleeding_edge/src/lithium.h
/branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
/branches/bleeding_edge/src/mips/lithium-mips.cc
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
/branches/bleeding_edge/src/x64/lithium-x64.cc
/branches/bleeding_edge/src/zone.h
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc Fri Jun 21 04:10:06 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc Tue Jun 25 05:22:26 2013
@@ -451,7 +451,7 @@
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++) {
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Fri Jun 21
04:10:06 2013
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Jun 25
05:22:26 2013
@@ -62,7 +62,7 @@
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
=======================================
--- /branches/bleeding_edge/src/compiler.cc Mon Jun 24 06:37:46 2013
+++ /branches/bleeding_edge/src/compiler.cc Tue Jun 25 05:22:26 2013
@@ -1223,5 +1223,33 @@
Handle<Code>(info->code()),
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
=======================================
--- /branches/bleeding_edge/src/compiler.h Mon Jun 24 06:37:46 2013
+++ /branches/bleeding_edge/src/compiler.h Tue Jun 25 05:22:26 2013
@@ -633,6 +633,29 @@
};
+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_
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Tue Jun 25 00:47:53 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Tue Jun 25 05:22:26 2013
@@ -963,7 +963,7 @@
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();
@@ -2384,7 +2384,7 @@
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());
@@ -11553,74 +11553,14 @@
sizes_.Add(size);
}
-
-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
}
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Tue Jun 25 00:47:53 2013
+++ /branches/bleeding_edge/src/hydrogen.h Tue Jun 25 05:22:26 2013
@@ -1955,30 +1955,17 @@
};
-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);
+ HGraph* graph_;
- 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);
};
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Fri Jun 21
04:10:06 2013
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Jun 25
05:22:26 2013
@@ -74,7 +74,7 @@
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Fri Jun 21 04:10:06
2013
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Jun 25 05:22:26
2013
@@ -481,7 +481,7 @@
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.
=======================================
--- /branches/bleeding_edge/src/lithium-allocator.cc Fri Jun 7 08:18:49
2013
+++ /branches/bleeding_edge/src/lithium-allocator.cc Tue Jun 25 05:22:26
2013
@@ -1101,7 +1101,7 @@
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) {
@@ -1113,7 +1113,7 @@
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();
@@ -1204,7 +1204,7 @@
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;
@@ -1244,7 +1244,7 @@
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);
@@ -1265,7 +1265,7 @@
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();
@@ -1377,7 +1377,7 @@
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());
@@ -1496,14 +1496,14 @@
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();
@@ -2192,4 +2192,16 @@
#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
=======================================
--- /branches/bleeding_edge/src/lithium-allocator.h Fri May 3 07:58:06 2013
+++ /branches/bleeding_edge/src/lithium-allocator.h Tue Jun 25 05:22:26 2013
@@ -646,6 +646,20 @@
};
+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_
=======================================
--- /branches/bleeding_edge/src/lithium.cc Mon Jun 3 08:32:22 2013
+++ /branches/bleeding_edge/src/lithium.cc Tue Jun 25 05:22:26 2013
@@ -307,7 +307,7 @@
}
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();
@@ -489,6 +489,13 @@
iterator.Advance();
}
}
+
+
+LPhase::~LPhase() {
+ if (ShouldProduceTraceOutput()) {
+ isolate()->GetHTracer()->TraceLithium(name(), chunk_);
+ }
+}
} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/lithium.h Wed Jun 12 07:22:49 2013
+++ /branches/bleeding_edge/src/lithium.h Tue Jun 25 05:22:26 2013
@@ -778,6 +778,20 @@
};
+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_
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Mon Jun 24
17:09:32 2013
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Jun 25
05:22:26 2013
@@ -62,7 +62,7 @@
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Fri Jun 21 13:31:06
2013
+++ /branches/bleeding_edge/src/mips/lithium-mips.cc Tue Jun 25 05:22:26
2013
@@ -455,7 +455,7 @@
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++) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Fri Jun 21
04:10:06 2013
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Jun 25
05:22:26 2013
@@ -67,7 +67,7 @@
#define __ masm()->
bool LCodeGen::GenerateCode() {
- HPhase phase("Z_Code generation", chunk());
+ LPhase phase("Z_Code generation", chunk());
ASSERT(is_unused());
status_ = GENERATING;
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc Fri Jun 21 04:10:06 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc Tue Jun 25 05:22:26 2013
@@ -456,7 +456,7 @@
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++) {
=======================================
--- /branches/bleeding_edge/src/zone.h Wed Jun 19 00:48:41 2013
+++ /branches/bleeding_edge/src/zone.h Tue Jun 25 05:22:26 2013
@@ -240,6 +240,8 @@
INLINE(ZoneScope(Zone* zone, ZoneScopeMode mode));
virtual ~ZoneScope();
+
+ Zone* zone() const { return zone_; }
inline bool ShouldDeleteOnExit();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.