| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 8985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8996 eval_right->SetJoinId(expr->RightId()); | 8996 eval_right->SetJoinId(expr->RightId()); |
| 8997 set_current_block(eval_right); | 8997 set_current_block(eval_right); |
| 8998 Visit(expr->right()); | 8998 Visit(expr->right()); |
| 8999 } | 8999 } |
| 9000 | 9000 |
| 9001 } else if (ast_context()->IsValue()) { | 9001 } else if (ast_context()->IsValue()) { |
| 9002 CHECK_ALIVE(VisitForValue(expr->left())); | 9002 CHECK_ALIVE(VisitForValue(expr->left())); |
| 9003 ASSERT(current_block() != NULL); | 9003 ASSERT(current_block() != NULL); |
| 9004 HValue* left_value = Top(); | 9004 HValue* left_value = Top(); |
| 9005 | 9005 |
| 9006 if (left_value->IsConstant()) { | 9006 // Short-circuit left values that always evaluate to the same boolean value. |
| 9007 HConstant* left_constant = HConstant::cast(left_value); | 9007 if (expr->left()->ToBooleanIsTrue() || expr->left()->ToBooleanIsFalse()) { |
| 9008 if ((is_logical_and && left_constant->BooleanValue()) || | 9008 // l (evals true) && r -> r |
| 9009 (!is_logical_and && !left_constant->BooleanValue())) { | 9009 // l (evals true) || r -> l |
| 9010 Drop(1); // left_value. | 9010 // l (evals false) && r -> l |
| 9011 // l (evals false) || r -> r |
| 9012 if (is_logical_and == expr->left()->ToBooleanIsTrue()) { |
| 9013 Drop(1); |
| 9011 CHECK_ALIVE(VisitForValue(expr->right())); | 9014 CHECK_ALIVE(VisitForValue(expr->right())); |
| 9012 } | 9015 } |
| 9013 return ast_context()->ReturnValue(Pop()); | 9016 return ast_context()->ReturnValue(Pop()); |
| 9014 } | 9017 } |
| 9015 | 9018 |
| 9016 // We need an extra block to maintain edge-split form. | 9019 // We need an extra block to maintain edge-split form. |
| 9017 HBasicBlock* empty_block = graph()->CreateBasicBlock(); | 9020 HBasicBlock* empty_block = graph()->CreateBasicBlock(); |
| 9018 HBasicBlock* eval_right = graph()->CreateBasicBlock(); | 9021 HBasicBlock* eval_right = graph()->CreateBasicBlock(); |
| 9019 ToBooleanStub::Types expected(expr->left()->to_boolean_types()); | 9022 ToBooleanStub::Types expected(expr->left()->to_boolean_types()); |
| 9020 HBranch* test = is_logical_and | 9023 HBranch* test = is_logical_and |
| (...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10808 if (ShouldProduceTraceOutput()) { | 10811 if (ShouldProduceTraceOutput()) { |
| 10809 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10812 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 10810 } | 10813 } |
| 10811 | 10814 |
| 10812 #ifdef DEBUG | 10815 #ifdef DEBUG |
| 10813 graph_->Verify(false); // No full verify. | 10816 graph_->Verify(false); // No full verify. |
| 10814 #endif | 10817 #endif |
| 10815 } | 10818 } |
| 10816 | 10819 |
| 10817 } } // namespace v8::internal | 10820 } } // namespace v8::internal |
| OLD | NEW |