V8 Project
v8::internal::BoundsCheckBbData Class Reference
+ Inheritance diagram for v8::internal::BoundsCheckBbData:
+ Collaboration diagram for v8::internal::BoundsCheckBbData:

Public Member Functions

BoundsCheckKeyKey () const
 
int32_t LowerOffset () const
 
int32_t UpperOffset () const
 
HBasicBlock * BasicBlock () const
 
HBoundsCheck * LowerCheck () const
 
HBoundsCheck * UpperCheck () const
 
BoundsCheckBbDataNextInBasicBlock () const
 
BoundsCheckBbDataFatherInDominatorTree () const
 
bool OffsetIsCovered (int32_t offset) const
 
bool HasSingleCheck ()
 
void UpdateUpperOffsets (HBoundsCheck *check, int32_t offset)
 
void UpdateLowerOffsets (HBoundsCheck *check, int32_t offset)
 
void CoverCheck (HBoundsCheck *new_check, int32_t new_offset)
 
 BoundsCheckBbData (BoundsCheckKey *key, int32_t lower_offset, int32_t upper_offset, HBasicBlock *bb, HBoundsCheck *lower_check, HBoundsCheck *upper_check, BoundsCheckBbData *next_in_bb, BoundsCheckBbData *father_in_dt)
 
- Public Member Functions inherited from v8::internal::ZoneObject
 INLINE (void *operator new(size_t size, Zone *zone))
 
void operator delete (void *, size_t)
 
void operator delete (void *pointer, Zone *zone)
 

Private Member Functions

void MoveIndexIfNecessary (HValue *index_raw, HBoundsCheck *insert_before, HInstruction *end_of_scan_range)
 
void TightenCheck (HBoundsCheck *original_check, HBoundsCheck *tighter_check, int32_t new_offset)
 
 DISALLOW_COPY_AND_ASSIGN (BoundsCheckBbData)
 

Private Attributes

BoundsCheckKeykey_
 
int32_t lower_offset_
 
int32_t upper_offset_
 
HBasicBlock * basic_block_
 
HBoundsCheck * lower_check_
 
HBoundsCheck * upper_check_
 
BoundsCheckBbDatanext_in_bb_
 
BoundsCheckBbDatafather_in_dt_
 

Detailed Description

Definition at line 96 of file hydrogen-bce.cc.

Constructor & Destructor Documentation

◆ BoundsCheckBbData()

v8::internal::BoundsCheckBbData::BoundsCheckBbData ( BoundsCheckKey key,
int32_t  lower_offset,
int32_t  upper_offset,
HBasicBlock *  bb,
HBoundsCheck *  lower_check,
HBoundsCheck *  upper_check,
BoundsCheckBbData next_in_bb,
BoundsCheckBbData father_in_dt 
)
inline

Definition at line 195 of file hydrogen-bce.cc.

203  : key_(key),
204  lower_offset_(lower_offset),
205  upper_offset_(upper_offset),
206  basic_block_(bb),
207  lower_check_(lower_check),
208  upper_check_(upper_check),
209  next_in_bb_(next_in_bb),
210  father_in_dt_(father_in_dt) { }
BoundsCheckBbData * next_in_bb_
BoundsCheckBbData * father_in_dt_

Member Function Documentation

◆ BasicBlock()

HBasicBlock* v8::internal::BoundsCheckBbData::BasicBlock ( ) const
inline

Definition at line 101 of file hydrogen-bce.cc.

101 { return basic_block_; }

References basic_block_.

Referenced by v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock().

+ Here is the caller graph for this function:

◆ CoverCheck()

void v8::internal::BoundsCheckBbData::CoverCheck ( HBoundsCheck *  new_check,
int32_t  new_offset 
)
inline

Definition at line 143 of file hydrogen-bce.cc.

