Index: src/fast-codegen.cc |
=================================================================== |
--- src/fast-codegen.cc (revision 3181) |
+++ src/fast-codegen.cc (working copy) |
@@ -35,6 +35,8 @@ |
namespace v8 { |
namespace internal { |
+#define __ ACCESS_MASM(masm_) |
+ |
Handle<Code> FastCodeGenerator::MakeCode(FunctionLiteral* fun, |
Handle<Script> script, |
bool is_eval) { |
@@ -71,21 +73,6 @@ |
} |
-// All platform macro assemblers in {ia32,x64,arm} have a push(Register) |
-// function. |
-void FastCodeGenerator::Move(Expression::Context context, Register source) { |
- switch (context) { |
- case Expression::kUninitialized: |
- UNREACHABLE(); |
- case Expression::kEffect: |
- break; |
- case Expression::kValue: |
- masm_->push(source); |
- break; |
- } |
-} |
- |
- |
void FastCodeGenerator::VisitDeclarations( |
ZoneList<Declaration*>* declarations) { |
int length = declarations->length(); |
@@ -202,6 +189,79 @@ |
} |
+void FastCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) { |
+#ifdef DEBUG |
+ Expression::Context expected = Expression::kUninitialized; |
+ switch (expr->context()) { |
+ case Expression::kUninitialized: |
+ UNREACHABLE(); |
+ case Expression::kEffect: // Fall through. |
+ case Expression::kTest: |
+ // The value of the left subexpression is not needed. |
+ expected = Expression::kTest; |
+ break; |
+ case Expression::kValue: |
+ // The value of the left subexpression is needed and its specific |
+ // context depends on the operator. |
+ expected = (expr->op() == Token::OR) |
+ ? Expression::kValueTest |
+ : Expression::kTestValue; |
+ break; |
+ case Expression::kValueTest: |
+ // The value of the left subexpression is needed for OR. |
+ expected = (expr->op() == Token::OR) |
+ ? Expression::kValueTest |
+ : Expression::kTest; |
+ break; |
+ case Expression::kTestValue: |
+ // The value of the left subexpression is needed for AND. |
+ expected = (expr->op() == Token::OR) |
+ ? Expression::kTest |
+ : Expression::kTestValue; |
+ break; |
+ } |
+ ASSERT_EQ(expected, expr->left()->context()); |
+ ASSERT_EQ(expr->context(), expr->right()->context()); |
+#endif |
+ |
+ Label eval_right, done; |
+ Label* saved_true = true_label_; |
+ Label* saved_false = false_label_; |
+ |
+ // Set up the appropriate context for the left subexpression based on the |
+ // operation and our own context. |
+ if (expr->op() == Token::OR) { |
+ // If there is no usable true label in the OR expression's context, use |
+ // the end of this expression, otherwise inherit the same true label. |
+ if (expr->context() == Expression::kEffect || |
+ expr->context() == Expression::kValue) { |
+ true_label_ = &done; |
+ } |
+ // The false label is the label of the second subexpression. |
+ false_label_ = &eval_right; |
+ } else { |
+ ASSERT_EQ(Token::AND, expr->op()); |
+ // The true label is the label of the second subexpression. |
+ true_label_ = &eval_right; |
+ // If there is no usable false label in the AND expression's context, |
+ // use the end of the expression, otherwise inherit the same true label. |
William Hesse
2009/10/30 12:09:39
Typo: inherit the same false label
Kevin Millikin (Chromium)
2009/10/30 13:45:53
Thanks.
|
+ if (expr->context() == Expression::kEffect || |
+ expr->context() == Expression::kValue) { |
+ false_label_ = &done; |
+ } |
+ } |
+ |
+ Visit(expr->left()); |
+ true_label_ = saved_true; |
+ false_label_ = saved_false; |
+ |
+ __ bind(&eval_right); |
+ Visit(expr->right()); |
+ |
+ __ bind(&done); |
+} |
+ |
+ |
void FastCodeGenerator::VisitDeclaration(Declaration* decl) { |
UNREACHABLE(); |
} |
@@ -344,4 +404,7 @@ |
} |
+#undef __ |
+ |
+ |
} } // namespace v8::internal |