Revision: 21082
Author:   haitao.f...@intel.com
Date:     Wed Apr 30 09:23:41 2014 UTC
Log:      Introduce DropUnderReturnAddress for x64 port.

R=verwa...@chromium.org

Review URL: https://codereview.chromium.org/242113005
http://code.google.com/p/v8/source/detail?r=21082

Modified:
 /branches/bleeding_edge/src/x64/builtins-x64.cc
 /branches/bleeding_edge/src/x64/macro-assembler-x64.cc
 /branches/bleeding_edge/src/x64/macro-assembler-x64.h

=======================================
--- /branches/bleeding_edge/src/x64/builtins-x64.cc Tue Apr 29 06:42:26 2014 UTC +++ /branches/bleeding_edge/src/x64/builtins-x64.cc Wed Apr 30 09:23:41 2014 UTC
@@ -724,7 +724,7 @@
     // Tear down internal frame.
   }

-  __ Pop(MemOperand(rsp, 0));  // Ignore state offset
+  __ DropUnderReturnAddress(1);  // Ignore state offset
   __ ret(0);  // Return to IC Miss stub, continuation still on stack.
 }

@@ -901,12 +901,13 @@
   __ bind(&shift_arguments);
   { Label loop;
     __ movp(rcx, rax);
+    StackArgumentsAccessor args(rsp, rcx);
     __ bind(&loop);
-    __ movp(rbx, Operand(rsp, rcx, times_pointer_size, 0));
-    __ movp(Operand(rsp, rcx, times_pointer_size, 1 * kPointerSize), rbx);
+    __ movp(rbx, args.GetArgumentOperand(1));
+    __ movp(args.GetArgumentOperand(0), rbx);
     __ decp(rcx);
-    __ j(not_sign, &loop);  // While non-negative (to copy return address).
-    __ popq(rbx);  // Discard copy of return address.
+    __ j(not_zero, &loop);  // While non-zero.
+ __ DropUnderReturnAddress(1, rbx); // Drop one slot under return address.
     __ decp(rax);  // One fewer argument (first argument is new receiver).
   }

=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Wed Apr 30 09:12:18 2014 UTC +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Wed Apr 30 09:23:41 2014 UTC
@@ -2683,6 +2683,20 @@
     addp(rsp, Immediate(stack_elements * kPointerSize));
   }
 }
+
+
+void MacroAssembler::DropUnderReturnAddress(int stack_elements,
+                                            Register scratch) {
+  ASSERT(stack_elements > 0);
+  if (kPointerSize == kInt64Size && stack_elements == 1) {
+    popq(MemOperand(rsp, 0));
+    return;
+  }
+
+  PopReturnAddressTo(scratch);
+  Drop(stack_elements);
+  PushReturnAddressFrom(scratch);
+}


 void MacroAssembler::Push(Register src) {
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.h Wed Apr 30 09:12:18 2014 UTC +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.h Wed Apr 30 09:23:41 2014 UTC
@@ -815,6 +815,11 @@
   // Emit code to discard a non-negative number of pointer-sized elements
   // from the stack, clobbering only the rsp register.
   void Drop(int stack_elements);
+  // Emit code to discard a positive number of pointer-sized elements
+  // from the stack under the return address which remains on the top,
+  // clobbering the rsp register.
+  void DropUnderReturnAddress(int stack_elements,
+                              Register scratch = kScratchRegister);

   void Call(Label* target) { call(target); }
   void Push(Register src);

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to