144  {
145  DCHECK(new_check->index()->representation().IsSmiOrInteger32());
146  bool keep_new_check = false;
147 
148  if (new_offset > upper_offset_) {
149  upper_offset_ = new_offset;
150  if (HasSingleCheck()) {
151  keep_new_check = true;
152  upper_check_ = new_check;
153  } else {
154  TightenCheck(upper_check_, new_check, new_offset);
156  }
157  } else if (new_offset < lower_offset_) {
158  lower_offset_ = new_offset;
159  if (HasSingleCheck()) {
160  keep_new_check = true;
161  lower_check_ = new_check;
162  } else {
163  TightenCheck(lower_check_, new_check, new_offset);
165  }
166  } else {
167  // Should never have called CoverCheck() in this case.
168  UNREACHABLE();
169  }
170 
171  if (!keep_new_check) {
172  if (FLAG_trace_bce) {
173  base::OS::Print("Eliminating check #%d after tightening\n",
174  new_check->id());
175  }
176  new_check->block()->graph()->isolate()->counters()->
177  bounds_checks_eliminated()->Increment();
178  new_check->DeleteAndReplaceWith(new_check->ActualValue());
179  } else {
180  HBoundsCheck* first_check = new_check == lower_check_ ? upper_check_
181  : lower_check_;
182  if (FLAG_trace_bce) {
183  base::OS::Print("Moving second check #%d after first check #%d\n",
184  new_check->id(), first_check->id());
185  }
186  // The length is guaranteed to be live at first_check.
187  DCHECK(new_check->length() == first_check->length());
188  HInstruction* old_position = new_check->next();
189  new_check->Unlink();
190  new_check->InsertAfter(first_check);
191  MoveIndexIfNecessary(new_check->index(), new_check, old_position);
192  }
193  }
static void Print(const char *format,...)
void UpdateLowerOffsets(HBoundsCheck *check, int32_t offset)
void TightenCheck(HBoundsCheck *original_check, HBoundsCheck *tighter_check, int32_t new_offset)
void UpdateUpperOffsets(HBoundsCheck *check, int32_t offset)
void MoveIndexIfNecessary(HValue *index_raw, HBoundsCheck *insert_before, HInstruction *end_of_scan_range)
#define UNREACHABLE()
Definition: logging.h:30
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, HasSingleCheck(), lower_check_, lower_offset_, MoveIndexIfNecessary(), v8::internal::HInstruction::next(), v8::base::OS::Print(), TightenCheck(), v8::internal::HInstruction::Unlink(), UNREACHABLE, UpdateLowerOffsets(), UpdateUpperOffsets(), upper_check_, and upper_offset_.

Referenced by v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock().

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

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::BoundsCheckBbData::DISALLOW_COPY_AND_ASSIGN ( BoundsCheckBbData  )
private

◆ FatherInDominatorTree()

BoundsCheckBbData* v8::internal::BoundsCheckBbData::FatherInDominatorTree ( ) const
inline

Definition at line 105 of file hydrogen-bce.cc.

105 { return father_in_dt_; }

References father_in_dt_.

Referenced by v8::internal::HBoundsCheckEliminationPhase::PostProcessBlock(), UpdateLowerOffsets(), and UpdateUpperOffsets().

+ Here is the caller graph for this function:

◆ HasSingleCheck()

bool v8::internal::BoundsCheckBbData::HasSingleCheck ( )
inline

Definition at line 111 of file hydrogen-bce.cc.

111 { return lower_check_ == upper_check_; }

References lower_check_, and upper_check_.

Referenced by CoverCheck().

+ Here is the caller graph for this function:

◆ Key()

BoundsCheckKey* v8::internal::BoundsCheckBbData::Key ( ) const
inline

Definition at line 98 of file hydrogen-bce.cc.

98 { return key_; }

References key_.

Referenced by v8::internal::HBoundsCheckEliminationPhase::PostProcessBlock().

+ Here is the caller graph for this function:

◆ LowerCheck()

HBoundsCheck* v8::internal::BoundsCheckBbData::LowerCheck ( ) const
inline

Definition at line 102 of file hydrogen-bce.cc.

102 { return lower_check_; }

References lower_check_.

Referenced by v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock(), and UpdateLowerOffsets().

+ Here is the caller graph for this function:

◆ LowerOffset()

int32_t v8::internal::BoundsCheckBbData::LowerOffset ( ) const
inline

Definition at line 99 of file hydrogen-bce.cc.

99 { return lower_offset_; }

References lower_offset_.

Referenced by OffsetIsCovered(), and v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock().

+ Here is the caller graph for this function:

◆ MoveIndexIfNecessary()

