summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2012-01-15 17:05:34 +0100
committerMike Pall <mike>2012-01-15 17:05:34 +0100
commit2f396c6db7c1f0737ebd32c82265befa563b1586 (patch)
treeb53530c3307053468f7404c619d393fbef0ed2f7
parent248cf2ffa9f43e9645c345d58ae2822fd2225979 (diff)
downloadluajit2-2f396c6db7c1f0737ebd32c82265befa563b1586.tar.gz
FFI: Don't touch frame in callbacks with tailcalls to fast functions.
-rw-r--r--src/lj_ccallback.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lj_ccallback.c b/src/lj_ccallback.c
index f3474588..3c95958d 100644
--- a/src/lj_ccallback.c
+++ b/src/lj_ccallback.c
@@ -274,6 +274,7 @@ void lj_ccallback_mcode_free(CTState *cts)
#elif LJ_TARGET_ARM
#define CALLBACK_HANDLE_REGARG \
+ UNUSED(isfp); \
if (n > 1) ngpr = (ngpr + 1u) & ~1u; /* Align to regpair. */ \
if (ngpr + n <= maxgpr) { \
sp = &cts->cb.gpr[ngpr]; \
@@ -455,11 +456,13 @@ void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o)
GCfunc *fn;
TValue *obase = L->base;
L->base = L->top; /* Keep continuation frame for throwing errors. */
- /* PC of RET* is lost. Point to last line for result conv. errors. */
- fn = curr_func(L);
- if (isluafunc(fn)) {
- GCproto *pt = funcproto(fn);
- setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc+1);
+ if (o >= L->base) {
+ /* PC of RET* is lost. Point to last line for result conv. errors. */
+ fn = curr_func(L);
+ if (isluafunc(fn)) {
+ GCproto *pt = funcproto(fn);
+ setcframe_pc(L->cframe, proto_bc(pt)+pt->sizebc+1);
+ }
}
callback_conv_result(cts, L, o);
/* Finally drop C frame and continuation frame. */