Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: src/x64/deoptimizer-x64.cc

Issue 199903002: Introduce Push and Pop macro instructions for x64 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased with bleeding_edge Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/debug-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { 172 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) {
173 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); 173 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i);
174 int offset = i * kDoubleSize; 174 int offset = i * kDoubleSize;
175 __ movsd(Operand(rsp, offset), xmm_reg); 175 __ movsd(Operand(rsp, offset), xmm_reg);
176 } 176 }
177 177
178 // We push all registers onto the stack, even though we do not need 178 // We push all registers onto the stack, even though we do not need
179 // to restore all later. 179 // to restore all later.
180 for (int i = 0; i < kNumberOfRegisters; i++) { 180 for (int i = 0; i < kNumberOfRegisters; i++) {
181 Register r = Register::from_code(i); 181 Register r = Register::from_code(i);
182 __ push(r); 182 __ pushq(r);
183 } 183 }
184 184
185 const int kSavedRegistersAreaSize = kNumberOfRegisters * kRegisterSize + 185 const int kSavedRegistersAreaSize = kNumberOfRegisters * kRegisterSize +
186 kDoubleRegsSize; 186 kDoubleRegsSize;
187 187
188 // We use this to keep the value of the fifth argument temporarily. 188 // We use this to keep the value of the fifth argument temporarily.
189 // Unfortunately we can't store it directly in r8 (used for passing 189 // Unfortunately we can't store it directly in r8 (used for passing
190 // this on linux), since it is another parameter passing register on windows. 190 // this on linux), since it is another parameter passing register on windows.
191 Register arg5 = r11; 191 Register arg5 = r11;
192 192
(...skipping 30 matching lines...) Expand all
223 { AllowExternalCallThatCantCauseGC scope(masm()); 223 { AllowExternalCallThatCantCauseGC scope(masm());
224 __ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6); 224 __ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6);
225 } 225 }
226 // Preserve deoptimizer object in register rax and get the input 226 // Preserve deoptimizer object in register rax and get the input
227 // frame descriptor pointer. 227 // frame descriptor pointer.
228 __ movp(rbx, Operand(rax, Deoptimizer::input_offset())); 228 __ movp(rbx, Operand(rax, Deoptimizer::input_offset()));
229 229
230 // Fill in the input registers. 230 // Fill in the input registers.
231 for (int i = kNumberOfRegisters -1; i >= 0; i--) { 231 for (int i = kNumberOfRegisters -1; i >= 0; i--) {
232 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); 232 int offset = (i * kPointerSize) + FrameDescription::registers_offset();
233 __ pop(Operand(rbx, offset)); 233 __ Pop(Operand(rbx, offset));
234 } 234 }
235 235
236 // Fill in the double input registers. 236 // Fill in the double input registers.
237 int double_regs_offset = FrameDescription::double_registers_offset(); 237 int double_regs_offset = FrameDescription::double_registers_offset();
238 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { 238 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) {
239 int dst_offset = i * kDoubleSize + double_regs_offset; 239 int dst_offset = i * kDoubleSize + double_regs_offset;
240 __ pop(Operand(rbx, dst_offset)); 240 __ popq(Operand(rbx, dst_offset));
241 } 241 }
242 242
243 // Remove the bailout id and return address from the stack. 243 // Remove the bailout id and return address from the stack.
244 __ addq(rsp, Immediate(1 * kRegisterSize + kPCOnStackSize)); 244 __ addq(rsp, Immediate(1 * kRegisterSize + kPCOnStackSize));
245 245
246 // Compute a pointer to the unwinding limit in register rcx; that is 246 // Compute a pointer to the unwinding limit in register rcx; that is
247 // the first stack slot not part of the input frame. 247 // the first stack slot not part of the input frame.
248 __ movp(rcx, Operand(rbx, FrameDescription::frame_size_offset())); 248 __ movp(rcx, Operand(rbx, FrameDescription::frame_size_offset()));
249 __ addq(rcx, rsp); 249 __ addq(rcx, rsp);
250 250
251 // Unwind the stack down to - but not including - the unwinding 251 // Unwind the stack down to - but not including - the unwinding
252 // limit and copy the contents of the activation frame to the input 252 // limit and copy the contents of the activation frame to the input
253 // frame description. 253 // frame description.
254 __ lea(rdx, Operand(rbx, FrameDescription::frame_content_offset())); 254 __ lea(rdx, Operand(rbx, FrameDescription::frame_content_offset()));
255 Label pop_loop_header; 255 Label pop_loop_header;
256 __ jmp(&pop_loop_header); 256 __ jmp(&pop_loop_header);
257 Label pop_loop; 257 Label pop_loop;
258 __ bind(&pop_loop); 258 __ bind(&pop_loop);
259 __ pop(Operand(rdx, 0)); 259 __ Pop(Operand(rdx, 0));
260 __ addq(rdx, Immediate(sizeof(intptr_t))); 260 __ addq(rdx, Immediate(sizeof(intptr_t)));
261 __ bind(&pop_loop_header); 261 __ bind(&pop_loop_header);
262 __ cmpq(rcx, rsp); 262 __ cmpq(rcx, rsp);
263 __ j(not_equal, &pop_loop); 263 __ j(not_equal, &pop_loop);
264 264
265 // Compute the output frame in the deoptimizer. 265 // Compute the output frame in the deoptimizer.
266 __ push(rax); 266 __ pushq(rax);
267 __ PrepareCallCFunction(2); 267 __ PrepareCallCFunction(2);
268 __ movp(arg_reg_1, rax); 268 __ movp(arg_reg_1, rax);
269 __ LoadAddress(arg_reg_2, ExternalReference::isolate_address(isolate())); 269 __ LoadAddress(arg_reg_2, ExternalReference::isolate_address(isolate()));
270 { 270 {
271 AllowExternalCallThatCantCauseGC scope(masm()); 271 AllowExternalCallThatCantCauseGC scope(masm());
272 __ CallCFunction( 272 __ CallCFunction(
273 ExternalReference::compute_output_frames_function(isolate()), 2); 273 ExternalReference::compute_output_frames_function(isolate()), 2);
274 } 274 }
275 __ pop(rax); 275 __ popq(rax);
276 276
277 // Replace the current frame with the output frames. 277 // Replace the current frame with the output frames.
278 Label outer_push_loop, inner_push_loop, 278 Label outer_push_loop, inner_push_loop,
279 outer_loop_header, inner_loop_header; 279 outer_loop_header, inner_loop_header;
280 // Outer loop state: rax = current FrameDescription**, rdx = one past the 280 // Outer loop state: rax = current FrameDescription**, rdx = one past the
281 // last FrameDescription**. 281 // last FrameDescription**.
282 __ movl(rdx, Operand(rax, Deoptimizer::output_count_offset())); 282 __ movl(rdx, Operand(rax, Deoptimizer::output_count_offset()));
283 __ movp(rax, Operand(rax, Deoptimizer::output_offset())); 283 __ movp(rax, Operand(rax, Deoptimizer::output_offset()));
284 __ lea(rdx, Operand(rax, rdx, times_pointer_size, 0)); 284 __ lea(rdx, Operand(rax, rdx, times_pointer_size, 0));
285 __ jmp(&outer_loop_header); 285 __ jmp(&outer_loop_header);
286 __ bind(&outer_push_loop); 286 __ bind(&outer_push_loop);
287 // Inner loop state: rbx = current FrameDescription*, rcx = loop index. 287 // Inner loop state: rbx = current FrameDescription*, rcx = loop index.
288 __ movp(rbx, Operand(rax, 0)); 288 __ movp(rbx, Operand(rax, 0));
289 __ movp(rcx, Operand(rbx, FrameDescription::frame_size_offset())); 289 __ movp(rcx, Operand(rbx, FrameDescription::frame_size_offset()));
290 __ jmp(&inner_loop_header); 290 __ jmp(&inner_loop_header);
291 __ bind(&inner_push_loop); 291 __ bind(&inner_push_loop);
292 __ subq(rcx, Immediate(sizeof(intptr_t))); 292 __ subq(rcx, Immediate(sizeof(intptr_t)));
293 __ push(Operand(rbx, rcx, times_1, FrameDescription::frame_content_offset())); 293 __ Push(Operand(rbx, rcx, times_1, FrameDescription::frame_content_offset()));
294 __ bind(&inner_loop_header); 294 __ bind(&inner_loop_header);
295 __ testq(rcx, rcx); 295 __ testq(rcx, rcx);
296 __ j(not_zero, &inner_push_loop); 296 __ j(not_zero, &inner_push_loop);
297 __ addq(rax, Immediate(kPointerSize)); 297 __ addq(rax, Immediate(kPointerSize));
298 __ bind(&outer_loop_header); 298 __ bind(&outer_loop_header);
299 __ cmpq(rax, rdx); 299 __ cmpq(rax, rdx);
300 __ j(below, &outer_push_loop); 300 __ j(below, &outer_push_loop);
301 301
302 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) { 302 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); ++i) {
303 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); 303 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i);
304 int src_offset = i * kDoubleSize + double_regs_offset; 304 int src_offset = i * kDoubleSize + double_regs_offset;
305 __ movsd(xmm_reg, Operand(rbx, src_offset)); 305 __ movsd(xmm_reg, Operand(rbx, src_offset));
306 } 306 }
307 307
308 // Push state, pc, and continuation from the last output frame. 308 // Push state, pc, and continuation from the last output frame.
309 __ push(Operand(rbx, FrameDescription::state_offset())); 309 __ Push(Operand(rbx, FrameDescription::state_offset()));
310 __ push(Operand(rbx, FrameDescription::pc_offset())); 310 __ Push(Operand(rbx, FrameDescription::pc_offset()));
311 __ push(Operand(rbx, FrameDescription::continuation_offset())); 311 __ Push(Operand(rbx, FrameDescription::continuation_offset()));
312 312
313 // Push the registers from the last output frame. 313 // Push the registers from the last output frame.
314 for (int i = 0; i < kNumberOfRegisters; i++) { 314 for (int i = 0; i < kNumberOfRegisters; i++) {
315 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); 315 int offset = (i * kPointerSize) + FrameDescription::registers_offset();
316 __ push(Operand(rbx, offset)); 316 __ Push(Operand(rbx, offset));
317 } 317 }
318 318
319 // Restore the registers from the stack. 319 // Restore the registers from the stack.
320 for (int i = kNumberOfRegisters - 1; i >= 0 ; i--) { 320 for (int i = kNumberOfRegisters - 1; i >= 0 ; i--) {
321 Register r = Register::from_code(i); 321 Register r = Register::from_code(i);
322 // Do not restore rsp, simply pop the value into the next register 322 // Do not restore rsp, simply pop the value into the next register
323 // and overwrite this afterwards. 323 // and overwrite this afterwards.
324 if (r.is(rsp)) { 324 if (r.is(rsp)) {
325 ASSERT(i > 0); 325 ASSERT(i > 0);
326 r = Register::from_code(i - 1); 326 r = Register::from_code(i - 1);
327 } 327 }
328 __ pop(r); 328 __ popq(r);
329 } 329 }
330 330
331 // Set up the roots register. 331 // Set up the roots register.
332 __ InitializeRootRegister(); 332 __ InitializeRootRegister();
333 __ InitializeSmiConstantRegister(); 333 __ InitializeSmiConstantRegister();
334 334
335 // Return to the continuation point. 335 // Return to the continuation point.
336 __ ret(0); 336 __ ret(0);
337 } 337 }
338 338
339 339
340 void Deoptimizer::TableEntryGenerator::GeneratePrologue() { 340 void Deoptimizer::TableEntryGenerator::GeneratePrologue() {
341 // Create a sequence of deoptimization entries. 341 // Create a sequence of deoptimization entries.
342 Label done; 342 Label done;
343 for (int i = 0; i < count(); i++) { 343 for (int i = 0; i < count(); i++) {
344 int start = masm()->pc_offset(); 344 int start = masm()->pc_offset();
345 USE(start); 345 USE(start);
346 __ push_imm32(i); 346 __ pushq_imm32(i);
347 __ jmp(&done); 347 __ jmp(&done);
348 ASSERT(masm()->pc_offset() - start == table_entry_size_); 348 ASSERT(masm()->pc_offset() - start == table_entry_size_);
349 } 349 }
350 __ bind(&done); 350 __ bind(&done);
351 } 351 }
352 352
353 353
354 void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { 354 void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) {
355 SetFrameSlot(offset, value); 355 SetFrameSlot(offset, value);
356 } 356 }
357 357
358 358
359 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { 359 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) {
360 SetFrameSlot(offset, value); 360 SetFrameSlot(offset, value);
361 } 361 }
362 362
363 363
364 void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { 364 void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) {
365 // No out-of-line constant pool support. 365 // No out-of-line constant pool support.
366 UNREACHABLE(); 366 UNREACHABLE();
367 } 367 }
368 368
369 369
370 #undef __ 370 #undef __
371 371
372 372
373 } } // namespace v8::internal 373 } } // namespace v8::internal
374 374
375 #endif // V8_TARGET_ARCH_X64 375 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/debug-x64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698