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

Side by Side Diff: src/hydrogen.cc

Issue 10006008: Check for NaN in inlined versions of Math.min, Math.max. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rearrange Created 8 years, 8 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-2056.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5712 matching lines...) Expand 10 before | Expand all | Expand 10 after
5723 HBasicBlock* return_left = graph()->CreateBasicBlock(); 5723 HBasicBlock* return_left = graph()->CreateBasicBlock();
5724 HBasicBlock* return_right = graph()->CreateBasicBlock(); 5724 HBasicBlock* return_right = graph()->CreateBasicBlock();
5725 5725
5726 compare->SetSuccessorAt(0, return_left); 5726 compare->SetSuccessorAt(0, return_left);
5727 compare->SetSuccessorAt(1, return_right); 5727 compare->SetSuccessorAt(1, return_right);
5728 current_block()->Finish(compare); 5728 current_block()->Finish(compare);
5729 5729
5730 set_current_block(return_left); 5730 set_current_block(return_left);
5731 Push(left); 5731 Push(left);
5732 set_current_block(return_right); 5732 set_current_block(return_right);
5733 Push(right); 5733 // The branch above always returns the right operand if either of
5734 // them is NaN, but the spec requires that max/min(NaN, X) = NaN.
5735 // We add another branch that checks if the left operand is NaN or not.
5736 if (left_operand->representation().IsDouble()) {
5737 // If left_operand != left_operand then it is NaN.
5738 HCompareIDAndBranch* compare_nan = new(zone()) HCompareIDAndBranch(
5739 left_operand, left_operand, Token::EQ);
5740 compare_nan->SetInputRepresentation(left_operand->representation());
5741 HBasicBlock* left_is_number = graph()->CreateBasicBlock();
5742 HBasicBlock* left_is_nan = graph()->CreateBasicBlock();
5743 compare_nan->SetSuccessorAt(0, left_is_number);
5744 compare_nan->SetSuccessorAt(1, left_is_nan);
5745 current_block()->Finish(compare_nan);
5746 set_current_block(left_is_nan);
5747 Push(left);
5748 set_current_block(left_is_number);
5749 Push(right);
5750 return_right = CreateJoin(left_is_number, left_is_nan, expr->id());
5751 } else {
5752 Push(right);
5753 }
5734 5754
5735 HBasicBlock* join = CreateJoin(return_left, return_right, expr->id()); 5755 HBasicBlock* join = CreateJoin(return_left, return_right, expr->id());
5736 set_current_block(join); 5756 set_current_block(join);
5737 ast_context()->ReturnValue(Pop()); 5757 ast_context()->ReturnValue(Pop());
5738 return true; 5758 return true;
5739 } 5759 }
5740 break; 5760 break;
5741 default: 5761 default:
5742 // Not yet supported for inlining. 5762 // Not yet supported for inlining.
5743 break; 5763 break;
(...skipping 2466 matching lines...) Expand 10 before | Expand all | Expand 10 after
8210 } 8230 }
8211 } 8231 }
8212 8232
8213 #ifdef DEBUG 8233 #ifdef DEBUG
8214 if (graph_ != NULL) graph_->Verify(false); // No full verify. 8234 if (graph_ != NULL) graph_->Verify(false); // No full verify.
8215 if (allocator_ != NULL) allocator_->Verify(); 8235 if (allocator_ != NULL) allocator_->Verify();
8216 #endif 8236 #endif
8217 } 8237 }
8218 8238
8219 } } // namespace v8::internal 8239 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-2056.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698