| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 for (int i = 0; i < num_registers(); i++) { | 135 for (int i = 0; i < num_registers(); i++) { |
| 136 if (!is_used(i)) { | 136 if (!is_used(i)) { |
| 137 Register free_reg = { i }; | 137 Register free_reg = { i }; |
| 138 return Result(free_reg, cgen_); | 138 return Result(free_reg, cgen_); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 return Result(cgen_); | 141 return Result(cgen_); |
| 142 } | 142 } |
| 143 | 143 |
| 144 | 144 |
| 145 Result RegisterAllocator::AllocateByteRegisterWithoutSpilling() { |
| 146 Result result = AllocateWithoutSpilling(); |
| 147 // Check that the register is a byte register. If not, unuse the |
| 148 // register if valid and return an invalid result. |
| 149 if (result.is_valid() && !result.reg().is_byte_register()) { |
| 150 result.Unuse(); |
| 151 return Result(cgen_); |
| 152 } |
| 153 return result; |
| 154 } |
| 155 |
| 156 |
| 145 Result RegisterAllocator::Allocate() { | 157 Result RegisterAllocator::Allocate() { |
| 146 Result result = AllocateWithoutSpilling(); | 158 Result result = AllocateWithoutSpilling(); |
| 147 if (!result.is_valid()) { | 159 if (!result.is_valid()) { |
| 148 // Ask the current frame to spill a register. | 160 // Ask the current frame to spill a register. |
| 149 ASSERT(cgen_->has_valid_frame()); | 161 ASSERT(cgen_->has_valid_frame()); |
| 150 Register free_reg = cgen_->frame()->SpillAnyRegister(); | 162 Register free_reg = cgen_->frame()->SpillAnyRegister(); |
| 151 if (free_reg.is_valid()) { | 163 if (free_reg.is_valid()) { |
| 152 ASSERT(!is_used(free_reg)); | 164 ASSERT(!is_used(free_reg)); |
| 153 return Result(free_reg, cgen_); | 165 return Result(free_reg, cgen_); |
| 154 } | 166 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 169 cgen_->frame()->Spill(target); | 181 cgen_->frame()->Spill(target); |
| 170 ASSERT(!is_used(target)); | 182 ASSERT(!is_used(target)); |
| 171 return Result(target, cgen_); | 183 return Result(target, cgen_); |
| 172 } | 184 } |
| 173 // Otherwise (if it's referenced outside the frame) we cannot allocate it. | 185 // Otherwise (if it's referenced outside the frame) we cannot allocate it. |
| 174 return Result(cgen_); | 186 return Result(cgen_); |
| 175 } | 187 } |
| 176 | 188 |
| 177 | 189 |
| 178 } } // namespace v8::internal | 190 } } // namespace v8::internal |
| OLD | NEW |