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

Side by Side Diff: src/hydrogen.cc

Issue 11503011: Revert r13176. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 if (FLAG_array_bounds_checks_elimination) EliminateRedundantBoundsChecks(); 3329 EliminateRedundantBoundsChecks();
3330 if (FLAG_array_index_dehoisting) DehoistSimpleArrayIndexComputations(); 3330 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(new_check->index()); 3487 new_check->DeleteAndReplaceWith(NULL);
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.
3594 void HGraph::EliminateRedundantBoundsChecks(HBasicBlock* bb, 3598 void HGraph::EliminateRedundantBoundsChecks(HBasicBlock* bb,
3595 BoundsCheckTable* table) { 3599 BoundsCheckTable* table) {
3596 BoundsCheckBbData* bb_data_list = NULL; 3600 BoundsCheckBbData* bb_data_list = NULL;
3597 3601
3598 for (HInstruction* i = bb->first(); i != NULL; i = i->next()) { 3602 for (HInstruction* i = bb->first(); i != NULL; i = i->next()) {
3599 if (!i->IsBoundsCheck()) continue; 3603 if (!i->IsBoundsCheck()) continue;
3604
3600 HBoundsCheck* check = HBoundsCheck::cast(i); 3605 HBoundsCheck* check = HBoundsCheck::cast(i);
3606 check->ReplaceAllUsesWith(check->index());
3607
3608 if (!FLAG_array_bounds_checks_elimination) continue;
3601 3609
3602 int32_t offset; 3610 int32_t offset;
3603 BoundsCheckKey* key = 3611 BoundsCheckKey* key =
3604 BoundsCheckKey::Create(zone(), check, &offset); 3612 BoundsCheckKey::Create(zone(), check, &offset);
3605 if (key == NULL) continue; 3613 if (key == NULL) continue;
3606 BoundsCheckBbData** data_p = table->LookupOrInsert(key, zone()); 3614 BoundsCheckBbData** data_p = table->LookupOrInsert(key, zone());
3607 BoundsCheckBbData* data = *data_p; 3615 BoundsCheckBbData* data = *data_p;
3608 if (data == NULL) { 3616 if (data == NULL) {
3609 bb_data_list = new(zone()) BoundsCheckBbData(key, 3617 bb_data_list = new(zone()) BoundsCheckBbData(key,
3610 offset, 3618 offset,
3611 offset, 3619 offset,
3612 bb, 3620 bb,
3613 check, 3621 check,
3614 check, 3622 check,
3615 bb_data_list, 3623 bb_data_list,
3616 NULL); 3624 NULL);
3617 *data_p = bb_data_list; 3625 *data_p = bb_data_list;
3618 } else if (data->OffsetIsCovered(offset)) { 3626 } else if (data->OffsetIsCovered(offset)) {
3619 check->DeleteAndReplaceWith(check->index()); 3627 check->DeleteAndReplaceWith(NULL);
3620 } else if (data->BasicBlock() == bb) { 3628 } else if (data->BasicBlock() == bb) {
3621 data->CoverCheck(check, offset); 3629 data->CoverCheck(check, offset);
3622 } else { 3630 } else {
3623 int32_t new_lower_offset = offset < data->LowerOffset() 3631 int32_t new_lower_offset = offset < data->LowerOffset()
3624 ? offset 3632 ? offset
3625 : data->LowerOffset(); 3633 : data->LowerOffset();
3626 int32_t new_upper_offset = offset > data->UpperOffset() 3634 int32_t new_upper_offset = offset > data->UpperOffset()
3627 ? offset 3635 ? offset
3628 : data->UpperOffset(); 3636 : data->UpperOffset();
3629 bb_data_list = new(zone()) BoundsCheckBbData(key, 3637 bb_data_list = new(zone()) BoundsCheckBbData(key,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 if (index->HasNoUses()) { 3712 if (index->HasNoUses()) {
3705 index->DeleteAndReplaceWith(NULL); 3713 index->DeleteAndReplaceWith(NULL);
3706 } 3714 }
3707 ASSERT(value >= 0); 3715 ASSERT(value >= 0);
3708 array_operation->SetIndexOffset(static_cast<uint32_t>(value)); 3716 array_operation->SetIndexOffset(static_cast<uint32_t>(value));
3709 array_operation->SetDehoisted(true); 3717 array_operation->SetDehoisted(true);
3710 } 3718 }
3711 3719
3712 3720
3713 void HGraph::DehoistSimpleArrayIndexComputations() { 3721 void HGraph::DehoistSimpleArrayIndexComputations() {
3722 if (!FLAG_array_index_dehoisting) return;
3723
3714 HPhase phase("H_Dehoist index computations", this); 3724 HPhase phase("H_Dehoist index computations", this);
3715 for (int i = 0; i < blocks()->length(); ++i) { 3725 for (int i = 0; i < blocks()->length(); ++i) {
3716 for (HInstruction* instr = blocks()->at(i)->first(); 3726 for (HInstruction* instr = blocks()->at(i)->first();
3717 instr != NULL; 3727 instr != NULL;
3718 instr = instr->next()) { 3728 instr = instr->next()) {
3719 ArrayInstructionInterface* array_instruction = NULL; 3729 ArrayInstructionInterface* array_instruction = NULL;
3720 if (instr->IsLoadKeyed()) { 3730 if (instr->IsLoadKeyed()) {
3721 HLoadKeyed* op = HLoadKeyed::cast(instr); 3731 HLoadKeyed* op = HLoadKeyed::cast(instr);
3722 array_instruction = static_cast<ArrayInstructionInterface*>(op); 3732 array_instruction = static_cast<ArrayInstructionInterface*>(op);
3723 } else if (instr->IsStoreKeyed()) { 3733 } else if (instr->IsStoreKeyed()) {
(...skipping 6358 matching lines...) Expand 10 before | Expand all | Expand 10 after
10082 } 10092 }
10083 } 10093 }
10084 10094
10085 #ifdef DEBUG 10095 #ifdef DEBUG
10086 if (graph_ != NULL) graph_->Verify(false); // No full verify. 10096 if (graph_ != NULL) graph_->Verify(false); // No full verify.
10087 if (allocator_ != NULL) allocator_->Verify(); 10097 if (allocator_ != NULL) allocator_->Verify();
10088 #endif 10098 #endif
10089 } 10099 }
10090 10100
10091 } } // namespace v8::internal 10101 } } // 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