Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1463)

Side by Side Diff: src/hydrogen.cc

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
Patch Set: Addressed review comments. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3308 matching lines...) Expand 10 before | Expand all | Expand 10 after
3319 if (FLAG_use_range) { 3319 if (FLAG_use_range) {
3320 HRangeAnalysis rangeAnalysis(this); 3320 HRangeAnalysis rangeAnalysis(this);
3321 rangeAnalysis.Analyze(); 3321 rangeAnalysis.Analyze();
3322 } 3322 }
3323 ComputeMinusZeroChecks(); 3323 ComputeMinusZeroChecks();
3324 3324
3325 // Eliminate redundant stack checks on backwards branches. 3325 // Eliminate redundant stack checks on backwards branches.
3326 HStackCheckEliminator sce(this); 3326 HStackCheckEliminator sce(this);
3327 sce.Process(); 3327 sce.Process();
3328 3328
3329 EliminateRedundantBoundsChecks(); 3329 if (FLAG_array_bounds_checks_elimination) EliminateRedundantBoundsChecks();
3330 DehoistSimpleArrayIndexComputations(); 3330 if (FLAG_array_index_dehoisting) DehoistSimpleArrayIndexComputations();
3331 if (FLAG_dead_code_elimination) DeadCodeElimination(); 3331 if (FLAG_dead_code_elimination) DeadCodeElimination();
3332 3332
3333 return true; 3333 return true;
3334 } 3334 }
3335 3335
3336 3336
3337 // We try to "factor up" HBoundsCheck instructions towards the root of the 3337 // We try to "factor up" HBoundsCheck instructions towards the root of the
3338 // dominator tree. 3338 // dominator tree.
3339 // For now we handle checks where the index is like "exp + int32value". 3339 // For now we handle checks where the index is like "exp + int32value".
3340 // If in the dominator tree we check "exp + v1" and later (dominated) 3340 // If in the dominator tree we check "exp + v1" and later (dominated)
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3712 if (index->HasNoUses()) { 3704 if (index->HasNoUses()) {
3713 index->DeleteAndReplaceWith(NULL); 3705 index->DeleteAndReplaceWith(NULL);
3714 } 3706 }
3715 ASSERT(value >= 0); 3707 ASSERT(value >= 0);
3716 array_operation->SetIndexOffset(static_cast<uint32_t>(value)); 3708 array_operation->SetIndexOffset(static_cast<uint32_t>(value));
3717 array_operation->SetDehoisted(true); 3709 array_operation->SetDehoisted(true);
3718 } 3710 }
3719 3711
3720 3712
3721 void HGraph::DehoistSimpleArrayIndexComputations() { 3713 void HGraph::DehoistSimpleArrayIndexComputations() {
3722 if (!FLAG_array_index_dehoisting) return;
3723
3724 HPhase phase("H_Dehoist index computations", this); 3714 HPhase phase("H_Dehoist index computations", this);
3725 for (int i = 0; i < blocks()->length(); ++i) { 3715 for (int i = 0; i < blocks()->length(); ++i) {
3726 for (HInstruction* instr = blocks()->at(i)->first(); 3716 for (HInstruction* instr = blocks()->at(i)->first();
3727 instr != NULL; 3717 instr != NULL;
3728 instr = instr->next()) { 3718 instr = instr->next()) {
3729 ArrayInstructionInterface* array_instruction = NULL; 3719 ArrayInstructionInterface* array_instruction = NULL;
3730 if (instr->IsLoadKeyed()) { 3720 if (instr->IsLoadKeyed()) {
3731 HLoadKeyed* op = HLoadKeyed::cast(instr); 3721 HLoadKeyed* op = HLoadKeyed::cast(instr);
3732 array_instruction = static_cast<ArrayInstructionInterface*>(op); 3722 array_instruction = static_cast<ArrayInstructionInterface*>(op);
3733 } else if (instr->IsStoreKeyed()) { 3723 } else if (instr->IsStoreKeyed()) {
(...skipping 6325 matching lines...) Expand 10 before | Expand all | Expand 10 after
10059 } 10049 }
10060 } 10050 }
10061 10051
10062 #ifdef DEBUG 10052 #ifdef DEBUG
10063 if (graph_ != NULL) graph_->Verify(false); // No full verify. 10053 if (graph_ != NULL) graph_->Verify(false); // No full verify.
10064 if (allocator_ != NULL) allocator_->Verify(); 10054 if (allocator_ != NULL) allocator_->Verify();
10065 #endif 10055 #endif
10066 } 10056 }
10067 10057
10068 } } // namespace v8::internal 10058 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698