From: fschneider@chromium.org Date: Fri, 9 Sep 2011 09:17:57 +0000 (+0000) Subject: Add a function to compute loop nesting level to HBasicBlock. X-Git-Tag: upstream/4.7.83~18518 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=366416f7bd280c2081b2cb655cf6c9c28c295e65;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/hydrogen.cc b/src/hydrogen.cc index ab25299..a0a850a 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -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) { ASSERT(IsLoopHeader()); @@ -6567,6 +6578,8 @@ void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { PrintBlockProperty("dominator", current->dominator()->block_id()); } + PrintIntProperty("loop_depth", current->LoopNestingDepth()); + if (chunk != NULL) { int first_index = current->first_instruction_index(); int last_index = current->last_instruction_index(); diff --git a/src/hydrogen.h b/src/hydrogen.h index 614991f..3f12503 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -102,6 +102,7 @@ class HBasicBlock: public ZoneObject { void RemovePhi(HPhi* phi); void AddInstruction(HInstruction* instr); bool Dominates(HBasicBlock* other) const; + int LoopNestingDepth() const; void SetInitialEnvironment(HEnvironment* env); void ClearEnvironment() { last_environment_ = NULL; }