| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 void RegisterAllocator::Initialize() { | 35 void RegisterAllocator::Initialize() { |
| 36 registers_.Reset(); | 36 registers_.Reset(); |
| 37 registers_.Use(esp); | 37 registers_.Use(esp); |
| 38 registers_.Use(ebp); | 38 registers_.Use(ebp); |
| 39 registers_.Use(esi); | 39 registers_.Use(esi); |
| 40 registers_.Use(edi); | 40 registers_.Use(edi); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 Register RegisterAllocator::Allocate() { | 44 Register RegisterAllocator::AllocateWithoutSpilling() { |
| 45 // Return the first free register, if any. | 45 // Return the first free register, if any. |
| 46 for (int i = 0; i < num_registers(); i++) { | 46 for (int i = 0; i < num_registers(); i++) { |
| 47 if (!registers_.is_used(i)) { | 47 if (!registers_.is_used(i)) { |
| 48 Register result = { i }; | 48 Register result = { i }; |
| 49 registers_.Use(result); | 49 registers_.Use(result); |
| 50 return result; | 50 return result; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 return no_reg; |
| 54 } |
| 53 | 55 |
| 54 // Ask the current frame to spill a register. | 56 |
| 55 ASSERT(code_generator_->frame() != NULL); | 57 Register RegisterAllocator::Allocate() { |
| 56 Register result = code_generator_->frame()->SpillAnyRegister(); | 58 Register result = AllocateWithoutSpilling(); |
| 57 if (!result.is(no_reg)) { | 59 if (result.is(no_reg)) { |
| 58 ASSERT(!registers_.is_used(result.code())); | 60 // Ask the current frame to spill a register. |
| 59 registers_.Use(result); | 61 ASSERT(code_generator_->frame() != NULL); |
| 62 result = code_generator_->frame()->SpillAnyRegister(); |
| 63 if (!result.is(no_reg)) { |
| 64 ASSERT(!registers_.is_used(result.code())); |
| 65 registers_.Use(result); |
| 66 } |
| 60 } | 67 } |
| 61 | |
| 62 return result; | 68 return result; |
| 63 } | 69 } |
| 64 | 70 |
| 65 | 71 |
| 66 } } // namespace v8::internal | 72 } } // namespace v8::internal |
| OLD | NEW |