Revision: 3188 Author: [email protected] Date: Fri Oct 30 08:34:09 2009 Log: Implement new support for if statements in top-level code.
Review URL: http://codereview.chromium.org/346022 http://code.google.com/p/v8/source/detail?r=3188 Modified: /branches/bleeding_edge/src/compiler.cc /branches/bleeding_edge/src/fast-codegen.cc ======================================= --- /branches/bleeding_edge/src/compiler.cc Fri Oct 30 07:06:48 2009 +++ /branches/bleeding_edge/src/compiler.cc Fri Oct 30 08:34:09 2009 @@ -538,7 +538,11 @@ void CodeGenSelector::VisitIfStatement(IfStatement* stmt) { - BAILOUT("IfStatement"); + ProcessExpression(stmt->condition(), Expression::kTest); + CHECK_BAILOUT; + Visit(stmt->then_statement()); + CHECK_BAILOUT; + Visit(stmt->else_statement()); } ======================================= --- /branches/bleeding_edge/src/fast-codegen.cc Fri Oct 30 07:06:48 2009 +++ /branches/bleeding_edge/src/fast-codegen.cc Fri Oct 30 08:34:09 2009 @@ -289,7 +289,27 @@ void FastCodeGenerator::VisitIfStatement(IfStatement* stmt) { - UNREACHABLE(); + // Expressions cannot recursively enter statements, there are no labels in + // the state. + ASSERT_EQ(NULL, true_label_); + ASSERT_EQ(NULL, false_label_); + Label then_part, else_part, done; + + // Do not worry about optimizing for empty then or else bodies. + true_label_ = &then_part; + false_label_ = &else_part; + Visit(stmt->condition()); + true_label_ = NULL; + false_label_ = NULL; + + __ bind(&then_part); + Visit(stmt->then_statement()); + __ jmp(&done); + + __ bind(&else_part); + Visit(stmt->else_statement()); + + __ bind(&done); } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
