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

Side by Side Diff: src/hydrogen.cc

Issue 9147034: Inlining Math.min and Math.max in crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Port to x64 and arm. Created 8 years, 11 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 | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('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 5122 matching lines...) Expand 10 before | Expand all | Expand 10 after
5133 AddCheckConstantFunction(expr, receiver, receiver_map, true); 5133 AddCheckConstantFunction(expr, receiver, receiver_map, true);
5134 Drop(1); 5134 Drop(1);
5135 HValue* context = environment()->LookupContext(); 5135 HValue* context = environment()->LookupContext();
5136 HGlobalObject* global_object = new(zone()) HGlobalObject(context); 5136 HGlobalObject* global_object = new(zone()) HGlobalObject(context);
5137 AddInstruction(global_object); 5137 AddInstruction(global_object);
5138 HRandom* result = new(zone()) HRandom(global_object); 5138 HRandom* result = new(zone()) HRandom(global_object);
5139 ast_context()->ReturnInstruction(result, expr->id()); 5139 ast_context()->ReturnInstruction(result, expr->id());
5140 return true; 5140 return true;
5141 } 5141 }
5142 break; 5142 break;
5143 case kMathMax:
5144 case kMathMin:
5145 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
5146 AddCheckConstantFunction(expr, receiver, receiver_map, true);
5147 HValue* right = Pop();
5148 HValue* left = Pop();
5149 // Do not inline if the return representation is not certain.
5150 if (!left->representation().Equals(right->representation())) {
5151 Push(left);
5152 Push(right);
5153 return false;
5154 }
5155
5156 Pop(); // Pop receiver.
5157 Token::Value op = (id == kMathMin) ? Token::LT : Token::GT;
5158 HCompareIDAndBranch* compare = NULL;
5159
5160 if (left->representation().IsTagged()) {
5161 HChange* left_cvt =
5162 new(zone()) HChange(left, Representation::Double(), false, true);
5163 left_cvt->SetFlag(HValue::kBailoutOnMinusZero);
5164 AddInstruction(left_cvt);
5165 HChange* right_cvt =
5166 new(zone()) HChange(right, Representation::Double(), false, true);
5167 right_cvt->SetFlag(HValue::kBailoutOnMinusZero);
5168 AddInstruction(right_cvt);
5169 compare = new(zone()) HCompareIDAndBranch(left_cvt, right_cvt, op);
5170 compare->SetInputRepresentation(Representation::Double());
5171 } else {
5172 compare = new(zone()) HCompareIDAndBranch(left, right, op);
5173 compare->SetInputRepresentation(left->representation());
5174 }
5175
5176 HBasicBlock* return_left = graph()->CreateBasicBlock();
5177 HBasicBlock* return_right = graph()->CreateBasicBlock();
5178
5179 compare->SetSuccessorAt(0, return_left);
5180 compare->SetSuccessorAt(1, return_right);
5181 current_block()->Finish(compare);
5182
5183 set_current_block(return_left);
5184 Push(left);
5185 set_current_block(return_right);
5186 Push(right);
5187
5188 HBasicBlock* join = CreateJoin(return_left, return_right, expr->id());
5189 set_current_block(join);
5190 ast_context()->ReturnValue(Pop());
5191 return true;
5192 }
5193 break;
5143 default: 5194 default:
5144 // Not yet supported for inlining. 5195 // Not yet supported for inlining.
5145 break; 5196 break;
5146 } 5197 }
5147 return false; 5198 return false;
5148 } 5199 }
5149 5200
5150 5201
5151 bool HGraphBuilder::TryCallApply(Call* expr) { 5202 bool HGraphBuilder::TryCallApply(Call* expr) {
5152 Expression* callee = expr->expression(); 5203 Expression* callee = expr->expression();
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after
7333 } 7384 }
7334 } 7385 }
7335 7386
7336 #ifdef DEBUG 7387 #ifdef DEBUG
7337 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7388 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7338 if (allocator_ != NULL) allocator_->Verify(); 7389 if (allocator_ != NULL) allocator_->Verify();
7339 #endif 7390 #endif
7340 } 7391 }
7341 7392
7342 } } // namespace v8::internal 7393 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698