Revision: 4429
Author: [email protected]
Date: Thu Apr 15 07:06:57 2010
Log: Add tracking of loop nesting to ARM code.
Review URL: http://codereview.chromium.org/1645008
http://code.google.com/p/v8/source/detail?r=4429
Modified:
/branches/bleeding_edge/src/arm/codegen-arm.cc
/branches/bleeding_edge/src/arm/codegen-arm.h
/branches/bleeding_edge/src/ia32/codegen-ia32.cc
/branches/bleeding_edge/src/x64/codegen-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/codegen-arm.cc Thu Apr 15 02:34:47 2010
+++ /branches/bleeding_edge/src/arm/codegen-arm.cc Thu Apr 15 07:06:57 2010
@@ -133,6 +133,7 @@
allocator_(NULL),
cc_reg_(al),
state_(NULL),
+ loop_nesting_(0),
function_return_is_shadowed_(false) {
}
@@ -156,6 +157,11 @@
ASSERT(frame_ == NULL);
frame_ = new VirtualFrame();
cc_reg_ = al;
+
+ // Adjust for function-level loop nesting.
+ ASSERT_EQ(0, loop_nesting_);
+ loop_nesting_ = info->loop_nesting();
+
{
CodeGenState state(this);
@@ -379,6 +385,10 @@
ASSERT_EQ(return_sequence_length,
masm_->InstructionsGeneratedSince(&check_exit_codesize));
}
+
+ // Adjust for function-level loop nesting.
+ ASSERT(loop_nesting_ == info->loop_nesting());
+ loop_nesting_ = 0;
// Code generation state must be reset.
ASSERT(!has_cc());
@@ -1885,6 +1895,7 @@
CodeForStatementPosition(node);
node->break_target()->set_direction(JumpTarget::FORWARD_ONLY);
JumpTarget body(JumpTarget::BIDIRECTIONAL);
+ IncrementLoopNesting();
// Label the top of the loop for the backward CFG edge. If the test
// is always true we can use the continue target, and if the test is
@@ -1945,6 +1956,7 @@
if (node->break_target()->is_linked()) {
node->break_target()->Bind();
}
+ DecrementLoopNesting();
ASSERT(!has_valid_frame() || frame_->height() == original_height);
}
@@ -1963,6 +1975,7 @@
if (info == ALWAYS_FALSE) return;
node->break_target()->set_direction(JumpTarget::FORWARD_ONLY);
+ IncrementLoopNesting();
// Label the top of the loop with the continue target for the backward
// CFG edge.
@@ -1994,6 +2007,7 @@
if (node->break_target()->is_linked()) {
node->break_target()->Bind();
}
+ DecrementLoopNesting();
ASSERT(!has_valid_frame() || frame_->height() == original_height);
}
@@ -2015,6 +2029,7 @@
if (info == ALWAYS_FALSE) return;
node->break_target()->set_direction(JumpTarget::FORWARD_ONLY);
+ IncrementLoopNesting();
// If there is no update statement, label the top of the loop with the
// continue target, otherwise with the loop target.
@@ -2069,6 +2084,7 @@
if (node->break_target()->is_linked()) {
node->break_target()->Bind();
}
+ DecrementLoopNesting();
ASSERT(!has_valid_frame() || frame_->height() == original_height);
}
=======================================
--- /branches/bleeding_edge/src/arm/codegen-arm.h Wed Apr 14 07:46:15 2010
+++ /branches/bleeding_edge/src/arm/codegen-arm.h Thu Apr 15 07:06:57 2010
@@ -215,8 +215,10 @@
JumpTarget* true_target() const { return state_->true_target(); }
JumpTarget* false_target() const { return state_->false_target(); }
- // We don't track loop nesting level on ARM yet.
- int loop_nesting() const { return 0; }
+ // Track loop nesting level.
+ int loop_nesting() const { return loop_nesting_; }
+ void IncrementLoopNesting() { loop_nesting_++; }
+ void DecrementLoopNesting() { loop_nesting_--; }
// Node visitors.
void VisitStatements(ZoneList<Statement*>* statements);
@@ -284,6 +286,7 @@
void LoadFromSlot(Slot* slot, TypeofState typeof_state);
// Store the value on top of the stack to a slot.
void StoreToSlot(Slot* slot, InitState init_state);
+
// Load a keyed property, leaving it in r0. The receiver and key are
// passed on the stack, and remain there.
void EmitKeyedLoad(bool is_global);
@@ -458,6 +461,7 @@
RegisterAllocator* allocator_;
Condition cc_reg_;
CodeGenState* state_;
+ int loop_nesting_;
// Jump targets
BreakTarget function_return_;
=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.cc Thu Apr 15 05:41:30
2010
+++ /branches/bleeding_edge/src/ia32/codegen-ia32.cc Thu Apr 15 07:06:57
2010
@@ -140,7 +140,8 @@
set_in_spilled_code(false);
// Adjust for function-level loop nesting.
- loop_nesting_ += info->loop_nesting();
+ ASSERT_EQ(0, loop_nesting_);
+ loop_nesting_ = info->loop_nesting();
JumpTarget::set_compiling_deferred_code(false);
@@ -333,7 +334,8 @@
}
// Adjust for function-level loop nesting.
- loop_nesting_ -= info->loop_nesting();
+ ASSERT_EQ(info->loop_nesting(), loop_nesting_);
+ loop_nesting_ = 0;
// Code generation state must be reset.
ASSERT(state_ == NULL);
=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.cc Thu Apr 15 05:41:30 2010
+++ /branches/bleeding_edge/src/x64/codegen-x64.cc Thu Apr 15 07:06:57 2010
@@ -290,6 +290,7 @@
set_in_spilled_code(false);
// Adjust for function-level loop nesting.
+ ASSERT_EQ(0, loop_nesting_);
loop_nesting_ += info->loop_nesting();
JumpTarget::set_compiling_deferred_code(false);
@@ -483,11 +484,11 @@
}
// Adjust for function-level loop nesting.
- loop_nesting_ -= info->loop_nesting();
+ ASSERT_EQ(loop_nesting_, info->loop_nesting());
+ loop_nesting_ = 0;
// Code generation state must be reset.
ASSERT(state_ == NULL);
- ASSERT(loop_nesting() == 0);
ASSERT(!function_return_is_shadowed_);
function_return_.Unuse();
DeleteFrame();
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
To unsubscribe, reply using "remove me" as the subject.