V8 Project
v8::internal::HCanonicalizePhase Class Reference

#include <hydrogen-canonicalize.h>

+ Inheritance diagram for v8::internal::HCanonicalizePhase:
+ Collaboration diagram for v8::internal::HCanonicalizePhase:

Public Member Functions

 HCanonicalizePhase (HGraph *graph)
 
void Run ()
 
- Public Member Functions inherited from v8::internal::HPhase
 HPhase (const char *name, HGraph *graph)
 
 ~HPhase ()
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (HCanonicalizePhase)
 

Additional Inherited Members

- Protected Member Functions inherited from v8::internal::HPhase
HGraph * graph () const
 

Detailed Description

Definition at line 14 of file hydrogen-canonicalize.h.

Constructor & Destructor Documentation

◆ HCanonicalizePhase()

v8::internal::HCanonicalizePhase::HCanonicalizePhase ( HGraph *  graph)
inlineexplicit

Definition at line 16 of file hydrogen-canonicalize.h.

17  : HPhase("H_Canonicalize", graph) { }
HGraph * graph() const
Definition: hydrogen.h:2802
HPhase(const char *name, HGraph *graph)
Definition: hydrogen.h:2796

Member Function Documentation

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::HCanonicalizePhase::DISALLOW_COPY_AND_ASSIGN ( HCanonicalizePhase  )
private

◆ Run()

void v8::internal::HCanonicalizePhase::Run ( )

Definition at line 11 of file hydrogen-canonicalize.cc.

11  {
12  const ZoneList<HBasicBlock*>* blocks(graph()->blocks());
13  // Before removing no-op instructions, save their semantic value.
14  // We must be careful not to set the flag unnecessarily, because GVN
15  // cannot identify two instructions when their flag value differs.
16  for (int i = 0; i < blocks->length(); ++i) {
17  for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
18  HInstruction* instr = it.Current();
19  if (instr->IsArithmeticBinaryOperation()) {
20  if (instr->representation().IsInteger32()) {
21  if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
24  }
25  } else if (instr->representation().IsSmi()) {
26  if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
29  } else if (instr->HasAtLeastOneUseWithFlagAndNoneWithout(
31  // Avoid redundant minus zero check
33  }
34  }
35  }
36  }
37  }
38 
39  // Perform actual Canonicalization pass.
40  HRedundantPhiEliminationPhase redundant_phi_eliminator(graph());
41  for (int i = 0; i < blocks->length(); ++i) {
42  // Eliminate redundant phis in the block first; changes to their inputs
43  // might have made them redundant, and eliminating them creates more
44  // opportunities for constant folding and strength reduction.
45  redundant_phi_eliminator.ProcessBlock(blocks->at(i));
46  // Now canonicalize each instruction.
47  for (HInstructionIterator it(blocks->at(i)); !it.Done(); it.Advance()) {
48  HInstruction* instr = it.Current();
49  HValue* value = instr->Canonicalize();
50  if (value != instr) instr->DeleteAndReplaceWith(value);
51  }
52  }
53 }

References v8::internal::List< T, AllocationPolicy >::at(), v8::internal::HValue::Canonicalize(), v8::internal::HValue::DeleteAndReplaceWith(), v8::internal::HPhase::graph(), v8::internal::HValue::HasAtLeastOneUseWithFlagAndNoneWithout(), v8::internal::Representation::IsInteger32(), v8::internal::Representation::IsSmi(), v8::internal::HValue::kAllUsesTruncatingToInt32, v8::internal::HValue::kAllUsesTruncatingToSmi, v8::internal::HValue::kTruncatingToInt32, v8::internal::HValue::kTruncatingToSmi, v8::internal::HRedundantPhiEliminationPhase::ProcessBlock(), v8::internal::HValue::representation(), and v8::internal::HValue::SetFlag().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: