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" | |
9 #include "src/safepoint-table.h" | 8 #include "src/safepoint-table.h" |
10 | 9 |
11 namespace v8 { | 10 namespace v8 { |
12 namespace internal { | 11 namespace internal { |
13 | 12 |
14 | 13 |
15 int Deoptimizer::patch_size() { | 14 int Deoptimizer::patch_size() { |
16 const int kCallInstructionSizeInWords = 4; | 15 const int kCallInstructionSizeInWords = 4; |
17 return kCallInstructionSizeInWords * Assembler::kInstrSize; | 16 return kCallInstructionSizeInWords * Assembler::kInstrSize; |
18 } | 17 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { | 81 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
83 // Set the register values. The values are not important as there are no | 82 // Set the register values. The values are not important as there are no |
84 // callee saved registers in JavaScript frames, so all registers are | 83 // callee saved registers in JavaScript frames, so all registers are |
85 // spilled. Registers fp and sp are set to the correct values though. | 84 // spilled. Registers fp and sp are set to the correct values though. |
86 | 85 |
87 for (int i = 0; i < Register::kNumRegisters; i++) { | 86 for (int i = 0; i < Register::kNumRegisters; i++) { |
88 input_->SetRegister(i, i * 4); | 87 input_->SetRegister(i, i * 4); |
89 } | 88 } |
90 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); | 89 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
91 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); | 90 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
92 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; i++) { | 91 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { |
93 input_->SetDoubleRegister(i, 0.0); | 92 input_->SetDoubleRegister(i, 0.0); |
94 } | 93 } |
95 | 94 |
96 // Fill the frame content from the actual data on the frame. | 95 // Fill the frame content from the actual data on the frame. |
97 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { | 96 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
98 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); | 97 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); |
99 } | 98 } |
100 } | 99 } |
101 | 100 |
102 | 101 |
(...skipping 30 matching lines...) Expand all Loading... |
133 void Deoptimizer::TableEntryGenerator::Generate() { | 132 void Deoptimizer::TableEntryGenerator::Generate() { |
134 GeneratePrologue(); | 133 GeneratePrologue(); |
135 | 134 |
136 // Unlike on ARM we don't save all the registers, just the useful ones. | 135 // Unlike on ARM we don't save all the registers, just the useful ones. |
137 // For the rest, there are gaps on the stack, so the offsets remain the same. | 136 // For the rest, there are gaps on the stack, so the offsets remain the same. |
138 const int kNumberOfRegisters = Register::kNumRegisters; | 137 const int kNumberOfRegisters = Register::kNumRegisters; |
139 | 138 |
140 RegList restored_regs = kJSCallerSaved | kCalleeSaved; | 139 RegList restored_regs = kJSCallerSaved | kCalleeSaved; |
141 RegList saved_regs = restored_regs | sp.bit() | ra.bit(); | 140 RegList saved_regs = restored_regs | sp.bit() | ra.bit(); |
142 | 141 |
143 const int kDoubleRegsSize = kDoubleSize * DoubleRegister::kMaxNumRegisters; | 142 const int kDoubleRegsSize = |
| 143 kDoubleSize * FPURegister::kMaxNumAllocatableRegisters; |
144 | 144 |
145 // Save all FPU registers before messing with them. | 145 // Save all FPU registers before messing with them. |
146 __ Subu(sp, sp, Operand(kDoubleRegsSize)); | 146 __ Subu(sp, sp, Operand(kDoubleRegsSize)); |
147 const RegisterConfiguration* config = RegisterConfiguration::ArchDefault(); | 147 for (int i = 0; i < FPURegister::kMaxNumAllocatableRegisters; ++i) { |
148 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 148 FPURegister fpu_reg = FPURegister::FromAllocationIndex(i); |
149 int code = config->GetAllocatableDoubleCode(i); | 149 int offset = i * kDoubleSize; |
150 const DoubleRegister fpu_reg = DoubleRegister::from_code(code); | |
151 int offset = code * kDoubleSize; | |
152 __ sdc1(fpu_reg, MemOperand(sp, offset)); | 150 __ sdc1(fpu_reg, MemOperand(sp, offset)); |
153 } | 151 } |
154 | 152 |
155 // Push saved_regs (needed to populate FrameDescription::registers_). | 153 // Push saved_regs (needed to populate FrameDescription::registers_). |
156 // Leave gaps for other registers. | 154 // Leave gaps for other registers. |
157 __ Subu(sp, sp, kNumberOfRegisters * kPointerSize); | 155 __ Subu(sp, sp, kNumberOfRegisters * kPointerSize); |
158 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { | 156 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { |
159 if ((saved_regs & (1 << i)) != 0) { | 157 if ((saved_regs & (1 << i)) != 0) { |
160 __ sw(ToRegister(i), MemOperand(sp, kPointerSize * i)); | 158 __ sw(ToRegister(i), MemOperand(sp, kPointerSize * i)); |
161 } | 159 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 __ sw(a2, MemOperand(a1, offset)); | 208 __ sw(a2, MemOperand(a1, offset)); |
211 } else if (FLAG_debug_code) { | 209 } else if (FLAG_debug_code) { |
212 __ li(a2, kDebugZapValue); | 210 __ li(a2, kDebugZapValue); |
213 __ sw(a2, MemOperand(a1, offset)); | 211 __ sw(a2, MemOperand(a1, offset)); |
214 } | 212 } |
215 } | 213 } |
216 | 214 |
217 int double_regs_offset = FrameDescription::double_registers_offset(); | 215 int double_regs_offset = FrameDescription::double_registers_offset(); |
218 // Copy FPU registers to | 216 // Copy FPU registers to |
219 // double_registers_[DoubleRegister::kNumAllocatableRegisters] | 217 // double_registers_[DoubleRegister::kNumAllocatableRegisters] |
220 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 218 for (int i = 0; i < FPURegister::NumAllocatableRegisters(); ++i) { |
221 int code = config->GetAllocatableDoubleCode(i); | 219 int dst_offset = i * kDoubleSize + double_regs_offset; |
222 int dst_offset = code * kDoubleSize + double_regs_offset; | 220 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
223 int src_offset = code * kDoubleSize + kNumberOfRegisters * kPointerSize; | |
224 __ ldc1(f0, MemOperand(sp, src_offset)); | 221 __ ldc1(f0, MemOperand(sp, src_offset)); |
225 __ sdc1(f0, MemOperand(a1, dst_offset)); | 222 __ sdc1(f0, MemOperand(a1, dst_offset)); |
226 } | 223 } |
227 | 224 |
228 // Remove the bailout id and the saved registers from the stack. | 225 // Remove the bailout id and the saved registers from the stack. |
229 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 226 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
230 | 227 |
231 // Compute a pointer to the unwinding limit in register a2; that is | 228 // Compute a pointer to the unwinding limit in register a2; that is |
232 // the first stack slot not part of the input frame. | 229 // the first stack slot not part of the input frame. |
233 __ lw(a2, MemOperand(a1, FrameDescription::frame_size_offset())); | 230 __ lw(a2, MemOperand(a1, FrameDescription::frame_size_offset())); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 __ lw(t3, MemOperand(t2, FrameDescription::frame_content_offset())); | 277 __ lw(t3, MemOperand(t2, FrameDescription::frame_content_offset())); |
281 __ push(t3); | 278 __ push(t3); |
282 __ bind(&inner_loop_header); | 279 __ bind(&inner_loop_header); |
283 __ BranchShort(&inner_push_loop, ne, a3, Operand(zero_reg)); | 280 __ BranchShort(&inner_push_loop, ne, a3, Operand(zero_reg)); |
284 | 281 |
285 __ Addu(t0, t0, Operand(kPointerSize)); | 282 __ Addu(t0, t0, Operand(kPointerSize)); |
286 __ bind(&outer_loop_header); | 283 __ bind(&outer_loop_header); |
287 __ BranchShort(&outer_push_loop, lt, t0, Operand(a1)); | 284 __ BranchShort(&outer_push_loop, lt, t0, Operand(a1)); |
288 | 285 |
289 __ lw(a1, MemOperand(a0, Deoptimizer::input_offset())); | 286 __ lw(a1, MemOperand(a0, Deoptimizer::input_offset())); |
290 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 287 for (int i = 0; i < FPURegister::kMaxNumAllocatableRegisters; ++i) { |
291 int code = config->GetAllocatableDoubleCode(i); | 288 const FPURegister fpu_reg = FPURegister::FromAllocationIndex(i); |
292 const DoubleRegister fpu_reg = DoubleRegister::from_code(code); | 289 int src_offset = i * kDoubleSize + double_regs_offset; |
293 int src_offset = code * kDoubleSize + double_regs_offset; | |
294 __ ldc1(fpu_reg, MemOperand(a1, src_offset)); | 290 __ ldc1(fpu_reg, MemOperand(a1, src_offset)); |
295 } | 291 } |
296 | 292 |
297 // Push state, pc, and continuation from the last output frame. | 293 // Push state, pc, and continuation from the last output frame. |
298 __ lw(t2, MemOperand(a2, FrameDescription::state_offset())); | 294 __ lw(t2, MemOperand(a2, FrameDescription::state_offset())); |
299 __ push(t2); | 295 __ push(t2); |
300 | 296 |
301 __ lw(t2, MemOperand(a2, FrameDescription::pc_offset())); | 297 __ lw(t2, MemOperand(a2, FrameDescription::pc_offset())); |
302 __ push(t2); | 298 __ push(t2); |
303 __ lw(t2, MemOperand(a2, FrameDescription::continuation_offset())); | 299 __ lw(t2, MemOperand(a2, FrameDescription::continuation_offset())); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // No embedded constant pool support. | 399 // No embedded constant pool support. |
404 UNREACHABLE(); | 400 UNREACHABLE(); |
405 } | 401 } |
406 | 402 |
407 | 403 |
408 #undef __ | 404 #undef __ |
409 | 405 |
410 | 406 |
411 } // namespace internal | 407 } // namespace internal |
412 } // namespace v8 | 408 } // namespace v8 |
OLD | NEW |