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

Side by Side Diff: src/hydrogen.cc

Issue 14471034: Better handling of Phi nodes with constant inputs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cleanup as discussed Created 7 years, 7 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/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 3509 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 HValue* use = it.value(); 3520 HValue* use = it.value();
3521 if (use->IsPhi()) { 3521 if (use->IsPhi()) {
3522 int id = HPhi::cast(use)->phi_id(); 3522 int id = HPhi::cast(use)->phi_id();
3523 if (connected_phis[i]->UnionIsChanged(*connected_phis[id])) 3523 if (connected_phis[i]->UnionIsChanged(*connected_phis[id]))
3524 change = true; 3524 change = true;
3525 } 3525 }
3526 } 3526 }
3527 } 3527 }
3528 } 3528 }
3529 3529
3530 // (3a) Use the phi reachability information from step 2 to 3530 // Simplify constant phi inputs where possible.
3531 for (int i = 0; i < phi_count; ++i) {
3532 phi_list->at(i)->SimplifyConstantInputs();
3533 }
3534
3535 // Use the phi reachability information from step 2 to
3531 // push information about values which can't be converted to integer 3536 // push information about values which can't be converted to integer
3532 // without deoptimization through the phi use-def chains, avoiding 3537 // without deoptimization through the phi use-def chains, avoiding
3533 // unnecessary deoptimizations later. 3538 // unnecessary deoptimizations later.
3534 for (int i = 0; i < phi_count; ++i) { 3539 for (int i = 0; i < phi_count; ++i) {
3535 HPhi* phi = phi_list->at(i); 3540 HPhi* phi = phi_list->at(i);
3536 bool cti = phi->AllOperandsConvertibleToInteger(); 3541 bool cti = phi->AllOperandsConvertibleToInteger();
3537 if (cti) continue; 3542 if (cti) continue;
3538 3543
3539 for (BitVector::Iterator it(connected_phis.at(i)); 3544 for (BitVector::Iterator it(connected_phis.at(i));
3540 !it.Done(); 3545 !it.Done();
3541 it.Advance()) { 3546 it.Advance()) {
3542 HPhi* phi = phi_list->at(it.Current()); 3547 HPhi* phi = phi_list->at(it.Current());
3543 phi->set_is_convertible_to_integer(false); 3548 phi->set_is_convertible_to_integer(false);
3544 } 3549 }
3545 } 3550 }
3546 3551
3547 // (3b) Use the phi reachability information from step 2 to 3552 // Use the phi reachability information from step 2 to
3548 // sum up the non-phi use counts of all connected phis. 3553 // sum up the non-phi use counts of all connected phis.
3549 for (int i = 0; i < phi_count; ++i) { 3554 for (int i = 0; i < phi_count; ++i) {
3550 HPhi* phi = phi_list->at(i); 3555 HPhi* phi = phi_list->at(i);
3551 for (BitVector::Iterator it(connected_phis.at(i)); 3556 for (BitVector::Iterator it(connected_phis.at(i));
3552 !it.Done(); 3557 !it.Done();
3553 it.Advance()) { 3558 it.Advance()) {
3554 int index = it.Current(); 3559 int index = it.Current();
3555 HPhi* it_use = phi_list->at(index); 3560 HPhi* it_use = phi_list->at(index);
3556 if (index != i) phi->AddNonPhiUsesFrom(it_use); // Don't count twice. 3561 if (index != i) phi->AddNonPhiUsesFrom(it_use); // Don't count twice.
3557 } 3562 }
(...skipping 5889 matching lines...) Expand 10 before | Expand all | Expand 10 after
9447 HValue* context = environment()->LookupContext(); 9452 HValue* context = environment()->LookupContext();
9448 HInstruction* instr = 9453 HInstruction* instr =
9449 HMul::New(zone(), context, value, graph()->GetConstantMinus1()); 9454 HMul::New(zone(), context, value, graph()->GetConstantMinus1());
9450 TypeInfo info = oracle()->UnaryType(expr); 9455 TypeInfo info = oracle()->UnaryType(expr);
9451 Representation rep = ToRepresentation(info); 9456 Representation rep = ToRepresentation(info);
9452 if (info.IsUninitialized()) { 9457 if (info.IsUninitialized()) {
9453 AddSoftDeoptimize(); 9458 AddSoftDeoptimize();
9454 info = TypeInfo::Unknown(); 9459 info = TypeInfo::Unknown();
9455 } 9460 }
9456 if (instr->IsBinaryOperation()) { 9461 if (instr->IsBinaryOperation()) {
9457 HBinaryOperation::cast(instr)->set_observed_input_representation(rep, rep); 9462 HBinaryOperation::cast(instr)->set_observed_input_representation(1, rep);
9463 HBinaryOperation::cast(instr)->set_observed_input_representation(2, rep);
9458 } 9464 }
9459 return ast_context()->ReturnInstruction(instr, expr->id()); 9465 return ast_context()->ReturnInstruction(instr, expr->id());
9460 } 9466 }
9461 9467
9462 9468
9463 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) { 9469 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) {
9464 CHECK_ALIVE(VisitForValue(expr->expression())); 9470 CHECK_ALIVE(VisitForValue(expr->expression()));
9465 HValue* value = Pop(); 9471 HValue* value = Pop();
9466 TypeInfo info = oracle()->UnaryType(expr); 9472 TypeInfo info = oracle()->UnaryType(expr);
9467 if (info.IsUninitialized()) { 9473 if (info.IsUninitialized()) {
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
9888 break; 9894 break;
9889 case Token::SHL: 9895 case Token::SHL:
9890 instr = HShl::New(zone(), context, left, right); 9896 instr = HShl::New(zone(), context, left, right);
9891 break; 9897 break;
9892 default: 9898 default:
9893 UNREACHABLE(); 9899 UNREACHABLE();
9894 } 9900 }
9895 9901
9896 if (instr->IsBinaryOperation()) { 9902 if (instr->IsBinaryOperation()) {
9897 HBinaryOperation* binop = HBinaryOperation::cast(instr); 9903 HBinaryOperation* binop = HBinaryOperation::cast(instr);
9898 binop->set_observed_input_representation(left_rep, right_rep); 9904 binop->set_observed_input_representation(1, left_rep);
9905 binop->set_observed_input_representation(2, right_rep);
9899 binop->initialize_output_representation(result_rep); 9906 binop->initialize_output_representation(result_rep);
9900 } 9907 }
9901 return instr; 9908 return instr;
9902 } 9909 }
9903 9910
9904 9911
9905 // Check for the form (%_ClassOf(foo) === 'BarClass'). 9912 // Check for the form (%_ClassOf(foo) === 'BarClass').
9906 static bool IsClassOfTest(CompareOperation* expr) { 9913 static bool IsClassOfTest(CompareOperation* expr) {
9907 if (expr->op() != Token::EQ_STRICT) return false; 9914 if (expr->op() != Token::EQ_STRICT) return false;
9908 CallRuntime* call = expr->left()->AsCallRuntime(); 9915 CallRuntime* call = expr->left()->AsCallRuntime();
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
10268 AddInstruction(new(zone()) HCheckNonSmi(right)); 10275 AddInstruction(new(zone()) HCheckNonSmi(right));
10269 AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone())); 10276 AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone()));
10270 HCompareObjectEqAndBranch* result = 10277 HCompareObjectEqAndBranch* result =
10271 new(zone()) HCompareObjectEqAndBranch(left, right); 10278 new(zone()) HCompareObjectEqAndBranch(left, right);
10272 result->set_position(expr->position()); 10279 result->set_position(expr->position());
10273 return ast_context()->ReturnControl(result, expr->id()); 10280 return ast_context()->ReturnControl(result, expr->id());
10274 } else { 10281 } else {
10275 if (combined_rep.IsTagged() || combined_rep.IsNone()) { 10282 if (combined_rep.IsTagged() || combined_rep.IsNone()) {
10276 HCompareGeneric* result = 10283 HCompareGeneric* result =
10277 new(zone()) HCompareGeneric(context, left, right, op); 10284 new(zone()) HCompareGeneric(context, left, right, op);
10278 result->set_observed_input_representation(left_rep, right_rep); 10285 result->set_observed_input_representation(1, left_rep);
10286 result->set_observed_input_representation(2, right_rep);
10279 result->set_position(expr->position()); 10287 result->set_position(expr->position());
10280 return ast_context()->ReturnInstruction(result, expr->id()); 10288 return ast_context()->ReturnInstruction(result, expr->id());
10281 } else { 10289 } else {
10282 HCompareIDAndBranch* result = 10290 HCompareIDAndBranch* result =
10283 new(zone()) HCompareIDAndBranch(left, right, op); 10291 new(zone()) HCompareIDAndBranch(left, right, op);
10284 result->set_observed_input_representation(left_rep, right_rep); 10292 result->set_observed_input_representation(left_rep, right_rep);
10285 result->set_position(expr->position()); 10293 result->set_position(expr->position());
10286 return ast_context()->ReturnControl(result, expr->id()); 10294 return ast_context()->ReturnControl(result, expr->id());
10287 } 10295 }
10288 } 10296 }
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after
11919 } 11927 }
11920 } 11928 }
11921 11929
11922 #ifdef DEBUG 11930 #ifdef DEBUG
11923 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11931 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11924 if (allocator_ != NULL) allocator_->Verify(); 11932 if (allocator_ != NULL) allocator_->Verify();
11925 #endif 11933 #endif
11926 } 11934 }
11927 11935
11928 } } // namespace v8::internal 11936 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698