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

Side by Side Diff: src/hydrogen.cc

Issue 9372021: Enable inlining for Math.min/max in more cases. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | no next file » | 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 5293 matching lines...) Expand 10 before | Expand all | Expand 10 after
5304 ast_context()->ReturnInstruction(result, expr->id()); 5304 ast_context()->ReturnInstruction(result, expr->id());
5305 return true; 5305 return true;
5306 } 5306 }
5307 break; 5307 break;
5308 case kMathMax: 5308 case kMathMax:
5309 case kMathMin: 5309 case kMathMin:
5310 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { 5310 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
5311 AddCheckConstantFunction(expr, receiver, receiver_map, true); 5311 AddCheckConstantFunction(expr, receiver, receiver_map, true);
5312 HValue* right = Pop(); 5312 HValue* right = Pop();
5313 HValue* left = Pop(); 5313 HValue* left = Pop();
5314 // Do not inline if the return representation is not certain. 5314 Pop(); // Pop receiver.
5315 if (!left->representation().Equals(right->representation())) { 5315
5316 Push(left); 5316 HValue* left_operand = left;
5317 Push(right); 5317 HValue* right_operand = right;
5318 return false; 5318
5319 // If we do not have two integers, we convert to double for comparison.
5320 if (!left->representation().IsInteger32() ||
5321 !right->representation().IsInteger32()) {
5322 if (!left->representation().IsDouble()) {
5323 HChange* left_convert = new(zone()) HChange(
5324 left, Representation::Double(), false, true);
fschneider 2012/02/20 12:18:39 Please break like this and comment the boolean par
Yang 2012/02/20 13:14:11 Done.
5325 left_convert->SetFlag(HValue::kBailoutOnMinusZero);
5326 left_operand = AddInstruction(left_convert);
5327 }
5328 if (!right->representation().IsDouble()) {
5329 HChange* right_convert = new(zone()) HChange(
5330 right, Representation::Double(), false, true);
fschneider 2012/02/20 12:18:39 Also here: Short same-line comment for the boolean
Yang 2012/02/20 13:14:11 Done.
5331 right_convert->SetFlag(HValue::kBailoutOnMinusZero);
5332 right_operand = AddInstruction(right_convert);
5333 }
5319 } 5334 }
5320 5335
5321 Pop(); // Pop receiver. 5336 ASSERT(left_operand->representation().Equals(
5337 right_operand->representation()));
5338 ASSERT(!left_operand->representation().IsTagged());
5339
5322 Token::Value op = (id == kMathMin) ? Token::LT : Token::GT; 5340 Token::Value op = (id == kMathMin) ? Token::LT : Token::GT;
5323 HCompareIDAndBranch* compare = NULL;
5324 5341
5325 if (left->representation().IsTagged()) { 5342 HCompareIDAndBranch* compare =
5326 HChange* left_cvt = 5343 new(zone()) HCompareIDAndBranch(left_operand, right_operand, op);
5327 new(zone()) HChange(left, Representation::Double(), false, true); 5344 compare->SetInputRepresentation(left_operand->representation());
5328 left_cvt->SetFlag(HValue::kBailoutOnMinusZero);
5329 AddInstruction(left_cvt);
5330 HChange* right_cvt =
5331 new(zone()) HChange(right, Representation::Double(), false, true);
5332 right_cvt->SetFlag(HValue::kBailoutOnMinusZero);
5333 AddInstruction(right_cvt);
5334 compare = new(zone()) HCompareIDAndBranch(left_cvt, right_cvt, op);
5335 compare->SetInputRepresentation(Representation::Double());
5336 } else {
5337 compare = new(zone()) HCompareIDAndBranch(left, right, op);
5338 compare->SetInputRepresentation(left->representation());
5339 }
5340 5345
5341 HBasicBlock* return_left = graph()->CreateBasicBlock(); 5346 HBasicBlock* return_left = graph()->CreateBasicBlock();
5342 HBasicBlock* return_right = graph()->CreateBasicBlock(); 5347 HBasicBlock* return_right = graph()->CreateBasicBlock();
5343 5348
5344 compare->SetSuccessorAt(0, return_left); 5349 compare->SetSuccessorAt(0, return_left);
5345 compare->SetSuccessorAt(1, return_right); 5350 compare->SetSuccessorAt(1, return_right);
5346 current_block()->Finish(compare); 5351 current_block()->Finish(compare);
5347 5352
5348 set_current_block(return_left); 5353 set_current_block(return_left);
5349 Push(left); 5354 Push(left);
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
7628 } 7633 }
7629 } 7634 }
7630 7635
7631 #ifdef DEBUG 7636 #ifdef DEBUG
7632 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7637 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7633 if (allocator_ != NULL) allocator_->Verify(); 7638 if (allocator_ != NULL) allocator_->Verify();
7634 #endif 7639 #endif
7635 } 7640 }
7636 7641
7637 } } // namespace v8::internal 7642 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698