| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Improvements possible: | 111 // Improvements possible: |
| 112 // - eliminate redundant HCheckSmi, HCheckInstanceType instructions | 112 // - eliminate redundant HCheckSmi, HCheckInstanceType instructions |
| 113 // - track which values have been HCheckHeapObject'd | 113 // - track which values have been HCheckHeapObject'd |
| 114 } | 114 } |
| 115 | 115 |
| 116 return this; | 116 return this; |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Global analysis: Copy state to successor block. | 119 // Global analysis: Copy state to successor block. |
| 120 HCheckTable* Copy(HBasicBlock* succ, Zone* zone) { | 120 HCheckTable* Copy(HBasicBlock* succ, Zone* zone) { |
| 121 ASSERT(succ->IsReachable()); |
| 122 |
| 121 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); | 123 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); |
| 122 for (int i = 0; i < size_; i++) { | 124 for (int i = 0; i < size_; i++) { |
| 123 HCheckTableEntry* old_entry = &entries_[i]; | 125 HCheckTableEntry* old_entry = &entries_[i]; |
| 124 HCheckTableEntry* new_entry = ©->entries_[i]; | 126 HCheckTableEntry* new_entry = ©->entries_[i]; |
| 125 // TODO(titzer): keep the check if this block dominates the successor? | 127 // TODO(titzer): keep the check if this block dominates the successor? |
| 126 new_entry->object_ = old_entry->object_; | 128 new_entry->object_ = old_entry->object_; |
| 127 new_entry->check_ = NULL; | 129 new_entry->check_ = NULL; |
| 128 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone()); | 130 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone()); |
| 129 } | 131 } |
| 130 copy->cursor_ = cursor_; | 132 copy->cursor_ = cursor_; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 169 } |
| 168 } | 170 } |
| 169 // Learning on false branches requires storing negative facts. | 171 // Learning on false branches requires storing negative facts. |
| 170 } | 172 } |
| 171 | 173 |
| 172 return copy; | 174 return copy; |
| 173 } | 175 } |
| 174 | 176 |
| 175 // Global analysis: Merge this state with the other incoming state. | 177 // Global analysis: Merge this state with the other incoming state. |
| 176 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) { | 178 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) { |
| 179 ASSERT(succ->IsReachable()); |
| 180 |
| 177 if (that->size_ == 0) { | 181 if (that->size_ == 0) { |
| 178 // If the other state is empty, simply reset. | 182 // If the other state is empty, simply reset. |
| 179 size_ = 0; | 183 size_ = 0; |
| 180 cursor_ = 0; | 184 cursor_ = 0; |
| 181 return this; | 185 return this; |
| 182 } | 186 } |
| 183 bool compact = false; | 187 bool compact = false; |
| 184 for (int i = 0; i < size_; i++) { | 188 for (int i = 0; i < size_; i++) { |
| 185 HCheckTableEntry* this_entry = &entries_[i]; | 189 HCheckTableEntry* this_entry = &entries_[i]; |
| 186 HCheckTableEntry* that_entry = that->Find(this_entry->object_); | 190 HCheckTableEntry* that_entry = that->Find(this_entry->object_); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 Insert(object, MapConstant(instr->value())); | 308 Insert(object, MapConstant(instr->value())); |
| 305 } else { | 309 } else { |
| 306 // If the instruction changes maps, it should be handled above. | 310 // If the instruction changes maps, it should be handled above. |
| 307 CHECK(!instr->CheckGVNFlag(kChangesMaps)); | 311 CHECK(!instr->CheckGVNFlag(kChangesMaps)); |
| 308 } | 312 } |
| 309 } | 313 } |
| 310 | 314 |
| 311 void ReduceCompareMap(HCompareMap* instr) { | 315 void ReduceCompareMap(HCompareMap* instr) { |
| 312 MapSet maps = FindMaps(instr->value()->ActualValue()); | 316 MapSet maps = FindMaps(instr->value()->ActualValue()); |
| 313 if (maps == NULL) return; | 317 if (maps == NULL) return; |
| 318 |
| 319 TRACE(("CompareMap for #%d at B%d ", |
| 320 instr->value()->ActualValue()->id(), instr->block()->block_id())); |
| 321 |
| 314 if (maps->Contains(instr->map())) { | 322 if (maps->Contains(instr->map())) { |
| 315 if (maps->size() == 1) { | 323 if (maps->size() == 1) { |
| 316 // TODO(titzer): replace with goto true branch | |
| 317 INC_STAT(compares_true_); | 324 INC_STAT(compares_true_); |
| 325 |
| 326 TRACE(("replaced with goto B%d (true target)\n", |
| 327 instr->SuccessorAt(0)->block_id())); |
| 328 |
| 329 instr->block()->ReplaceControlWithGotoSuccessor(0); |
| 330 } else { |
| 331 TRACE(("can't be replaced with goto: ambiguous set of maps\n")); |
| 318 } | 332 } |
| 319 } else { | 333 } else { |
| 320 // TODO(titzer): replace with goto false branch | |
| 321 INC_STAT(compares_false_); | 334 INC_STAT(compares_false_); |
| 335 TRACE(("replaced with goto B%d (false target)\n", |
| 336 instr->SuccessorAt(1)->block_id())); |
| 337 |
| 338 instr->block()->ReplaceControlWithGotoSuccessor(1); |
| 322 } | 339 } |
| 323 } | 340 } |
| 324 | 341 |
| 325 void ReduceTransitionElementsKind(HTransitionElementsKind* instr) { | 342 void ReduceTransitionElementsKind(HTransitionElementsKind* instr) { |
| 326 MapSet maps = FindMaps(instr->object()->ActualValue()); | 343 MapSet maps = FindMaps(instr->object()->ActualValue()); |
| 327 // Can only learn more about an object that already has a known set of maps. | 344 // Can only learn more about an object that already has a known set of maps. |
| 328 if (maps == NULL) return; | 345 if (maps == NULL) return; |
| 329 if (maps->Contains(instr->original_map())) { | 346 if (maps->Contains(instr->original_map())) { |
| 330 // If the object has the original map, it will be transitioned. | 347 // If the object has the original map, it will be transitioned. |
| 331 maps->Remove(instr->original_map()); | 348 maps->Remove(instr->original_map()); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 PRINT_STAT(removed_cho); | 569 PRINT_STAT(removed_cho); |
| 553 PRINT_STAT(narrowed); | 570 PRINT_STAT(narrowed); |
| 554 PRINT_STAT(loads); | 571 PRINT_STAT(loads); |
| 555 PRINT_STAT(empty); | 572 PRINT_STAT(empty); |
| 556 PRINT_STAT(compares_true); | 573 PRINT_STAT(compares_true); |
| 557 PRINT_STAT(compares_false); | 574 PRINT_STAT(compares_false); |
| 558 PRINT_STAT(transitions); | 575 PRINT_STAT(transitions); |
| 559 } | 576 } |
| 560 | 577 |
| 561 } } // namespace v8::internal | 578 } } // namespace v8::internal |
| OLD | NEW |