Revision: 5264
Author: [email protected]
Date: Fri Aug 13 06:54:28 2010
Log: LiveEdit: implement stack manipulations for x64

Review URL: http://codereview.chromium.org/3120011
http://code.google.com/p/v8/source/detail?r=5264

Modified:
 /branches/bleeding_edge/src/arm/debug-arm.cc
 /branches/bleeding_edge/src/debug.cc
 /branches/bleeding_edge/src/debug.h
 /branches/bleeding_edge/src/ia32/debug-ia32.cc
 /branches/bleeding_edge/src/liveedit.cc
 /branches/bleeding_edge/src/mips/debug-mips.cc
 /branches/bleeding_edge/src/x64/debug-x64.cc
 /branches/bleeding_edge/test/mjsunit/mjsunit.status

=======================================
--- /branches/bleeding_edge/src/arm/debug-arm.cc        Fri Jul 30 04:58:43 2010
+++ /branches/bleeding_edge/src/arm/debug-arm.cc        Fri Aug 13 06:54:28 2010
@@ -292,16 +292,12 @@
 void Debug::GenerateFrameDropperLiveEdit(MacroAssembler* masm) {
   masm->Abort("LiveEdit frame dropping is not supported on arm");
 }
+
+const bool Debug::kFrameDropperSupported = false;

 #undef __


-Object** Debug::SetUpFrameDropperFrame(StackFrame* bottom_js_frame,
-                                       Handle<Code> code) {
-  UNREACHABLE();
-  return NULL;
-}
-const int Debug::kFrameDropperFrameSize = -1;

 #endif  // ENABLE_DEBUGGER_SUPPORT

=======================================
--- /branches/bleeding_edge/src/debug.cc        Wed Aug 11 03:52:34 2010
+++ /branches/bleeding_edge/src/debug.cc        Fri Aug 13 06:54:28 2010
@@ -580,6 +580,35 @@
 int Debug::ArchiveSpacePerThread() {
   return sizeof(ThreadLocal) + sizeof(registers_);
 }
+
+
+// Frame structure (conforms InternalFrame structure):
+//   -- code
+//   -- SMI maker
+//   -- function (slot is called "context")
+//   -- frame base
+Object** Debug::SetUpFrameDropperFrame(StackFrame* bottom_js_frame,
+                                       Handle<Code> code) {
+  ASSERT(bottom_js_frame->is_java_script());
+
+  Address fp = bottom_js_frame->fp();
+
+  // Move function pointer into "context" slot.
+  Memory::Object_at(fp + StandardFrameConstants::kContextOffset) =
+      Memory::Object_at(fp + JavaScriptFrameConstants::kFunctionOffset);
+
+  Memory::Object_at(fp + InternalFrameConstants::kCodeOffset) = *code;
+  Memory::Object_at(fp + StandardFrameConstants::kMarkerOffset) =
+      Smi::FromInt(StackFrame::INTERNAL);
+
+  return reinterpret_cast<Object**>(&Memory::Object_at(
+      fp + StandardFrameConstants::kContextOffset));
+}
+
+const int Debug::kFrameDropperFrameSize = 4;
+
+
+


 // Default break enabled.
=======================================
--- /branches/bleeding_edge/src/debug.h Fri Jul 30 04:58:43 2010
+++ /branches/bleeding_edge/src/debug.h Fri Aug 13 06:54:28 2010
@@ -400,6 +400,11 @@
   static void GenerateStubNoRegistersDebugBreak(MacroAssembler* masm);
   static void GenerateSlotDebugBreak(MacroAssembler* masm);
   static void GeneratePlainReturnLiveEdit(MacroAssembler* masm);
+
+ // FrameDropper is a code replacement for a JavaScript frame with possibly
+  // several frames above.
+  // There is no calling conventions here, because it never actually gets
+  // called, it only gets returned to.
   static void GenerateFrameDropperLiveEdit(MacroAssembler* masm);

   // Called from stub-cache.cc.
@@ -431,13 +436,14 @@
   // the value that is called 'restarter_frame_function_pointer'. The value
// at this address (possibly updated by GC) may be used later when preparing
   // 'step in' operation.
-  // The implementation is architecture-specific.
-  // TODO(LiveEdit): consider reviewing it as architecture-independent.
   static Object** SetUpFrameDropperFrame(StackFrame* bottom_js_frame,
                                          Handle<Code> code);

   static const int kFrameDropperFrameSize;

+  // Architecture-specific constant.
+  static const bool kFrameDropperSupported;
+
  private:
   static bool CompileDebuggerScript(int index);
   static void ClearOneShot();
=======================================
--- /branches/bleeding_edge/src/ia32/debug-ia32.cc      Thu Aug 12 10:27:07 2010
+++ /branches/bleeding_edge/src/ia32/debug-ia32.cc      Fri Aug 13 06:54:28 2010
@@ -254,15 +254,6 @@
 }


