| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 size_(0) { | 65 size_(0) { |
| 66 } | 66 } |
| 67 | 67 |
| 68 // The main processing of instructions. | 68 // The main processing of instructions. |
| 69 HCheckTable* Process(HInstruction* instr, Zone* zone) { | 69 HCheckTable* Process(HInstruction* instr, Zone* zone) { |
| 70 switch (instr->opcode()) { | 70 switch (instr->opcode()) { |
| 71 case HValue::kCheckMaps: { | 71 case HValue::kCheckMaps: { |
| 72 ReduceCheckMaps(HCheckMaps::cast(instr)); | 72 ReduceCheckMaps(HCheckMaps::cast(instr)); |
| 73 break; | 73 break; |
| 74 } | 74 } |
| 75 case HValue::kCheckValue: { | |
| 76 ReduceCheckValue(HCheckValue::cast(instr)); | |
| 77 break; | |
| 78 } | |
| 79 case HValue::kLoadNamedField: { | 75 case HValue::kLoadNamedField: { |
| 80 ReduceLoadNamedField(HLoadNamedField::cast(instr)); | 76 ReduceLoadNamedField(HLoadNamedField::cast(instr)); |
| 81 break; | 77 break; |
| 82 } | 78 } |
| 83 case HValue::kStoreNamedField: { | 79 case HValue::kStoreNamedField: { |
| 84 ReduceStoreNamedField(HStoreNamedField::cast(instr)); | 80 ReduceStoreNamedField(HStoreNamedField::cast(instr)); |
| 85 break; | 81 break; |
| 86 } | 82 } |
| 87 case HValue::kCompareMap: { | 83 case HValue::kCompareMap: { |
| 88 ReduceCompareMap(HCompareMap::cast(instr)); | 84 ReduceCompareMap(HCompareMap::cast(instr)); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 294 } |
| 299 return this; | 295 return this; |
| 300 } | 296 } |
| 301 | 297 |
| 302 void ReduceCheckMaps(HCheckMaps* instr) { | 298 void ReduceCheckMaps(HCheckMaps* instr) { |
| 303 HValue* object = instr->value()->ActualValue(); | 299 HValue* object = instr->value()->ActualValue(); |
| 304 HCheckTableEntry* entry = Find(object); | 300 HCheckTableEntry* entry = Find(object); |
| 305 if (entry != NULL) { | 301 if (entry != NULL) { |
| 306 // entry found; | 302 // entry found; |
| 307 MapSet a = entry->maps_; | 303 MapSet a = entry->maps_; |
| 308 MapSet i = instr->map_set()->Copy(phase_->zone()); | 304 const UniqueSet<Map>* i = instr->map_set(); |
| 309 if (a->IsSubset(i)) { | 305 if (a->IsSubset(i)) { |
| 310 // The first check is more strict; the second is redundant. | 306 // The first check is more strict; the second is redundant. |
| 311 if (entry->check_ != NULL) { | 307 if (entry->check_ != NULL) { |
| 312 TRACE(("Replacing redundant CheckMaps #%d at B%d with #%d\n", | 308 TRACE(("Replacing redundant CheckMaps #%d at B%d with #%d\n", |
| 313 instr->id(), instr->block()->block_id(), entry->check_->id())); | 309 instr->id(), instr->block()->block_id(), entry->check_->id())); |
| 314 instr->DeleteAndReplaceWith(entry->check_); | 310 instr->DeleteAndReplaceWith(entry->check_); |
| 315 INC_STAT(redundant_); | 311 INC_STAT(redundant_); |
| 316 } else { | 312 } else { |
| 317 TRACE(("Marking redundant CheckMaps #%d at B%d as dead\n", | 313 TRACE(("Marking redundant CheckMaps #%d at B%d as dead\n", |
| 318 instr->id(), instr->block()->block_id())); | 314 instr->id(), instr->block()->block_id())); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 357 } |
| 362 INC_STAT(narrowed_); | 358 INC_STAT(narrowed_); |
| 363 } | 359 } |
| 364 } | 360 } |
| 365 } else { | 361 } else { |
| 366 // No entry; insert a new one. | 362 // No entry; insert a new one. |
| 367 Insert(object, instr, instr->map_set()->Copy(phase_->zone())); | 363 Insert(object, instr, instr->map_set()->Copy(phase_->zone())); |
| 368 } | 364 } |
| 369 } | 365 } |
| 370 | 366 |
| 371 void ReduceCheckValue(HCheckValue* instr) { | |
| 372 // Canonicalize HCheckValues; they might have their values load-eliminated. | |
| 373 HValue* value = instr->Canonicalize(); | |
| 374 if (value == NULL) { | |
| 375 instr->DeleteAndReplaceWith(instr->value()); | |
| 376 INC_STAT(removed_); | |
| 377 } else if (value != instr) { | |
| 378 instr->DeleteAndReplaceWith(value); | |
| 379 INC_STAT(redundant_); | |
| 380 } | |
| 381 } | |
| 382 | |
| 383 void ReduceLoadNamedField(HLoadNamedField* instr) { | 367 void ReduceLoadNamedField(HLoadNamedField* instr) { |
| 384 // Reduce a load of the map field when it is known to be a constant. | 368 // Reduce a load of the map field when it is known to be a constant. |
| 385 if (!IsMapAccess(instr->access())) { | 369 if (!IsMapAccess(instr->access())) { |
| 386 // Check if we introduce field maps here. | 370 // Check if we introduce field maps here. |
| 387 if (instr->map_set()->size() != 0) { | 371 if (instr->map_set()->size() != 0) { |
| 388 Insert(instr, instr, instr->map_set()->Copy(phase_->zone())); | 372 Insert(instr, instr, instr->map_set()->Copy(phase_->zone())); |
| 389 } | 373 } |
| 390 return; | 374 return; |
| 391 } | 375 } |
| 392 | 376 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 PRINT_STAT(removed_cho); | 726 PRINT_STAT(removed_cho); |
| 743 PRINT_STAT(narrowed); | 727 PRINT_STAT(narrowed); |
| 744 PRINT_STAT(loads); | 728 PRINT_STAT(loads); |
| 745 PRINT_STAT(empty); | 729 PRINT_STAT(empty); |
| 746 PRINT_STAT(compares_true); | 730 PRINT_STAT(compares_true); |
| 747 PRINT_STAT(compares_false); | 731 PRINT_STAT(compares_false); |
| 748 PRINT_STAT(transitions); | 732 PRINT_STAT(transitions); |
| 749 } | 733 } |
| 750 | 734 |
| 751 } } // namespace v8::internal | 735 } } // namespace v8::internal |
| OLD | NEW |