Fix call unroll checks in the presence of metamethod frames.
[luajit-2.0.git] / src / lj_state.h
blob527f054efab0ca92a50e708b455b1b7488f7308c
1 /*
2 ** State and stack handling.
3 ** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
4 */
6 #ifndef _LJ_STATE_H
7 #define _LJ_STATE_H
9 #include "lj_obj.h"
11 #define incr_top(L) \
12 (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0))
14 #define savestack(L, p) ((char *)(p) - mref(L->stack, char))
15 #define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n)))
17 LJ_FUNC void lj_state_relimitstack(lua_State *L);
18 LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used);
19 LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need);
20 LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L);
22 static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need)
24 if ((mref(L->maxstack, char) - (char *)L->top) <=
25 (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue))
26 lj_state_growstack(L, need);
29 LJ_FUNC lua_State *lj_state_new(lua_State *L);
30 LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L);
31 #if LJ_64
32 LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud);
33 #endif
35 #endif