changeset 2951:5b6a9a63a280

Adjust saved SP when safepointing. 2012-05-28 Andrew Haley <aph@redhat.com> * thumb2.cpp (Thumb2_Safepoint): Adjust saved SP when safepointing.
author aph
date Mon, 28 May 2012 08:48:42 -0400
parents f293db049783
children 6a152e87cd76
files src/cpu/zero/vm/thumb2.cpp
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/zero/vm/thumb2.cpp	Mon May 28 08:01:18 2012 -0400
+++ b/src/cpu/zero/vm/thumb2.cpp	Mon May 28 08:48:42 2012 -0400
@@ -4244,6 +4244,15 @@
   //if (offset != 0) {
     Thumb2_save_locals(jinfo, stackdepth);
     //}
+
+  // The frame walking code used by the garbage collector
+  // (frame::interpreter_frame_tos_address()) assumes that the stack
+  // pointer points one word below the top item on the stack, so we
+  // have to adjust the SP saved in istate accordingly.  If we don't,
+  // the value on TOS won't be seen by the GC and we will crash later.
+  sub_imm(jinfo->codebuf, ARM_R0, Rstack, 4);
+  store_istate(jinfo, ARM_R0, ISTATE_STACK, stackdepth);
+
   mov_imm(jinfo->codebuf, ARM_R1, bci+CONSTMETHOD_CODEOFFSET);
   add_imm(jinfo->codebuf, ARM_R2, ISTATE_REG(jinfo),
 	  ISTATE_OFFSET(jinfo, stackdepth, 0));