diff options
author | Mike Pall <mike> | 2012-04-12 12:02:38 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-04-12 12:02:38 +0200 |
commit | 68ca796d28f616f38a376ed1bb1a3de29d1b1200 (patch) | |
tree | 1bc30d93af980f5cd2b9809ced05d73811cc94ee /src | |
parent | 3ed5172fe49ab9cd08e803c3bec1fc29492e24fe (diff) | |
download | luajit-68ca796d28f616f38a376ed1bb1a3de29d1b1200.tar.gz luajit-68ca796d28f616f38a376ed1bb1a3de29d1b1200.tar.bz2 luajit-68ca796d28f616f38a376ed1bb1a3de29d1b1200.zip |
Make lua_concat() work from C hook with partial frame.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_api.c | 2 | ||||
-rw-r--r-- | src/lj_meta.c | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/lj_api.c b/src/lj_api.c index 6c129164..b807900d 100644 --- a/src/lj_api.c +++ b/src/lj_api.c | |||
@@ -709,7 +709,7 @@ LUA_API void lua_concat(lua_State *L, int n) | |||
709 | if (n >= 2) { | 709 | if (n >= 2) { |
710 | n--; | 710 | n--; |
711 | do { | 711 | do { |
712 | TValue *top = lj_meta_cat(L, L->top-1, n); | 712 | TValue *top = lj_meta_cat(L, L->top-1, -n); |
713 | if (top == NULL) { | 713 | if (top == NULL) { |
714 | L->top -= n; | 714 | L->top -= n; |
715 | break; | 715 | break; |
diff --git a/src/lj_meta.c b/src/lj_meta.c index 4c4bf49d..ab8099e8 100644 --- a/src/lj_meta.c +++ b/src/lj_meta.c | |||
@@ -240,6 +240,8 @@ static LJ_AINLINE int tostring(lua_State *L, TValue *o) | |||
240 | /* Helper for CAT. Coercion, iterative concat, __concat metamethod. */ | 240 | /* Helper for CAT. Coercion, iterative concat, __concat metamethod. */ |
241 | TValue *lj_meta_cat(lua_State *L, TValue *top, int left) | 241 | TValue *lj_meta_cat(lua_State *L, TValue *top, int left) |
242 | { | 242 | { |
243 | int fromc = 0; | ||
244 | if (left < 0) { left = -left; fromc = 1; } | ||
243 | do { | 245 | do { |
244 | int n = 1; | 246 | int n = 1; |
245 | if (!(tvisstr(top-1) || tvisnumber(top-1)) || !tostring(L, top)) { | 247 | 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) | |||
300 | left -= n; | 302 | left -= n; |
301 | top -= n; | 303 | top -= n; |
302 | } while (left >= 1); | 304 | } while (left >= 1); |
303 | lj_gc_check_fixtop(L); | 305 | if (LJ_UNLIKELY(G(L)->gc.total >= G(L)->gc.threshold)) { |
306 | if (!fromc) L->top = curr_topL(L); | ||
307 | lj_gc_step(L); | ||
308 | } | ||
304 | return NULL; | 309 | return NULL; |
305 | } | 310 | } |
306 | 311 | ||