Ensure forward progress on trace exit to BC_ITERN.
Also use a safer way to force a static dispatch for BC_RET*. Reported by Bartel Eerdekens. Analyzed by Peter Cawley. #1000 #1045
This commit is contained in:
@@ -2571,7 +2571,8 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| daddiu DISPATCH, JGL, -GG_DISP2G-32768
|
||||
| sd BASE, L->base
|
||||
|1:
|
||||
| bltz CRET1, >9 // Check for error from exit.
|
||||
| sltiu TMP0, CRET1, -LUA_ERRERR // Check for error from exit.
|
||||
| beqz TMP0, >9
|
||||
|. ld LFUNC:RB, FRAME_FUNC(BASE)
|
||||
| .FPU lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float).
|
||||
| dsll MULTRES, CRET1, 3
|
||||
@@ -2586,14 +2587,16 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| .FPU cvt.d.s TOBIT, TOBIT
|
||||
| // Modified copy of ins_next which handles function header dispatch, too.
|
||||
| lw INS, 0(PC)
|
||||
| daddiu PC, PC, 4
|
||||
| addiu CRET1, CRET1, 17 // Static dispatch?
|
||||
| // Assumes TISNIL == ~LJ_VMST_INTERP == -1
|
||||
| sw TISNIL, DISPATCH_GL(vmstate)(DISPATCH)
|
||||
| decode_RD8a RD, INS
|
||||
| beqz CRET1, >5
|
||||
|. daddiu PC, PC, 4
|
||||
| decode_OP8a TMP1, INS
|
||||
| decode_OP8b TMP1
|
||||
| sltiu TMP2, TMP1, BC_FUNCF*8
|
||||
| daddu TMP0, DISPATCH, TMP1
|
||||
| decode_RD8a RD, INS
|
||||
| sltiu TMP2, TMP1, BC_FUNCF*8
|
||||
| ld AT, 0(TMP0)
|
||||
| decode_RA8a RA, INS
|
||||
| beqz TMP2, >2
|
||||
@@ -2622,6 +2625,22 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| jr AT
|
||||
|. daddu RA, RA, BASE
|
||||
|
|
||||
|5: // Dispatch to static entry of original ins replaced by BC_JLOOP.
|
||||
| ld TMP0, DISPATCH_J(trace)(DISPATCH)
|
||||
| decode_RD8b RD
|
||||
| daddu TMP0, TMP0, RD
|
||||
| ld TRACE:TMP2, 0(TMP0)
|
||||
| lw INS, TRACE:TMP2->startins
|
||||
| decode_OP8a TMP1, INS
|
||||
| decode_OP8b TMP1
|
||||
| daddu TMP0, DISPATCH, TMP1
|
||||
| decode_RD8a RD, INS
|
||||
| ld AT, GG_DISP2STATIC(TMP0)
|
||||
| decode_RA8a RA, INS
|
||||
| decode_RD8b RD
|
||||
| jr AT
|
||||
|. decode_RA8b RA
|
||||
|
|
||||
|9: // Rethrow error from the right C frame.
|
||||
| load_got lj_err_trace
|
||||
| sub CARG2, r0, CRET1
|
||||
|
||||
Reference in New Issue
Block a user