V8 Project
v8::internal::HStoreEliminationPhase Class Reference

#include <hydrogen-store-elimination.h>

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

Public Member Functions

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

Private Member Functions

void ProcessStore (HStoreNamedField *store)
 
void ProcessLoad (HLoadNamedField *load)
 
void ProcessInstr (HInstruction *instr, GVNFlagSet flags)
 

Private Attributes

ZoneList< HStoreNamedField * > unobserved_
 
HAliasAnalyzeraliasing_
 

Additional Inherited Members

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

Detailed Description

Definition at line 14 of file hydrogen-store-elimination.h.

Constructor & Destructor Documentation

◆ HStoreEliminationPhase()

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

Definition at line 16 of file hydrogen-store-elimination.h.

17  : HPhase("H_Store elimination", graph),
18  unobserved_(10, zone()),
19  aliasing_() { }
HGraph * graph() const
Definition: hydrogen.h:2802
HPhase(const char *name, HGraph *graph)
Definition: hydrogen.h:2796
ZoneList< HStoreNamedField * > unobserved_

Member Function Documentation

◆ ProcessInstr()

void v8::internal::HStoreEliminationPhase::ProcessInstr ( HInstruction instr,
GVNFlagSet  flags 
)
private

Definition at line 98 of file hydrogen-store-elimination.cc.

99  {
100  if (unobserved_.length() == 0) return; // Nothing to do.
101  if (instr->CanDeoptimize()) {
102  TRACE(("-- Observed stores at I%d (%s might deoptimize)\n",
103  instr->id(), instr->Mnemonic()));
104  unobserved_.Rewind(0);
105  return;
106  }
107  if (instr->CheckChangesFlag(kNewSpacePromotion)) {
108  TRACE(("-- Observed stores at I%d (%s might GC)\n",
109  instr->id(), instr->Mnemonic()));
110  unobserved_.Rewind(0);
111  return;
112  }
113  if (instr->DependsOnFlags().ContainsAnyOf(flags)) {
114  TRACE(("-- Observed stores at I%d (GVN flags of %s)\n",
115  instr->id(), instr->Mnemonic()));
116  unobserved_.Rewind(0);
117  return;
118  }
119 }
#define TRACE(x)

References v8::internal::HInstruction::CanDeoptimize(), v8::internal::HValue::CheckChangesFlag(), v8::internal::EnumSet< E, T >::ContainsAnyOf(), v8::internal::HValue::DependsOnFlags(), v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::HValue::id(), v8::internal::HValue::Mnemonic(), TRACE, and unobserved_.

Referenced by Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessLoad()

void v8::internal::HStoreEliminationPhase::ProcessLoad ( HLoadNamedField *  load)
private

Definition at line 82 of file hydrogen-store-elimination.cc.

82  {
83  HValue* object = load->object()->ActualValue();
84  int i = 0;
85  while (i < unobserved_.length()) {
86  HStoreNamedField* prev = unobserved_.at(i);
87  if (aliasing_->MayAlias(object, prev->object()->ActualValue()) &&
88  load->access().Equals(prev->access())) {
89  TRACE(("-- Observed store S%d by load L%d\n", prev->id(), load->id()));
91  } else {
92  i++;
93  }
94  }
95 }
bool MayAlias(HValue *a, HValue *b)
T & at(int i) const
Definition: list.h:69
T Remove(int i)
Definition: list-inl.h:103

References v8::internal::HValue::ActualValue(), aliasing_, v8::internal::List< T, AllocationPolicy >::at(), v8::internal::HAliasAnalyzer::MayAlias(), v8::internal::List< T, AllocationPolicy >::Remove(), TRACE, and unobserved_.

Referenced by Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ProcessStore()

void v8::internal::HStoreEliminationPhase::ProcessStore ( HStoreNamedField *  store)
private

Definition at line 57 of file hydrogen-store-elimination.cc.

