Revision: 4202
Author: [email protected]
Date: Mon Mar 22 04:55:12 2010
Log: Fix code generation for fast smi loops to support parameters as well.
This change fixes an assert we hit when we recognized a fast smi loop
with a parameter as the loop variable.
BUG=650
Review URL: http://codereview.chromium.org/1138003
http://code.google.com/p/v8/source/detail?r=4202
Modified:
/branches/bleeding_edge/src/arm/virtual-frame-arm.h
/branches/bleeding_edge/src/ia32/codegen-ia32.cc
/branches/bleeding_edge/src/ia32/codegen-ia32.h
/branches/bleeding_edge/src/ia32/virtual-frame-ia32.h
/branches/bleeding_edge/src/virtual-frame-inl.h
/branches/bleeding_edge/src/x64/virtual-frame-x64.h
/branches/bleeding_edge/test/mjsunit/compiler/loopcount.js
=======================================
--- /branches/bleeding_edge/src/arm/virtual-frame-arm.h Thu Mar 11 02:28:40
2010
+++ /branches/bleeding_edge/src/arm/virtual-frame-arm.h Mon Mar 22 04:55:12
2010
@@ -365,6 +365,7 @@
inline void Nip(int num_dropped);
inline void SetTypeForLocalAt(int index, NumberInfo info);
+ inline void SetTypeForParamAt(int index, NumberInfo info);
private:
static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset;
=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.cc Fri Mar 19 05:01:17
2010
+++ /branches/bleeding_edge/src/ia32/codegen-ia32.cc Mon Mar 22 04:55:12
2010
@@ -3650,6 +3650,26 @@
}
DecrementLoopNesting();
}
+
+
+void CodeGenerator::SetTypeForStackSlot(Slot* slot, NumberInfo info) {
+ ASSERT(slot->type() == Slot::LOCAL || slot->type() == Slot::PARAMETER);
+ if (slot->type() == Slot::LOCAL) {
+ frame_->SetTypeForLocalAt(slot->index(), info);
+ } else {
+ frame_->SetTypeForParamAt(slot->index(), info);
+ }
+ if (FLAG_debug_code && info.IsSmi()) {
+ if (slot->type() == Slot::LOCAL) {
+ frame_->PushLocalAt(slot->index());
+ } else {
+ frame_->PushParameterAt(slot->index());
+ }
+ Result var = frame_->Pop();
+ var.ToRegister();
+ __ AbortIfNotSmi(var.reg());
+ }
+}
void CodeGenerator::VisitForStatement(ForStatement* node) {
@@ -3752,15 +3772,7 @@
// the bottom check of the loop condition.
if (node->is_fast_smi_loop()) {
// Set number type of the loop variable to smi.
- Slot* slot = node->loop_variable()->slot();
- ASSERT(slot->type() == Slot::LOCAL);
- frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi());
- if (FLAG_debug_code) {
- frame_->PushLocalAt(slot->index());
- Result var = frame_->Pop();
- var.ToRegister();
- __ AbortIfNotSmi(var.reg());
- }
+ SetTypeForStackSlot(node->loop_variable()->slot(), NumberInfo::Smi());
}
Visit(node->body());
@@ -3786,15 +3798,7 @@
// expression if we are in a fast smi loop condition.
if (node->is_fast_smi_loop() && has_valid_frame()) {
// Set number type of the loop variable to smi.
- Slot* slot = node->loop_variable()->slot();
- ASSERT(slot->type() == Slot::LOCAL);
- frame_->SetTypeForLocalAt(slot->index(), NumberInfo::Smi());
- if (FLAG_debug_code) {
- frame_->PushLocalAt(slot->index());
- Result var = frame_->Pop();
- var.ToRegister();
- __ AbortIfNotSmi(var.reg());
- }
+ SetTypeForStackSlot(node->loop_variable()->slot(), NumberInfo::Smi());
}
// Based on the condition analysis, compile the backward jump as
=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.h Wed Mar 17 07:53:16 2010
+++ /branches/bleeding_edge/src/ia32/codegen-ia32.h Mon Mar 22 04:55:12 2010
@@ -652,6 +652,8 @@
void CodeForDoWhileConditionPosition(DoWhileStatement* stmt);
void CodeForSourcePosition(int pos);
+ void SetTypeForStackSlot(Slot* slot, NumberInfo info);
+
#ifdef DEBUG
// True if the registers are valid for entry to a block. There should
// be no frame-external references to (non-reserved) registers.
=======================================
--- /branches/bleeding_edge/src/ia32/virtual-frame-ia32.h Tue Mar 16
09:07:19 2010
+++ /branches/bleeding_edge/src/ia32/virtual-frame-ia32.h Mon Mar 22
04:55:12 2010
@@ -446,8 +446,9 @@
return true;
}
- // Update the type information of a local variable frame element
directly.
+ // Update the type information of a variable frame element directly.
inline void SetTypeForLocalAt(int index, NumberInfo info);
+ inline void SetTypeForParamAt(int index, NumberInfo info);
private:
static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset;
=======================================
--- /branches/bleeding_edge/src/virtual-frame-inl.h Thu Mar 11 02:28:40 2010
+++ /branches/bleeding_edge/src/virtual-frame-inl.h Mon Mar 22 04:55:12 2010
@@ -123,6 +123,11 @@
void VirtualFrame::SetTypeForLocalAt(int index, NumberInfo info) {
elements_[local0_index() + index].set_number_info(info);
}
+
+
+void VirtualFrame::SetTypeForParamAt(int index, NumberInfo info) {
+ elements_[param0_index() + index].set_number_info(info);
+}
} } // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/x64/virtual-frame-x64.h Thu Mar 11 02:28:40
2010
+++ /branches/bleeding_edge/src/x64/virtual-frame-x64.h Mon Mar 22 04:55:12
2010
@@ -417,6 +417,7 @@
inline void Nip(int num_dropped);
inline void SetTypeForLocalAt(int index, NumberInfo info);
+ inline void SetTypeForParamAt(int index, NumberInfo info);
private:
static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset;
=======================================
--- /branches/bleeding_edge/test/mjsunit/compiler/loopcount.js Thu Mar 18
07:32:02 2010
+++ /branches/bleeding_edge/test/mjsunit/compiler/loopcount.js Mon Mar 22
04:55:12 2010
@@ -84,3 +84,9 @@
}
}
assertEquals(42, f9());
+
+
+function f10(x) {
+ for (x = 0; x < 4; x++) {}
+}
+f10(42);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
To unsubscribe from this group, send email to v8-dev+unsubscribegooglegroups.com or reply
to this email with the words "REMOVE ME" as the subject.