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

Side by Side Diff: src/hydrogen.cc

Issue 10034015: Merged r10755, r11237 into 3.8 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.8
Patch Set: 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 | src/version.cc » ('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 5143 matching lines...) Expand 10 before | Expand all | Expand 10 after
5154 ast_context()->ReturnInstruction(result, expr->id()); 5154 ast_context()->ReturnInstruction(result, expr->id());
5155 return true; 5155 return true;
5156 } 5156 }
5157 break; 5157 break;
5158 case kMathMax: 5158 case kMathMax:
5159 case kMathMin: 5159 case kMathMin:
5160 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { 5160 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
5161 AddCheckConstantFunction(expr, receiver, receiver_map, true); 5161 AddCheckConstantFunction(expr, receiver, receiver_map, true);
5162 HValue* right = Pop(); 5162 HValue* right = Pop();
5163 HValue* left = Pop(); 5163 HValue* left = Pop();
5164 // Do not inline if the return representation is not certain. 5164 Pop(); // Pop receiver.
5165 if (!left->representation().Equals(right->representation())) { 5165
5166 Push(left); 5166 HValue* left_operand = left;
5167 Push(right); 5167 HValue* right_operand = right;
5168 return false; 5168
5169 // If we do not have two integers, we convert to double for comparison.
5170 if (!left->representation().IsInteger32() ||
5171 !right->representation().IsInteger32()) {
5172 if (!left->representation().IsDouble()) {
5173 HChange* left_convert = new(zone()) HChange(
5174 left,
5175 Representation::Double(),
5176 false, // Do not truncate when converting to double.
5177 true); // Deoptimize for undefined.
5178 left_convert->SetFlag(HValue::kBailoutOnMinusZero);
5179 left_operand = AddInstruction(left_convert);
5180 }
5181 if (!right->representation().IsDouble()) {
5182 HChange* right_convert = new(zone()) HChange(
5183 right,
5184 Representation::Double(),
5185 false, // Do not truncate when converting to double.
5186 true); // Deoptimize for undefined.
5187 right_convert->SetFlag(HValue::kBailoutOnMinusZero);
5188 right_operand = AddInstruction(right_convert);
5189 }
5169 } 5190 }
5170 5191
5171 Pop(); // Pop receiver. 5192 ASSERT(left_operand->representation().Equals(
5193 right_operand->representation()));
5194 ASSERT(!left_operand->representation().IsTagged());
5195
5172 Token::Value op = (id == kMathMin) ? Token::LT : Token::GT; 5196 Token::Value op = (id == kMathMin) ? Token::LT : Token::GT;
5173 HCompareIDAndBranch* compare = NULL;
5174 5197
5175 if (left->representation().IsTagged()) { 5198 HCompareIDAndBranch* compare =
5176 HChange* left_cvt = 5199 new(zone()) HCompareIDAndBranch(left_operand, right_operand, op);
5177 new(zone()) HChange(left, Representation::Double(), false, true); 5200 compare->SetInputRepresentation(left_operand->representation());
5178 left_cvt->SetFlag(HValue::kBailoutOnMinusZero);
5179 AddInstruction(left_cvt);
5180 HChange* right_cvt =
5181 new(zone()) HChange(right, Representation::Double(), false, true);
5182 right_cvt->SetFlag(HValue::kBailoutOnMinusZero);
5183 AddInstruction(right_cvt);
5184 compare = new(zone()) HCompareIDAndBranch(left_cvt, right_cvt, op);
5185 compare->SetInputRepresentation(Representation::Double());
5186 } else {
5187 compare = new(zone()) HCompareIDAndBranch(left, right, op);
5188 compare->SetInputRepresentation(left->representation());
5189 }
5190 5201
5191 HBasicBlock* return_left = graph()->CreateBasicBlock(); 5202 HBasicBlock* return_left = graph()->CreateBasicBlock();
5192 HBasicBlock* return_right = graph()->CreateBasicBlock(); 5203 HBasicBlock* return_right = graph()->CreateBasicBlock();
5193 5204
5194 compare->SetSuccessorAt(0, return_left); 5205 compare->SetSuccessorAt(0, return_left);
5195 compare->SetSuccessorAt(1, return_right); 5206 compare->SetSuccessorAt(1, return_right);
5196 current_block()->Finish(compare); 5207 current_block()->Finish(compare);
5197 5208
5198 set_current_block(return_left); 5209 set_current_block(return_left);
5199 Push(left); 5210 Push(left);
5200 set_current_block(return_right); 5211 set_current_block(return_right);
5201 Push(right); 5212 // The branch above always returns the right operand if either of
5213 // them is NaN, but the spec requires that max/min(NaN, X) = NaN.
5214 // We add another branch that checks if the left operand is NaN or not.
5215 if (left_operand->representation().IsDouble()) {
5216 // If left_operand != left_operand then it is NaN.
5217 HCompareIDAndBranch* compare_nan = new(zone()) HCompareIDAndBranch(
5218 left_operand, left_operand, Token::EQ);
5219 compare_nan->SetInputRepresentation(left_operand->representation());
5220 HBasicBlock* left_is_number = graph()->CreateBasicBlock();
5221 HBasicBlock* left_is_nan = graph()->CreateBasicBlock();
5222 compare_nan->SetSuccessorAt(0, left_is_number);
5223 compare_nan->SetSuccessorAt(1, left_is_nan);
5224 current_block()->Finish(compare_nan);
5225 set_current_block(left_is_nan);
5226 Push(left);
5227 set_current_block(left_is_number);
5228 Push(right);
5229 return_right = CreateJoin(left_is_number, left_is_nan, expr->id());
5230 } else {
5231 Push(right);
5232 }
5202 5233
5203 HBasicBlock* join = CreateJoin(return_left, return_right, expr->id()); 5234 HBasicBlock* join = CreateJoin(return_left, return_right, expr->id());
5204 set_current_block(join); 5235 set_current_block(join);
5205 ast_context()->ReturnValue(Pop()); 5236 ast_context()->ReturnValue(Pop());
5206 return true; 5237 return true;
5207 } 5238 }
5208 break; 5239 break;
5209 default: 5240 default:
5210 // Not yet supported for inlining. 5241 // Not yet supported for inlining.
5211 break; 5242 break;
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after
7450 } 7481 }
7451 } 7482 }
7452 7483
7453 #ifdef DEBUG 7484 #ifdef DEBUG
7454 if (graph_ != NULL) graph_->Verify(false); // No full verify. 7485 if (graph_ != NULL) graph_->Verify(false); // No full verify.
7455 if (allocator_ != NULL) allocator_->Verify(); 7486 if (allocator_ != NULL) allocator_->Verify();
7456 #endif 7487 #endif
7457 } 7488 }
7458 7489
7459 } } // namespace v8::internal 7490 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698