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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // TODO(titzer): keep the check if this block dominates the successor? | 125 // TODO(titzer): keep the check if this block dominates the successor? |
126 new_entry->object_ = old_entry->object_; | 126 new_entry->object_ = old_entry->object_; |
127 new_entry->check_ = NULL; | 127 new_entry->check_ = NULL; |
128 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone()); | 128 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone()); |
129 } | 129 } |
130 copy->cursor_ = cursor_; | 130 copy->cursor_ = cursor_; |
131 copy->size_ = size_; | 131 copy->size_ = size_; |
132 | 132 |
133 // Branch-sensitive analysis for certain comparisons may add more facts | 133 // Branch-sensitive analysis for certain comparisons may add more facts |
134 // to the state for the successor on the true branch. | 134 // to the state for the successor on the true branch. |
135 HControlInstruction* end = succ->predecessors()->at(0)->end(); | 135 HBasicBlock* pred_block = succ->predecessors()->at(0); |
136 if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ) { | 136 HControlInstruction* end = pred_block->end(); |
| 137 if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ && |
| 138 pred_block->IsReachable()) { |
137 if (end->IsCompareMap()) { | 139 if (end->IsCompareMap()) { |
138 // Learn on the true branch of if(CompareMap(x)). | 140 // Learn on the true branch of if(CompareMap(x)). |
139 HCompareMap* cmp = HCompareMap::cast(end); | 141 HCompareMap* cmp = HCompareMap::cast(end); |
140 HValue* object = cmp->value()->ActualValue(); | 142 HValue* object = cmp->value()->ActualValue(); |
141 HCheckTableEntry* entry = copy->Find(object); | 143 HCheckTableEntry* entry = copy->Find(object); |
142 if (entry == NULL) { | 144 if (entry == NULL) { |
143 copy->Insert(object, cmp->map()); | 145 copy->Insert(object, cmp->map()); |
144 } else { | 146 } else { |
145 MapSet list = new(phase_->zone()) UniqueSet<Map>(); | 147 MapSet list = new(phase_->zone()) UniqueSet<Map>(); |
146 list->Add(cmp->map(), phase_->zone()); | 148 list->Add(cmp->map(), phase_->zone()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 Insert(object, MapConstant(instr->value())); | 306 Insert(object, MapConstant(instr->value())); |
305 } else { | 307 } else { |
306 // If the instruction changes maps, it should be handled above. | 308 // If the instruction changes maps, it should be handled above. |
307 CHECK(!instr->CheckGVNFlag(kChangesMaps)); | 309 CHECK(!instr->CheckGVNFlag(kChangesMaps)); |
308 } | 310 } |
309 } | 311 } |
310 | 312 |
311 void ReduceCompareMap(HCompareMap* instr) { | 313 void ReduceCompareMap(HCompareMap* instr) { |
312 MapSet maps = FindMaps(instr->value()->ActualValue()); | 314 MapSet maps = FindMaps(instr->value()->ActualValue()); |
313 if (maps == NULL) return; | 315 if (maps == NULL) return; |
| 316 |
| 317 TRACE(("CompareMap for #%d at B%d ", |
| 318 instr->value()->ActualValue()->id(), instr->block()->block_id())); |
| 319 |
314 if (maps->Contains(instr->map())) { | 320 if (maps->Contains(instr->map())) { |
315 if (maps->size() == 1) { | 321 if (maps->size() == 1) { |
316 // TODO(titzer): replace with goto true branch | |
317 INC_STAT(compares_true_); | 322 INC_STAT(compares_true_); |
| 323 |
| 324 TRACE(("replaced with goto B%d (true target)\n", |
| 325 instr->SuccessorAt(0)->block_id())); |
| 326 |
| 327 instr->block()->ReplaceControlWithGotoSuccessor(0); |
| 328 } else { |
| 329 TRACE(("can't be replaced with goto: ambiguous set of maps\n")); |
318 } | 330 } |
319 } else { | 331 } else { |
320 // TODO(titzer): replace with goto false branch | |
321 INC_STAT(compares_false_); | 332 INC_STAT(compares_false_); |
| 333 TRACE(("replaced with goto B%d (false target)\n", |
| 334 instr->SuccessorAt(1)->block_id())); |
| 335 |
| 336 instr->block()->ReplaceControlWithGotoSuccessor(1); |
322 } | 337 } |
323 } | 338 } |
324 | 339 |
325 void ReduceTransitionElementsKind(HTransitionElementsKind* instr) { | 340 void ReduceTransitionElementsKind(HTransitionElementsKind* instr) { |
326 MapSet maps = FindMaps(instr->object()->ActualValue()); | 341 MapSet maps = FindMaps(instr->object()->ActualValue()); |
327 // Can only learn more about an object that already has a known set of maps. | 342 // Can only learn more about an object that already has a known set of maps. |
328 if (maps == NULL) return; | 343 if (maps == NULL) return; |
329 if (maps->Contains(instr->original_map())) { | 344 if (maps->Contains(instr->original_map())) { |
330 // If the object has the original map, it will be transitioned. | 345 // If the object has the original map, it will be transitioned. |
331 maps->Remove(instr->original_map()); | 346 maps->Remove(instr->original_map()); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 PRINT_STAT(removed_cho); | 567 PRINT_STAT(removed_cho); |
553 PRINT_STAT(narrowed); | 568 PRINT_STAT(narrowed); |
554 PRINT_STAT(loads); | 569 PRINT_STAT(loads); |
555 PRINT_STAT(empty); | 570 PRINT_STAT(empty); |
556 PRINT_STAT(compares_true); | 571 PRINT_STAT(compares_true); |
557 PRINT_STAT(compares_false); | 572 PRINT_STAT(compares_false); |
558 PRINT_STAT(transitions); | 573 PRINT_STAT(transitions); |
559 } | 574 } |
560 | 575 |
561 } } // namespace v8::internal | 576 } } // namespace v8::internal |
OLD | NEW |