void v8::internal::BoundsCheckBbData::MoveIndexIfNecessary ( HValue index_raw,
HBoundsCheck *  insert_before,
HInstruction end_of_scan_range 
)
inlineprivate

Definition at line 222 of file hydrogen-bce.cc.

224  {
225  // index_raw can be HAdd(index_base, offset), HSub(index_base, offset),
226  // HConstant(offset) or index_base directly.
227  // In the latter case, no need to move anything.
228  if (index_raw->IsAdd() || index_raw->IsSub()) {
229  HArithmeticBinaryOperation* index =
231  HValue* left_input = index->left();
232  HValue* right_input = index->right();
233  bool must_move_index = false;
234  bool must_move_left_input = false;
235  bool must_move_right_input = false;
236  for (HInstruction* cursor = end_of_scan_range; cursor != insert_before;) {
237  if (cursor == left_input) must_move_left_input = true;
238  if (cursor == right_input) must_move_right_input = true;
239  if (cursor == index) must_move_index = true;
240  if (cursor->previous() == NULL) {
241  cursor = cursor->block()->dominator()->end();
242  } else {
243  cursor = cursor->previous();
244  }
245  }
246  if (must_move_index) {
247  index->Unlink();
248  index->InsertBefore(insert_before);
249  }
250  // The BCE algorithm only selects mergeable bounds checks that share
251  // the same "index_base", so we'll only ever have to move constants.
252  if (must_move_left_input) {
253  HConstant::cast(left_input)->Unlink();
254  HConstant::cast(left_input)->InsertBefore(index);
255  }
256  if (must_move_right_input) {
257  HConstant::cast(right_input)->Unlink();
258  HConstant::cast(right_input)->InsertBefore(index);
259  }
260  } else if (index_raw->IsConstant()) {
261  HConstant* index = HConstant::cast(index_raw);
262  bool must_move = false;
263  for (HInstruction* cursor = end_of_scan_range; cursor != insert_before;) {
264  if (cursor == index) must_move = true;
265  if (cursor->previous() == NULL) {
266  cursor = cursor->block()->dominator()->end();
267  } else {
268  cursor = cursor->previous();
269  }
270  }
271  if (must_move) {
272  index->Unlink();
273  index->InsertBefore(insert_before);
274  }
275  }
276  }
static HValue * cast(HValue *value)
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::cast(), v8::internal::HInstruction::InsertBefore(), v8::internal::HBinaryOperation::left(), NULL, v8::internal::HBinaryOperation::right(), and v8::internal::HInstruction::Unlink().

Referenced by CoverCheck(), and TightenCheck().

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

◆ NextInBasicBlock()

BoundsCheckBbData* v8::internal::BoundsCheckBbData::NextInBasicBlock ( ) const
inline

Definition at line 104 of file hydrogen-bce.cc.

104 { return next_in_bb_; }

References next_in_bb_.

Referenced by v8::internal::HBoundsCheckEliminationPhase::PostProcessBlock().

+ Here is the caller graph for this function:

◆ OffsetIsCovered()

bool v8::internal::BoundsCheckBbData::OffsetIsCovered ( int32_t  offset) const
inline

Definition at line 107 of file hydrogen-bce.cc.

107  {
108  return offset >= LowerOffset() && offset <= UpperOffset();
109  }

References LowerOffset(), and UpperOffset().

Referenced by v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock().

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

◆ TightenCheck()

void v8::internal::BoundsCheckBbData::TightenCheck ( HBoundsCheck *  original_check,
HBoundsCheck *  tighter_check,
int32_t  new_offset 
)
inlineprivate

Definition at line 278 of file hydrogen-bce.cc.

280  {
281  DCHECK(original_check->length() == tighter_check->length());
282  MoveIndexIfNecessary(tighter_check->index(), original_check, tighter_check);
283  original_check->ReplaceAllUsesWith(original_check->index());
284  original_check->SetOperandAt(0, tighter_check->index());
285  if (FLAG_trace_bce) {
286  base::OS::Print("Tightened check #%d with offset %d from #%d\n",
287  original_check->id(), new_offset, tighter_check->id());
288  }
289  }

References DCHECK, MoveIndexIfNecessary(), and v8::base::OS::Print().

