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

Side by Side Diff: src/hydrogen.cc

Issue 18549004: Turn redundant phi elimination into proper HPhase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Trivial cleanup Created 7 years, 5 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/hydrogen.h ('k') | src/hydrogen-redundant-phi.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 22 matching lines...) Expand all
33 #include "codegen.h" 33 #include "codegen.h"
34 #include "full-codegen.h" 34 #include "full-codegen.h"
35 #include "hashmap.h" 35 #include "hashmap.h"
36 #include "hydrogen-dce.h" 36 #include "hydrogen-dce.h"
37 #include "hydrogen-environment-liveness.h" 37 #include "hydrogen-environment-liveness.h"
38 #include "hydrogen-escape-analysis.h" 38 #include "hydrogen-escape-analysis.h"
39 #include "hydrogen-infer-representation.h" 39 #include "hydrogen-infer-representation.h"
40 #include "hydrogen-gvn.h" 40 #include "hydrogen-gvn.h"
41 #include "hydrogen-osr.h" 41 #include "hydrogen-osr.h"
42 #include "hydrogen-range-analysis.h" 42 #include "hydrogen-range-analysis.h"
43 #include "hydrogen-redundant-phi.h"
43 #include "hydrogen-sce.h" 44 #include "hydrogen-sce.h"
44 #include "hydrogen-uint32-analysis.h" 45 #include "hydrogen-uint32-analysis.h"
45 #include "lithium-allocator.h" 46 #include "lithium-allocator.h"
46 #include "parser.h" 47 #include "parser.h"
47 #include "scopeinfo.h" 48 #include "scopeinfo.h"
48 #include "scopes.h" 49 #include "scopes.h"
49 #include "stub-cache.h" 50 #include "stub-cache.h"
50 #include "typing.h" 51 #include "typing.h"
51 52
52 #if V8_TARGET_ARCH_IA32 53 #if V8_TARGET_ARCH_IA32
(...skipping 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 } 2517 }
2517 if (instr->IsSoftDeoptimize()) { 2518 if (instr->IsSoftDeoptimize()) {
2518 ASSERT(block->IsDeoptimizing()); 2519 ASSERT(block->IsDeoptimizing());
2519 nullify = true; 2520 nullify = true;
2520 } 2521 }
2521 } 2522 }
2522 } 2523 }
2523 } 2524 }
2524 2525
2525 2526
2526 // Replace all phis consisting of a single non-loop operand plus any number of
2527 // loop operands by that single non-loop operand.
2528 void HGraph::EliminateRedundantPhis() {
2529 HPhase phase("H_Redundant phi elimination", this);
2530
2531 // We do a simple fixed point iteration without any work list, because
2532 // machine-generated JavaScript can lead to a very dense Hydrogen graph with
2533 // an enormous work list and will consequently result in OOM. Experiments
2534 // showed that this simple algorithm is good enough, and even e.g. tracking
2535 // the set or range of blocks to consider is not a real improvement.
2536 bool need_another_iteration;
2537 ZoneList<HPhi*> redundant_phis(blocks_.length(), zone());
2538 do {
2539 need_another_iteration = false;
2540 for (int i = 0; i < blocks_.length(); ++i) {
2541 HBasicBlock* block = blocks_[i];
2542 for (int j = 0; j < block->phis()->length(); j++) {
2543 HPhi* phi = block->phis()->at(j);
2544 HValue* replacement = phi->GetRedundantReplacement();
2545 if (replacement != NULL) {
2546 // Remember phi to avoid concurrent modification of the block's phis.
2547 redundant_phis.Add(phi, zone());
2548 for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) {
2549 HValue* value = it.value();
2550 value->SetOperandAt(it.index(), replacement);
2551 need_another_iteration |= value->IsPhi();
2552 }
2553 }
2554 }
2555 for (int i = 0; i < redundant_phis.length(); i++) {
2556 block->RemovePhi(redundant_phis[i]);
2557 }
2558 redundant_phis.Clear();
2559 }
2560 } while (need_another_iteration);
2561
2562 #if DEBUG
2563 // Make sure that we *really* removed all redundant phis.
2564 for (int i = 0; i < blocks_.length(); ++i) {
2565 for (int j = 0; j < blocks_[i]->phis()->length(); j++) {
2566 ASSERT(blocks_[i]->phis()->at(j)->GetRedundantReplacement() == NULL);
2567 }
2568 }
2569 #endif
2570 }
2571
2572
2573 bool HGraph::CheckArgumentsPhiUses() { 2527 bool HGraph::CheckArgumentsPhiUses() {
2574 int block_count = blocks_.length(); 2528 int block_count = blocks_.length();
2575 for (int i = 0; i < block_count; ++i) { 2529 for (int i = 0; i < block_count; ++i) {
2576 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { 2530 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
2577 HPhi* phi = blocks_[i]->phis()->at(j); 2531 HPhi* phi = blocks_[i]->phis()->at(j);
2578 // We don't support phi uses of arguments for now. 2532 // We don't support phi uses of arguments for now.
2579 if (phi->CheckFlag(HValue::kIsArguments)) return false; 2533 if (phi->CheckFlag(HValue::kIsArguments)) return false;
2580 } 2534 }
2581 } 2535 }
2582 return true; 2536 return true;
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
3410 if (FLAG_analyze_environment_liveness && maximum_environment_size() != 0) { 3364 if (FLAG_analyze_environment_liveness && maximum_environment_size() != 0) {
3411 Run<HEnvironmentLivenessAnalysisPhase>(); 3365 Run<HEnvironmentLivenessAnalysisPhase>();
3412 } 3366 }
3413 3367
3414 PropagateDeoptimizingMark(); 3368 PropagateDeoptimizingMark();
3415 if (!CheckConstPhiUses()) { 3369 if (!CheckConstPhiUses()) {
3416 *bailout_reason = SmartArrayPointer<char>(StrDup( 3370 *bailout_reason = SmartArrayPointer<char>(StrDup(
3417 "Unsupported phi use of const variable")); 3371 "Unsupported phi use of const variable"));
3418 return false; 3372 return false;
3419 } 3373 }
3420 EliminateRedundantPhis(); 3374 Run<HRedundantPhiEliminationPhase>();
3421 if (!CheckArgumentsPhiUses()) { 3375 if (!CheckArgumentsPhiUses()) {
3422 *bailout_reason = SmartArrayPointer<char>(StrDup( 3376 *bailout_reason = SmartArrayPointer<char>(StrDup(
3423 "Unsupported phi use of arguments")); 3377 "Unsupported phi use of arguments"));
3424 return false; 3378 return false;
3425 } 3379 }
3426 3380
3427 // Remove dead code and phis 3381 // Remove dead code and phis
3428 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); 3382 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>();
3429 CollectPhis(); 3383 CollectPhis();
3430 3384
(...skipping 7269 matching lines...) Expand 10 before | Expand all | Expand 10 after
10700 if (ShouldProduceTraceOutput()) { 10654 if (ShouldProduceTraceOutput()) {
10701 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10655 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10702 } 10656 }
10703 10657
10704 #ifdef DEBUG 10658 #ifdef DEBUG
10705 graph_->Verify(false); // No full verify. 10659 graph_->Verify(false); // No full verify.
10706 #endif 10660 #endif
10707 } 10661 }
10708 10662
10709 } } // namespace v8::internal 10663 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-redundant-phi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698