OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3405 if (current->representation().IsNone() && | 3405 if (current->representation().IsNone() && |
3406 current->CheckFlag(HInstruction::kFlexibleRepresentation)) { | 3406 current->CheckFlag(HInstruction::kFlexibleRepresentation)) { |
3407 current->ChangeRepresentation(Representation::Tagged()); | 3407 current->ChangeRepresentation(Representation::Tagged()); |
3408 } | 3408 } |
3409 } | 3409 } |
3410 } | 3410 } |
3411 } | 3411 } |
3412 | 3412 |
3413 | 3413 |
3414 void HGraph::MergeRemovableSimulates() { | 3414 void HGraph::MergeRemovableSimulates() { |
3415 ZoneList<HSimulate*> mergelist(2, zone()); | |
3415 for (int i = 0; i < blocks()->length(); ++i) { | 3416 for (int i = 0; i < blocks()->length(); ++i) { |
3416 HBasicBlock* block = blocks()->at(i); | 3417 HBasicBlock* block = blocks()->at(i); |
3417 // Always reset the folding candidate at the start of a block. | 3418 // Make sure the merge list is empty at the start of a block. |
3418 HSimulate* folding_candidate = NULL; | 3419 ASSERT(mergelist.is_empty()); |
3419 // Nasty heuristic: Never remove the first simulate in a block. This | 3420 // Nasty heuristic: Never remove the first simulate in a block. This |
3420 // just so happens to have a beneficial effect on register allocation. | 3421 // just so happens to have a beneficial effect on register allocation. |
3421 bool first = true; | 3422 bool first = true; |
3422 for (HInstruction* current = block->first(); | 3423 for (HInstruction* current = block->first(); |
3423 current != NULL; current = current->next()) { | 3424 current != NULL; current = current->next()) { |
3424 if (current->IsLeaveInlined()) { | 3425 if (current->IsLeaveInlined()) { |
3425 // Never fold simulates from inlined environments into simulates | 3426 // Never fold simulates from inlined environments into simulates |
3426 // in the outer environment. | 3427 // in the outer environment. |
3427 // (Before each HEnterInlined, there is a non-foldable HSimulate | 3428 // (Before each HEnterInlined, there is a non-foldable HSimulate |
3428 // anyway, so we get the barrier in the other direction for free.) | 3429 // anyway, so we get the barrier in the other direction for free.) |
3429 if (folding_candidate != NULL) { | 3430 // Simply remove all accumulated simulates without merging. |
Jakob Kummerow
2013/04/08 17:09:59
Please add to this comment:
This is safe because
| |
3430 folding_candidate->DeleteAndReplaceWith(NULL); | 3431 while (!mergelist.is_empty()) { |
3432 mergelist.RemoveLast()->DeleteAndReplaceWith(NULL); | |
3431 } | 3433 } |
3432 folding_candidate = NULL; | |
3433 continue; | 3434 continue; |
3434 } | 3435 } |
3435 // If we have an HSimulate and a candidate, perform the folding. | 3436 // Skip the non-simulates and the first simulate. |
3436 if (!current->IsSimulate()) continue; | 3437 if (!current->IsSimulate()) continue; |
3437 if (first) { | 3438 if (first) { |
3438 first = false; | 3439 first = false; |
3439 continue; | 3440 continue; |
3440 } | 3441 } |
3441 HSimulate* current_simulate = HSimulate::cast(current); | 3442 HSimulate* current_simulate = HSimulate::cast(current); |
3442 if (folding_candidate != NULL) { | 3443 if ((current_simulate->previous()->HasObservableSideEffects() && |
3443 folding_candidate->MergeInto(current_simulate); | 3444 !current_simulate->next()->IsSimulate()) || |
3444 folding_candidate->DeleteAndReplaceWith(NULL); | 3445 !current_simulate->is_candidate_for_removal()) { |
3445 folding_candidate = NULL; | 3446 // This simulate is not suitable for folding. |
3447 // Fold the ones accumulated so far. | |
3448 current_simulate->MergeWith(&mergelist); | |
3449 continue; | |
3450 } else { | |
3451 // Accumulate this simulate for folding later on. | |
3452 mergelist.Add(current_simulate, zone()); | |
3446 } | 3453 } |
3447 // Check if the current simulate is a candidate for folding. | 3454 } |
3448 if (current_simulate->previous()->HasObservableSideEffects() && | 3455 |
3449 !current_simulate->next()->IsSimulate()) { | 3456 if (!mergelist.is_empty()) { |
3450 continue; | 3457 // Merge the accumulated simulates at the end of the block. |
3451 } | 3458 HSimulate* last = mergelist.RemoveLast(); |
3452 if (!current_simulate->is_candidate_for_removal()) { | 3459 last->MergeWith(&mergelist); |
3453 continue; | |
3454 } | |
3455 folding_candidate = current_simulate; | |
3456 } | 3460 } |
3457 } | 3461 } |
3458 } | 3462 } |
3459 | 3463 |
3460 | 3464 |
3461 void HGraph::InitializeInferredTypes() { | 3465 void HGraph::InitializeInferredTypes() { |
3462 HPhase phase("H_Inferring types", this); | 3466 HPhase phase("H_Inferring types", this); |
3463 InitializeInferredTypes(0, this->blocks_.length() - 1); | 3467 InitializeInferredTypes(0, this->blocks_.length() - 1); |
3464 } | 3468 } |
3465 | 3469 |
(...skipping 7937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11403 } | 11407 } |
11404 } | 11408 } |
11405 | 11409 |
11406 #ifdef DEBUG | 11410 #ifdef DEBUG |
11407 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11411 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
11408 if (allocator_ != NULL) allocator_->Verify(); | 11412 if (allocator_ != NULL) allocator_->Verify(); |
11409 #endif | 11413 #endif |
11410 } | 11414 } |
11411 | 11415 |
11412 } } // namespace v8::internal | 11416 } } // namespace v8::internal |
OLD | NEW |