OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { | 85 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
86 // Set the register values. The values are not important as there are no | 86 // Set the register values. The values are not important as there are no |
87 // callee saved registers in JavaScript frames, so all registers are | 87 // callee saved registers in JavaScript frames, so all registers are |
88 // spilled. Registers rbp and rsp are set to the correct values though. | 88 // spilled. Registers rbp and rsp are set to the correct values though. |
89 for (int i = 0; i < Register::kNumRegisters; i++) { | 89 for (int i = 0; i < Register::kNumRegisters; i++) { |
90 input_->SetRegister(i, i * 4); | 90 input_->SetRegister(i, i * 4); |
91 } | 91 } |
92 input_->SetRegister(rsp.code(), reinterpret_cast<intptr_t>(frame->sp())); | 92 input_->SetRegister(rsp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
93 input_->SetRegister(rbp.code(), reinterpret_cast<intptr_t>(frame->fp())); | 93 input_->SetRegister(rbp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
| 94 xmm_value_t zero = {{0.0, 0.0}}; |
94 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { | 95 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { |
95 input_->SetDoubleRegister(i, 0.0); | 96 input_->SetXMMRegister(i, zero); |
96 } | 97 } |
97 | 98 |
98 // Fill the frame content from the actual data on the frame. | 99 // Fill the frame content from the actual data on the frame. |
99 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { | 100 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
100 input_->SetFrameSlot(i, Memory::uint64_at(tos + i)); | 101 input_->SetFrameSlot(i, Memory::uint64_at(tos + i)); |
101 } | 102 } |
102 } | 103 } |
103 | 104 |
104 | 105 |
105 void Deoptimizer::SetPlatformCompiledStubRegisters( | 106 void Deoptimizer::SetPlatformCompiledStubRegisters( |
106 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { | 107 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { |
107 intptr_t handler = | 108 intptr_t handler = |
108 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); | 109 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); |
109 int params = descriptor->GetHandlerParameterCount(); | 110 int params = descriptor->GetHandlerParameterCount(); |
110 output_frame->SetRegister(rax.code(), params); | 111 output_frame->SetRegister(rax.code(), params); |
111 output_frame->SetRegister(rbx.code(), handler); | 112 output_frame->SetRegister(rbx.code(), handler); |
112 } | 113 } |
113 | 114 |
114 | 115 |
115 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { | 116 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { |
116 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { | 117 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { |
117 double double_value = input_->GetDoubleRegister(i); | 118 xmm_value_t xmm_value = input_->GetXMMRegister(i); |
118 output_frame->SetDoubleRegister(i, double_value); | 119 output_frame->SetXMMRegister(i, xmm_value); |
119 } | 120 } |
120 } | 121 } |
121 | 122 |
122 | 123 |
123 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { | 124 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { |
124 // There is no dynamic alignment padding on x64 in the input frame. | 125 // There is no dynamic alignment padding on x64 in the input frame. |
125 return false; | 126 return false; |
126 } | 127 } |
127 | 128 |
128 | 129 |
129 Code* Deoptimizer::NotifyStubFailureBuiltin() { | 130 Code* Deoptimizer::NotifyStubFailureBuiltin() { |
130 return isolate_->builtins()->builtin(Builtins::kNotifyStubFailureSaveDoubles); | 131 return isolate_->builtins()->builtin(Builtins::kNotifyStubFailureSaveDoubles); |
131 } | 132 } |
132 | 133 |
133 | 134 |
134 #define __ masm()-> | 135 #define __ masm()-> |
135 | 136 |
136 void Deoptimizer::EntryGenerator::Generate() { | 137 void Deoptimizer::EntryGenerator::Generate() { |
137 GeneratePrologue(); | 138 GeneratePrologue(); |
138 | 139 |
139 // Save all general purpose registers before messing with them. | 140 // Save all general purpose registers before messing with them. |
140 const int kNumberOfRegisters = Register::kNumRegisters; | 141 const int kNumberOfRegisters = Register::kNumRegisters; |
141 | 142 |
142 const int kDoubleRegsSize = kDoubleSize * | 143 const int kXMMRegsSize = kFloat32x4Size * |
143 XMMRegister::NumAllocatableRegisters(); | 144 XMMRegister::NumAllocatableRegisters(); |
144 __ subq(rsp, Immediate(kDoubleRegsSize)); | 145 __ subq(rsp, Immediate(kXMMRegsSize)); |
145 | 146 |
146 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { | 147 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { |
147 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); | 148 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); |
148 int offset = i * kDoubleSize; | 149 int offset = i * kFloat32x4Size; |
149 __ movsd(Operand(rsp, offset), xmm_reg); | 150 __ movups(Operand(rsp, offset), xmm_reg); |
150 } | 151 } |
151 | 152 |
152 // We push all registers onto the stack, even though we do not need | 153 // We push all registers onto the stack, even though we do not need |
153 // to restore all later. | 154 // to restore all later. |
154 for (int i = 0; i < kNumberOfRegisters; i++) { | 155 for (int i = 0; i < kNumberOfRegisters; i++) { |
155 Register r = Register::from_code(i); | 156 Register r = Register::from_code(i); |
156 __ push(r); | 157 __ push(r); |
157 } | 158 } |
158 | 159 |
159 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize + | 160 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize + |
160 kDoubleRegsSize; | 161 kXMMRegsSize; |
161 | 162 |
162 // We use this to keep the value of the fifth argument temporarily. | 163 // We use this to keep the value of the fifth argument temporarily. |
163 // Unfortunately we can't store it directly in r8 (used for passing | 164 // Unfortunately we can't store it directly in r8 (used for passing |
164 // this on linux), since it is another parameter passing register on windows. | 165 // this on linux), since it is another parameter passing register on windows. |
165 Register arg5 = r11; | 166 Register arg5 = r11; |
166 | 167 |
167 // Get the bailout id from the stack. | 168 // Get the bailout id from the stack. |
168 __ movq(arg_reg_3, Operand(rsp, kSavedRegistersAreaSize)); | 169 __ movq(arg_reg_3, Operand(rsp, kSavedRegistersAreaSize)); |
169 | 170 |
170 // Get the address of the location in the code object | 171 // Get the address of the location in the code object |
(...skipping 30 matching lines...) Expand all Loading... |
201 // frame descriptor pointer. | 202 // frame descriptor pointer. |
202 __ movq(rbx, Operand(rax, Deoptimizer::input_offset())); | 203 __ movq(rbx, Operand(rax, Deoptimizer::input_offset())); |
203 | 204 |
204 // Fill in the input registers. | 205 // Fill in the input registers. |
205 for (int i = kNumberOfRegisters -1; i >= 0; i--) { | 206 for (int i = kNumberOfRegisters -1; i >= 0; i--) { |
206 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 207 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
207 __ pop(Operand(rbx, offset)); | 208 __ pop(Operand(rbx, offset)); |
208 } | 209 } |
209 | 210 |
210 // Fill in the double input registers. | 211 // Fill in the double input registers. |
211 int double_regs_offset = FrameDescription::double_registers_offset(); | 212 int xmm_regs_offset = FrameDescription::xmm_registers_offset(); |
212 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { | 213 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { |
213 int dst_offset = i * kDoubleSize + double_regs_offset; | 214 int dst_offset = i * kFloat32x4Size + xmm_regs_offset; |
214 __ pop(Operand(rbx, dst_offset)); | 215 __ pop(Operand(rbx, dst_offset)); |
| 216 __ pop(Operand(rbx, dst_offset + kDoubleSize)); |
215 } | 217 } |
216 | 218 |
217 // Remove the bailout id and return address from the stack. | 219 // Remove the bailout id and return address from the stack. |
218 __ addq(rsp, Immediate(2 * kPointerSize)); | 220 __ addq(rsp, Immediate(2 * kPointerSize)); |
219 | 221 |
220 // Compute a pointer to the unwinding limit in register rcx; that is | 222 // Compute a pointer to the unwinding limit in register rcx; that is |
221 // the first stack slot not part of the input frame. | 223 // the first stack slot not part of the input frame. |
222 __ movq(rcx, Operand(rbx, FrameDescription::frame_size_offset())); | 224 __ movq(rcx, Operand(rbx, FrameDescription::frame_size_offset())); |
223 __ addq(rcx, rsp); | 225 __ addq(rcx, rsp); |
224 | 226 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 __ bind(&inner_loop_header); | 270 __ bind(&inner_loop_header); |
269 __ testq(rcx, rcx); | 271 __ testq(rcx, rcx); |
270 __ j(not_zero, &inner_push_loop); | 272 __ j(not_zero, &inner_push_loop); |
271 __ addq(rax, Immediate(kPointerSize)); | 273 __ addq(rax, Immediate(kPointerSize)); |
272 __ bind(&outer_loop_header); | 274 __ bind(&outer_loop_header); |
273 __ cmpq(rax, rdx); | 275 __ cmpq(rax, rdx); |
274 __ j(below, &outer_push_loop); | 276 __ j(below, &outer_push_loop); |
275 | 277 |
276 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { | 278 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { |
277 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); | 279 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); |
278 int src_offset = i * kDoubleSize + double_regs_offset; | 280 int src_offset = i * kFloat32x4Size + xmm_regs_offset; |
279 __ movsd(xmm_reg, Operand(rbx, src_offset)); | 281 __ movups(xmm_reg, Operand(rbx, src_offset)); |
280 } | 282 } |
281 | 283 |
282 // Push state, pc, and continuation from the last output frame. | 284 // Push state, pc, and continuation from the last output frame. |
283 __ push(Operand(rbx, FrameDescription::state_offset())); | 285 __ push(Operand(rbx, FrameDescription::state_offset())); |
284 __ push(Operand(rbx, FrameDescription::pc_offset())); | 286 __ push(Operand(rbx, FrameDescription::pc_offset())); |
285 __ push(Operand(rbx, FrameDescription::continuation_offset())); | 287 __ push(Operand(rbx, FrameDescription::continuation_offset())); |
286 | 288 |
287 // Push the registers from the last output frame. | 289 // Push the registers from the last output frame. |
288 for (int i = 0; i < kNumberOfRegisters; i++) { | 290 for (int i = 0; i < kNumberOfRegisters; i++) { |
289 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 291 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 SetFrameSlot(offset, value); | 336 SetFrameSlot(offset, value); |
335 } | 337 } |
336 | 338 |
337 | 339 |
338 #undef __ | 340 #undef __ |
339 | 341 |
340 | 342 |
341 } } // namespace v8::internal | 343 } } // namespace v8::internal |
342 | 344 |
343 #endif // V8_TARGET_ARCH_X64 | 345 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |