Revision: 5607 Author: [email protected] Date: Fri Oct 8 06:07:55 2010 Log: Fix a bug in our handling of conditional expressions in test contexts.
In the FullCodeGenerator, we compile the true subexpression of a conditional (ternary) expression in the inherited context of the entire expression. This is correct for effect and value contexts, but not for test contexts where the context includes a possible fall-through label. Review URL: http://codereview.chromium.org/3621013 http://code.google.com/p/v8/source/detail?r=5607 Modified: /branches/bleeding_edge/src/full-codegen.cc /branches/bleeding_edge/src/full-codegen.h ======================================= --- /branches/bleeding_edge/src/full-codegen.cc Mon Oct 4 07:30:43 2010 +++ /branches/bleeding_edge/src/full-codegen.cc Fri Oct 8 06:07:55 2010 @@ -1128,9 +1128,14 @@ __ bind(&true_case); SetExpressionPosition(expr->then_expression(), expr->then_expression_position()); - Visit(expr->then_expression()); - // If control flow falls through Visit, jump to done. - if (!context()->IsTest()) { + if (context()->IsTest()) { + const TestContext* for_test = TestContext::cast(context()); + VisitForControl(expr->then_expression(), + for_test->true_label(), + for_test->false_label(), + NULL); + } else { + Visit(expr->then_expression()); __ jmp(&done); } ======================================= --- /branches/bleeding_edge/src/full-codegen.h Mon Oct 4 07:30:43 2010 +++ /branches/bleeding_edge/src/full-codegen.h Fri Oct 8 06:07:55 2010 @@ -603,6 +603,15 @@ true_label_(true_label), false_label_(false_label), fall_through_(fall_through) { } + + static const TestContext* cast(const ExpressionContext* context) { + ASSERT(context->IsTest()); + return reinterpret_cast<const TestContext*>(context); + } + + Label* true_label() const { return true_label_; } + Label* false_label() const { return false_label_; } + Label* fall_through() const { return fall_through_; } virtual void Plug(bool flag) const; virtual void Plug(Register reg) const; -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
