Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index cf20652a58a93dbf1ce6f3acc7a13883e5914e93..d486c8e7edc5dae518355f99f88281308faa1771 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -879,9 +879,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); |
@@ -979,6 +983,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(); |
} |