Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 478d938cf6fa27d74994d43674af59ca7f05ef41..efa47e0c3f7659207a116f0fe3a5c283a88b4580 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -9522,11 +9522,14 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) { |
ASSERT(current_block() != NULL); |
HValue* left_value = Top(); |
- if (left_value->IsConstant()) { |
- HConstant* left_constant = HConstant::cast(left_value); |
- if ((is_logical_and && left_constant->BooleanValue()) || |
- (!is_logical_and && !left_constant->BooleanValue())) { |
- Drop(1); // left_value. |
+ // Short-circuit left values that always evaluate to the same boolean value. |
+ if (expr->left()->ToBooleanIsTrue() || expr->left()->ToBooleanIsFalse()) { |
+ // l (evals true) && r -> r |
+ // l (evals true) || r -> l |
+ // l (evals false) && r -> l |
+ // l (evals false) || r -> r |
+ if (is_logical_and == expr->left()->ToBooleanIsTrue()) { |
+ Drop(1); |
CHECK_ALIVE(VisitForValue(expr->right())); |
} |
return ast_context()->ReturnValue(Pop()); |