Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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: { | 100 case HValue::kCheckHeapObject: { |
| 101 ReduceCheckHeapObject(HCheckHeapObject::cast(instr)); | 101 ReduceCheckHeapObject(HCheckHeapObject::cast(instr)); |
| 102 break; | 102 break; |
| 103 } | 103 } |
| 104 case HValue::kCompareObjectEqAndBranch: { | |
| 105 ReduceCompareObjectEqAndBranch(HCompareObjectEqAndBranch::cast(instr)); | |
| 106 break; | |
| 107 } | |
| 104 default: { | 108 default: { |
| 105 // If the instruction changes maps uncontrollably, drop everything. | 109 // If the instruction changes maps uncontrollably, drop everything. |
| 106 if (instr->CheckGVNFlag(kChangesMaps) || | 110 if (instr->CheckGVNFlag(kChangesMaps) || |
| 107 instr->CheckGVNFlag(kChangesOsrEntries)) { | 111 instr->CheckGVNFlag(kChangesOsrEntries)) { |
| 108 Kill(); | 112 Kill(); |
| 109 } | 113 } |
| 110 } | 114 } |
| 111 // Improvements possible: | 115 // Improvements possible: |
| 112 // - eliminate redundant HCheckSmi, HCheckInstanceType instructions | 116 // - eliminate redundant HCheckSmi, HCheckInstanceType instructions |
| 113 // - track which values have been HCheckHeapObject'd | 117 // - track which values have been HCheckHeapObject'd |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 } | 263 } |
| 260 | 264 |
| 261 void ReduceCheckHeapObject(HCheckHeapObject* instr) { | 265 void ReduceCheckHeapObject(HCheckHeapObject* instr) { |
| 262 if (FindMaps(instr->value()->ActualValue()) != NULL) { | 266 if (FindMaps(instr->value()->ActualValue()) != NULL) { |
| 263 // If the object has known maps, it's definitely a heap object. | 267 // If the object has known maps, it's definitely a heap object. |
| 264 instr->DeleteAndReplaceWith(instr->value()); | 268 instr->DeleteAndReplaceWith(instr->value()); |
| 265 INC_STAT(removed_cho_); | 269 INC_STAT(removed_cho_); |
| 266 } | 270 } |
| 267 } | 271 } |
| 268 | 272 |
| 273 void ReduceCompareObjectEqAndBranch(HCompareObjectEqAndBranch* instr) { | |
| 274 HValue* left = instr->left(); | |
| 275 HValue* right = instr->right(); | |
| 276 if (left->IsCheckMaps() && right->IsCheckMaps()) { | |
| 277 // Check one operand is enough. After licm, remove the correct one. | |
| 278 HCheckMaps* removed = NULL; | |
| 279 if (left->block()->block_id() > right->block()->block_id()) { | |
| 280 removed = HCheckMaps::cast(left); | |
| 281 } else { | |
| 282 removed = HCheckMaps::cast(right); | |
| 283 } | |
| 284 | |
| 285 if (removed->previous()->IsCheckHeapObject()) { | |
| 286 HCheckHeapObject* cho = HCheckHeapObject::cast(removed->previous()); | |
| 287 if (cho->value() == removed->ActualValue()) { | |
| 288 cho->DeleteAndReplaceWith(cho->value()); | |
| 289 INC_STAT(removed_cho_); | |
| 290 } | |
| 291 } | |
| 292 removed->DeleteAndReplaceWith(removed->ActualValue()); | |
|
titzer
2013/12/04 16:32:00
This transformation is completely incorrect. First
| |
| 293 INC_STAT(removed_); | |
| 294 } | |
| 295 } | |
| 296 | |
| 269 void ReduceStoreNamedField(HStoreNamedField* instr) { | 297 void ReduceStoreNamedField(HStoreNamedField* instr) { |
| 270 HValue* object = instr->object()->ActualValue(); | 298 HValue* object = instr->object()->ActualValue(); |
| 271 if (instr->has_transition()) { | 299 if (instr->has_transition()) { |
| 272 // This store transitions the object to a new map. | 300 // This store transitions the object to a new map. |
| 273 Kill(object); | 301 Kill(object); |
| 274 Insert(object, MapConstant(instr->transition())); | 302 Insert(object, MapConstant(instr->transition())); |
| 275 } else if (IsMapAccess(instr->access())) { | 303 } else if (IsMapAccess(instr->access())) { |
| 276 // This is a store directly to the map field of the object. | 304 // This is a store directly to the map field of the object. |
| 277 Kill(object); | 305 Kill(object); |
| 278 if (!instr->value()->IsConstant()) return; | 306 if (!instr->value()->IsConstant()) return; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 PRINT_STAT(removed_cho); | 555 PRINT_STAT(removed_cho); |
| 528 PRINT_STAT(narrowed); | 556 PRINT_STAT(narrowed); |
| 529 PRINT_STAT(loads); | 557 PRINT_STAT(loads); |
| 530 PRINT_STAT(empty); | 558 PRINT_STAT(empty); |
| 531 PRINT_STAT(compares_true); | 559 PRINT_STAT(compares_true); |
| 532 PRINT_STAT(compares_false); | 560 PRINT_STAT(compares_false); |
| 533 PRINT_STAT(transitions); | 561 PRINT_STAT(transitions); |
| 534 } | 562 } |
| 535 | 563 |
| 536 } } // namespace v8::internal | 564 } } // namespace v8::internal |
| OLD | NEW |