| 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-check-elimination.h" | 5 #include "src/hydrogen-check-elimination.h" |
| 6 | 6 |
| 7 #include "src/hydrogen-alias-analysis.h" | 7 #include "src/hydrogen-alias-analysis.h" |
| 8 #include "src/hydrogen-flow-engine.h" | 8 #include "src/hydrogen-flow-engine.h" |
| 9 | 9 |
| 10 #define GLOBAL 1 | 10 #define GLOBAL 1 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 HGraph* graph = instr->block()->graph(); | 366 HGraph* graph = instr->block()->graph(); |
| 367 if (entry->maps_->IsSubset(instr->maps())) { | 367 if (entry->maps_->IsSubset(instr->maps())) { |
| 368 // The first check is more strict; the second is redundant. | 368 // The first check is more strict; the second is redundant. |
| 369 if (entry->check_ != NULL) { | 369 if (entry->check_ != NULL) { |
| 370 DCHECK_NE(HCheckTableEntry::UNCHECKED_STABLE, entry->state_); | 370 DCHECK_NE(HCheckTableEntry::UNCHECKED_STABLE, entry->state_); |
| 371 TRACE(("Replacing redundant CheckMaps #%d at B%d with #%d\n", | 371 TRACE(("Replacing redundant CheckMaps #%d at B%d with #%d\n", |
| 372 instr->id(), instr->block()->block_id(), entry->check_->id())); | 372 instr->id(), instr->block()->block_id(), entry->check_->id())); |
| 373 instr->DeleteAndReplaceWith(entry->check_); | 373 instr->DeleteAndReplaceWith(entry->check_); |
| 374 INC_STAT(redundant_); | 374 INC_STAT(redundant_); |
| 375 } else if (entry->state_ == HCheckTableEntry::UNCHECKED_STABLE) { | 375 } else if (entry->state_ == HCheckTableEntry::UNCHECKED_STABLE) { |
| 376 DCHECK_EQ(NULL, entry->check_); | 376 DCHECK_NULL(entry->check_); |
| 377 TRACE(("Marking redundant CheckMaps #%d at B%d as stability check\n", | 377 TRACE(("Marking redundant CheckMaps #%d at B%d as stability check\n", |
| 378 instr->id(), instr->block()->block_id())); | 378 instr->id(), instr->block()->block_id())); |
| 379 instr->set_maps(entry->maps_->Copy(graph->zone())); | 379 instr->set_maps(entry->maps_->Copy(graph->zone())); |
| 380 instr->MarkAsStabilityCheck(); | 380 instr->MarkAsStabilityCheck(); |
| 381 entry->state_ = HCheckTableEntry::CHECKED_STABLE; | 381 entry->state_ = HCheckTableEntry::CHECKED_STABLE; |
| 382 } else if (!instr->IsStabilityCheck()) { | 382 } else if (!instr->IsStabilityCheck()) { |
| 383 TRACE(("Marking redundant CheckMaps #%d at B%d as dead\n", | 383 TRACE(("Marking redundant CheckMaps #%d at B%d as dead\n", |
| 384 instr->id(), instr->block()->block_id())); | 384 instr->id(), instr->block()->block_id())); |
| 385 // Mark check as dead but leave it in the graph as a checkpoint for | 385 // Mark check as dead but leave it in the graph as a checkpoint for |
| 386 // subsequent checks. | 386 // subsequent checks. |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 } | 677 } |
| 678 } | 678 } |
| 679 if (compact) Compact(); | 679 if (compact) Compact(); |
| 680 } | 680 } |
| 681 | 681 |
| 682 // Kill everything in the table that may alias {object}. | 682 // Kill everything in the table that may alias {object}. |
| 683 void Kill(HValue* object) { | 683 void Kill(HValue* object) { |
| 684 bool compact = false; | 684 bool compact = false; |
| 685 for (int i = 0; i < size_; i++) { | 685 for (int i = 0; i < size_; i++) { |
| 686 HCheckTableEntry* entry = &entries_[i]; | 686 HCheckTableEntry* entry = &entries_[i]; |
| 687 DCHECK(entry->object_ != NULL); | 687 DCHECK_NOT_NULL(entry->object_); |
| 688 if (phase_->aliasing_->MayAlias(entry->object_, object)) { | 688 if (phase_->aliasing_->MayAlias(entry->object_, object)) { |
| 689 entry->object_ = NULL; | 689 entry->object_ = NULL; |
| 690 compact = true; | 690 compact = true; |
| 691 } | 691 } |
| 692 } | 692 } |
| 693 if (compact) Compact(); | 693 if (compact) Compact(); |
| 694 DCHECK(Find(object) == NULL); | 694 DCHECK_NULL(Find(object)); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void Compact() { | 697 void Compact() { |
| 698 // First, compact the array in place. | 698 // First, compact the array in place. |
| 699 int max = size_, dest = 0, old_cursor = cursor_; | 699 int max = size_, dest = 0, old_cursor = cursor_; |
| 700 for (int i = 0; i < max; i++) { | 700 for (int i = 0; i < max; i++) { |
| 701 if (entries_[i].object_ != NULL) { | 701 if (entries_[i].object_ != NULL) { |
| 702 if (dest != i) entries_[dest] = entries_[i]; | 702 if (dest != i) entries_[dest] = entries_[i]; |
| 703 dest++; | 703 dest++; |
| 704 } else { | 704 } else { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 PRINT_STAT(removed_cit); | 894 PRINT_STAT(removed_cit); |
| 895 PRINT_STAT(narrowed); | 895 PRINT_STAT(narrowed); |
| 896 PRINT_STAT(loads); | 896 PRINT_STAT(loads); |
| 897 PRINT_STAT(empty); | 897 PRINT_STAT(empty); |
| 898 PRINT_STAT(compares_true); | 898 PRINT_STAT(compares_true); |
| 899 PRINT_STAT(compares_false); | 899 PRINT_STAT(compares_false); |
| 900 PRINT_STAT(transitions); | 900 PRINT_STAT(transitions); |
| 901 } | 901 } |
| 902 | 902 |
| 903 } } // namespace v8::internal | 903 } } // namespace v8::internal |
| OLD | NEW |