]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Make lua_concat() work from C hook with partial frame.
authorMike Pall <mike>
Thu, 12 Apr 2012 10:02:38 +0000 (12:02 +0200)
committerMike Pall <mike>
Thu, 12 Apr 2012 10:02:38 +0000 (12:02 +0200)
src/lj_api.c
src/lj_meta.c

index 6c1291645ce69877d3c836439f4d30f46511d712..b807900dd4e39d8936e0323e77c3353699b7ee94 100644 (file)
@@ -709,7 +709,7 @@ LUA_API void lua_concat(lua_State *L, int n)
   if (n >= 2) {
     n--;
     do {
-      TValue *top = lj_meta_cat(L, L->top-1, n);
+      TValue *top = lj_meta_cat(L, L->top-1, -n);
       if (top == NULL) {
        L->top -= n;
        break;
index 4c4bf49d3d2f39877ed8ee3149293923e19e8e92..ab8099e8b0807a443467543ee7143bca4c33659f 100644 (file)
@@ -240,6 +240,8 @@ static LJ_AINLINE int tostring(lua_State *L, TValue *o)
 /* Helper for CAT. Coercion, iterative concat, __concat metamethod. */
 TValue *lj_meta_cat(lua_State *L, TValue *top, int left)
 {
+  int fromc = 0;
+  if (left < 0) { left = -left; fromc = 1; }
   do {
     int n = 1;
     if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) {
@@ -300,7 +302,10 @@ TValue *lj_meta_cat(lua_State *L, TValue *top, int left)
     left -= n;
     top -= n;
   } while (left >= 1);
-  lj_gc_check_fixtop(L);
+  if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) {
+    if (!fromc) L->top = curr_topL(L);
+    lj_gc_step(L);
+  }
   return NULL;
 }