Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: src/hydrogen.cc

Issue 143263022: Fix short-circuiting logical and/or in HOptimizedGraphBuilder. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-336148.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9504 matching lines...) Expand 10 before | Expand all | Expand 10 after
9515 eval_right->SetJoinId(expr->RightId()); 9515 eval_right->SetJoinId(expr->RightId());
9516 set_current_block(eval_right); 9516 set_current_block(eval_right);
9517 Visit(expr->right()); 9517 Visit(expr->right());
9518 } 9518 }
9519 9519
9520 } else if (ast_context()->IsValue()) { 9520 } else if (ast_context()->IsValue()) {
9521 CHECK_ALIVE(VisitForValue(expr->left())); 9521 CHECK_ALIVE(VisitForValue(expr->left()));
9522 ASSERT(current_block() != NULL); 9522 ASSERT(current_block() != NULL);
9523 HValue* left_value = Top(); 9523 HValue* left_value = Top();
9524 9524
9525 if (left_value->IsConstant()) { 9525 // Short-circuit left values that always evaluate to the same boolean value.
9526 HConstant* left_constant = HConstant::cast(left_value); 9526 if (expr->left()->ToBooleanIsTrue() || expr->left()->ToBooleanIsFalse()) {
9527 if ((is_logical_and && left_constant->BooleanValue()) || 9527 // l (evals true) && r -> r
9528 (!is_logical_and && !left_constant->BooleanValue())) { 9528 // l (evals true) || r -> l
9529 Drop(1); // left_value. 9529 // l (evals false) && r -> l
9530 // l (evals false) || r -> r
9531 if (is_logical_and == expr->left()->ToBooleanIsTrue()) {
9532 Drop(1);
9530 CHECK_ALIVE(VisitForValue(expr->right())); 9533 CHECK_ALIVE(VisitForValue(expr->right()));
9531 } 9534 }
9532 return ast_context()->ReturnValue(Pop()); 9535 return ast_context()->ReturnValue(Pop());
9533 } 9536 }
9534 9537
9535 // We need an extra block to maintain edge-split form. 9538 // We need an extra block to maintain edge-split form.
9536 HBasicBlock* empty_block = graph()->CreateBasicBlock(); 9539 HBasicBlock* empty_block = graph()->CreateBasicBlock();
9537 HBasicBlock* eval_right = graph()->CreateBasicBlock(); 9540 HBasicBlock* eval_right = graph()->CreateBasicBlock();
9538 ToBooleanStub::Types expected(expr->left()->to_boolean_types()); 9541 ToBooleanStub::Types expected(expr->left()->to_boolean_types());
9539 HBranch* test = is_logical_and 9542 HBranch* test = is_logical_and
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
11365 if (ShouldProduceTraceOutput()) { 11368 if (ShouldProduceTraceOutput()) {
11366 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11369 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11367 } 11370 }
11368 11371
11369 #ifdef DEBUG 11372 #ifdef DEBUG
11370 graph_->Verify(false); // No full verify. 11373 graph_->Verify(false); // No full verify.
11371 #endif 11374 #endif
11372 } 11375 }
11373 11376
11374 } } // namespace v8::internal 11377 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-336148.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698