Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index 893aa0369c3c5f7c9033075d32315c6ed2326261..915392635cf4de59587282c3bfae7f26066aec6f 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -5128,6 +5128,57 @@ bool HGraphBuilder::TryInlineBuiltinFunction(Call* expr, |
| return true; |
| } |
| break; |
| + case kMathMax: |
| + case kMathMin: |
| + if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { |
| + AddCheckConstantFunction(expr, receiver, receiver_map, true); |
| + HValue* right = Pop(); |
| + HValue* left = Pop(); |
| + // Do not inline if the return representation is not certain. |
| + if (!left->representation().Equals(right->representation())) { |
| + Push(left); |
| + Push(right); |
| + return false; |
| + } |
| + |
| + Pop(); // Pop receiver. |
| + Token::Value op = (id == kMathMin) ? Token::LT : Token::GT; |
| + HCompareIDAndBranch* compare = NULL; |
| + |
| + if (left->representation().IsTagged()) { |
| + HInstruction* left_cvt = |
|
fschneider
2012/01/11 10:29:32
maybe use HChange* instead (it's shorter and a bet
|
| + new(zone()) HChange(left, Representation::Double(), false, true); |
| + left_cvt->SetFlag(HValue::kBailoutOnMinusZero); |
| + AddInstruction(left_cvt); |
| + HInstruction* right_cvt = |
|
fschneider
2012/01/11 10:29:32
HChange* also here.
|
| + new(zone()) HChange(right, Representation::Double(), false, true); |
| + right_cvt->SetFlag(HValue::kBailoutOnMinusZero); |
| + AddInstruction(right_cvt); |
| + compare = new(zone()) HCompareIDAndBranch(left_cvt, right_cvt, op); |
| + compare->SetInputRepresentation(Representation::Double()); |
| + } else { |
| + compare = new(zone()) HCompareIDAndBranch(left, right, op); |
| + compare->SetInputRepresentation(left->representation()); |
| + } |
| + |
| + HBasicBlock* return_left = graph()->CreateBasicBlock(); |
| + HBasicBlock* return_right = graph()->CreateBasicBlock(); |
| + |
| + compare->SetSuccessorAt(0, return_left); |
| + compare->SetSuccessorAt(1, return_right); |
| + current_block()->Finish(compare); |
| + |
| + set_current_block(return_left); |
| + Push(left); |
| + set_current_block(return_right); |
| + Push(right); |
| + |
| + HBasicBlock* join = CreateJoin(return_left, return_right, expr->id()); |
| + set_current_block(join); |
| + ast_context()->ReturnValue(Pop()); |
| + return true; |
| + } |
| + break; |
| default: |
| // Not yet supported for inlining. |
| break; |