Make lua_concat() work from C hook with partial frame.

This commit is contained in:
Mike Pall 2012-04-12 12:02:38 +02:00
parent 3ed5172fe4
commit 68ca796d28
2 changed files with 7 additions and 2 deletions

View File

@ -709,7 +709,7 @@ LUA_API void lua_concat(lua_State *L, int n)
if (n >= 2) { if (n >= 2) {
n--; n--;
do { do {
TValue *top = lj_meta_cat(L, L->top-1, n); TValue *top = lj_meta_cat(L, L->top-1, -n);
if (top == NULL) { if (top == NULL) {
L->top -= n; L->top -= n;
break; break;

View File

@ -240,6 +240,8 @@ static LJ_AINLINE int tostring(lua_State *L, TValue *o)
/* Helper for CAT. Coercion, iterative concat, __concat metamethod. */ /* Helper for CAT. Coercion, iterative concat, __concat metamethod. */
TValue *lj_meta_cat(lua_State *L, TValue *top, int left) TValue *lj_meta_cat(lua_State *L, TValue *top, int left)
{ {
int fromc = 0;
if (left < 0) { left = -left; fromc = 1; }
do { do {
int n = 1; int n = 1;
if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) { 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; left -= n;
top -= n; top -= n;
} while (left >= 1); } 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; return NULL;
} }