]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
PPC: Handle stack growth on return to C.
authorMike Pall <mike>
Tue, 31 Aug 2010 22:25:35 +0000 (00:25 +0200)
committerMike Pall <mike>
Tue, 31 Aug 2010 22:25:35 +0000 (00:25 +0200)
src/buildvm_ppc.dasc

index 7e8178cd5215f63988312378bcb483d3e469c296..d016ec47d5f9b7136f773e9489a1e6ca7e4c9599 100644 (file)
@@ -329,7 +329,20 @@ static void build_subroutines(BuildCtx *ctx)
   |  b <3
   |
   |8:  // Corner case: need to grow stack for filling up results.
-  |  NYI
+  |  // This can happen if:
+  |  // - A C function grows the stack (a lot).
+  |  // - The GC shrinks the stack in between.
+  |  // - A return back from a lua_call() with (high) nresults adjustment.
+  |  stw BASE, L->top                  // Save current top held in BASE (yes).
+  |   mr SAVE0, RD
+  |  mr CARG2, TMP2
+  |  mr CARG1, L
+  |  bl extern lj_state_growstack      // (lua_State *L, int n)
+  |    lwz TMP2, SAVE_NRES
+  |   mr RD, SAVE0
+  |    slwi TMP2, TMP2, 3
+  |  lwz BASE, L->top                  // Need the (realloced) L->top in BASE.
+  |  b <2
   |
   |->vm_unwind_c:                      // Unwind C stack, return from vm_pcall.
   |  NYI