V8 Project
hydrogen-redundant-phi.cc
Go to the documentation of this file.
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 namespace v8 {
8 namespace internal {
9 
11  // Gather all phis from all blocks first.
12  const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
13  ZoneList<HPhi*> all_phis(blocks->length(), zone());
14  for (int i = 0; i < blocks->length(); ++i) {
15  HBasicBlock* block = blocks->at(i);
16  for (int j = 0; j < block->phis()->length(); j++) {
17  all_phis.Add(block->phis()->at(j), zone());
18  }
19  }
20 
21  // Iteratively reduce all phis in the list.
22  ProcessPhis(&all_phis);
23 
24 #if DEBUG
25  // Make sure that we *really* removed all redundant phis.
26  for (int i = 0; i < blocks->length(); ++i) {
27  for (int j = 0; j < blocks->at(i)->phis()->length(); j++) {
28  DCHECK(blocks->at(i)->phis()->at(j)->GetRedundantReplacement() == NULL);
29  }
30  }
31 #endif
32 }
33 
34 
36  ProcessPhis(block->phis());
37 }
38 
39 
41  bool updated;
42  do {
43  // Iterately replace all redundant phis in the given list.
44  updated = false;
45  for (int i = 0; i < phis->length(); i++) {
46  HPhi* phi = phis->at(i);
47  if (phi->CheckFlag(HValue::kIsDead)) continue; // Already replaced.
48 
49  HValue* replacement = phi->GetRedundantReplacement();
50  if (replacement != NULL) {
52  for (HUseIterator it(phi->uses()); !it.Done(); it.Advance()) {
53  HValue* value = it.value();
54  value->SetOperandAt(it.index(), replacement);
55  // Iterate again if used in another non-dead phi.
56  updated |= value->IsPhi() && !value->CheckFlag(HValue::kIsDead);
57  }
58  phi->block()->RemovePhi(phi);
59  }
60  }
61  } while (updated);
62 }
63 
64 
65 } } // namespace v8::internal
HGraph * graph() const
Definition: hydrogen.h:2802
void ProcessPhis(const ZoneList< HPhi * > *phis)
void SetOperandAt(int index, HValue *value)
bool CheckFlag(Flag f) const
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17
T & at(int i) const
Definition: list.h:69
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Definition: logging.h:205
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20