| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 ASSERT(cgen_->has_valid_frame()); | 96 ASSERT(cgen_->has_valid_frame()); |
| 97 cgen_->frame()->Spill(target); | 97 cgen_->frame()->Spill(target); |
| 98 ASSERT(cgen_->allocator()->count(target) == 1); | 98 ASSERT(cgen_->allocator()->count(target) == 1); |
| 99 } | 99 } |
| 100 ASSERT(is_register()); | 100 ASSERT(is_register()); |
| 101 ASSERT(reg().is(target)); | 101 ASSERT(reg().is(target)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 // ------------------------------------------------------------------------- | 105 // ------------------------------------------------------------------------- |
| 106 // RegisterFile implementation. |
| 107 |
| 108 |
| 109 void RegisterFile::CopyTo(RegisterFile* other) { |
| 110 for (int i = 0; i < kNumRegisters; i++) { |
| 111 other->ref_counts_[i] = ref_counts_[i]; |
| 112 } |
| 113 } |
| 114 |
| 115 |
| 116 // ------------------------------------------------------------------------- |
| 106 // RegisterAllocator implementation. | 117 // RegisterAllocator implementation. |
| 107 | 118 |
| 108 void RegisterAllocator::Initialize() { | 119 void RegisterAllocator::Initialize() { |
| 120 Reset(); |
| 121 Use(edi); |
| 122 } |
| 123 |
| 124 |
| 125 void RegisterAllocator::Reset() { |
| 109 registers_.Reset(); | 126 registers_.Reset(); |
| 110 Use(esp); | 127 Use(esp); |
| 111 Use(ebp); | 128 Use(ebp); |
| 112 Use(esi); | 129 Use(esi); |
| 113 Use(edi); | |
| 114 } | 130 } |
| 115 | 131 |
| 116 | 132 |
| 117 Result RegisterAllocator::AllocateWithoutSpilling() { | 133 Result RegisterAllocator::AllocateWithoutSpilling() { |
| 118 // Return the first free register, if any. | 134 // Return the first free register, if any. |
| 119 for (int i = 0; i < num_registers(); i++) { | 135 for (int i = 0; i < num_registers(); i++) { |
| 120 if (!is_used(i)) { | 136 if (!is_used(i)) { |
| 121 Register free_reg = { i }; | 137 Register free_reg = { i }; |
| 122 return Result(free_reg, cgen_); | 138 return Result(free_reg, cgen_); |
| 123 } | 139 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 153 cgen_->frame()->Spill(target); | 169 cgen_->frame()->Spill(target); |
| 154 ASSERT(!is_used(target)); | 170 ASSERT(!is_used(target)); |
| 155 return Result(target, cgen_); | 171 return Result(target, cgen_); |
| 156 } | 172 } |
| 157 // Otherwise (if it's referenced outside the frame) we cannot allocate it. | 173 // Otherwise (if it's referenced outside the frame) we cannot allocate it. |
| 158 return Result(cgen_); | 174 return Result(cgen_); |
| 159 } | 175 } |
| 160 | 176 |
| 161 | 177 |
| 162 } } // namespace v8::internal | 178 } } // namespace v8::internal |
| OLD | NEW |