Define CFRAME structure for x64 interpreter.

This commit is contained in:
Mike Pall 2009-12-28 23:45:32 +01:00
parent 61abf342a3
commit 8a9cfa4b45
3 changed files with 35 additions and 14 deletions

View File

@ -264,8 +264,9 @@ void lj_dispatch_ins(lua_State *L, const BCIns *pc, uint32_t nres)
GCproto *pt = funcproto(fn);
BCReg slots = cur_topslot(pt, pc, nres);
global_State *g = G(L);
const BCIns *oldpc = cframe_Lpc(L);
cframe_Lpc(L) = pc;
void *cf = cframe_raw(L->cframe);
const BCIns *oldpc = cframe_pc(cf);
setcframe_pc(cf, pc);
L->top = L->base + slots; /* Fix top. */
#if LJ_HASJIT
{

View File

@ -58,12 +58,28 @@ enum {
/* These definitions must match with the arch-specific *.dasc files. */
#if LJ_TARGET_X86
#define CFRAME_OFS_ERRF (15*sizeof(void *))
#define CFRAME_OFS_NRES (14*sizeof(void *))
#define CFRAME_OFS_PREV (13*sizeof(void *))
#define CFRAME_OFS_L (12*sizeof(void *))
#define CFRAME_OFS_PC (6*sizeof(void *))
#define CFRAME_SIZE (12*sizeof(void *))
#define CFRAME_OFS_ERRF (15*4)
#define CFRAME_OFS_NRES (14*4)
#define CFRAME_OFS_PREV (13*4)
#define CFRAME_OFS_L (12*4)
#define CFRAME_OFS_PC (6*4)
#define CFRAME_SIZE (12*4)
#elif LJ_TARGET_X64
#if _WIN64
#define CFRAME_OFS_ERRF (23*4)
#define CFRAME_OFS_NRES (22*4)
#define CFRAME_OFS_PREV (13*8)
#define CFRAME_OFS_L (24*4)
#define CFRAME_OFS_PC (25*4)
#define CFRAME_SIZE (10*8)
#else
#define CFRAME_OFS_ERRF (3*4)
#define CFRAME_OFS_NRES (2*4)
#define CFRAME_OFS_PREV (4*8)
#define CFRAME_OFS_L (4*4)
#define CFRAME_OFS_PC (5*4)
#define CFRAME_SIZE (10*8)
#endif
#else
#error "Missing CFRAME_* definitions for this architecture"
#endif
@ -72,11 +88,15 @@ enum {
#define CFRAME_CANYIELD ((intptr_t)(CFRAME_RESUME))
#define CFRAME_RAWMASK (~CFRAME_CANYIELD)
#define cframe_errfunc(cf) (*(ptrdiff_t *)(((char *)cf)+CFRAME_OFS_ERRF))
#define cframe_nres(cf) (*(ptrdiff_t *)(((char *)cf)+CFRAME_OFS_NRES))
#define cframe_prev(cf) (*(void **)(((char *)cf)+CFRAME_OFS_PREV))
#define cframe_L(cf) (*(lua_State **)(((char *)cf)+CFRAME_OFS_L))
#define cframe_pc(cf) (*(const BCIns **)(((char *)cf)+CFRAME_OFS_PC))
#define cframe_errfunc(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_ERRF))
#define cframe_nres(cf) (*(int32_t *)(((char *)(cf))+CFRAME_OFS_NRES))
#define cframe_prev(cf) (*(void **)(((char *)(cf))+CFRAME_OFS_PREV))
#define cframe_L(cf) \
(&gcref(*(GCRef *)(((char *)(cf))+CFRAME_OFS_L))->th)
#define cframe_pc(cf) \
(mref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), const BCIns))
#define setcframe_pc(cf, pc) \
(setmref(*(MRef *)(((char *)(cf))+CFRAME_OFS_PC), (pc)))
#define cframe_canyield(cf) ((intptr_t)(cf) & CFRAME_CANYIELD)
#define cframe_raw(cf) ((void *)((intptr_t)(cf) & CFRAME_RAWMASK))
#define cframe_Lpc(L) cframe_pc(cframe_raw(L->cframe))

View File

@ -572,7 +572,7 @@ void * LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr)
/* Restore interpreter state. */
lj_snap_restore(J, exptr);
cf = cframe_raw(L->cframe);
cframe_pc(cf) = J->pc;
setcframe_pc(cf, J->pc);
lj_vmevent_send(L, TEXIT,
ExitState *ex = (ExitState *)exptr;