OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/codegen.h" | 5 #include "src/codegen.h" |
6 #include "src/deoptimizer.h" | 6 #include "src/deoptimizer.h" |
7 #include "src/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
8 #include "src/register-configuration.h" | 8 #include "src/register-configuration.h" |
9 #include "src/safepoint-table.h" | 9 #include "src/safepoint-table.h" |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 GeneratePrologue(); | 107 GeneratePrologue(); |
108 | 108 |
109 // Unlike on ARM we don't save all the registers, just the useful ones. | 109 // Unlike on ARM we don't save all the registers, just the useful ones. |
110 // For the rest, there are gaps on the stack, so the offsets remain the same. | 110 // For the rest, there are gaps on the stack, so the offsets remain the same. |
111 const int kNumberOfRegisters = Register::kNumRegisters; | 111 const int kNumberOfRegisters = Register::kNumRegisters; |
112 | 112 |
113 RegList restored_regs = kJSCallerSaved | kCalleeSaved; | 113 RegList restored_regs = kJSCallerSaved | kCalleeSaved; |
114 RegList saved_regs = restored_regs | sp.bit() | ra.bit(); | 114 RegList saved_regs = restored_regs | sp.bit() | ra.bit(); |
115 | 115 |
116 const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kMaxNumRegisters; | 116 const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kMaxNumRegisters; |
| 117 const int kFloatRegsSize = kFloatSize * FloatRegister::kMaxNumRegisters; |
117 | 118 |
118 // Save all FPU registers before messing with them. | 119 // Save all FPU registers before messing with them. |
119 __ Subu(sp, sp, Operand(kDoubleRegsSize)); | 120 __ Subu(sp, sp, Operand(kDoubleRegsSize)); |
120 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); | 121 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); |
121 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 122 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
122 int code = config->GetAllocatableDoubleCode(i); | 123 int code = config->GetAllocatableDoubleCode(i); |
123 const DoubleRegister fpu_reg = DoubleRegister::from_code(code); | 124 const DoubleRegister fpu_reg = DoubleRegister::from_code(code); |
124 int offset = code * kDoubleSize; | 125 int offset = code * kDoubleSize; |
125 __ Sdc1(fpu_reg, MemOperand(sp, offset)); | 126 __ Sdc1(fpu_reg, MemOperand(sp, offset)); |
126 } | 127 } |
127 | 128 |
| 129 __ Subu(sp, sp, Operand(kFloatRegsSize)); |
| 130 for (int i = 0; i < config->num_allocatable_float_registers(); ++i) { |
| 131 int code = config->GetAllocatableFloatCode(i); |
| 132 const FloatRegister fpu_reg = FloatRegister::from_code(code); |
| 133 int offset = code * kFloatSize; |
| 134 __ swc1(fpu_reg, MemOperand(sp, offset)); |
| 135 } |
| 136 |
128 // Push saved_regs (needed to populate FrameDescription::registers_). | 137 // Push saved_regs (needed to populate FrameDescription::registers_). |
129 // Leave gaps for other registers. | 138 // Leave gaps for other registers. |
130 __ Subu(sp, sp, kNumberOfRegisters * kPointerSize); | 139 __ Subu(sp, sp, kNumberOfRegisters * kPointerSize); |
131 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { | 140 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { |
132 if ((saved_regs & (1 << i)) != 0) { | 141 if ((saved_regs & (1 << i)) != 0) { |
133 __ sw(ToRegister(i), MemOperand(sp, kPointerSize * i)); | 142 __ sw(ToRegister(i), MemOperand(sp, kPointerSize * i)); |
134 } | 143 } |
135 } | 144 } |
136 | 145 |
137 __ li(a2, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 146 __ li(a2, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
138 __ sw(fp, MemOperand(a2)); | 147 __ sw(fp, MemOperand(a2)); |
139 | 148 |
140 const int kSavedRegistersAreaSize = | 149 const int kSavedRegistersAreaSize = |
141 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; | 150 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize + kFloatRegsSize; |
142 | 151 |
143 // Get the bailout id from the stack. | 152 // Get the bailout id from the stack. |
144 __ lw(a2, MemOperand(sp, kSavedRegistersAreaSize)); | 153 __ lw(a2, MemOperand(sp, kSavedRegistersAreaSize)); |
145 | 154 |
146 // Get the address of the location in the code object (a3) (return | 155 // Get the address of the location in the code object (a3) (return |
147 // address for lazy deoptimization) and compute the fp-to-sp delta in | 156 // address for lazy deoptimization) and compute the fp-to-sp delta in |
148 // register t0. | 157 // register t0. |
149 __ mov(a3, ra); | 158 __ mov(a3, ra); |
150 // Correct one word for bailout id. | 159 // Correct one word for bailout id. |
151 __ Addu(t0, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 160 __ Addu(t0, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 __ sw(a2, MemOperand(a1, offset)); | 200 __ sw(a2, MemOperand(a1, offset)); |
192 } | 201 } |
193 } | 202 } |
194 | 203 |
195 int double_regs_offset = FrameDescription::double_registers_offset(); | 204 int double_regs_offset = FrameDescription::double_registers_offset(); |
196 // Copy FPU registers to | 205 // Copy FPU registers to |
197 // double_registers_[DoubleRegister::kNumAllocatableRegisters] | 206 // double_registers_[DoubleRegister::kNumAllocatableRegisters] |
198 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 207 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
199 int code = config->GetAllocatableDoubleCode(i); | 208 int code = config->GetAllocatableDoubleCode(i); |
200 int dst_offset = code * kDoubleSize + double_regs_offset; | 209 int dst_offset = code * kDoubleSize + double_regs_offset; |
201 int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize; | 210 int src_offset = |
| 211 code * kDoubleSize + kNumberOfRegisters * kPointerSize + kFloatRegsSize; |
202 __ Ldc1(f0, MemOperand(sp, src_offset)); | 212 __ Ldc1(f0, MemOperand(sp, src_offset)); |
203 __ Sdc1(f0, MemOperand(a1, dst_offset)); | 213 __ Sdc1(f0, MemOperand(a1, dst_offset)); |
204 } | 214 } |
205 | 215 |
| 216 // Copy FPU registers to |
| 217 // float_registers_[FloatRegister::kNumAllocatableRegisters] |
| 218 int float_regs_offset = FrameDescription::float_registers_offset(); |
| 219 for (int i = 0; i < config->num_allocatable_float_registers(); ++i) { |
| 220 int code = config->GetAllocatableFloatCode(i); |
| 221 int dst_offset = code * kFloatSize + float_regs_offset; |
| 222 int src_offset = code * kFloatSize + kNumberOfRegisters * kPointerSize; |
| 223 __ lwc1(f0, MemOperand(sp, src_offset)); |
| 224 __ swc1(f0, MemOperand(a1, dst_offset)); |
| 225 } |
| 226 |
206 // Remove the bailout id and the saved registers from the stack. | 227 // Remove the bailout id and the saved registers from the stack. |
207 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 228 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
208 | 229 |
209 // Compute a pointer to the unwinding limit in register a2; that is | 230 // Compute a pointer to the unwinding limit in register a2; that is |
210 // the first stack slot not part of the input frame. | 231 // the first stack slot not part of the input frame. |
211 __ lw(a2, MemOperand(a1, FrameDescription::frame_size_offset())); | 232 __ lw(a2, MemOperand(a1, FrameDescription::frame_size_offset())); |
212 __ Addu(a2, a2, sp); | 233 __ Addu(a2, a2, sp); |
213 | 234 |
214 // Unwind the stack down to - but not including - the unwinding | 235 // Unwind the stack down to - but not including - the unwinding |
215 // limit and copy the contents of the activation frame to the input | 236 // limit and copy the contents of the activation frame to the input |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // No embedded constant pool support. | 403 // No embedded constant pool support. |
383 UNREACHABLE(); | 404 UNREACHABLE(); |
384 } | 405 } |
385 | 406 |
386 | 407 |
387 #undef __ | 408 #undef __ |
388 | 409 |
389 | 410 |
390 } // namespace internal | 411 } // namespace internal |
391 } // namespace v8 | 412 } // namespace v8 |
OLD | NEW |