Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 2eb235df04c701bbbedcca3656b62b6eb6d33b88..f3db893557f2cb9e08697842203d251810984329 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -840,9 +840,13 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { |
void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) { |
switch (binop->op()) { |
case Token::COMMA: |
+ VisitCommaExpression(binop); |
+ break; |
case Token::OR: |
+ VisitLogicalOrExpression(binop); |
+ break; |
case Token::AND: |
- UNIMPLEMENTED(); |
+ VisitLogicalAndExpression(binop); |
break; |
default: |
VisitArithmeticExpression(binop); |
@@ -940,6 +944,53 @@ void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* binop) { |
} |
+void BytecodeGenerator::VisitCommaExpression(BinaryOperation* binop) { |
+ Expression* left = binop->left(); |
+ Expression* right = binop->right(); |
+ |
+ Visit(left); |
+ Visit(right); |
+} |
+ |
+ |
+void BytecodeGenerator::VisitLogicalOrExpression(BinaryOperation* binop) { |
+ Expression* left = binop->left(); |
+ Expression* right = binop->right(); |
+ |
+ // Short-circuit evaluation- If it is known that left is always true, |
+ // no need to visit right |
+ if (left->ToBooleanIsTrue()) { |
+ Visit(left); |
+ } else { |
+ BytecodeLabel end_label; |
+ |
+ Visit(left); |
+ builder()->JumpIfToBooleanTrue(&end_label); |
+ Visit(right); |
+ builder()->Bind(&end_label); |
+ } |
+} |
+ |
+ |
+void BytecodeGenerator::VisitLogicalAndExpression(BinaryOperation* binop) { |
+ Expression* left = binop->left(); |
+ Expression* right = binop->right(); |
+ |
+ // Short-circuit evaluation- If it is known that left is always false, |
+ // no need to visit right |
+ if (left->ToBooleanIsFalse()) { |
+ Visit(left); |
+ } else { |
+ BytecodeLabel end_label; |
+ |
+ Visit(left); |
+ builder()->JumpIfToBooleanFalse(&end_label); |
+ Visit(right); |
+ builder()->Bind(&end_label); |
+ } |
+} |
+ |
+ |
LanguageMode BytecodeGenerator::language_mode() const { |
return info()->language_mode(); |
} |