summaryrefslogtreecommitdiff
path: root/src/lj_api.c
diff options
context:
space:
mode:
authorMike Pall <mike>2012-10-09 13:19:57 +0200
committerMike Pall <mike>2012-10-09 13:19:57 +0200
commiteabfdfe1aa3b4b9c37b99137e6d5fb7cadbd47e9 (patch)
treeb7cf8922d69daedd5d5733214a77439c8986f570 /src/lj_api.c
parentda682b0e9184d4db7e8e477c682947d106790240 (diff)
downloadluajit2-eabfdfe1aa3b4b9c37b99137e6d5fb7cadbd47e9.tar.gz
Don't use stack unwinding for lua_yield().
Diffstat (limited to 'src/lj_api.c')
-rw-r--r--src/lj_api.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index 5a0bd07a..8d35e0d0 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -1103,6 +1103,9 @@ LUA_API int lua_yield(lua_State *L, int nresults)
while (--nresults >= 0) copyTV(L, t++, f++);
L->top = t;
}
+ L->cframe = NULL;
+ L->status = LUA_YIELD;
+ return -1;
} else { /* Yield from hook: add a pseudo-frame. */
TValue *top = L->top;
hook_leave(g);
@@ -1112,14 +1115,14 @@ LUA_API int lua_yield(lua_State *L, int nresults)
setframe_gc(top+2, obj2gco(L));
setframe_ftsz(top+2, (int)((char *)(top+3)-(char *)L->base)+FRAME_CONT);
L->top = L->base = top+3;
- }
#if LJ_TARGET_X64
- lj_err_throw(L, LUA_YIELD);
+ lj_err_throw(L, LUA_YIELD);
#else
- L->cframe = NULL;
- L->status = LUA_YIELD;
- lj_vm_unwind_c(cf, LUA_YIELD);
+ L->cframe = NULL;
+ L->status = LUA_YIELD;
+ lj_vm_unwind_c(cf, LUA_YIELD);
#endif
+ }
}
lj_err_msg(L, LJ_ERR_CYIELD);
return 0; /* unreachable */