diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index a13fa90477..39c6653164 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -3766,7 +3766,7 @@ void CodeGenerator::VisitForStatement(ForStatement* node) { // Set the type of the loop variable to smi before compiling the test // expression if we are in a fast smi loop condition. - if (node->is_fast_smi_loop()) { + 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); diff --git a/test/mjsunit/compiler/loopcount.js b/test/mjsunit/compiler/loopcount.js index 736d9a7791..da9bc6b7f0 100644 --- a/test/mjsunit/compiler/loopcount.js +++ b/test/mjsunit/compiler/loopcount.js @@ -75,3 +75,12 @@ function f8() { return i; } assertEquals(0x40000002, f8()); + + +function f9() { + var i; + for (i = 0; i < 42; i++) { + return 42; + } +} +assertEquals(42, f9());