Commit c80cba3b authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Add the for statement back into the set of things the

non-optimizing compiler can cope with.  By default it bails out
to the old compiler on encountering a for loop (for performance)
but with this change the --always-fast-compiler flag will enable
functions with for loops to be compiled in the non-optimizing
compiler.  Also enables the non-optimizing compiler on functions
that can be lazily compiled (again only with the flag).
Review URL: http://codereview.chromium.org/552065

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3667 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b21bc9ed
......@@ -469,7 +469,8 @@ Handle<JSFunction> Compiler::BuildBoilerplate(FunctionLiteral* literal,
// Generate code and return it.
bool is_compiled = false;
if (FLAG_fast_compiler && literal->try_fast_codegen()) {
if (FLAG_always_fast_compiler ||
(FLAG_fast_compiler && literal->try_fast_codegen())) {
FullCodeGenSyntaxChecker checker;
checker.Check(literal);
if (checker.has_supported_syntax()) {
......
......@@ -172,7 +172,20 @@ void FullCodeGenSyntaxChecker::VisitWhileStatement(WhileStatement* stmt) {
void FullCodeGenSyntaxChecker::VisitForStatement(ForStatement* stmt) {
BAILOUT("ForStatement");
if (!FLAG_always_fast_compiler) BAILOUT("ForStatement");
if (stmt->init() != NULL) {
Visit(stmt->init());
CHECK_BAILOUT;
}
if (stmt->cond() != NULL) {
Visit(stmt->cond());
CHECK_BAILOUT;
}
Visit(stmt->body());
if (stmt->next() != NULL) {
CHECK_BAILOUT;
Visit(stmt->next());
}
}
......@@ -855,7 +868,48 @@ void FullCodeGenerator::VisitWhileStatement(WhileStatement* stmt) {
void FullCodeGenerator::VisitForStatement(ForStatement* stmt) {
UNREACHABLE();
Comment cmnt(masm_, "[ ForStatement");
SetStatementPosition(stmt);
Label test, body, stack_limit_hit, stack_check_success;
Iteration loop_statement(this, stmt);
if (stmt->init() != NULL) {
Visit(stmt->init());
}
increment_loop_depth();
// Emit the test at the bottom of the loop (even if empty).
__ jmp(&test);
__ bind(&body);
Visit(stmt->body());
__ bind(loop_statement.continue_target());
SetStatementPosition(stmt);
if (stmt->next() != NULL) {
Visit(stmt->next());
}
__ bind(&test);
// Check stack before looping.
__ StackLimitCheck(&stack_limit_hit);
__ bind(&stack_check_success);
if (stmt->cond() != NULL) {
VisitForControl(stmt->cond(), &body, loop_statement.break_target());
} else {
__ jmp(&body);
}
__ bind(&stack_limit_hit);
StackCheckStub stack_stub;
__ CallStub(&stack_stub);
__ jmp(&stack_check_success);
__ bind(loop_statement.break_target());
decrement_loop_depth();
}
......
......@@ -79,4 +79,4 @@ f();
assertEquals(0, result);
// Get rid of the debug event listener.
Debug.setListener(null);
\ No newline at end of file
Debug.setListener(null);
// Copyright 2010 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Test missing condition in for loop.
for (var i = 0; ; i++) {
if (i > 100) break;
}
assertEquals(101, i);
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