Referenced by CoverCheck().

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

◆ UpdateLowerOffsets()

void v8::internal::BoundsCheckBbData::UpdateLowerOffsets ( HBoundsCheck *  check,
int32_t  offset 
)
inline

Definition at line 122 of file hydrogen-bce.cc.

122  {
124  while (data != NULL && data->LowerCheck() == check) {
125  DCHECK(data->lower_offset_ > offset);
126  data->lower_offset_ = offset;
127  data = data->FatherInDominatorTree();
128  }
129  }
BoundsCheckBbData * FatherInDominatorTree() const
BoundsCheckBbData(BoundsCheckKey *key, int32_t lower_offset, int32_t upper_offset, HBasicBlock *bb, HBoundsCheck *lower_check, HBoundsCheck *upper_check, BoundsCheckBbData *next_in_bb, BoundsCheckBbData *father_in_dt)

References DCHECK, FatherInDominatorTree(), lower_offset_, LowerCheck(), and NULL.

Referenced by CoverCheck().

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

◆ UpdateUpperOffsets()

void v8::internal::BoundsCheckBbData::UpdateUpperOffsets ( HBoundsCheck *  check,
int32_t  offset 
)
inline

Definition at line 113 of file hydrogen-bce.cc.

113  {
115  while (data != NULL && data->UpperCheck() == check) {
116  DCHECK(data->upper_offset_ < offset);
117  data->upper_offset_ = offset;
118  data = data->FatherInDominatorTree();
119  }
120  }

References DCHECK, FatherInDominatorTree(), NULL, upper_offset_, and UpperCheck().

Referenced by CoverCheck().

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

◆ UpperCheck()

HBoundsCheck* v8::internal::BoundsCheckBbData::UpperCheck ( ) const
inline

Definition at line 103 of file hydrogen-bce.cc.

103 { return upper_check_; }

References upper_check_.

Referenced by v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock(), and UpdateUpperOffsets().

+ Here is the caller graph for this function:

◆ UpperOffset()

int32_t v8::internal::BoundsCheckBbData::UpperOffset ( ) const
inline

Definition at line 100 of file hydrogen-bce.cc.

100 { return upper_offset_; }

References upper_offset_.

Referenced by OffsetIsCovered(), and v8::internal::HBoundsCheckEliminationPhase::PreProcessBlock().

+ Here is the caller graph for this function:

Member Data Documentation

◆ basic_block_

HBasicBlock* v8::internal::BoundsCheckBbData::basic_block_
private

Definition at line 216 of file hydrogen-bce.cc.

Referenced by BasicBlock().

◆ father_in_dt_

BoundsCheckBbData* v8::internal::BoundsCheckBbData::father_in_dt_
private

Definition at line 220 of file hydrogen-bce.cc.

Referenced by FatherInDominatorTree().

◆ key_

BoundsCheckKey* v8::internal::BoundsCheckBbData::key_
private

Definition at line 213 of file hydrogen-bce.cc.

Referenced by Key().

◆ lower_check_

HBoundsCheck* v8::internal::BoundsCheckBbData::lower_check_
private

Definition at line 217 of file hydrogen-bce.cc.

Referenced by CoverCheck(), HasSingleCheck(), and LowerCheck().

◆ lower_offset_

int32_t v8::internal::BoundsCheckBbData::lower_offset_
private

Definition at line 214 of file hydrogen-bce.cc.

Referenced by CoverCheck(), LowerOffset(), and UpdateLowerOffsets().

◆ next_in_bb_

BoundsCheckBbData* v8::internal::BoundsCheckBbData::next_in_bb_
private

Definition at line 219 of file hydrogen-bce.cc.

Referenced by NextInBasicBlock().

◆ upper_check_

HBoundsCheck* v8::internal::BoundsCheckBbData::upper_check_
private

Definition at line 218 of file hydrogen-bce.cc.

Referenced by CoverCheck(), HasSingleCheck(), and UpperCheck().

◆ upper_offset_

int32_t v8::internal::BoundsCheckBbData::upper_offset_
private

Definition at line 215 of file hydrogen-bce.cc.

Referenced by CoverCheck(), UpdateUpperOffsets(), and UpperOffset().


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