| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 | 44 |
| 45 // The register allocator uses small integers to represent the | 45 // The register allocator uses small integers to represent the |
| 46 // non-reserved assembler registers. The mapping is: | 46 // non-reserved assembler registers. The mapping is: |
| 47 | 47 |
| 48 // eax <-> 0, ebx <-> 1, ecx <-> 2, edx <-> 3, edi <-> 4. | 48 // eax <-> 0, ebx <-> 1, ecx <-> 2, edx <-> 3, edi <-> 4. |
| 49 | 49 |
| 50 int RegisterAllocator::ToNumber(Register reg) { | 50 int RegisterAllocator::ToNumber(Register reg) { |
| 51 ASSERT(reg.is_valid() && !IsReserved(reg)); | 51 ASSERT(reg.is_valid() && !IsReserved(reg)); |
| 52 static int numbers[] = { | 52 const int kNumbers[] = { |
| 53 0, // eax | 53 0, // eax |
| 54 2, // ecx | 54 2, // ecx |
| 55 3, // edx | 55 3, // edx |
| 56 1, // ebx | 56 1, // ebx |
| 57 -1, // esp | 57 -1, // esp |
| 58 -1, // ebp | 58 -1, // ebp |
| 59 -1, // esi | 59 -1, // esi |
| 60 4 // edi | 60 4 // edi |
| 61 }; | 61 }; |
| 62 return numbers[reg.code()]; | 62 return kNumbers[reg.code()]; |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 Register RegisterAllocator::ToRegister(int num) { | 66 Register RegisterAllocator::ToRegister(int num) { |
| 67 ASSERT(num >= 0 && num < kNumRegisters); | 67 ASSERT(num >= 0 && num < kNumRegisters); |
| 68 const Register registers[] = { eax, ebx, ecx, edx, edi }; | 68 const Register kRegisters[] = { eax, ebx, ecx, edx, edi }; |
| 69 return registers[num]; | 69 return kRegisters[num]; |
| 70 } | 70 } |
| 71 | 71 |
| 72 | 72 |
| 73 void RegisterAllocator::Initialize() { | 73 void RegisterAllocator::Initialize() { |
| 74 Reset(); | 74 Reset(); |
| 75 // The non-reserved edi register is live on JS function entry. | 75 // The non-reserved edi register is live on JS function entry. |
| 76 Use(edi); // JS function. | 76 Use(edi); // JS function. |
| 77 } | 77 } |
| 78 | 78 |
| 79 | 79 |
| 80 } } // namespace v8::internal | 80 } } // namespace v8::internal |
| 81 | 81 |
| 82 #endif // V8_IA32_REGISTER_ALLOCATOR_IA32_INL_H_ | 82 #endif // V8_IA32_REGISTER_ALLOCATOR_IA32_INL_H_ |
| OLD | NEW |