57  {
58  HValue* object = store->object()->ActualValue();
59  int i = 0;
60  while (i < unobserved_.length()) {
61  HStoreNamedField* prev = unobserved_.at(i);
62  if (aliasing_->MustAlias(object, prev->object()->ActualValue()) &&
63  prev->CanBeReplacedWith(store)) {
64  // This store is guaranteed to overwrite the previous store.
65  prev->DeleteAndReplaceWith(NULL);
66  TRACE(("++ Unobserved store S%d overwritten by S%d\n",
67  prev->id(), store->id()));
69  } else {
70  // TODO(titzer): remove map word clearing from folded allocations.
71  i++;
72  }
73  }
74  // Only non-transitioning stores are removable.
75  if (!store->has_transition()) {
76  TRACE(("-- Might remove store S%d\n", store->id()));
77  unobserved_.Add(store, zone());
78  }
79 }
bool MustAlias(HValue *a, HValue *b)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
Definition: list-inl.h:17
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

References v8::internal::HValue::ActualValue(), v8::internal::List< T, AllocationPolicy >::Add(), aliasing_, v8::internal::List< T, AllocationPolicy >::at(), v8::internal::HAliasAnalyzer::MustAlias(), NULL, v8::internal::List< T, AllocationPolicy >::Remove(), TRACE, and unobserved_.

Referenced by Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Run()

void v8::internal::HStoreEliminationPhase::Run ( )

Definition at line 14 of file hydrogen-store-elimination.cc.

14  {
15  GVNFlagSet flags; // Use GVN flags as an approximation for some instructions.
16  flags.RemoveAll();
17 
18  flags.Add(kArrayElements);
19  flags.Add(kArrayLengths);
20  flags.Add(kStringLengths);
21  flags.Add(kBackingStoreFields);
22  flags.Add(kDoubleArrayElements);
23  flags.Add(kDoubleFields);
24  flags.Add(kElementsPointer);
25  flags.Add(kInobjectFields);
26  flags.Add(kExternalMemory);
27  flags.Add(kStringChars);
28  flags.Add(kTypedArrayElements);
29 
30  for (int i = 0; i < graph()->blocks()->length(); i++) {
31  unobserved_.Rewind(0);
32  HBasicBlock* block = graph()->blocks()->at(i);
33  if (!block->IsReachable()) continue;
34  for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
35  HInstruction* instr = it.Current();
36  if (instr->CheckFlag(HValue::kIsDead)) continue;
37 
38  // TODO(titzer): eliminate unobserved HStoreKeyed instructions too.
39  switch (instr->opcode()) {
40  case HValue::kStoreNamedField:
41  // Remove any unobserved stores overwritten by this store.
42  ProcessStore(HStoreNamedField::cast(instr));
43  break;
44  case HValue::kLoadNamedField:
45  // Observe any unobserved stores on this object + field.
46  ProcessLoad(HLoadNamedField::cast(instr));
47  break;
48  default:
49  ProcessInstr(instr, flags);
50  break;
51  }
52  }
53  }
54 }
void ProcessInstr(HInstruction *instr, GVNFlagSet flags)
EnumSet< GVNFlag, int32_t > GVNFlagSet

References v8::internal::HValue::CheckFlag(), v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::HPhase::graph(), v8::internal::HValue::kIsDead, v8::internal::HValue::opcode(), ProcessInstr(), ProcessLoad(), ProcessStore(), and unobserved_.

+ Here is the call graph for this function:

Member Data Documentation

◆ aliasing_

HAliasAnalyzer* v8::internal::HStoreEliminationPhase::aliasing_
private

Definition at line 24 of file hydrogen-store-elimination.h.

Referenced by ProcessLoad(), and ProcessStore().

◆ unobserved_

ZoneList<HStoreNamedField*> v8::internal::HStoreEliminationPhase::unobserved_
private

Definition at line 23 of file hydrogen-store-elimination.h.

Referenced by ProcessInstr(), ProcessLoad(), ProcessStore(), and Run().


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