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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) { | 49 static inline LifetimePosition Min(LifetimePosition a, LifetimePosition b) { |
50 return a.Value() < b.Value() ? a : b; | 50 return a.Value() < b.Value() ? a : b; |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) { | 54 static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) { |
55 return a.Value() > b.Value() ? a : b; | 55 return a.Value() > b.Value() ? a : b; |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 UsePosition::UsePosition(LifetimePosition pos, LOperand* operand) | 59 UsePosition::UsePosition(LifetimePosition pos, |
| 60 LOperand* operand, |
| 61 LOperand* hint) |
60 : operand_(operand), | 62 : operand_(operand), |
61 hint_(NULL), | 63 hint_(hint), |
62 pos_(pos), | 64 pos_(pos), |
63 next_(NULL), | 65 next_(NULL), |
64 requires_reg_(false), | 66 requires_reg_(false), |
65 register_beneficial_(true) { | 67 register_beneficial_(true) { |
66 if (operand_ != NULL && operand_->IsUnallocated()) { | 68 if (operand_ != NULL && operand_->IsUnallocated()) { |
67 LUnallocated* unalloc = LUnallocated::cast(operand_); | 69 LUnallocated* unalloc = LUnallocated::cast(operand_); |
68 requires_reg_ = unalloc->HasRegisterPolicy(); | 70 requires_reg_ = unalloc->HasRegisterPolicy(); |
69 register_beneficial_ = !unalloc->HasAnyPolicy(); | 71 register_beneficial_ = !unalloc->HasAnyPolicy(); |
70 } | 72 } |
71 ASSERT(pos_.IsValid()); | 73 ASSERT(pos_.IsValid()); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 // that each new use interval either precedes or intersects with | 444 // that each new use interval either precedes or intersects with |
443 // last added interval. | 445 // last added interval. |
444 ASSERT(start.Value() < first_interval_->end().Value()); | 446 ASSERT(start.Value() < first_interval_->end().Value()); |
445 first_interval_->start_ = Min(start, first_interval_->start_); | 447 first_interval_->start_ = Min(start, first_interval_->start_); |
446 first_interval_->end_ = Max(end, first_interval_->end_); | 448 first_interval_->end_ = Max(end, first_interval_->end_); |
447 } | 449 } |
448 } | 450 } |
449 } | 451 } |
450 | 452 |
451 | 453 |
452 UsePosition* LiveRange::AddUsePosition(LifetimePosition pos, | 454 void LiveRange::AddUsePosition(LifetimePosition pos, |
453 LOperand* operand, | 455 LOperand* operand, |
454 Zone* zone) { | 456 LOperand* hint, |
| 457 Zone* zone) { |
455 LAllocator::TraceAlloc("Add to live range %d use position %d\n", | 458 LAllocator::TraceAlloc("Add to live range %d use position %d\n", |
456 id_, | 459 id_, |
457 pos.Value()); | 460 pos.Value()); |
458 UsePosition* use_pos = new(zone) UsePosition(pos, operand); | 461 UsePosition* use_pos = new(zone) UsePosition(pos, operand, hint); |
459 UsePosition* prev = NULL; | 462 UsePosition* prev = NULL; |
460 UsePosition* current = first_pos_; | 463 UsePosition* current = first_pos_; |
461 while (current != NULL && current->pos().Value() < pos.Value()) { | 464 while (current != NULL && current->pos().Value() < pos.Value()) { |
462 prev = current; | 465 prev = current; |
463 current = current->next(); | 466 current = current->next(); |
464 } | 467 } |
465 | 468 |
466 if (prev == NULL) { | 469 if (prev == NULL) { |
467 use_pos->set_next(first_pos_); | 470 use_pos->set_next(first_pos_); |
468 first_pos_ = use_pos; | 471 first_pos_ = use_pos; |
469 } else { | 472 } else { |
470 use_pos->next_ = prev->next_; | 473 use_pos->next_ = prev->next_; |
471 prev->next_ = use_pos; | 474 prev->next_ = use_pos; |
472 } | 475 } |
473 | |
474 return use_pos; | |
475 } | 476 } |
476 | 477 |
477 | 478 |
478 void LiveRange::ConvertOperands(Zone* zone) { | 479 void LiveRange::ConvertOperands(Zone* zone) { |
479 LOperand* op = CreateAssignedOperand(zone); | 480 LOperand* op = CreateAssignedOperand(zone); |
480 UsePosition* use_pos = first_pos(); | 481 UsePosition* use_pos = first_pos(); |
481 while (use_pos != NULL) { | 482 while (use_pos != NULL) { |
482 ASSERT(Start().Value() <= use_pos->pos().Value() && | 483 ASSERT(Start().Value() <= use_pos->pos().Value() && |
483 use_pos->pos().Value() <= End().Value()); | 484 use_pos->pos().Value() <= End().Value()); |
484 | 485 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 | 719 |
719 void LAllocator::Define(LifetimePosition position, | 720 void LAllocator::Define(LifetimePosition position, |
720 LOperand* operand, | 721 LOperand* operand, |
721 LOperand* hint) { | 722 LOperand* hint) { |
722 LiveRange* range = LiveRangeFor(operand); | 723 LiveRange* range = LiveRangeFor(operand); |
723 if (range == NULL) return; | 724 if (range == NULL) return; |
724 | 725 |
725 if (range->IsEmpty() || range->Start().Value() > position.Value()) { | 726 if (range->IsEmpty() || range->Start().Value() > position.Value()) { |
726 // Can happen if there is a definition without use. | 727 // Can happen if there is a definition without use. |
727 range->AddUseInterval(position, position.NextInstruction(), zone_); | 728 range->AddUseInterval(position, position.NextInstruction(), zone_); |
728 range->AddUsePosition(position.NextInstruction(), NULL, zone_); | 729 range->AddUsePosition(position.NextInstruction(), NULL, NULL, zone_); |
729 } else { | 730 } else { |
730 range->ShortenTo(position); | 731 range->ShortenTo(position); |
731 } | 732 } |
732 | 733 |
733 if (operand->IsUnallocated()) { | 734 if (operand->IsUnallocated()) { |
734 LUnallocated* unalloc_operand = LUnallocated::cast(operand); | 735 LUnallocated* unalloc_operand = LUnallocated::cast(operand); |
735 range->AddUsePosition(position, unalloc_operand, zone_)->set_hint(hint); | 736 range->AddUsePosition(position, unalloc_operand, hint, zone_); |
736 } | 737 } |
737 } | 738 } |
738 | 739 |
739 | 740 |
740 void LAllocator::Use(LifetimePosition block_start, | 741 void LAllocator::Use(LifetimePosition block_start, |
741 LifetimePosition position, | 742 LifetimePosition position, |
742 LOperand* operand, | 743 LOperand* operand, |
743 LOperand* hint) { | 744 LOperand* hint) { |
744 LiveRange* range = LiveRangeFor(operand); | 745 LiveRange* range = LiveRangeFor(operand); |
745 if (range == NULL) return; | 746 if (range == NULL) return; |
746 if (operand->IsUnallocated()) { | 747 if (operand->IsUnallocated()) { |
747 LUnallocated* unalloc_operand = LUnallocated::cast(operand); | 748 LUnallocated* unalloc_operand = LUnallocated::cast(operand); |
748 range->AddUsePosition(position, unalloc_operand, zone_)->set_hint(hint); | 749 range->AddUsePosition(position, unalloc_operand, hint, zone_); |
749 } | 750 } |
750 range->AddUseInterval(block_start, position, zone_); | 751 range->AddUseInterval(block_start, position, zone_); |
751 } | 752 } |
752 | 753 |
753 | 754 |
754 void LAllocator::AddConstraintsGapMove(int index, | 755 void LAllocator::AddConstraintsGapMove(int index, |
755 LOperand* from, | 756 LOperand* from, |
756 LOperand* to) { | 757 LOperand* to) { |
757 LGap* gap = GapAt(index); | 758 LGap* gap = GapAt(index); |
758 LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START, zone()); | 759 LParallelMove* move = gap->GetOrCreateParallelMove(LGap::START, zone()); |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 LiveRange* current = live_ranges()->at(i); | 2188 LiveRange* current = live_ranges()->at(i); |
2188 if (current != NULL) current->Verify(); | 2189 if (current != NULL) current->Verify(); |
2189 } | 2190 } |
2190 } | 2191 } |
2191 | 2192 |
2192 | 2193 |
2193 #endif | 2194 #endif |
2194 | 2195 |
2195 | 2196 |
2196 } } // namespace v8::internal | 2197 } } // namespace v8::internal |
OLD | NEW |