OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 GeneratePrologue(); | 114 GeneratePrologue(); |
115 | 115 |
116 // Unlike on ARM we don't save all the registers, just the useful ones. | 116 // Unlike on ARM we don't save all the registers, just the useful ones. |
117 // For the rest, there are gaps on the stack, so the offsets remain the same. | 117 // For the rest, there are gaps on the stack, so the offsets remain the same. |
118 const int kNumberOfRegisters = Register::kNumRegisters; | 118 const int kNumberOfRegisters = Register::kNumRegisters; |
119 | 119 |
120 RegList restored_regs = kJSCallerSaved | kCalleeSaved; | 120 RegList restored_regs = kJSCallerSaved | kCalleeSaved; |
121 RegList saved_regs = restored_regs | sp.bit(); | 121 RegList saved_regs = restored_regs | sp.bit(); |
122 | 122 |
123 const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kNumRegisters; | 123 const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kNumRegisters; |
| 124 const int kFloatRegsSize = kFloatSize * FloatRegister::kNumRegisters; |
124 | 125 |
125 // Save all double registers before messing with them. | 126 // Save all double registers before messing with them. |
126 __ subi(sp, sp, Operand(kDoubleRegsSize)); | 127 __ subi(sp, sp, Operand(kDoubleRegsSize)); |
127 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); | 128 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); |
128 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 129 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
129 int code = config->GetAllocatableDoubleCode(i); | 130 int code = config->GetAllocatableDoubleCode(i); |
130 const DoubleRegister dreg = DoubleRegister::from_code(code); | 131 const DoubleRegister dreg = DoubleRegister::from_code(code); |
131 int offset = code * kDoubleSize; | 132 int offset = code * kDoubleSize; |
132 __ stfd(dreg, MemOperand(sp, offset)); | 133 __ stfd(dreg, MemOperand(sp, offset)); |
133 } | 134 } |
| 135 // Save all float registers before messing with them. |
| 136 __ subi(sp, sp, Operand(kFloatRegsSize)); |
| 137 for (int i = 0; i < config->num_allocatable_float_registers(); ++i) { |
| 138 int code = config->GetAllocatableFloatCode(i); |
| 139 const FloatRegister freg = FloatRegister::from_code(code); |
| 140 int offset = code * kFloatSize; |
| 141 __ stfs(freg, MemOperand(sp, offset)); |
| 142 } |
134 | 143 |
135 // Push saved_regs (needed to populate FrameDescription::registers_). | 144 // Push saved_regs (needed to populate FrameDescription::registers_). |
136 // Leave gaps for other registers. | 145 // Leave gaps for other registers. |
137 __ subi(sp, sp, Operand(kNumberOfRegisters * kPointerSize)); | 146 __ subi(sp, sp, Operand(kNumberOfRegisters * kPointerSize)); |
138 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { | 147 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { |
139 if ((saved_regs & (1 << i)) != 0) { | 148 if ((saved_regs & (1 << i)) != 0) { |
140 __ StoreP(ToRegister(i), MemOperand(sp, kPointerSize * i)); | 149 __ StoreP(ToRegister(i), MemOperand(sp, kPointerSize * i)); |
141 } | 150 } |
142 } | 151 } |
143 | 152 |
144 __ mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 153 __ mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
145 __ StoreP(fp, MemOperand(ip)); | 154 __ StoreP(fp, MemOperand(ip)); |
146 | 155 |
147 const int kSavedRegistersAreaSize = | 156 const int kSavedRegistersAreaSize = |
148 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; | 157 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize + kFloatRegsSize; |
149 | 158 |
150 // Get the bailout id from the stack. | 159 // Get the bailout id from the stack. |
151 __ LoadP(r5, MemOperand(sp, kSavedRegistersAreaSize)); | 160 __ LoadP(r5, MemOperand(sp, kSavedRegistersAreaSize)); |
152 | 161 |
153 // Get the address of the location in the code object (r6) (return | 162 // Get the address of the location in the code object (r6) (return |
154 // address for lazy deoptimization) and compute the fp-to-sp delta in | 163 // address for lazy deoptimization) and compute the fp-to-sp delta in |
155 // register r7. | 164 // register r7. |
156 __ mflr(r6); | 165 __ mflr(r6); |
157 // Correct one word for bailout id. | 166 // Correct one word for bailout id. |
158 __ addi(r7, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 167 __ addi(r7, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
(...skipping 30 matching lines...) Expand all Loading... |
189 __ LoadP(r5, MemOperand(sp, i * kPointerSize)); | 198 __ LoadP(r5, MemOperand(sp, i * kPointerSize)); |
190 __ StoreP(r5, MemOperand(r4, offset)); | 199 __ StoreP(r5, MemOperand(r4, offset)); |
191 } | 200 } |
192 | 201 |
193 int double_regs_offset = FrameDescription::double_registers_offset(); | 202 int double_regs_offset = FrameDescription::double_registers_offset(); |
194 // Copy double registers to | 203 // Copy double registers to |
195 // double_registers_[DoubleRegister::kNumRegisters] | 204 // double_registers_[DoubleRegister::kNumRegisters] |
196 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 205 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
197 int code = config->GetAllocatableDoubleCode(i); | 206 int code = config->GetAllocatableDoubleCode(i); |
198 int dst_offset = code * kDoubleSize + double_regs_offset; | 207 int dst_offset = code * kDoubleSize + double_regs_offset; |
199 int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize; | 208 int src_offset = |
| 209 code * kDoubleSize + kNumberOfRegisters * kPointerSize + kFloatRegsSize; |
200 __ lfd(d0, MemOperand(sp, src_offset)); | 210 __ lfd(d0, MemOperand(sp, src_offset)); |
201 __ stfd(d0, MemOperand(r4, dst_offset)); | 211 __ stfd(d0, MemOperand(r4, dst_offset)); |
202 } | 212 } |
203 | 213 int float_regs_offset = FrameDescription::float_registers_offset(); |
| 214 // Copy float registers to |
| 215 // float_registers_[FloatRegister::kNumRegisters] |
| 216 for (int i = 0; i < config->num_allocatable_float_registers(); ++i) { |
| 217 int code = config->GetAllocatableFloatCode(i); |
| 218 int dst_offset = code * kFloatSize + float_regs_offset; |
| 219 int src_offset = code * kFloatSize + kNumberOfRegisters * kPointerSize; |
| 220 __ lfs(d0, MemOperand(sp, src_offset)); |
| 221 __ stfs(d0, MemOperand(r4, dst_offset)); |
| 222 } |
204 // Remove the bailout id and the saved registers from the stack. | 223 // Remove the bailout id and the saved registers from the stack. |
205 __ addi(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 224 __ addi(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
206 | 225 |
207 // Compute a pointer to the unwinding limit in register r5; that is | 226 // Compute a pointer to the unwinding limit in register r5; that is |
208 // the first stack slot not part of the input frame. | 227 // the first stack slot not part of the input frame. |
209 __ LoadP(r5, MemOperand(r4, FrameDescription::frame_size_offset())); | 228 __ LoadP(r5, MemOperand(r4, FrameDescription::frame_size_offset())); |
210 __ add(r5, r5, sp); | 229 __ add(r5, r5, sp); |
211 | 230 |
212 // Unwind the stack down to - but not including - the unwinding | 231 // Unwind the stack down to - but not including - the unwinding |
213 // limit and copy the contents of the activation frame to the input | 232 // limit and copy the contents of the activation frame to the input |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 354 |
336 void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { | 355 void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { |
337 DCHECK(FLAG_enable_embedded_constant_pool); | 356 DCHECK(FLAG_enable_embedded_constant_pool); |
338 SetFrameSlot(offset, value); | 357 SetFrameSlot(offset, value); |
339 } | 358 } |
340 | 359 |
341 | 360 |
342 #undef __ | 361 #undef __ |
343 } // namespace internal | 362 } // namespace internal |
344 } // namespace v8 | 363 } // namespace v8 |
OLD | NEW |