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