OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/hydrogen-bce.h" | 5 #include "src/hydrogen-bce.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 | 9 |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 TightenCheck(lower_check_, new_check, new_offset); | 163 TightenCheck(lower_check_, new_check, new_offset); |
164 UpdateLowerOffsets(lower_check_, lower_offset_); | 164 UpdateLowerOffsets(lower_check_, lower_offset_); |
165 } | 165 } |
166 } else { | 166 } else { |
167 // Should never have called CoverCheck() in this case. | 167 // Should never have called CoverCheck() in this case. |
168 UNREACHABLE(); | 168 UNREACHABLE(); |
169 } | 169 } |
170 | 170 |
171 if (!keep_new_check) { | 171 if (!keep_new_check) { |
172 if (FLAG_trace_bce) { | 172 if (FLAG_trace_bce) { |
173 OS::Print("Eliminating check #%d after tightening\n", | 173 base::OS::Print("Eliminating check #%d after tightening\n", |
174 new_check->id()); | 174 new_check->id()); |
175 } | 175 } |
176 new_check->block()->graph()->isolate()->counters()-> | 176 new_check->block()->graph()->isolate()->counters()-> |
177 bounds_checks_eliminated()->Increment(); | 177 bounds_checks_eliminated()->Increment(); |
178 new_check->DeleteAndReplaceWith(new_check->ActualValue()); | 178 new_check->DeleteAndReplaceWith(new_check->ActualValue()); |
179 } else { | 179 } else { |
180 HBoundsCheck* first_check = new_check == lower_check_ ? upper_check_ | 180 HBoundsCheck* first_check = new_check == lower_check_ ? upper_check_ |
181 : lower_check_; | 181 : lower_check_; |
182 if (FLAG_trace_bce) { | 182 if (FLAG_trace_bce) { |
183 OS::Print("Moving second check #%d after first check #%d\n", | 183 base::OS::Print("Moving second check #%d after first check #%d\n", |
184 new_check->id(), first_check->id()); | 184 new_check->id(), first_check->id()); |
185 } | 185 } |
186 // The length is guaranteed to be live at first_check. | 186 // The length is guaranteed to be live at first_check. |
187 ASSERT(new_check->length() == first_check->length()); | 187 ASSERT(new_check->length() == first_check->length()); |
188 HInstruction* old_position = new_check->next(); | 188 HInstruction* old_position = new_check->next(); |
189 new_check->Unlink(); | 189 new_check->Unlink(); |
190 new_check->InsertAfter(first_check); | 190 new_check->InsertAfter(first_check); |
191 MoveIndexIfNecessary(new_check->index(), new_check, old_position); | 191 MoveIndexIfNecessary(new_check->index(), new_check, old_position); |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 276 } |
277 | 277 |
278 void TightenCheck(HBoundsCheck* original_check, | 278 void TightenCheck(HBoundsCheck* original_check, |
279 HBoundsCheck* tighter_check, | 279 HBoundsCheck* tighter_check, |
280 int32_t new_offset) { | 280 int32_t new_offset) { |
281 ASSERT(original_check->length() == tighter_check->length()); | 281 ASSERT(original_check->length() == tighter_check->length()); |
282 MoveIndexIfNecessary(tighter_check->index(), original_check, tighter_check); | 282 MoveIndexIfNecessary(tighter_check->index(), original_check, tighter_check); |
283 original_check->ReplaceAllUsesWith(original_check->index()); | 283 original_check->ReplaceAllUsesWith(original_check->index()); |
284 original_check->SetOperandAt(0, tighter_check->index()); | 284 original_check->SetOperandAt(0, tighter_check->index()); |
285 if (FLAG_trace_bce) { | 285 if (FLAG_trace_bce) { |
286 OS::Print("Tightened check #%d with offset %d from #%d\n", | 286 base::OS::Print("Tightened check #%d with offset %d from #%d\n", |
287 original_check->id(), new_offset, tighter_check->id()); | 287 original_check->id(), new_offset, tighter_check->id()); |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 DISALLOW_COPY_AND_ASSIGN(BoundsCheckBbData); | 291 DISALLOW_COPY_AND_ASSIGN(BoundsCheckBbData); |
292 }; | 292 }; |
293 | 293 |
294 | 294 |
295 static bool BoundsCheckKeyMatch(void* key1, void* key2) { | 295 static bool BoundsCheckKeyMatch(void* key1, void* key2) { |
296 BoundsCheckKey* k1 = static_cast<BoundsCheckKey*>(key1); | 296 BoundsCheckKey* k1 = static_cast<BoundsCheckKey*>(key1); |
297 BoundsCheckKey* k2 = static_cast<BoundsCheckKey*>(key2); | 297 BoundsCheckKey* k2 = static_cast<BoundsCheckKey*>(key2); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 bb_data_list = new(zone()) BoundsCheckBbData(key, | 389 bb_data_list = new(zone()) BoundsCheckBbData(key, |
390 offset, | 390 offset, |
391 offset, | 391 offset, |
392 bb, | 392 bb, |
393 check, | 393 check, |
394 check, | 394 check, |
395 bb_data_list, | 395 bb_data_list, |
396 NULL); | 396 NULL); |
397 *data_p = bb_data_list; | 397 *data_p = bb_data_list; |
398 if (FLAG_trace_bce) { | 398 if (FLAG_trace_bce) { |
399 OS::Print("Fresh bounds check data for block #%d: [%d]\n", | 399 base::OS::Print("Fresh bounds check data for block #%d: [%d]\n", |
400 bb->block_id(), offset); | 400 bb->block_id(), offset); |
401 } | 401 } |
402 } else if (data->OffsetIsCovered(offset)) { | 402 } else if (data->OffsetIsCovered(offset)) { |
403 bb->graph()->isolate()->counters()-> | 403 bb->graph()->isolate()->counters()-> |
404 bounds_checks_eliminated()->Increment(); | 404 bounds_checks_eliminated()->Increment(); |
405 if (FLAG_trace_bce) { | 405 if (FLAG_trace_bce) { |
406 OS::Print("Eliminating bounds check #%d, offset %d is covered\n", | 406 base::OS::Print("Eliminating bounds check #%d, offset %d is covered\n", |
407 check->id(), offset); | 407 check->id(), offset); |
408 } | 408 } |
409 check->DeleteAndReplaceWith(check->ActualValue()); | 409 check->DeleteAndReplaceWith(check->ActualValue()); |
410 } else if (data->BasicBlock() == bb) { | 410 } else if (data->BasicBlock() == bb) { |
411 // TODO(jkummerow): I think the following logic would be preferable: | 411 // TODO(jkummerow): I think the following logic would be preferable: |
412 // if (data->Basicblock() == bb || | 412 // if (data->Basicblock() == bb || |
413 // graph()->use_optimistic_licm() || | 413 // graph()->use_optimistic_licm() || |
414 // bb->IsLoopSuccessorDominator()) { | 414 // bb->IsLoopSuccessorDominator()) { |
415 // data->CoverCheck(check, offset) | 415 // data->CoverCheck(check, offset) |
416 // } else { | 416 // } else { |
417 // /* add pristine BCBbData like in (data == NULL) case above */ | 417 // /* add pristine BCBbData like in (data == NULL) case above */ |
(...skipping 14 matching lines...) Expand all Loading... |
432 : data->UpperOffset(); | 432 : data->UpperOffset(); |
433 bb_data_list = new(zone()) BoundsCheckBbData(key, | 433 bb_data_list = new(zone()) BoundsCheckBbData(key, |
434 new_lower_offset, | 434 new_lower_offset, |
435 new_upper_offset, | 435 new_upper_offset, |
436 bb, | 436 bb, |
437 data->LowerCheck(), | 437 data->LowerCheck(), |
438 data->UpperCheck(), | 438 data->UpperCheck(), |
439 bb_data_list, | 439 bb_data_list, |
440 data); | 440 data); |
441 if (FLAG_trace_bce) { | 441 if (FLAG_trace_bce) { |
442 OS::Print("Updated bounds check data for block #%d: [%d - %d]\n", | 442 base::OS::Print("Updated bounds check data for block #%d: [%d - %d]\n", |
443 bb->block_id(), new_lower_offset, new_upper_offset); | 443 bb->block_id(), new_lower_offset, new_upper_offset); |
444 } | 444 } |
445 table_.Insert(key, bb_data_list, zone()); | 445 table_.Insert(key, bb_data_list, zone()); |
446 } | 446 } |
447 } | 447 } |
448 | 448 |
449 return bb_data_list; | 449 return bb_data_list; |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 void HBoundsCheckEliminationPhase::PostProcessBlock( | 453 void HBoundsCheckEliminationPhase::PostProcessBlock( |
454 HBasicBlock* block, BoundsCheckBbData* data) { | 454 HBasicBlock* block, BoundsCheckBbData* data) { |
455 while (data != NULL) { | 455 while (data != NULL) { |
456 if (data->FatherInDominatorTree()) { | 456 if (data->FatherInDominatorTree()) { |
457 table_.Insert(data->Key(), data->FatherInDominatorTree(), zone()); | 457 table_.Insert(data->Key(), data->FatherInDominatorTree(), zone()); |
458 } else { | 458 } else { |
459 table_.Delete(data->Key()); | 459 table_.Delete(data->Key()); |
460 } | 460 } |
461 data = data->NextInBasicBlock(); | 461 data = data->NextInBasicBlock(); |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 } } // namespace v8::internal | 465 } } // namespace v8::internal |
OLD | NEW |