mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Replace GCproto reference with bytecode PC in GCfuncL.
This commit is contained in:
parent
d5a46621f9
commit
bb0384c366
@ -305,6 +305,8 @@
|
||||
#define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field))
|
||||
#define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field))
|
||||
|
|
||||
#define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto))
|
||||
|
|
||||
|// Decrement hashed hotcount and trigger trace recorder if zero.
|
||||
|.macro hotloop, reg
|
||||
| mov reg, PC
|
||||
@ -406,11 +408,10 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| // RA = new base, RB = LFUNC, RC = nargs+1, (BASE = old base), PC = return
|
||||
| // DISPATCH initialized
|
||||
| mov BASE, RA
|
||||
| mov PROTO:RB, LFUNC:RB->pt
|
||||
| mov [BASE-4], PC // Store caller PC.
|
||||
| movzx RA, byte PROTO:RB->framesize
|
||||
| lea PC, [PROTO:RB+sizeof(GCproto)]
|
||||
| mov KBASE, PROTO:RB->k
|
||||
| mov PC, LFUNC:RB->pc
|
||||
| movzx RA, byte [PC+PC2PROTO(framesize)]
|
||||
| mov KBASE, [PC+PC2PROTO(k)]
|
||||
| mov L:RB, SAVE_L
|
||||
| lea RA, [BASE+RA*8] // Top of frame.
|
||||
| lea RC, [BASE+NARGS:RC*8-4] // Points to tag of 1st free slot.
|
||||
@ -437,16 +438,16 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| lea PC, [NARGS:RC*8+FRAME_VARG]
|
||||
| lea BASE, [RA+PC-FRAME_VARG]
|
||||
| mov [BASE-8], LFUNC:RB // Store copy of LFUNC.
|
||||
| mov PROTO:RB, LFUNC:RB->pt
|
||||
| mov [BASE-4], PC // Store delta + FRAME_VARG.
|
||||
| movzx PC, byte PROTO:RB->framesize
|
||||
| lea KBASE, [BASE+PC*8]
|
||||
| mov L:PC, SAVE_L
|
||||
| mov PC, LFUNC:RB->pc
|
||||
| movzx RB, byte [PC+PC2PROTO(framesize)]
|
||||
| lea KBASE, [BASE+RB*8]
|
||||
| mov L:RB, SAVE_L
|
||||
| lea RC, [BASE+4]
|
||||
| cmp KBASE, L:PC->maxstack
|
||||
| cmp KBASE, L:RB->maxstack
|
||||
| ja ->gate_lv_growstack // Need to grow stack.
|
||||
| movzx PC, byte PROTO:RB->numparams
|
||||
| test PC, PC
|
||||
| movzx RB, byte [PC+PC2PROTO(numparams)]
|
||||
| test RB, RB
|
||||
| jz >2
|
||||
|1: // Copy fixarg slots up.
|
||||
| add RA, 8
|
||||
@ -458,12 +459,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| mov [RC], KBASE
|
||||
| add RC, 8
|
||||
| mov dword [RA-4], LJ_TNIL // Clear old fixarg slot (help the GC).
|
||||
| sub PC, 1
|
||||
| sub RB, 1
|
||||
| jnz <1
|
||||
|2:
|
||||
| movzx RA, byte PROTO:RB->framesize
|
||||
| lea PC, [PROTO:RB+sizeof(GCproto)]
|
||||
| mov KBASE, PROTO:RB->k
|
||||
| movzx RA, byte [PC+PC2PROTO(framesize)]
|
||||
| mov KBASE, [PC+PC2PROTO(k)]
|
||||
| lea RA, [BASE+RA*8]
|
||||
| jmp <9
|
||||
|
|
||||
@ -663,6 +663,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| jmp >1
|
||||
|
|
||||
|->gate_lv_growstack: // Grow stack for vararg Lua function.
|
||||
//XXX
|
||||
| sub RC, 8
|
||||
| mov BASE, RA
|
||||
| mov RA, KBASE
|
||||
@ -863,8 +864,8 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
| mov RA, dword [RB-16]
|
||||
|.endif
|
||||
| mov LFUNC:KBASE, [BASE-8]
|
||||
| mov PROTO:KBASE, LFUNC:KBASE->pt
|
||||
| mov KBASE, PROTO:KBASE->k
|
||||
| mov KBASE, LFUNC:KBASE->pc
|
||||
| mov KBASE, [KBASE+PC2PROTO(k)]
|
||||
| // BASE = base, RC = result, RB = meta base
|
||||
| jmp RAa // Jump to continuation.
|
||||
|
|
||||
@ -2719,8 +2720,8 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
|
||||
|->vm_exit_interp:
|
||||
#if LJ_HASJIT
|
||||
| mov LFUNC:KBASE, [BASE-8]
|
||||
| mov PROTO:KBASE, LFUNC:KBASE->pt
|
||||
| mov KBASE, PROTO:KBASE->k
|
||||
| mov KBASE, LFUNC:KBASE->pc
|
||||
| mov KBASE, [KBASE+PC2PROTO(k)]
|
||||
| mov dword [DISPATCH+DISPATCH_GL(jit_L)], 0
|
||||
| set_vmstate INTERP
|
||||
| ins_next
|
||||
@ -4454,8 +4455,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
| not RDa
|
||||
| lea BASE, [BASE+RD*8]
|
||||
| mov LFUNC:KBASE, [BASE-8]
|
||||
| mov PROTO:KBASE, LFUNC:KBASE->pt
|
||||
| mov KBASE, PROTO:KBASE->k
|
||||
| mov KBASE, LFUNC:KBASE->pc
|
||||
| mov KBASE, [KBASE+PC2PROTO(k)]
|
||||
| jmp <4
|
||||
|
|
||||
|7: // Tailcall from a vararg function.
|
||||
@ -4492,8 +4493,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
| ins_AB_ // RA = base, RB = nresults+1, (RC = 1)
|
||||
| mov LFUNC:RC, [BASE-8]
|
||||
| lea RA, [BASE+RA*8]
|
||||
| mov PROTO:RC, LFUNC:RC->pt
|
||||
| movzx RC, byte PROTO:RC->numparams
|
||||
| mov RC, LFUNC:RC->pc
|
||||
| movzx RC, byte [RC+PC2PROTO(numparams)]
|
||||
| mov TMP1, KBASE // Need one more free register.
|
||||
| lea KBASE, [BASE+RC*8+(8+FRAME_VARG)]
|
||||
| sub KBASE, [BASE-4]
|
||||
@ -4618,8 +4619,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
|
||||
| not RAa // Note: ~RA = -(RA+1)
|
||||
| lea BASE, [BASE+RA*8] // base = base - (RA+1)*8
|
||||
| mov LFUNC:KBASE, [BASE-8]
|
||||
| mov PROTO:KBASE, LFUNC:KBASE->pt
|
||||
| mov KBASE, PROTO:KBASE->k
|
||||
| mov KBASE, LFUNC:KBASE->pc
|
||||
| mov KBASE, [KBASE+PC2PROTO(k)]
|
||||
| ins_next
|
||||
|
|
||||
|6: // Fill up results with nil.
|
||||
|
@ -112,8 +112,8 @@ GCfunc *lj_func_newL(lua_State *L, GCproto *pt, GCtab *env)
|
||||
fn->l.gct = ~LJ_TFUNC;
|
||||
fn->l.ffid = FF_LUA;
|
||||
fn->l.nupvalues = cast_byte(pt->sizeuv);
|
||||
/* NOBARRIER: The GCfunc is new (marked white). */
|
||||
setgcref(fn->l.pt, obj2gco(pt));
|
||||
/* NOBARRIER: Really a setgcref. But the GCfunc is new (marked white). */
|
||||
setmref(fn->l.pc, proto_bc(pt));
|
||||
setgcref(fn->l.env, obj2gco(env));
|
||||
fn->l.gate = (pt->flags & PROTO_IS_VARARG) ? lj_gate_lv : lj_gate_lf;
|
||||
return fn;
|
||||
@ -137,7 +137,7 @@ GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent)
|
||||
GCupval *uv;
|
||||
if ((v & 0x8000)) {
|
||||
uv = func_finduv(L, base + (v & 0xff));
|
||||
uv->dhash = (uint32_t)(uintptr_t)gcref(parent->pt) ^ (v << 24);
|
||||
uv->dhash = (uint32_t)(uintptr_t)mref(parent->pc, char) ^ (v << 24);
|
||||
} else {
|
||||
uv = &gcref(puv[v])->uv;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ typedef struct GCfuncC {
|
||||
|
||||
typedef struct GCfuncL {
|
||||
GCfuncHeader;
|
||||
GCRef pt; /* Link to prototype this function is based on. */
|
||||
MRef pc; /* Start PC (and GCproto reference). */
|
||||
GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */
|
||||
} GCfuncL;
|
||||
|
||||
@ -443,7 +443,8 @@ typedef union GCfunc {
|
||||
#define isluafunc(fn) ((fn)->c.ffid == FF_LUA)
|
||||
#define iscfunc(fn) ((fn)->c.ffid == FF_C)
|
||||
#define isffunc(fn) ((fn)->c.ffid > FF_C)
|
||||
#define funcproto(fn) check_exp(isluafunc(fn), &gcref((fn)->l.pt)->pt)
|
||||
#define funcproto(fn) \
|
||||
check_exp(isluafunc(fn), (GCproto *)(mref((fn)->l.pc, char)-sizeof(GCproto)))
|
||||
#define sizeCfunc(n) (sizeof(GCfuncC)-sizeof(TValue)+sizeof(TValue)*(n))
|
||||
#define sizeLfunc(n) (sizeof(GCfuncL)-sizeof(GCRef)+sizeof(GCRef)*(n))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user