Update LuaJIT to the latest 2.1.0 source (f3c8569)

This commit is contained in:
Alex Szpakowski
2021-12-03 20:50:23 -04:00
parent 4f24e5473f
commit c3986a9541
216 changed files with 6026 additions and 1838 deletions
+114 -29
View File
@@ -1,6 +1,6 @@
|// Low-level VM code for MIPS64 CPUs.
|// Bytecode interpreter, fast functions and helper functions.
|// Copyright (C) 2005-2020 Mike Pall. See Copyright Notice in luajit.h
|// Copyright (C) 2005-2021 Mike Pall. See Copyright Notice in luajit.h
|//
|// Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
|// Sponsored by Cisco Systems, Inc.
@@ -193,7 +193,7 @@
|//-----------------------------------------------------------------------
|
|// Trap for not-yet-implemented parts.
|.macro NYI; .long 0xf0f0f0f0; .endmacro
|.macro NYI; .long 0xec1cf0f0; .endmacro
|
|// Macros to mark delay slots.
|.macro ., a; a; .endmacro
@@ -556,6 +556,10 @@ static void build_subroutines(BuildCtx *ctx)
| b ->vm_returnc
|. li RD, 16 // 2 results: false + error message.
|
|->vm_unwind_stub: // Jump to exit stub from unwinder.
| jr CARG1
|. move ra, CARG2
|
|//-----------------------------------------------------------------------
|//-- Grow stack for calls -----------------------------------------------
|//-----------------------------------------------------------------------
@@ -724,11 +728,11 @@ static void build_subroutines(BuildCtx *ctx)
| ld PC, -24(RB) // Restore PC from [cont|PC].
| cleartp LFUNC:TMP1
| daddu TMP2, RA, RD
| ld TMP1, LFUNC:TMP1->pc
|.if FFI
| bnez AT, >1
|.endif
|. sd TISNIL, -8(TMP2) // Ensure one valid arg.
| ld TMP1, LFUNC:TMP1->pc
| // BASE = base, RA = resultptr, RB = meta base
| jr TMP0 // Jump to continuation.
|. ld KBASE, PC2PROTO(k)(TMP1)
@@ -1318,27 +1322,24 @@ static void build_subroutines(BuildCtx *ctx)
|//-- Base library: iterators -------------------------------------------
|
|.ffunc_1 next
| checktp CARG2, CARG1, -LJ_TTAB, ->fff_fallback
| checktp CARG1, -LJ_TTAB, ->fff_fallback
| daddu TMP2, BASE, NARGS8:RC
| sd TISNIL, 0(TMP2) // Set missing 2nd arg to nil.
| ld PC, FRAME_PC(BASE)
| load_got lj_tab_next
| sd BASE, L->base // Add frame since C call can throw.
| sd BASE, L->top // Dummy frame length is ok.
| daddiu CARG3, BASE, 8
| sd PC, SAVE_PC
| call_intern lj_tab_next // (lua_State *L, GCtab *t, TValue *key)
|. move CARG1, L
| // Returns 0 at end of traversal.
| ld PC, FRAME_PC(BASE)
| daddiu CARG2, BASE, 8
| call_intern lj_tab_next // (GCtab *t, cTValue *key, TValue *o)
|. daddiu CARG3, BASE, -16
| // Returns 1=found, 0=end, -1=error.
| daddiu RA, BASE, -16
| bgtz CRET1, ->fff_res // Found key/value.
|. li RD, (2+1)*8
| beqz CRET1, ->fff_restv // End of traversal: return nil.
|. move CARG1, TISNIL
| ld TMP0, 8(BASE)
| daddiu RA, BASE, -16
| ld TMP2, 16(BASE)
| sd TMP0, 0(RA)
| sd TMP2, 8(RA)
| b ->fff_res
|. li RD, (2+1)*8
| ld CFUNC:RB, FRAME_FUNC(BASE)
| cleartp CFUNC:RB
| b ->fff_fallback // Invalid key.
|. li RC, 2*8
|
|.ffunc_1 pairs
| checktp TAB:TMP1, CARG1, -LJ_TTAB, ->fff_fallback
@@ -2037,7 +2038,7 @@ static void build_subroutines(BuildCtx *ctx)
| ld TMP0, SBUF:CARG1->b
| sd L, SBUF:CARG1->L
| sd BASE, L->base
| sd TMP0, SBUF:CARG1->p
| sd TMP0, SBUF:CARG1->w
| call_intern extern lj_buf_putstr_ .. name
|. sd PC, SAVE_PC
| load_got lj_buf_tostr
@@ -2622,8 +2623,9 @@ static void build_subroutines(BuildCtx *ctx)
|. daddu RA, RA, BASE
|
|9: // Rethrow error from the right C frame.
| load_got lj_err_run
| call_intern lj_err_run // (lua_State *L)
| load_got lj_err_trace
| sub CARG2, r0, CRET1
| call_intern lj_err_trace // (lua_State *L, int errcode)
|. move CARG1, L
|.endif
|
@@ -2902,6 +2904,70 @@ static void build_subroutines(BuildCtx *ctx)
|//-- Miscellaneous functions --------------------------------------------
|//-----------------------------------------------------------------------
|
|.define NEXT_TAB, TAB:CARG1
|.define NEXT_IDX, CARG2
|.define NEXT_ASIZE, CARG3
|.define NEXT_NIL, CARG4
|.define NEXT_TMP0, r12
|.define NEXT_TMP1, r13
|.define NEXT_TMP2, r14
|.define NEXT_RES_VK, CRET1
|.define NEXT_RES_IDX, CRET2
|.define NEXT_RES_PTR, sp
|.define NEXT_RES_VAL, 0(sp)
|.define NEXT_RES_KEY, 8(sp)
|
|// TValue *lj_vm_next(GCtab *t, uint32_t idx)
|// Next idx returned in CRET2.
|->vm_next:
|.if JIT and ENDIAN_LE
| lw NEXT_ASIZE, NEXT_TAB->asize
| ld NEXT_TMP0, NEXT_TAB->array
| li NEXT_NIL, LJ_TNIL
|1: // Traverse array part.
| sltu AT, NEXT_IDX, NEXT_ASIZE
| sll NEXT_TMP1, NEXT_IDX, 3
| beqz AT, >5
|. daddu NEXT_TMP1, NEXT_TMP0, NEXT_TMP1
| li AT, LJ_TISNUM
| ld NEXT_TMP2, 0(NEXT_TMP1)
| dsll AT, AT, 47
| or NEXT_TMP1, NEXT_IDX, AT
| beq NEXT_TMP2, NEXT_NIL, <1
|. addiu NEXT_IDX, NEXT_IDX, 1
| sd NEXT_TMP2, NEXT_RES_VAL
| sd NEXT_TMP1, NEXT_RES_KEY
| move NEXT_RES_VK, NEXT_RES_PTR
| jr ra
|. move NEXT_RES_IDX, NEXT_IDX
|
|5: // Traverse hash part.
| subu NEXT_RES_IDX, NEXT_IDX, NEXT_ASIZE
| ld NODE:NEXT_RES_VK, NEXT_TAB->node
| sll NEXT_TMP2, NEXT_RES_IDX, 5
| lw NEXT_TMP0, NEXT_TAB->hmask
| sll AT, NEXT_RES_IDX, 3
| subu AT, NEXT_TMP2, AT
| daddu NODE:NEXT_RES_VK, NODE:NEXT_RES_VK, AT
|6:
| sltu AT, NEXT_TMP0, NEXT_RES_IDX
| bnez AT, >8
|. nop
| ld NEXT_TMP2, NODE:NEXT_RES_VK->val
| bne NEXT_TMP2, NEXT_NIL, >9
|. addiu NEXT_RES_IDX, NEXT_RES_IDX, 1
| // Skip holes in hash part.
| b <6
|. daddiu NODE:NEXT_RES_VK, NODE:NEXT_RES_VK, sizeof(Node)
|
|8: // End of iteration. Set the key to nil (not the value).
| sd NEXT_NIL, NEXT_RES_KEY
| move NEXT_RES_VK, NEXT_RES_PTR
|9:
| jr ra
|. addu NEXT_RES_IDX, NEXT_RES_IDX, NEXT_ASIZE
|.endif
|
|//-----------------------------------------------------------------------
|//-- FFI helper functions -----------------------------------------------
|//-----------------------------------------------------------------------
@@ -4698,10 +4764,11 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
break;
case BC_ITERN:
| // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8)
|.if JIT
| // NYI: add hotloop, record BC_ITERN.
|.if JIT and ENDIAN_LE
| hotloop
|.endif
|->vm_IITERN:
| // RA = base*8, (RB = (nresults+1)*8, RC = (nargs+1)*8 (2+1)*8)
| daddu RA, BASE, RA
| ld TAB:RB, -16(RA)
| lw RC, -8+LO(RA) // Get index from control var.
@@ -4722,11 +4789,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
|. addiu RC, RC, 1
| sd TMP2, 0(RA)
| sd CARG1, 8(RA)
| or TMP0, RC, CARG3
| lui TMP3, (-(BCBIAS_J*4 >> 16) & 65535)
| decode_RD4b RD
| daddu RD, RD, TMP3
| sw TMP0, -8+LO(RA) // Update control var.
| sw RC, -8+LO(RA) // Update control var.
| daddu PC, PC, RD
|3:
| ins_next
@@ -4776,9 +4842,9 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| daddiu TMP1, TMP1, -FF_next_N
| or AT, AT, TMP1
| bnez AT, >5
|. lui TMP1, 0xfffe
|. lui TMP1, (LJ_KEYINDEX >> 16)
| daddu PC, TMP0, TMP2
| ori TMP1, TMP1, 0x7fff
| ori TMP1, TMP1, (LJ_KEYINDEX & 0xffff)
| dsll TMP1, TMP1, 32
| sd TMP1, -8(RA)
|1:
@@ -4788,8 +4854,27 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| li TMP1, BC_ITERC
| sb TMP3, -4+OFS_OP(PC)
| daddu PC, TMP0, TMP2
|.if JIT
| lb TMP0, OFS_OP(PC)
| li AT, BC_ITERN
| bne TMP0, AT, >6
|. lhu TMP2, OFS_RD(PC)
|.endif
| b <1
|. sb TMP1, OFS_OP(PC)
|.if JIT
|6: // Unpatch JLOOP.
| ld TMP0, DISPATCH_J(trace)(DISPATCH)
| sll TMP2, TMP2, 3
| daddu TMP0, TMP0, TMP2
| ld TRACE:TMP2, 0(TMP0)
| lw TMP0, TRACE:TMP2->startins
| li AT, -256
| and TMP0, TMP0, AT
| or TMP0, TMP0, TMP1
| b <1
|. sw TMP0, 0(PC)
|.endif
break;
case BC_VARG: