| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 case HValue::kTransitionElementsKind: { | 91 case HValue::kTransitionElementsKind: { |
| 92 ReduceTransitionElementsKind( | 92 ReduceTransitionElementsKind( |
| 93 HTransitionElementsKind::cast(instr)); | 93 HTransitionElementsKind::cast(instr)); |
| 94 break; | 94 break; |
| 95 } | 95 } |
| 96 case HValue::kCheckMapValue: { | 96 case HValue::kCheckMapValue: { |
| 97 ReduceCheckMapValue(HCheckMapValue::cast(instr)); | 97 ReduceCheckMapValue(HCheckMapValue::cast(instr)); |
| 98 break; | 98 break; |
| 99 } | 99 } |
| 100 case HValue::kCheckHeapObject: { |
| 101 ReduceCheckHeapObject(HCheckHeapObject::cast(instr)); |
| 102 break; |
| 103 } |
| 100 default: { | 104 default: { |
| 101 // If the instruction changes maps uncontrollably, drop everything. | 105 // If the instruction changes maps uncontrollably, drop everything. |
| 102 if (instr->CheckGVNFlag(kChangesMaps) || | 106 if (instr->CheckGVNFlag(kChangesMaps) || |
| 103 instr->CheckGVNFlag(kChangesOsrEntries)) { | 107 instr->CheckGVNFlag(kChangesOsrEntries)) { |
| 104 Kill(); | 108 Kill(); |
| 105 } | 109 } |
| 106 } | 110 } |
| 107 // Improvements possible: | 111 // Improvements possible: |
| 108 // - eliminate HCheckSmi and HCheckHeapObject | 112 // - eliminate redundant HCheckSmi, HCheckInstanceType instructions |
| 113 // - track which values have been HCheckHeapObject'd |
| 109 } | 114 } |
| 110 | 115 |
| 111 return this; | 116 return this; |
| 112 } | 117 } |
| 113 | 118 |
| 114 // Global analysis: Copy state to successor block. | 119 // Global analysis: Copy state to successor block. |
| 115 HCheckTable* Copy(HBasicBlock* succ, Zone* zone) { | 120 HCheckTable* Copy(HBasicBlock* succ, Zone* zone) { |
| 116 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); | 121 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); |
| 117 for (int i = 0; i < size_; i++) { | 122 for (int i = 0; i < size_; i++) { |
| 118 HCheckTableEntry* old_entry = &entries_[i]; | 123 HCheckTableEntry* old_entry = &entries_[i]; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 maps->Clear(); | 234 maps->Clear(); |
| 230 maps->Add(map, phase_->zone()); | 235 maps->Add(map, phase_->zone()); |
| 231 } | 236 } |
| 232 } | 237 } |
| 233 } else { | 238 } else { |
| 234 // No prior information. | 239 // No prior information. |
| 235 Insert(object, map); | 240 Insert(object, map); |
| 236 } | 241 } |
| 237 } | 242 } |
| 238 | 243 |
| 244 void ReduceCheckHeapObject(HCheckHeapObject* instr) { |
| 245 if (FindMaps(instr->value()->ActualValue()) != NULL) { |
| 246 // If the object has known maps, it's definitely a heap object. |
| 247 instr->DeleteAndReplaceWith(instr->value()); |
| 248 INC_STAT(removed_cho_); |
| 249 } |
| 250 } |
| 251 |
| 239 void ReduceStoreNamedField(HStoreNamedField* instr) { | 252 void ReduceStoreNamedField(HStoreNamedField* instr) { |
| 240 HValue* object = instr->object()->ActualValue(); | 253 HValue* object = instr->object()->ActualValue(); |
| 241 if (instr->has_transition()) { | 254 if (instr->has_transition()) { |
| 242 // This store transitions the object to a new map. | 255 // This store transitions the object to a new map. |
| 243 Kill(object); | 256 Kill(object); |
| 244 Insert(object, MapConstant(instr->transition())); | 257 Insert(object, MapConstant(instr->transition())); |
| 245 } else if (IsMapAccess(instr->access())) { | 258 } else if (IsMapAccess(instr->access())) { |
| 246 // This is a store directly to the map field of the object. | 259 // This is a store directly to the map field of the object. |
| 247 Kill(object); | 260 Kill(object); |
| 248 if (!instr->value()->IsConstant()) return; | 261 if (!instr->value()->IsConstant()) return; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 494 } |
| 482 } | 495 } |
| 483 | 496 |
| 484 if (FLAG_trace_check_elimination) PrintStats(); | 497 if (FLAG_trace_check_elimination) PrintStats(); |
| 485 } | 498 } |
| 486 | 499 |
| 487 | 500 |
| 488 // Are we eliminated yet? | 501 // Are we eliminated yet? |
| 489 void HCheckEliminationPhase::PrintStats() { | 502 void HCheckEliminationPhase::PrintStats() { |
| 490 #if DEBUG | 503 #if DEBUG |
| 491 if (redundant_ > 0) PrintF(" redundant = %2d\n", redundant_); | 504 #define PRINT_STAT(x) if (x##_ > 0) PrintF(" %-16s = %2d\n", #x, x##_) |
| 492 if (removed_ > 0) PrintF(" removed = %2d\n", removed_); | 505 #else |
| 493 if (narrowed_ > 0) PrintF(" narrowed = %2d\n", narrowed_); | 506 #define PRINT_STAT(x) |
| 494 if (loads_ > 0) PrintF(" loads = %2d\n", loads_); | |
| 495 if (empty_ > 0) PrintF(" empty = %2d\n", empty_); | |
| 496 if (compares_true_ > 0) PrintF(" cmp_true = %2d\n", compares_true_); | |
| 497 if (compares_false_ > 0) PrintF(" cmp_false = %2d\n", compares_false_); | |
| 498 if (transitions_ > 0) PrintF(" transitions = %2d\n", transitions_); | |
| 499 #endif | 507 #endif |
| 508 PRINT_STAT(redundant); |
| 509 PRINT_STAT(removed); |
| 510 PRINT_STAT(removed_cho); |
| 511 PRINT_STAT(narrowed); |
| 512 PRINT_STAT(loads); |
| 513 PRINT_STAT(empty); |
| 514 PRINT_STAT(compares_true); |
| 515 PRINT_STAT(compares_false); |
| 516 PRINT_STAT(transitions); |
| 500 } | 517 } |
| 501 | 518 |
| 502 } } // namespace v8::internal | 519 } } // namespace v8::internal |
| OLD | NEW |