Author: [EMAIL PROTECTED]
Date: Mon Nov 17 09:44:16 2008
New Revision: 774

Modified:
    branches/bleeding_edge/src/builtins-arm.cc
    branches/bleeding_edge/src/runtime.cc
    branches/bleeding_edge/src/top.h

Log:
Some debugging support fixes on ARM simulator port.

1) Let SaveContext remember the top JS frame stack pointer so it works in  
simulator where C stack and JS stack are separated;
2) Use the new calling convension in %DebugBreakCallHelper function;

Review URL: http://codereview.chromium.org/10663

Modified: branches/bleeding_edge/src/builtins-arm.cc
==============================================================================
--- branches/bleeding_edge/src/builtins-arm.cc  (original)
+++ branches/bleeding_edge/src/builtins-arm.cc  Mon Nov 17 09:44:16 2008
@@ -663,36 +663,7 @@
    // they will have the correct value when returning from the debugger.
    __ SaveRegistersToMemory(kJSCallerSaved);

-  // This is a direct call from a debug breakpoint. To build a fake JS  
frame
-  // with no parameters push a function and a receiver, keep the current
-  // return address in lr, and set r0 to zero.
-  __ mov(ip, Operand(ExternalReference::the_hole_value_location()));
-  __ ldr(r3, MemOperand(ip));
-  __ mov(r0, Operand(0));  // Null receiver and zero arguments.
-  __ stm(db_w, sp, r0.bit() | r3.bit());  // push function and receiver
-
-  // r0: number of arguments.
-  // What follows is an inlined version of EnterJSFrame(0, 0).
-  // It needs to be kept in sync if any calling conventions are changed.
-
-  // Compute parameter pointer before making changes
-  // ip = sp + kPointerSize*(args_len+1);  // +1 for receiver, args_len ==  
0
-  __ add(ip, sp, Operand(kPointerSize));
-
-  __ mov(r3, Operand(0));  // args_len to be saved
-  __ mov(r2, Operand(cp));  // context to be saved
-
-  // push in reverse order: context (r2), args_len (r3), caller_pp,  
caller_fp,
-  // sp_on_exit (ip == pp), return address
-  __ stm(db_w, sp, r2.bit() | r3.bit() | pp.bit() | fp.bit() |
-         ip.bit() | lr.bit());
-  // Setup new frame pointer.
-  __ add(fp, sp, Operand(-StandardFrameConstants::kContextOffset));
-  __ mov(pp, Operand(ip));  // setup new parameter pointer
-  // r0 is already set to 0 as spare slot to store caller code object  
during GC
-  __ push(r0);  // code pointer
-
-  // Inlined EnterJSFrame ends here.
+  __ EnterInternalFrame();

    // Store the registers containing object pointers on the expression  
stack to
    // make sure that these are correctly updated during GC.
@@ -702,7 +673,7 @@
  #ifdef DEBUG
    __ RecordComment("// Calling from debug break to runtime - come in -  
over");
  #endif
-  // r0 is already 0, no arguments
+  __ mov(r0, Operand(0));  // no arguments
    __ mov(r1, Operand(ExternalReference::debug_break()));

    CEntryDebugBreakStub ceb;
@@ -713,14 +684,7 @@
    // Use sp as base to pop.
    __ CopyRegistersFromStackToMemory(sp, r3, pointer_regs);

-  // What follows is an inlined version of ExitJSFrame(0).
-  // It needs to be kept in sync if any calling conventions are changed.
-  // NOTE: loading the return address to lr and discarding the (fake)  
function
-  //       is an addition to this inlined copy.
-
-  __ mov(sp, Operand(fp));  // respect ABI stack constraint
-  __ ldm(ia, sp, pp.bit() | fp.bit() | sp.bit() | lr.bit());
-  __ pop();  // discard fake function
+  __ LeaveInternalFrame();

    // Inlined ExitJSFrame ends here.


Modified: branches/bleeding_edge/src/runtime.cc
==============================================================================
--- branches/bleeding_edge/src/runtime.cc       (original)
+++ branches/bleeding_edge/src/runtime.cc       Mon Nov 17 09:44:16 2008
@@ -4797,9 +4797,10 @@
    // Traverse the saved contexts chain to find the active context for the
    // selected frame.
    SaveContext* save = Top::save_context();
-  while (save != NULL && reinterpret_cast<Address>(save) <  
it.frame()->sp()) {
+  while (save != NULL && !save->below(it.frame())) {
      save = save->prev();
    }
+  ASSERT(save != NULL);

    // Get the frame id.
    Handle<Object> frame_id(WrapFrameId(it.frame()->id()));
@@ -5299,7 +5300,7 @@
    // Traverse the saved contexts chain to find the active context for the
    // selected frame.
    SaveContext* save = Top::save_context();
-  while (save != NULL && reinterpret_cast<Address>(save) < frame->sp()) {
+  while (save != NULL && !save->below(frame)) {
      save = save->prev();
    }
    ASSERT(save != NULL);

Modified: branches/bleeding_edge/src/top.h
==============================================================================
--- branches/bleeding_edge/src/top.h    (original)
+++ branches/bleeding_edge/src/top.h    Mon Nov 17 09:44:16 2008
@@ -312,6 +312,10 @@
  #endif
        prev_(Top::save_context()) {
      Top::set_save_context(this);
+
+    // If there is no JS frame under the current C frame, use the value 0.
+    JavaScriptFrameIterator it;
+    js_sp_ = it.done() ? 0 : it.frame()->sp();
    }

    ~SaveContext() {
@@ -322,12 +326,18 @@
    Handle<Context> context() { return context_; }
    SaveContext* prev() { return prev_; }

+  // Returns true if this save context is below a given JavaScript frame.
+  bool below(JavaScriptFrame* frame) {
+    return (js_sp_ == 0) || (frame->sp() < js_sp_);
+  }
+
   private:
    Handle<Context> context_;
  #if __GNUC_VERSION__ >= 40100 && __GNUC_VERSION__ < 40300
    Handle<Context> dummy_;
  #endif
    SaveContext* prev_;
+  Address js_sp_;  // The top JS frame's sp when saving context.
  };



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

Reply via email to