-// FrameDropper is a code replacement for a JavaScript frame with possibly
-// several frames above.
-// There is no calling conventions here, because it never actually gets called,
-// it only gets returned to.
-// Frame structure (conforms InternalFrame structure):
-//   -- code
-//   -- SMI maker
-//   -- function (slot is called "context")
-//   -- frame base
 void Debug::GenerateFrameDropperLiveEdit(MacroAssembler* masm) {
   ExternalReference restarter_frame_function_slot =
       ExternalReference(Debug_Address::RestarterFrameFunctionPointer());
@@ -286,30 +277,9 @@
   __ jmp(Operand(edx));
 }

-#undef __
-
-
-// TODO(LiveEdit): consider making it platform-independent.
-// TODO(LiveEdit): use more named constants instead of numbers.
-Object** Debug::SetUpFrameDropperFrame(StackFrame* bottom_js_frame,
-                                       Handle<Code> code) {
-  ASSERT(bottom_js_frame->is_java_script());
-
-  Address fp = bottom_js_frame->fp();
-
-  // Move function pointer into slot that is called referenced
-  // as StandardFrame::context()
-  Memory::Object_at(fp - 1 * kPointerSize) =
-      Memory::Object_at(fp - 2 * kPointerSize);
-
-  Memory::Object_at(fp - 3 * kPointerSize) = *code;
- Memory::Object_at(fp - 2 * kPointerSize) = Smi::FromInt(StackFrame::INTERNAL);
-
- return reinterpret_cast<Object**>(&Memory::Object_at(fp - 1 * kPointerSize));
-}
-
-const int Debug::kFrameDropperFrameSize = 4;
-
+const bool Debug::kFrameDropperSupported = true;
+
+#undef __

 #endif  // ENABLE_DEBUGGER_SUPPORT

=======================================
--- /branches/bleeding_edge/src/liveedit.cc     Thu Aug 12 09:01:56 2010
+++ /branches/bleeding_edge/src/liveedit.cc     Fri Aug 13 06:54:28 2010
@@ -1206,7 +1206,7 @@
                               int bottom_js_frame_index,
                               Debug::FrameDropMode* mode,
                               Object*** restarter_frame_function_pointer) {
-  if (Debug::kFrameDropperFrameSize < 0) {
+  if (!Debug::kFrameDropperSupported) {
     return "Stack manipulations are not supported in this architecture.";
   }

=======================================
--- /branches/bleeding_edge/src/mips/debug-mips.cc      Fri Jul 30 04:58:43 2010
+++ /branches/bleeding_edge/src/mips/debug-mips.cc      Fri Aug 13 06:54:28 2010
@@ -114,15 +114,10 @@
   masm->Abort("LiveEdit frame dropping is not supported on mips");
 }

-#undef __
-
-
-Object** Debug::SetUpFrameDropperFrame(StackFrame* bottom_js_frame,
-                                       Handle<Code> code) {
-  UNREACHABLE();
-  return NULL;
-}
-const int Debug::kFrameDropperFrameSize = -1;
+
+const bool Debug::kFrameDropperSupported = false;
+
+#undef __


 #endif  // ENABLE_DEBUGGER_SUPPORT
=======================================
--- /branches/bleeding_edge/src/x64/debug-x64.cc        Fri Jul 30 04:58:43 2010
+++ /branches/bleeding_edge/src/x64/debug-x64.cc        Fri Aug 13 06:54:28 2010
@@ -202,23 +202,39 @@


 void Debug::GeneratePlainReturnLiveEdit(MacroAssembler* masm) {
-  masm->Abort("LiveEdit frame dropping is not supported on x64");
+  masm->ret(0);
 }


 void Debug::GenerateFrameDropperLiveEdit(MacroAssembler* masm) {
-  masm->Abort("LiveEdit frame dropping is not supported on x64");
-}
+  ExternalReference restarter_frame_function_slot =
+      ExternalReference(Debug_Address::RestarterFrameFunctionPointer());
+  __ movq(rax, restarter_frame_function_slot);
+  __ movq(Operand(rax, 0), Immediate(0));
+
+  // We do not know our frame height, but set rsp based on rbp.
+  __ lea(rsp, Operand(rbp, -1 * kPointerSize));
+
+  __ pop(rdi);  // Function.
+  __ pop(rbp);
+
+  // Load context from the function.
+  __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
+
+  // Get function code.
+  __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
+  __ movq(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset));
+  __ lea(rdx, FieldOperand(rdx, Code::kHeaderSize));
+
+  // Re-run JSFunction, rdi is function, rsi is context.
+  __ jmp(rdx);
+}
+
+const bool Debug::kFrameDropperSupported = true;

 #undef __


-Object** Debug::SetUpFrameDropperFrame(StackFrame* bottom_js_frame,
-                                       Handle<Code> code) {
-  UNREACHABLE();
-  return NULL;
-}
-const int Debug::kFrameDropperFrameSize = -1;


 void BreakLocationIterator::ClearDebugBreakAtReturn() {
=======================================
--- /branches/bleeding_edge/test/mjsunit/mjsunit.status Tue Jun 22 15:20:58 2010 +++ /branches/bleeding_edge/test/mjsunit/mjsunit.status Fri Aug 13 06:54:28 2010
@@ -72,8 +72,4 @@
 # Skip all tests on MIPS.
 *: SKIP

-[ $arch == x64 ]
-# Stack manipulations in LiveEdit is implemented for ia32 only.
-debug-liveedit-check-stack: SKIP
-
-
+

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to