Delete LREG and replace it's uses with RB.

This frees up a register and fixes a bug where RB was not loaded
correctly into LREG.
This commit is contained in:
Michael Munday 2017-01-11 14:42:24 -05:00
parent 65906fbc49
commit 084ab26280

View File

@ -41,8 +41,7 @@
|.define KBASE, r8 // Constants of current Lua function. |.define KBASE, r8 // Constants of current Lua function.
|.define PC, r9 // Next PC. |.define PC, r9 // Next PC.
|.define DISPATCH, r10 // Opcode dispatch table. |.define DISPATCH, r10 // Opcode dispatch table.
|.define LREG, r11 // Register holding lua_State (also in SAVE_L). |.define ITYPE, r11 //
|.define ITYPE, r13 //
| |
|// The following temporaries are not saved across C calls, except for RD. |// The following temporaries are not saved across C calls, except for RD.
|.define RA, r1 |.define RA, r1
@ -368,7 +367,7 @@ static void build_subroutines(BuildCtx *ctx)
| |
|->vm_leave_cp: |->vm_leave_cp:
| lg RA, SAVE_CFRAME // Restore previous C frame. | lg RA, SAVE_CFRAME // Restore previous C frame.
| stg RA, L:LREG->cframe | stg RA, L:RB->cframe
| lghi CRET1, 0 // Ok return status for vm_pcall. | lghi CRET1, 0 // Ok return status for vm_pcall.
| |
|->vm_leave_unw: |->vm_leave_unw:
@ -498,7 +497,6 @@ static void build_subroutines(BuildCtx *ctx)
| st RD, SAVE_NRES | st RD, SAVE_NRES
| stg RD, SAVE_ERRF | stg RD, SAVE_ERRF
| stg KBASE, L:RB->cframe | stg KBASE, L:RB->cframe
| lgr LREG, L:RB
| clm RD, 1, L:RB->status | clm RD, 1, L:RB->status
| je >2 // Initial resume (like a call). | je >2 // Initial resume (like a call).
| |
@ -543,16 +541,15 @@ static void build_subroutines(BuildCtx *ctx)
| stg L:RB, SAVE_PC // Any value outside of bytecode is ok. | stg L:RB, SAVE_PC // Any value outside of bytecode is ok.
| aghi DISPATCH, GG_G2DISP | aghi DISPATCH, GG_G2DISP
| stg sp, L:RB->cframe | stg sp, L:RB->cframe
| lgr L:LREG, L:RB // TODO: use RB instead of LREG here?
| |
|2: // Entry point for vm_resume/vm_cpcall (RA = base, LREG = L, PC = ftype). |2: // Entry point for vm_resume/vm_cpcall (RA = base, RB = L, PC = ftype).
| stg L:LREG, DISPATCH_GL(cur_L)(DISPATCH) | stg L:RB, DISPATCH_GL(cur_L)(DISPATCH)
| set_vmstate INTERP | set_vmstate INTERP
| lg BASE, L:LREG->base // BASE = old base (used in vmeta_call). | lg BASE, L:RB->base // BASE = old base (used in vmeta_call).
| agr PC, RA | agr PC, RA
| sgr PC, BASE // PC = frame delta + frame type | sgr PC, BASE // PC = frame delta + frame type
| |
| lg RD, L:LREG->top | lg RD, L:RB->top
| sgr RD, RA | sgr RD, RA
| srlg NARGS:RD, NARGS:RD, 3 | srlg NARGS:RD, NARGS:RD, 3
| aghi NARGS:RD, 1 // RD = nargs+1 | aghi NARGS:RD, 1 // RD = nargs+1
@ -569,23 +566,23 @@ static void build_subroutines(BuildCtx *ctx)
|->vm_cpcall: // Setup protected C frame, call C. |->vm_cpcall: // Setup protected C frame, call C.
| // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp)
| saveregs | saveregs
| lgr LREG, CARG1 | lgr L:RB, CARG1
| stg LREG, SAVE_L | stg L:RB, SAVE_L
| stg LREG, SAVE_PC // Any value outside of bytecode is ok. | stg L:RB, SAVE_PC // Any value outside of bytecode is ok.
| |
| lg KBASE, L:LREG->stack // Compute -savestack(L, L->top). | lg KBASE, L:RB->stack // Compute -savestack(L, L->top).
| sg KBASE, L:LREG->top | sg KBASE, L:RB->top
| lg DISPATCH, L:LREG->glref // Setup pointer to dispatch table. | lg DISPATCH, L:RB->glref // Setup pointer to dispatch table.
| lghi RA, 0 | lghi RA, 0
| stg RA, SAVE_ERRF // No error function. | stg RA, SAVE_ERRF // No error function.
| st KBASE, SAVE_NRES // Neg. delta means cframe w/o frame. | st KBASE, SAVE_NRES // Neg. delta means cframe w/o frame.
| aghi DISPATCH, GG_G2DISP | aghi DISPATCH, GG_G2DISP
| // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe). | // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe).
| |
| lg KBASE, L:LREG->cframe // Add our C frame to cframe chain. | lg KBASE, L:RB->cframe // Add our C frame to cframe chain.
| stg KBASE, SAVE_CFRAME | stg KBASE, SAVE_CFRAME
| stg sp, L:LREG->cframe | stg sp, L:RB->cframe
| stg L:LREG, DISPATCH_GL(cur_L)(DISPATCH) | stg L:RB, DISPATCH_GL(cur_L)(DISPATCH)
| |
| basr r14, CARG4 // (lua_State *L, lua_CFunction func, void *ud) | basr r14, CARG4 // (lua_State *L, lua_CFunction func, void *ud)
| // TValue * (new base) or NULL returned in r2 (CRET1/). | // TValue * (new base) or NULL returned in r2 (CRET1/).