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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 spilled_(false), | 133 spilled_(false), |
134 is_double_(false), | 134 is_double_(false), |
135 assigned_register_(kInvalidAssignment), | 135 assigned_register_(kInvalidAssignment), |
136 last_interval_(NULL), | 136 last_interval_(NULL), |
137 first_interval_(NULL), | 137 first_interval_(NULL), |
138 first_pos_(NULL), | 138 first_pos_(NULL), |
139 parent_(NULL), | 139 parent_(NULL), |
140 next_(NULL), | 140 next_(NULL), |
141 current_interval_(NULL), | 141 current_interval_(NULL), |
142 last_processed_use_(NULL), | 142 last_processed_use_(NULL), |
| 143 current_hint_operand_(NULL), |
143 spill_operand_(new(zone) LOperand()), | 144 spill_operand_(new(zone) LOperand()), |
144 spill_start_index_(kMaxInt) { } | 145 spill_start_index_(kMaxInt) { } |
145 | 146 |
146 | 147 |
147 void LiveRange::set_assigned_register(int reg, | 148 void LiveRange::set_assigned_register(int reg, |
148 RegisterKind register_kind, | 149 RegisterKind register_kind, |
149 Zone* zone) { | 150 Zone* zone) { |
150 ASSERT(!HasRegisterAssigned() && !IsSpilled()); | 151 ASSERT(!HasRegisterAssigned() && !IsSpilled()); |
151 assigned_register_ = reg; | 152 assigned_register_ = reg; |
152 is_double_ = (register_kind == DOUBLE_REGISTERS); | 153 is_double_ = (register_kind == DOUBLE_REGISTERS); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 446 |
446 | 447 |
447 void LiveRange::AddUsePosition(LifetimePosition pos, | 448 void LiveRange::AddUsePosition(LifetimePosition pos, |
448 LOperand* operand, | 449 LOperand* operand, |
449 LOperand* hint, | 450 LOperand* hint, |
450 Zone* zone) { | 451 Zone* zone) { |
451 LAllocator::TraceAlloc("Add to live range %d use position %d\n", | 452 LAllocator::TraceAlloc("Add to live range %d use position %d\n", |
452 id_, | 453 id_, |
453 pos.Value()); | 454 pos.Value()); |
454 UsePosition* use_pos = new(zone) UsePosition(pos, operand, hint); | 455 UsePosition* use_pos = new(zone) UsePosition(pos, operand, hint); |
| 456 UsePosition* prev_hint = NULL; |
455 UsePosition* prev = NULL; | 457 UsePosition* prev = NULL; |
456 UsePosition* current = first_pos_; | 458 UsePosition* current = first_pos_; |
457 while (current != NULL && current->pos().Value() < pos.Value()) { | 459 while (current != NULL && current->pos().Value() < pos.Value()) { |
| 460 prev_hint = current->HasHint() ? current : prev_hint; |
458 prev = current; | 461 prev = current; |
459 current = current->next(); | 462 current = current->next(); |
460 } | 463 } |
461 | 464 |
462 if (prev == NULL) { | 465 if (prev == NULL) { |
463 use_pos->set_next(first_pos_); | 466 use_pos->set_next(first_pos_); |
464 first_pos_ = use_pos; | 467 first_pos_ = use_pos; |
465 } else { | 468 } else { |
466 use_pos->next_ = prev->next_; | 469 use_pos->next_ = prev->next_; |
467 prev->next_ = use_pos; | 470 prev->next_ = use_pos; |
468 } | 471 } |
| 472 |
| 473 if (prev_hint == NULL && use_pos->HasHint()) { |
| 474 current_hint_operand_ = hint; |
| 475 } |
469 } | 476 } |
470 | 477 |
471 | 478 |
472 void LiveRange::ConvertOperands(Zone* zone) { | 479 void LiveRange::ConvertOperands(Zone* zone) { |
473 LOperand* op = CreateAssignedOperand(zone); | 480 LOperand* op = CreateAssignedOperand(zone); |
474 UsePosition* use_pos = first_pos(); | 481 UsePosition* use_pos = first_pos(); |
475 while (use_pos != NULL) { | 482 while (use_pos != NULL) { |
476 ASSERT(Start().Value() <= use_pos->pos().Value() && | 483 ASSERT(Start().Value() <= use_pos->pos().Value() && |
477 use_pos->pos().Value() <= End().Value()); | 484 use_pos->pos().Value() <= End().Value()); |
478 | 485 |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 for (int i = 0; i < move_operands->length(); ++i) { | 918 for (int i = 0; i < move_operands->length(); ++i) { |
912 LMoveOperands* cur = &move_operands->at(i); | 919 LMoveOperands* cur = &move_operands->at(i); |
913 if (cur->IsIgnored()) continue; | 920 if (cur->IsIgnored()) continue; |
914 LOperand* from = cur->source(); | 921 LOperand* from = cur->source(); |
915 LOperand* to = cur->destination(); | 922 LOperand* to = cur->destination(); |
916 HPhi* phi = LookupPhi(to); | 923 HPhi* phi = LookupPhi(to); |
917 LOperand* hint = to; | 924 LOperand* hint = to; |
918 if (phi != NULL) { | 925 if (phi != NULL) { |
919 // This is a phi resolving move. | 926 // This is a phi resolving move. |
920 if (!phi->block()->IsLoopHeader()) { | 927 if (!phi->block()->IsLoopHeader()) { |
921 hint = LiveRangeFor(phi->id())->FirstHint(); | 928 hint = LiveRangeFor(phi->id())->current_hint_operand(); |
922 } | 929 } |
923 } else { | 930 } else { |
924 if (to->IsUnallocated()) { | 931 if (to->IsUnallocated()) { |
925 if (live->Contains(LUnallocated::cast(to)->virtual_register())) { | 932 if (live->Contains(LUnallocated::cast(to)->virtual_register())) { |
926 Define(curr_position, to, from); | 933 Define(curr_position, to, from); |
927 live->Remove(LUnallocated::cast(to)->virtual_register()); | 934 live->Remove(LUnallocated::cast(to)->virtual_register()); |
928 } else { | 935 } else { |
929 cur->Eliminate(); | 936 cur->Eliminate(); |
930 continue; | 937 continue; |
931 } | 938 } |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 LiveRange* current = live_ranges()->at(i); | 2185 LiveRange* current = live_ranges()->at(i); |
2179 if (current != NULL) current->Verify(); | 2186 if (current != NULL) current->Verify(); |
2180 } | 2187 } |
2181 } | 2188 } |
2182 | 2189 |
2183 | 2190 |
2184 #endif | 2191 #endif |
2185 | 2192 |
2186 | 2193 |
2187 } } // namespace v8::internal | 2194 } } // namespace v8::internal |
OLD | NEW |