Add a function to compute loop nesting level to HBasicBlock.

Review URL: http://codereview.chromium.org/7857031

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9207 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c6e19bfb
...@@ -220,6 +220,17 @@ bool HBasicBlock::Dominates(HBasicBlock* other) const { ...@@ -220,6 +220,17 @@ bool HBasicBlock::Dominates(HBasicBlock* other) const {
} }
int HBasicBlock::LoopNestingDepth() const {
const HBasicBlock* current = this;
int result = (current->IsLoopHeader()) ? 1 : 0;
while (current->parent_loop_header() != NULL) {
current = current->parent_loop_header();
result++;
}
return result;
}
void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) {
ASSERT(IsLoopHeader()); ASSERT(IsLoopHeader());
...@@ -6567,6 +6578,8 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { ...@@ -6567,6 +6578,8 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) {
PrintBlockProperty("dominator", current->dominator()->block_id()); PrintBlockProperty("dominator", current->dominator()->block_id());
} }
PrintIntProperty("loop_depth", current->LoopNestingDepth());
if (chunk != NULL) { if (chunk != NULL) {
int first_index = current->first_instruction_index(); int first_index = current->first_instruction_index();
int last_index = current->last_instruction_index(); int last_index = current->last_instruction_index();
......
...@@ -102,6 +102,7 @@ class HBasicBlock: public ZoneObject { ...@@ -102,6 +102,7 @@ class HBasicBlock: public ZoneObject {
void RemovePhi(HPhi* phi); void RemovePhi(HPhi* phi);
void AddInstruction(HInstruction* instr); void AddInstruction(HInstruction* instr);
bool Dominates(HBasicBlock* other) const; bool Dominates(HBasicBlock* other) const;
int LoopNestingDepth() const;
void SetInitialEnvironment(HEnvironment* env); void SetInitialEnvironment(HEnvironment* env);
void ClearEnvironment() { last_environment_ = NULL; } void ClearEnvironment() { last_environment_ = NULL; }
......
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