 Chromium Code Reviews
 Chromium Code Reviews Issue 11445016:
  Make keyed operations use the unchecked index but still depend on the checked one.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 11445016:
  Make keyed operations use the unchecked index but still depend on the checked one.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| OLD | NEW | 
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright | 
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. | 
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above | 
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following | 
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided | 
| (...skipping 3466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3477 Key()->IndexBase(), | 3477 Key()->IndexBase(), | 
| 3478 new_check->index()->representation(), | 3478 new_check->index()->representation(), | 
| 3479 new_offset); | 3479 new_offset); | 
| 3480 lower_check_->SetOperandAt(0, added_lower_index_); | 3480 lower_check_->SetOperandAt(0, added_lower_index_); | 
| 3481 } | 3481 } | 
| 3482 } else { | 3482 } else { | 
| 3483 ASSERT(false); | 3483 ASSERT(false); | 
| 3484 } | 3484 } | 
| 3485 | 3485 | 
| 3486 if (!keep_new_check) { | 3486 if (!keep_new_check) { | 
| 3487 new_check->DeleteAndReplaceWith(NULL); | 3487 new_check->DeleteAndReplaceWith(new_check->index()); | 
| 3488 } | 3488 } | 
| 3489 } | 3489 } | 
| 3490 | 3490 | 
| 3491 void RemoveZeroOperations() { | 3491 void RemoveZeroOperations() { | 
| 3492 RemoveZeroAdd(&added_lower_index_, &added_lower_offset_); | 3492 RemoveZeroAdd(&added_lower_index_, &added_lower_offset_); | 
| 3493 RemoveZeroAdd(&added_upper_index_, &added_upper_offset_); | 3493 RemoveZeroAdd(&added_upper_index_, &added_upper_offset_); | 
| 3494 } | 3494 } | 
| 3495 | 3495 | 
| 3496 BoundsCheckBbData(BoundsCheckKey* key, | 3496 BoundsCheckBbData(BoundsCheckKey* key, | 
| 3497 int32_t lower_offset, | 3497 int32_t lower_offset, | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3584 Remove(key, key->Hash()); | 3584 Remove(key, key->Hash()); | 
| 3585 } | 3585 } | 
| 3586 | 3586 | 
| 3587 explicit BoundsCheckTable(Zone* zone) | 3587 explicit BoundsCheckTable(Zone* zone) | 
| 3588 : ZoneHashMap(BoundsCheckKeyMatch, ZoneHashMap::kDefaultHashMapCapacity, | 3588 : ZoneHashMap(BoundsCheckKeyMatch, ZoneHashMap::kDefaultHashMapCapacity, | 
| 3589 ZoneAllocationPolicy(zone)) { } | 3589 ZoneAllocationPolicy(zone)) { } | 
| 3590 }; | 3590 }; | 
| 3591 | 3591 | 
| 3592 | 3592 | 
| 3593 // Eliminates checks in bb and recursively in the dominated blocks. | 3593 // Eliminates checks in bb and recursively in the dominated blocks. | 
| 3594 // Also replace the results of check instructions with the original value, if | |
| 3595 // the result is used. This is safe now, since we don't do code motion after | |
| 3596 // this point. It enables better register allocation since the value produced | |
| 3597 // by check instructions is really a copy of the original value. | |
| 3598 void HGraph::EliminateRedundantBoundsChecks(HBasicBlock* bb, | 3594 void HGraph::EliminateRedundantBoundsChecks(HBasicBlock* bb, | 
| 3599 BoundsCheckTable* table) { | 3595 BoundsCheckTable* table) { | 
| 3600 BoundsCheckBbData* bb_data_list = NULL; | 3596 BoundsCheckBbData* bb_data_list = NULL; | 
| 3601 | 3597 | 
| 3602 for (HInstruction* i = bb->first(); i != NULL; i = i->next()) { | 3598 for (HInstruction* i = bb->first(); i != NULL; i = i->next()) { | 
| 3603 if (!i->IsBoundsCheck()) continue; | 3599 if (!i->IsBoundsCheck()) continue; | 
| 3604 | |
| 3605 HBoundsCheck* check = HBoundsCheck::cast(i); | 3600 HBoundsCheck* check = HBoundsCheck::cast(i); | 
| 3606 check->ReplaceAllUsesWith(check->index()); | |
| 3607 | |
| 3608 if (!FLAG_array_bounds_checks_elimination) continue; | |
| 3609 | 3601 | 
| 3610 int32_t offset; | 3602 int32_t offset; | 
| 3611 BoundsCheckKey* key = | 3603 BoundsCheckKey* key = | 
| 3612 BoundsCheckKey::Create(zone(), check, &offset); | 3604 BoundsCheckKey::Create(zone(), check, &offset); | 
| 3613 if (key == NULL) continue; | 3605 if (key == NULL) continue; | 
| 3614 BoundsCheckBbData** data_p = table->LookupOrInsert(key, zone()); | 3606 BoundsCheckBbData** data_p = table->LookupOrInsert(key, zone()); | 
| 3615 BoundsCheckBbData* data = *data_p; | 3607 BoundsCheckBbData* data = *data_p; | 
| 3616 if (data == NULL) { | 3608 if (data == NULL) { | 
| 3617 bb_data_list = new(zone()) BoundsCheckBbData(key, | 3609 bb_data_list = new(zone()) BoundsCheckBbData(key, | 
| 3618 offset, | 3610 offset, | 
| 3619 offset, | 3611 offset, | 
| 3620 bb, | 3612 bb, | 
| 3621 check, | 3613 check, | 
| 3622 check, | 3614 check, | 
| 3623 bb_data_list, | 3615 bb_data_list, | 
| 3624 NULL); | 3616 NULL); | 
| 3625 *data_p = bb_data_list; | 3617 *data_p = bb_data_list; | 
| 3626 } else if (data->OffsetIsCovered(offset)) { | 3618 } else if (data->OffsetIsCovered(offset)) { | 
| 3627 check->DeleteAndReplaceWith(NULL); | 3619 check->DeleteAndReplaceWith(check->index()); | 
| 3628 } else if (data->BasicBlock() == bb) { | 3620 } else if (data->BasicBlock() == bb) { | 
| 3629 data->CoverCheck(check, offset); | 3621 data->CoverCheck(check, offset); | 
| 3630 } else { | 3622 } else { | 
| 3631 int32_t new_lower_offset = offset < data->LowerOffset() | 3623 int32_t new_lower_offset = offset < data->LowerOffset() | 
| 3632 ? offset | 3624 ? offset | 
| 3633 : data->LowerOffset(); | 3625 : data->LowerOffset(); | 
| 3634 int32_t new_upper_offset = offset > data->UpperOffset() | 3626 int32_t new_upper_offset = offset > data->UpperOffset() | 
| 3635 ? offset | 3627 ? offset | 
| 3636 : data->UpperOffset(); | 3628 : data->UpperOffset(); | 
| 3637 bb_data_list = new(zone()) BoundsCheckBbData(key, | 3629 bb_data_list = new(zone()) BoundsCheckBbData(key, | 
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3657 if (data->FatherInDominatorTree()) { | 3649 if (data->FatherInDominatorTree()) { | 
| 3658 table->Insert(data->Key(), data->FatherInDominatorTree(), zone()); | 3650 table->Insert(data->Key(), data->FatherInDominatorTree(), zone()); | 
| 3659 } else { | 3651 } else { | 
| 3660 table->Delete(data->Key()); | 3652 table->Delete(data->Key()); | 
| 3661 } | 3653 } | 
| 3662 } | 3654 } | 
| 3663 } | 3655 } | 
| 3664 | 3656 | 
| 3665 | 3657 | 
| 3666 void HGraph::EliminateRedundantBoundsChecks() { | 3658 void HGraph::EliminateRedundantBoundsChecks() { | 
| 3659 if (!FLAG_array_bounds_checks_elimination) return; | |
| 
Sven Panne
2012/12/06 14:59:02
For consistency with the other phases, move this t
 
Massi
2012/12/07 10:11:11
Done.
 | |
| 3660 | |
| 3667 HPhase phase("H_Eliminate bounds checks", this); | 3661 HPhase phase("H_Eliminate bounds checks", this); | 
| 3668 BoundsCheckTable checks_table(zone()); | 3662 BoundsCheckTable checks_table(zone()); | 
| 3669 EliminateRedundantBoundsChecks(entry_block(), &checks_table); | 3663 EliminateRedundantBoundsChecks(entry_block(), &checks_table); | 
| 3670 } | 3664 } | 
| 3671 | 3665 | 
| 3672 | 3666 | 
| 3673 static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) { | 3667 static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) { | 
| 3674 HValue* index = array_operation->GetKey(); | 3668 HValue* index = array_operation->GetKey(); | 
| 3675 if (!index->representation().IsInteger32()) return; | 3669 if (!index->representation().IsInteger32()) return; | 
| 3676 | 3670 | 
| (...skipping 6382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10059 } | 10053 } | 
| 10060 } | 10054 } | 
| 10061 | 10055 | 
| 10062 #ifdef DEBUG | 10056 #ifdef DEBUG | 
| 10063 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10057 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 
| 10064 if (allocator_ != NULL) allocator_->Verify(); | 10058 if (allocator_ != NULL) allocator_->Verify(); | 
| 10065 #endif | 10059 #endif | 
| 10066 } | 10060 } | 
| 10067 | 10061 | 
| 10068 } } // namespace v8::internal | 10062 } } // namespace v8::internal | 
| OLD | NEW |