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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 const int kSavedRegistersAreaSize = kNumberOfRegisters * kRegisterSize + | 159 const int kSavedRegistersAreaSize = kNumberOfRegisters * kRegisterSize + |
160 kDoubleRegsSize; | 160 kDoubleRegsSize; |
161 | 161 |
162 // We use this to keep the value of the fifth argument temporarily. | 162 // 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 | 163 // 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. | 164 // this on linux), since it is another parameter passing register on windows. |
165 Register arg5 = r11; | 165 Register arg5 = r11; |
166 | 166 |
167 // Get the bailout id from the stack. | 167 // Get the bailout id from the stack. |
168 __ movq(arg_reg_3, Operand(rsp, kSavedRegistersAreaSize)); | 168 __ movp(arg_reg_3, Operand(rsp, kSavedRegistersAreaSize)); |
169 | 169 |
170 // Get the address of the location in the code object | 170 // Get the address of the location in the code object |
171 // and compute the fp-to-sp delta in register arg5. | 171 // and compute the fp-to-sp delta in register arg5. |
172 __ movq(arg_reg_4, Operand(rsp, kSavedRegistersAreaSize + 1 * kRegisterSize)); | 172 __ movp(arg_reg_4, Operand(rsp, kSavedRegistersAreaSize + 1 * kRegisterSize)); |
173 __ lea(arg5, Operand(rsp, kSavedRegistersAreaSize + 1 * kRegisterSize + | 173 __ lea(arg5, Operand(rsp, kSavedRegistersAreaSize + 1 * kRegisterSize + |
174 kPCOnStackSize)); | 174 kPCOnStackSize)); |
175 | 175 |
176 __ subq(arg5, rbp); | 176 __ subq(arg5, rbp); |
177 __ neg(arg5); | 177 __ neg(arg5); |
178 | 178 |
179 // Allocate a new deoptimizer object. | 179 // Allocate a new deoptimizer object. |
180 __ PrepareCallCFunction(6); | 180 __ PrepareCallCFunction(6); |
181 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 181 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
182 __ movq(arg_reg_1, rax); | 182 __ movp(arg_reg_1, rax); |
183 __ Set(arg_reg_2, type()); | 183 __ Set(arg_reg_2, type()); |
184 // Args 3 and 4 are already in the right registers. | 184 // Args 3 and 4 are already in the right registers. |
185 | 185 |
186 // On windows put the arguments on the stack (PrepareCallCFunction | 186 // On windows put the arguments on the stack (PrepareCallCFunction |
187 // has created space for this). On linux pass the arguments in r8 and r9. | 187 // has created space for this). On linux pass the arguments in r8 and r9. |
188 #ifdef _WIN64 | 188 #ifdef _WIN64 |
189 __ movq(Operand(rsp, 4 * kPointerSize), arg5); | 189 __ movp(Operand(rsp, 4 * kPointerSize), arg5); |
190 __ LoadAddress(arg5, ExternalReference::isolate_address(isolate())); | 190 __ LoadAddress(arg5, ExternalReference::isolate_address(isolate())); |
191 __ movq(Operand(rsp, 5 * kPointerSize), arg5); | 191 __ movp(Operand(rsp, 5 * kPointerSize), arg5); |
192 #else | 192 #else |
193 __ movq(r8, arg5); | 193 __ movp(r8, arg5); |
194 __ LoadAddress(r9, ExternalReference::isolate_address(isolate())); | 194 __ LoadAddress(r9, ExternalReference::isolate_address(isolate())); |
195 #endif | 195 #endif |
196 | 196 |
197 { AllowExternalCallThatCantCauseGC scope(masm()); | 197 { AllowExternalCallThatCantCauseGC scope(masm()); |
198 __ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6); | 198 __ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6); |
199 } | 199 } |
200 // Preserve deoptimizer object in register rax and get the input | 200 // Preserve deoptimizer object in register rax and get the input |
201 // frame descriptor pointer. | 201 // frame descriptor pointer. |
202 __ movq(rbx, Operand(rax, Deoptimizer::input_offset())); | 202 __ movp(rbx, Operand(rax, Deoptimizer::input_offset())); |
203 | 203 |
204 // Fill in the input registers. | 204 // Fill in the input registers. |
205 for (int i = kNumberOfRegisters -1; i >= 0; i--) { | 205 for (int i = kNumberOfRegisters -1; i >= 0; i--) { |
206 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 206 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
207 __ pop(Operand(rbx, offset)); | 207 __ pop(Operand(rbx, offset)); |
208 } | 208 } |
209 | 209 |
210 // Fill in the double input registers. | 210 // Fill in the double input registers. |
211 int double_regs_offset = FrameDescription::double_registers_offset(); | 211 int double_regs_offset = FrameDescription::double_registers_offset(); |
212 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { | 212 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { |
213 int dst_offset = i * kDoubleSize + double_regs_offset; | 213 int dst_offset = i * kDoubleSize + double_regs_offset; |
214 __ pop(Operand(rbx, dst_offset)); | 214 __ pop(Operand(rbx, dst_offset)); |
215 } | 215 } |
216 | 216 |
217 // Remove the bailout id and return address from the stack. | 217 // Remove the bailout id and return address from the stack. |
218 __ addq(rsp, Immediate(1 * kRegisterSize + kPCOnStackSize)); | 218 __ addq(rsp, Immediate(1 * kRegisterSize + kPCOnStackSize)); |
219 | 219 |
220 // Compute a pointer to the unwinding limit in register rcx; that is | 220 // Compute a pointer to the unwinding limit in register rcx; that is |
221 // the first stack slot not part of the input frame. | 221 // the first stack slot not part of the input frame. |
222 __ movq(rcx, Operand(rbx, FrameDescription::frame_size_offset())); | 222 __ movp(rcx, Operand(rbx, FrameDescription::frame_size_offset())); |
223 __ addq(rcx, rsp); | 223 __ addq(rcx, rsp); |
224 | 224 |
225 // Unwind the stack down to - but not including - the unwinding | 225 // Unwind the stack down to - but not including - the unwinding |
226 // limit and copy the contents of the activation frame to the input | 226 // limit and copy the contents of the activation frame to the input |
227 // frame description. | 227 // frame description. |
228 __ lea(rdx, Operand(rbx, FrameDescription::frame_content_offset())); | 228 __ lea(rdx, Operand(rbx, FrameDescription::frame_content_offset())); |
229 Label pop_loop_header; | 229 Label pop_loop_header; |
230 __ jmp(&pop_loop_header); | 230 __ jmp(&pop_loop_header); |
231 Label pop_loop; | 231 Label pop_loop; |
232 __ bind(&pop_loop); | 232 __ bind(&pop_loop); |
233 __ pop(Operand(rdx, 0)); | 233 __ pop(Operand(rdx, 0)); |
234 __ addq(rdx, Immediate(sizeof(intptr_t))); | 234 __ addq(rdx, Immediate(sizeof(intptr_t))); |
235 __ bind(&pop_loop_header); | 235 __ bind(&pop_loop_header); |
236 __ cmpq(rcx, rsp); | 236 __ cmpq(rcx, rsp); |
237 __ j(not_equal, &pop_loop); | 237 __ j(not_equal, &pop_loop); |
238 | 238 |
239 // Compute the output frame in the deoptimizer. | 239 // Compute the output frame in the deoptimizer. |
240 __ push(rax); | 240 __ push(rax); |
241 __ PrepareCallCFunction(2); | 241 __ PrepareCallCFunction(2); |
242 __ movq(arg_reg_1, rax); | 242 __ movp(arg_reg_1, rax); |
243 __ LoadAddress(arg_reg_2, ExternalReference::isolate_address(isolate())); | 243 __ LoadAddress(arg_reg_2, ExternalReference::isolate_address(isolate())); |
244 { | 244 { |
245 AllowExternalCallThatCantCauseGC scope(masm()); | 245 AllowExternalCallThatCantCauseGC scope(masm()); |
246 __ CallCFunction( | 246 __ CallCFunction( |
247 ExternalReference::compute_output_frames_function(isolate()), 2); | 247 ExternalReference::compute_output_frames_function(isolate()), 2); |
248 } | 248 } |
249 __ pop(rax); | 249 __ pop(rax); |
250 | 250 |
251 // Replace the current frame with the output frames. | 251 // Replace the current frame with the output frames. |
252 Label outer_push_loop, inner_push_loop, | 252 Label outer_push_loop, inner_push_loop, |
253 outer_loop_header, inner_loop_header; | 253 outer_loop_header, inner_loop_header; |
254 // Outer loop state: rax = current FrameDescription**, rdx = one past the | 254 // Outer loop state: rax = current FrameDescription**, rdx = one past the |
255 // last FrameDescription**. | 255 // last FrameDescription**. |
256 __ movl(rdx, Operand(rax, Deoptimizer::output_count_offset())); | 256 __ movl(rdx, Operand(rax, Deoptimizer::output_count_offset())); |
257 __ movq(rax, Operand(rax, Deoptimizer::output_offset())); | 257 __ movp(rax, Operand(rax, Deoptimizer::output_offset())); |
258 __ lea(rdx, Operand(rax, rdx, times_pointer_size, 0)); | 258 __ lea(rdx, Operand(rax, rdx, times_pointer_size, 0)); |
259 __ jmp(&outer_loop_header); | 259 __ jmp(&outer_loop_header); |
260 __ bind(&outer_push_loop); | 260 __ bind(&outer_push_loop); |
261 // Inner loop state: rbx = current FrameDescription*, rcx = loop index. | 261 // Inner loop state: rbx = current FrameDescription*, rcx = loop index. |
262 __ movq(rbx, Operand(rax, 0)); | 262 __ movp(rbx, Operand(rax, 0)); |
263 __ movq(rcx, Operand(rbx, FrameDescription::frame_size_offset())); | 263 __ movp(rcx, Operand(rbx, FrameDescription::frame_size_offset())); |
264 __ jmp(&inner_loop_header); | 264 __ jmp(&inner_loop_header); |
265 __ bind(&inner_push_loop); | 265 __ bind(&inner_push_loop); |
266 __ subq(rcx, Immediate(sizeof(intptr_t))); | 266 __ subq(rcx, Immediate(sizeof(intptr_t))); |
267 __ push(Operand(rbx, rcx, times_1, FrameDescription::frame_content_offset())); | 267 __ push(Operand(rbx, rcx, times_1, FrameDescription::frame_content_offset())); |
268 __ bind(&inner_loop_header); | 268 __ bind(&inner_loop_header); |
269 __ testq(rcx, rcx); | 269 __ testq(rcx, rcx); |
270 __ j(not_zero, &inner_push_loop); | 270 __ j(not_zero, &inner_push_loop); |
271 __ addq(rax, Immediate(kPointerSize)); | 271 __ addq(rax, Immediate(kPointerSize)); |
272 __ bind(&outer_loop_header); | 272 __ bind(&outer_loop_header); |
273 __ cmpq(rax, rdx); | 273 __ cmpq(rax, rdx); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 SetFrameSlot(offset, value); | 334 SetFrameSlot(offset, value); |
335 } | 335 } |
336 | 336 |
337 | 337 |
338 #undef __ | 338 #undef __ |
339 | 339 |
340 | 340 |
341 } } // namespace v8::internal | 341 } } // namespace v8::internal |
342 | 342 |
343 #endif // V8_TARGET_ARCH_X64 | 343 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |