2 ** This file has been pre-processed with DynASM.
3 ** http://luajit.org/dynasm.html
4 ** DynASM version 1.3.0, DynASM mips version 1.3.0
5 ** DO NOT EDIT! The original file is in "buildvm_mips.dasc".
8 #if DASM_VERSION != 10300
9 #error "Version mismatch between DynASM and included encoding engine"
12 #define DASM_SECTION_CODE_OP 0
13 #define DASM_SECTION_CODE_SUB 1
14 #define DASM_MAXSECTION 2
15 static const unsigned int build_actionlist
[6323] = {
6350 GLOB_vm_unwind_c_eh
,
6352 GLOB_vm_unwind_ff_eh
,
6353 GLOB_vm_growstack_c
,
6354 GLOB_vm_growstack_l
,
6358 GLOB_vm_call_dispatch
,
6360 GLOB_vm_call_dispatch_f
,
6362 GLOB_cont_ffi_callback
,
6381 GLOB_vmeta_equal_cd
,
6394 GLOB_ff_getmetatable
,
6396 GLOB_ff_setmetatable
,
6407 GLOB_ff_coroutine_resume
,
6408 GLOB_ff_coroutine_wrap_aux
,
6409 GLOB_ff_coroutine_yield
,
6441 GLOB_ff_string_byte
,
6442 GLOB_ff_string_char
,
6447 GLOB_ff_string_reverse
,
6448 GLOB_ff_string_lower
,
6449 GLOB_ff_string_upper
,
6458 GLOB_ff_bit_arshift
,
6469 GLOB_vm_exit_handler
,
6470 GLOB_vm_exit_interp
,
6472 GLOB_vm_ffi_callback
,
6481 static const char *const globnames
[] = {
6500 "vm_call_dispatch_f",
6502 "cont_ffi_callback",
6547 "ff_coroutine_resume",
6548 "ff_coroutine_wrap_aux",
6549 "ff_coroutine_yield",
6587 "ff_string_reverse",
6621 static const char *const extnames
[] = {
6624 #define Dt1(_V) (int)(ptrdiff_t)&(((lua_State *)0)_V)
6625 #define Dt2(_V) (int)(ptrdiff_t)&(((global_State *)0)_V)
6626 #define Dt3(_V) (int)(ptrdiff_t)&(((TValue *)0)_V)
6627 #define Dt4(_V) (int)(ptrdiff_t)&(((GCobj *)0)_V)
6628 #define Dt5(_V) (int)(ptrdiff_t)&(((GCstr *)0)_V)
6629 #define Dt6(_V) (int)(ptrdiff_t)&(((GCtab *)0)_V)
6630 #define Dt7(_V) (int)(ptrdiff_t)&(((GCfuncL *)0)_V)
6631 #define Dt8(_V) (int)(ptrdiff_t)&(((GCfuncC *)0)_V)
6632 #define Dt9(_V) (int)(ptrdiff_t)&(((GCproto *)0)_V)
6633 #define DtA(_V) (int)(ptrdiff_t)&(((GCupval *)0)_V)
6634 #define DtB(_V) (int)(ptrdiff_t)&(((Node *)0)_V)
6635 #define DtC(_V) (int)(ptrdiff_t)&(((int *)0)_V)
6636 #define DtD(_V) (int)(ptrdiff_t)&(((GCtrace *)0)_V)
6637 #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field))
6638 #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field))
6639 #define GG_DISP2GOT (GG_OFS(got) - GG_OFS(dispatch))
6640 #define DISPATCH_GOT(name) (GG_DISP2GOT + 4*LJ_GOT_##name)
6641 #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto))
6643 /* Generate subroutines used by opcodes and other parts of the VM. */
6644 /* The .code_sub section should be last to help static branch prediction. */
6645 static void build_subroutines(BuildCtx
*ctx
)
6648 dasm_put(Dst
, 1, FRAME_P
, LJ_TTRUE
, LJ_ENDIAN_SELECT(-4,-8), LJ_ENDIAN_SELECT(-4,-8), FRAME_TYPE
, FRAME_C
, Dt1(->base
), ~LJ_VMST_C
, DISPATCH_GL(vmstate
), Dt1(->top
));
6649 dasm_put(Dst
, 57, Dt1(->cframe
), 72+9*4, 72+8*4, 24+5*8, 72+7*4, 72+6*4, 24+4*8, 72+5*4, 72+4*4, 24+3*8, 72+3*4, 72+2*4, 24+2*8, 72+1*4, 72+0*4, 24+1*8, 24+0*8, Dt1(->maxstack
), LJ_ENDIAN_SELECT(4,0));
6650 dasm_put(Dst
, 109, DISPATCH_GOT(lj_state_growstack
), Dt1(->top
), ~LJ_VMST_C
, Dt1(->glref
), Dt2(->vmstate
), LJ_TNIL
, Dt1(->base
), Dt1(->glref
), LJ_TFALSE
, ~LJ_VMST_INTERP
, LJ_ENDIAN_SELECT(-4,-8), GG_G2DISP
, LJ_ENDIAN_SELECT(4,0));
6651 dasm_put(Dst
, 172, DISPATCH_GL(vmstate
), LUA_MINSTACK
, Dt1(->base
), Dt1(->top
), DISPATCH_GOT(lj_state_growstack
), Dt1(->base
), Dt1(->top
), LJ_ENDIAN_SELECT(-8,-4), Dt7(->pc
), 72+9*4, 72+8*4, 24+5*8, 72+7*4, 72+6*4, 24+4*8, 72+5*4, 72+4*4);
6652 dasm_put(Dst
, 235, 24+3*8, 72+3*4, 72+2*4, 24+2*8, 72+1*4, 72+0*4, 24+1*8, 24+0*8, Dt1(->glref
), Dt1(->status
), FRAME_CP
, CFRAME_RESUME
, GG_G2DISP
, Dt1(->cframe
), Dt1(->base
), Dt1(->top
), LJ_ENDIAN_SELECT(-4,-8), Dt1(->status
), ~LJ_VMST_INTERP
, DISPATCH_GL(vmstate
), FRAME_TYPE
);
6653 dasm_put(Dst
, 296, LJ_TNIL
, 72+9*4, 72+8*4, 24+5*8, 72+7*4, 72+6*4, 24+4*8, 72+5*4, 72+4*4, 24+3*8, 72+3*4, 72+2*4, 24+2*8, 72+1*4, 72+0*4, 24+1*8, 24+0*8, FRAME_CP
, 72+9*4);
6654 dasm_put(Dst
, 345, 72+8*4, 24+5*8, 72+7*4, 72+6*4, 24+4*8, 72+5*4, 72+4*4, 24+3*8, 72+3*4, 72+2*4, 24+2*8, 72+1*4, 72+0*4, 24+1*8, 24+0*8, FRAME_C
, Dt1(->cframe
), Dt1(->cframe
), Dt1(->glref
), GG_G2DISP
, Dt1(->base
));
6655 dasm_put(Dst
, 396, Dt1(->top
), ~LJ_VMST_INTERP
, LJ_TNIL
, DISPATCH_GL(vmstate
), LJ_ENDIAN_SELECT(-4,-8), LJ_TFUNC
, LJ_ENDIAN_SELECT(-8,-4), LJ_ENDIAN_SELECT(-4,-8), Dt7(->pc
), 72+9*4, 72+8*4, 24+5*8, 72+7*4, 72+6*4, 24+4*8, 72+5*4, 72+4*4, 24+3*8, 72+3*4);
6656 dasm_put(Dst
, 457, 72+2*4, 24+2*8, 72+1*4, 72+0*4, 24+1*8, 24+0*8, Dt1(->stack
), Dt1(->top
), Dt1(->cframe
), Dt1(->cframe
), Dt1(->glref
), FRAME_CP
, GG_G2DISP
, -16+LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(-8,-4));
6660 dasm_put(Dst
, 508, -16+LJ_ENDIAN_SELECT(4,0), Dt7(->pc
));
6664 dasm_put(Dst
, 517, -8+LJ_ENDIAN_SELECT(4,0), PC2PROTO(k
));
6668 dasm_put(Dst
, 531, Dt1(->base
), DISPATCH_GL(tmptv
), LJ_TSTR
, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), DISPATCH_GL(tmptv
), LJ_TTAB
, LJ_ENDIAN_SELECT(0,4), DISPATCH_GL(tmptv2
), LJ_ENDIAN_SELECT(4,0), LJ_TSTR
, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), DISPATCH_GL(tmptv
));
6669 dasm_put(Dst
, 589, DISPATCH_GOT(lj_meta_tget
), Dt1(->base
), -FRAME_CONT
, Dt1(->top
), -16+LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(-8,-4), DISPATCH_GL(tmptv
), LJ_TSTR
, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), DISPATCH_GL(tmptv
), LJ_TTAB
, LJ_ENDIAN_SELECT(0,4), DISPATCH_GL(tmptv2
), LJ_ENDIAN_SELECT(4,0), LJ_TSTR
, LJ_ENDIAN_SELECT(0,4));
6670 dasm_put(Dst
, 651, LJ_ENDIAN_SELECT(4,0), DISPATCH_GL(tmptv
), DISPATCH_GOT(lj_meta_tset
), Dt1(->base
), -FRAME_CONT
, Dt1(->top
), -16+LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(-8,-4), DISPATCH_GOT(lj_meta_comp
), Dt1(->base
), LJ_ENDIAN_SELECT(2,0), (-(BCBIAS_J
*4 >> 16) & 65535));
6671 dasm_put(Dst
, 721, -4+LJ_ENDIAN_SELECT(1,2), LJ_ENDIAN_SELECT(4,0), LJ_TISTRUECOND
, LJ_ENDIAN_SELECT(4,0), LJ_TISTRUECOND
, DISPATCH_GOT(lj_meta_equal
), Dt1(->base
));
6673 dasm_put(Dst
, 776, DISPATCH_GOT(lj_meta_equal_cd
), Dt1(->base
));
6675 dasm_put(Dst
, 789, DISPATCH_GOT(lj_meta_arith
), Dt1(->base
), -16+LJ_ENDIAN_SELECT(4,0), FRAME_CONT
);
6676 #ifdef LUAJIT_ENABLE_LUA52COMPAT
6679 dasm_put(Dst
, 820, DISPATCH_GOT(lj_meta_len
), Dt1(->base
));
6680 #ifdef LUAJIT_ENABLE_LUA52COMPAT
6685 dasm_put(Dst
, 839, DISPATCH_GOT(lj_meta_call
), Dt1(->base
), LJ_ENDIAN_SELECT(-8,-4), LJ_ENDIAN_SELECT(-4,-8), Dt7(->pc
), DISPATCH_GOT(lj_meta_call
), Dt1(->base
), LJ_ENDIAN_SELECT(-4,-8), LJ_ENDIAN_SELECT(-8,-4), DISPATCH_GOT(lj_meta_for
), Dt1(->base
));
6687 dasm_put(Dst
, 896, BC_JFORI
);
6691 dasm_put(Dst
, 904, BC_JFORI
, BC_FORI
);
6693 dasm_put(Dst
, 911, BC_FORI
);
6695 dasm_put(Dst
, 915, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TISTRUECOND
, LJ_ENDIAN_SELECT(-4,-8), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, Dt8(->upvalue
), LJ_ENDIAN_SELECT(4,0));
6696 dasm_put(Dst
, 970, LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, LJ_TUDATA
, Dt6(->metatable
), DISPATCH_GL(gcroot
[GCROOT_MMNAME
+MM_metatable
]), LJ_TNIL
, Dt6(->hmask
), LJ_TTAB
, Dt5(->hash
), Dt6(->node
), LJ_TSTR
, offsetof(Node
, key
)+LJ_ENDIAN_SELECT(4,0), offsetof(Node
, key
)+LJ_ENDIAN_SELECT(0,4), DtB(->next
), offsetof(Node
, val
)+LJ_ENDIAN_SELECT(4,0), offsetof(Node
, val
)+LJ_ENDIAN_SELECT(0,4));
6697 dasm_put(Dst
, 1020, LJ_TISNUM
, LJ_TISNUM
, DISPATCH_GL(gcroot
[GCROOT_BASEMT
]), LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), 8+LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, -LJ_TTAB
, Dt6(->metatable
), Dt6(->marked
));
6698 dasm_put(Dst
, 1075, LJ_GC_BLACK
, Dt6(->metatable
), DISPATCH_GL(gc
.grayagain
), ~LJ_GC_BLACK
& 255, DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), DISPATCH_GOT(lj_tab_get
), -LJ_TTAB
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6699 dasm_put(Dst
, 1129, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TSTR
, DISPATCH_GL(gcroot
[GCROOT_BASEMT_NUM
]), LJ_TISNUM
, Dt1(->base
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), DISPATCH_GOT(lj_str_fromnum
), LJ_TSTR
, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(-4,-8), DISPATCH_GOT(lj_tab_next
));
6700 dasm_put(Dst
, 1184, Dt1(->base
), Dt1(->top
), LJ_TNIL
, (2+1)*8, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, LJ_ENDIAN_SELECT(-4,-8));
6701 #ifdef LUAJIT_ENABLE_LUA52COMPAT
6702 dasm_put(Dst
, 1219, Dt6(->metatable
), Dt8(->upvalue
[0]));
6704 dasm_put(Dst
, 1226, Dt8(->upvalue
[0]));
6706 dasm_put(Dst
, 1229, 8+LJ_ENDIAN_SELECT(4,0), (3+1)*8, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), 8+LJ_ENDIAN_SELECT(4,0), -LJ_TTAB
, LJ_TISNUM
, LJ_ENDIAN_SELECT(-4,-8), Dt6(->asize
), Dt6(->array
), LJ_ENDIAN_SELECT(4,0), (0+1)*8, (2+1)*8, Dt6(->hmask
));
6707 dasm_put(Dst
, 1292, DISPATCH_GOT(lj_tab_getinth
), (0+1)*8, (0+1)*8, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, LJ_ENDIAN_SELECT(-4,-8));
6708 #ifdef LUAJIT_ENABLE_LUA52COMPAT
6709 dasm_put(Dst
, 1323, Dt6(->metatable
), Dt8(->upvalue
[0]));
6711 dasm_put(Dst
, 1330, Dt8(->upvalue
[0]));
6713 dasm_put(Dst
, 1333, 8+LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(0,4), (3+1)*8, DISPATCH_GL(hookmask
), HOOK_ACTIVE_SHIFT
, 8+FRAME_PCALL
, 8+LJ_ENDIAN_SELECT(4,0), DISPATCH_GL(hookmask
), LJ_TFUNC
, HOOK_ACTIVE_SHIFT
, 16+FRAME_PCALL
, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4));
6714 dasm_put(Dst
, 1392, LJ_TTHREAD
, Dt1(->status
), Dt1(->cframe
), Dt1(->top
), Dt1(->base
), -LUA_YIELD
, Dt1(->maxstack
), LJ_ENDIAN_SELECT(-4,-8), Dt1(->base
), Dt1(->top
), Dt1(->top
));
6715 dasm_put(Dst
, 1451, Dt1(->base
), LUA_YIELD
+1, Dt1(->top
), ~LJ_VMST_INTERP
, Dt1(->base
), DISPATCH_GL(vmstate
), Dt1(->maxstack
), Dt1(->top
), FRAME_TYPE
, LJ_TTRUE
, -8+LJ_ENDIAN_SELECT(4,0), LJ_TFALSE
, Dt1(->top
));
6716 dasm_put(Dst
, 1511, (2+1)*8, -8+LJ_ENDIAN_SELECT(4,0), FRAME_TYPE
, DISPATCH_GOT(lj_state_growstack
), Dt8(->upvalue
[0].gcr
), Dt1(->status
), Dt1(->cframe
), Dt1(->top
), Dt1(->base
), -LUA_YIELD
, Dt1(->maxstack
), LJ_ENDIAN_SELECT(-4,-8), Dt1(->base
), Dt1(->top
));
6717 dasm_put(Dst
, 1566, Dt1(->top
), Dt1(->base
), LUA_YIELD
+1, Dt1(->top
), ~LJ_VMST_INTERP
, Dt1(->base
), DISPATCH_GL(vmstate
), Dt1(->maxstack
), Dt1(->top
), FRAME_TYPE
);
6718 dasm_put(Dst
, 1627, DISPATCH_GOT(lj_ffh_coroutine_wrap_err
), DISPATCH_GOT(lj_state_growstack
), Dt1(->cframe
), Dt1(->base
), CFRAME_RESUME
, Dt1(->top
), LUA_YIELD
, Dt1(->cframe
), Dt1(->status
), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6719 dasm_put(Dst
, 1682, LJ_ENDIAN_SELECT(-4,-8), LJ_ENDIAN_SELECT(-4,-8), -8+LJ_ENDIAN_SELECT(4,0), -8+LJ_ENDIAN_SELECT(0,4), (1+1)*8, FRAME_TYPE
, -8+LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6720 dasm_put(Dst
, 1750, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(log
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(log10
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0));
6721 dasm_put(Dst
, 1806, DISPATCH_GOT(exp
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(sin
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(cos
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(tan
));
6722 dasm_put(Dst
, 1862, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(asin
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(acos
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(atan
), LJ_TISNUM
);
6723 dasm_put(Dst
, 1918, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(sinh
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(cosh
), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(tanh
), LJ_TISNUM
);
6724 dasm_put(Dst
, 1977, LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, DISPATCH_GOT(pow
), LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, DISPATCH_GOT(atan2
), LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
6725 dasm_put(Dst
, 2039, DISPATCH_GOT(fmod
), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, Dt8(->upvalue
[0]), LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
6726 dasm_put(Dst
, 2094, DISPATCH_GOT(ldexp
), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, DISPATCH_GOT(frexp
), LJ_ENDIAN_SELECT(-4,-8), DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv
), (2+1)*8, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, DISPATCH_GOT(modf
), LJ_ENDIAN_SELECT(-4,-8), (2+1)*8);
6727 dasm_put(Dst
, 2158, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6728 dasm_put(Dst
, 2217, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TSTR
, Dt5(->len
), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), -LJ_TSTR
, Dt5(->len
), Dt5([1]), LJ_ENDIAN_SELECT(-4,-8), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), LJ_ENDIAN_SELECT(4,0));
6729 dasm_put(Dst
, 2276, LJ_TISNUM
, DISPATCH_GOT(lj_str_new
), Dt1(->base
), Dt1(->base
), LJ_TSTR
, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), 16+LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
6730 dasm_put(Dst
, 2337, LJ_TSTR
, Dt5(->len
), sizeof(GCstr
)-1, DISPATCH_GL(strempty
), LJ_TSTR
, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), -LJ_TSTR
, LJ_TISNUM
, Dt5(->len
), DISPATCH_GL(tmpbuf
.sz
));
6731 dasm_put(Dst
, 2407, DISPATCH_GL(tmpbuf
.buf
), Dt5([1]), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TSTR
, DISPATCH_GL(tmpbuf
.sz
), Dt5(->len
), sizeof(GCstr
), DISPATCH_GL(tmpbuf
.buf
));
6732 dasm_put(Dst
, 2464, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TSTR
, DISPATCH_GL(tmpbuf
.sz
), Dt5(->len
), sizeof(GCstr
), DISPATCH_GL(tmpbuf
.buf
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
));
6733 dasm_put(Dst
, 2527, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TSTR
, DISPATCH_GL(tmpbuf
.sz
), Dt5(->len
), sizeof(GCstr
), DISPATCH_GL(tmpbuf
.buf
), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, DISPATCH_GOT(lj_tab_len
), LJ_ENDIAN_SELECT(4,0));
6734 dasm_put(Dst
, 2586, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0));
6735 dasm_put(Dst
, 2649, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0));
6736 dasm_put(Dst
, 2719, 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0));
6737 dasm_put(Dst
, 2790, 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), 8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, Dt8(->f
));
6738 dasm_put(Dst
, 2863, LJ_ENDIAN_SELECT(-4,-8), 8*LUA_MINSTACK
, Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), Dt1(->base
), Dt1(->top
), LJ_ENDIAN_SELECT(-8,-4), Dt7(->pc
), FRAME_TYPE
, LJ_ENDIAN_SELECT(1,2), DISPATCH_GOT(lj_state_growstack
), LUA_MINSTACK
, Dt1(->base
));
6739 dasm_put(Dst
, 2931, DISPATCH_GOT(lj_gc_step
), Dt1(->base
), Dt1(->top
), Dt1(->base
), Dt1(->top
), LJ_ENDIAN_SELECT(-8,-4));
6741 dasm_put(Dst
, 2957, DISPATCH_GL(hookmask
), HOOK_VMEVENT
, DISPATCH_GL(hookcount
), HOOK_ACTIVE
, LUA_MASKLINE
|LUA_MASKCOUNT
, DISPATCH_GL(hookcount
));
6743 dasm_put(Dst
, 2980, DISPATCH_GL(hookmask
), HOOK_ACTIVE
, GG_DISP2STATIC
, DISPATCH_GL(hookmask
), DISPATCH_GL(hookcount
), HOOK_ACTIVE
, LUA_MASKLINE
|LUA_MASKCOUNT
, DISPATCH_GL(hookcount
), LUA_MASKLINE
, DISPATCH_GOT(lj_dispatch_ins
), Dt1(->base
), Dt1(->base
));
6744 dasm_put(Dst
, 3028, GG_DISP2STATIC
, -24+LJ_ENDIAN_SELECT(0,4));
6746 dasm_put(Dst
, 3047, LJ_ENDIAN_SELECT(-8,-4), GG_DISP2J
, Dt7(->pc
), DISPATCH_J(L
), PC2PROTO(framesize
), DISPATCH_GOT(lj_trace_hot
), Dt1(->base
), Dt1(->top
));
6748 dasm_put(Dst
, 3072);
6750 dasm_put(Dst
, 3074);
6752 dasm_put(Dst
, 3077);
6754 dasm_put(Dst
, 3080);
6756 dasm_put(Dst
, 3083, DISPATCH_GOT(lj_dispatch_call
), Dt1(->base
), Dt1(->top
), Dt1(->base
), Dt1(->top
), LJ_ENDIAN_SELECT(-8,-4));
6758 dasm_put(Dst
, 3107, -(16+32*8+32*4), 16+0*8, 16+32*8+0*4, 16+32*8+1*4, 16+2*8, 16+32*8+2*4, 16+32*8+3*4, 16+4*8, 16+32*8+4*4, 16+32*8+5*4, 16+6*8, 16+32*8+6*4, 16+32*8+7*4, 16+8*8, 16+32*8+8*4, 16+32*8+9*4, 16+10*8, 16+32*8+10*4, 16+32*8+11*4, 16+12*8, 16+32*8+12*4, 16+32*8+13*4, 16+14*8);
6759 dasm_put(Dst
, 3154, 16+32*8+14*4, 16+32*8+15*4, 16+16*8, 16+32*8+16*4, 16+32*8+17*4, 16+18*8, 16+32*8+18*4, 16+32*8+19*4, 16+20*8, 16+32*8+20*4, 16+32*8+21*4, 16+22*8, 16+32*8+22*4, 16+32*8+23*4, 16+24*8, 16+32*8+24*4, 16+32*8+25*4, 16+26*8, 16+32*8+26*4, 16+32*8+27*4, 16+28*8, 16+32*8+28*4, 16+30*8);
6760 dasm_put(Dst
, 3201, 16+32*8+30*4, 16+32*8+31*4, ~LJ_VMST_EXIT
, 16+32*8+32*4, -GG_DISP2G
-32768, DISPATCH_GL(vmstate
), 16+32*8+29*4, DISPATCH_GL(jit_L
), DISPATCH_GL(jit_base
), DISPATCH_GOT(lj_trace_exit
), DISPATCH_J(L
), DISPATCH_J(parent
), DISPATCH_J(exitno
), GG_DISP2J
, Dt1(->base
), Dt1(->cframe
), Dt1(->base
));
6762 dasm_put(Dst
, 3245);
6764 dasm_put(Dst
, 3247, -GG_DISP2G
-32768, LJ_ENDIAN_SELECT(-8,-4), LJ_TNIL
, Dt7(->pc
), DISPATCH_GL(jit_L
), PC2PROTO(k
), DISPATCH_GL(vmstate
), BC_FUNCF
*4, DISPATCH_GOT(lj_err_throw
));
6766 dasm_put(Dst
, 3296);
6768 dasm_put(Dst
, 3344);
6770 dasm_put(Dst
, 3367);
6772 #define DtE(_V) (int)(ptrdiff_t)&(((CTState *)0)_V)
6773 dasm_put(Dst
, 3369, 72+9*4, 72+8*4, 24+5*8, 72+7*4, 72+6*4, 24+4*8, 72+5*4, 72+4*4, 24+3*8, 72+3*4, 72+2*4, 24+2*8, 72+1*4, 72+0*4, 24+1*8, 24+0*8, Dt2(->ctype_state
), GG_G2DISP
, DISPATCH_GOT(lj_ccallback_enter
), DtE(->cb
.slot
), DtE(->cb
.gpr
[0]), DtE(->cb
.gpr
[1]), DtE(->cb
.fpr
[0]));
6774 dasm_put(Dst
, 3417, DtE(->cb
.gpr
[2]), DtE(->cb
.gpr
[3]), DtE(->cb
.fpr
[1]), 112+16, DtE(->cb
.stack
), Dt1(->base
), Dt1(->top
), LJ_ENDIAN_SELECT(-8,-4), ~LJ_VMST_INTERP
, LJ_TNIL
, DISPATCH_GL(vmstate
), Dt7(->pc
));
6776 dasm_put(Dst
, 3461);
6778 dasm_put(Dst
, 3463, DISPATCH_GOT(lj_ccallback_leave
), DISPATCH_GL(ctype_state
), Dt1(->base
), Dt1(->top
), DtE(->L
), DtE(->cb
.gpr
[0]), DtE(->cb
.fpr
[0]), DtE(->cb
.gpr
[1]), DtE(->cb
.fpr
[1]));
6780 dasm_put(Dst
, 3487);
6782 #define DtF(_V) (int)(ptrdiff_t)&(((CCallState *)0)_V)
6783 dasm_put(Dst
, 3489, DtF(->spadj
), DtF(->nsp
), offsetof(CCallState
, stack
), DtF(->func
), DtF(->gpr
[1]), DtF(->gpr
[2]), DtF(->gpr
[3]), DtF(->fpr
[0]), DtF(->fpr
[1]), DtF(->gpr
[0]), DtF(->gpr
[0]), DtF(->gpr
[1]), DtF(->fpr
[0]), DtF(->fpr
[1]));
6787 /* Generate the code for a single instruction. */
6788 static void build_ins(BuildCtx
*ctx
, BCOp op
, int defop
)
6791 dasm_put(Dst
, 3545, defop
);
6795 /* -- Comparison ops ---------------------------------------------------- */
6797 /* Remember: all ops branch for a true comparison, fall through otherwise. */
6799 case BC_ISLT
: case BC_ISGE
: case BC_ISLE
: case BC_ISGT
:
6800 dasm_put(Dst
, 3547, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, LJ_ENDIAN_SELECT(2,0), (-(BCBIAS_J
*4 >> 16) & 65535));
6801 if (op
== BC_ISLT
|| op
== BC_ISGE
) {
6802 dasm_put(Dst
, 3570);
6804 dasm_put(Dst
, 3572);
6806 if (op
== BC_ISLT
|| op
== BC_ISLE
) {
6807 dasm_put(Dst
, 3574);
6809 dasm_put(Dst
, 3576);
6811 dasm_put(Dst
, 3578);
6814 case BC_ISEQV
: case BC_ISNEV
:
6815 vk
= op
== BC_ISEQV
;
6816 dasm_put(Dst
, 3592, LJ_ENDIAN_SELECT(4,0), -4+LJ_ENDIAN_SELECT(2,0), LJ_ENDIAN_SELECT(4,0), (-(BCBIAS_J
*4 >> 16) & 65535), LJ_TISNUM
, LJ_TISNUM
);
6818 dasm_put(Dst
, 3616);
6820 dasm_put(Dst
, 3618);
6822 dasm_put(Dst
, 3620, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(0,4));
6824 dasm_put(Dst
, 3639, LJ_TCDATA
);
6826 dasm_put(Dst
, 3644, LJ_TISPRI
);
6828 dasm_put(Dst
, 3647);
6830 dasm_put(Dst
, 3650, LJ_TISTABUD
+1);
6832 dasm_put(Dst
, 3661);
6834 dasm_put(Dst
, 3663);
6836 dasm_put(Dst
, 3665, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_eq
, 1-vk
);
6839 case BC_ISEQS
: case BC_ISNES
:
6840 vk
= op
== BC_ISEQS
;
6841 dasm_put(Dst
, 3682, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), -4+LJ_ENDIAN_SELECT(2,0));
6843 dasm_put(Dst
, 3693, LJ_TCDATA
);
6845 dasm_put(Dst
, 3698, -LJ_TSTR
, (-(BCBIAS_J
*4 >> 16) & 65535));
6847 dasm_put(Dst
, 3708);
6849 dasm_put(Dst
, 3710);
6851 dasm_put(Dst
, 3712);
6854 case BC_ISEQN
: case BC_ISNEN
:
6855 vk
= op
== BC_ISEQN
;
6856 dasm_put(Dst
, 3725, LJ_ENDIAN_SELECT(4,0), -4+LJ_ENDIAN_SELECT(2,0), (-(BCBIAS_J
*4 >> 16) & 65535), LJ_TISNUM
);
6858 dasm_put(Dst
, 3740);
6860 dasm_put(Dst
, 3743);
6862 dasm_put(Dst
, 3746);
6864 dasm_put(Dst
, 3749);
6866 dasm_put(Dst
, 3753);
6868 dasm_put(Dst
, 3757);
6870 dasm_put(Dst
, 3769, LJ_TCDATA
);
6874 case BC_ISEQP
: case BC_ISNEP
:
6875 vk
= op
== BC_ISEQP
;
6876 dasm_put(Dst
, 3779, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(2,0));
6878 dasm_put(Dst
, 3788, LJ_TCDATA
);
6880 dasm_put(Dst
, 3793, (-(BCBIAS_J
*4 >> 16) & 65535));
6882 dasm_put(Dst
, 3799);
6884 dasm_put(Dst
, 3801);
6886 dasm_put(Dst
, 3803);
6889 /* -- Unary test and copy ops ------------------------------------------- */
6891 case BC_ISTC
: case BC_ISFC
: case BC_IST
: case BC_ISF
:
6892 dasm_put(Dst
, 3816, LJ_ENDIAN_SELECT(2,0), LJ_ENDIAN_SELECT(4,0));
6893 if (op
== BC_IST
|| op
== BC_ISF
) {
6894 dasm_put(Dst
, 3823, LJ_TISTRUECOND
, (-(BCBIAS_J
*4 >> 16) & 65535));
6896 dasm_put(Dst
, 3830);
6898 dasm_put(Dst
, 3832);
6900 dasm_put(Dst
, 3834);
6902 dasm_put(Dst
, 3836, LJ_TISTRUECOND
);
6903 if (op
== BC_ISTC
) {
6904 dasm_put(Dst
, 3840);
6906 dasm_put(Dst
, 3843);
6908 dasm_put(Dst
, 3846, (-(BCBIAS_J
*4 >> 16) & 65535));
6910 dasm_put(Dst
, 3855);
6913 /* -- Unary ops --------------------------------------------------------- */
6916 dasm_put(Dst
, 3867);
6919 dasm_put(Dst
, 3883, LJ_ENDIAN_SELECT(4,0), LJ_TFALSE
, LJ_TISTRUECOND
, LJ_TTRUE
, LJ_ENDIAN_SELECT(4,0));
6922 dasm_put(Dst
, 3907, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6925 dasm_put(Dst
, 3930, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TSTR
, LJ_TTAB
, Dt5(->len
));
6926 #ifdef LUAJIT_ENABLE_LUA52COMPAT
6927 dasm_put(Dst
, 3964, Dt6(->metatable
));
6929 dasm_put(Dst
, 3971, DISPATCH_GOT(lj_tab_len
));
6930 #ifdef LUAJIT_ENABLE_LUA52COMPAT
6931 dasm_put(Dst
, 3980, Dt6(->nomm
), 1<<MM_len
);
6935 /* -- Binary ops -------------------------------------------------------- */
6938 case BC_ADDVN
: case BC_ADDNV
: case BC_ADDVV
:
6939 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
6940 dasm_put(Dst
, 3992);
6943 dasm_put(Dst
, 3996, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6946 dasm_put(Dst
, 4005, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6949 dasm_put(Dst
, 4014, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
6952 dasm_put(Dst
, 4028);
6954 case BC_SUBVN
: case BC_SUBNV
: case BC_SUBVV
:
6955 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
6956 dasm_put(Dst
, 4045);
6959 dasm_put(Dst
, 4049, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6962 dasm_put(Dst
, 4058, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6965 dasm_put(Dst
, 4067, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
6968 dasm_put(Dst
, 4081);
6970 case BC_MULVN
: case BC_MULNV
: case BC_MULVV
:
6971 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
6972 dasm_put(Dst
, 4098);
6975 dasm_put(Dst
, 4102, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6978 dasm_put(Dst
, 4111, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6981 dasm_put(Dst
, 4120, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
6984 dasm_put(Dst
, 4134);
6986 case BC_DIVVN
: case BC_DIVNV
: case BC_DIVVV
:
6987 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
6988 dasm_put(Dst
, 4151);
6991 dasm_put(Dst
, 4155, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6994 dasm_put(Dst
, 4164, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
6997 dasm_put(Dst
, 4173, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
7000 dasm_put(Dst
, 4187);
7003 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
7004 dasm_put(Dst
, 4204);
7007 dasm_put(Dst
, 4208, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
7010 dasm_put(Dst
, 4217, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
7013 dasm_put(Dst
, 4226, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
7016 dasm_put(Dst
, 4240);
7018 case BC_MODNV
: case BC_MODVV
:
7019 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
7020 dasm_put(Dst
, 4262);
7023 dasm_put(Dst
, 4266, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
7026 dasm_put(Dst
, 4275, LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
);
7029 dasm_put(Dst
, 4284, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
);
7032 dasm_put(Dst
, 4298);
7035 dasm_put(Dst
, 4305, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, DISPATCH_GOT(pow
));
7039 dasm_put(Dst
, 4341, Dt1(->base
), DISPATCH_GOT(lj_meta_cat
), Dt1(->base
));
7042 /* -- Constant ops ------------------------------------------------------ */
7045 dasm_put(Dst
, 4376, LJ_TSTR
, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0));
7049 dasm_put(Dst
, 4398, LJ_TCDATA
, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0));
7053 dasm_put(Dst
, 4420);
7056 dasm_put(Dst
, 4437);
7059 dasm_put(Dst
, 4453, LJ_ENDIAN_SELECT(4,0));
7062 dasm_put(Dst
, 4470, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0));
7065 /* -- Upvalue and function ops ------------------------------------------ */
7068 dasm_put(Dst
, 4494, LJ_ENDIAN_SELECT(-8,-4), Dt7(->uvptr
), DtA(->v
));
7071 dasm_put(Dst
, 4517, LJ_ENDIAN_SELECT(-8,-4), Dt7(->uvptr
), DtA(->marked
), DtA(->v
), LJ_GC_BLACK
, DtA(->closed
), LJ_ENDIAN_SELECT(4,0), LJ_GC_BLACK
|1, -(LJ_TISNUM
+1), LJ_TISGCV
- (LJ_TISNUM
+1), LJ_ENDIAN_SELECT(0,4), Dt4(->gch
.marked
), LJ_GC_WHITES
, DISPATCH_GOT(lj_gc_barrieruv
), GG_DISP2G
);
7074 dasm_put(Dst
, 4577, LJ_ENDIAN_SELECT(-8,-4), Dt7(->uvptr
), DtA(->marked
), DtA(->v
), Dt5(->marked
), LJ_GC_BLACK
, DtA(->closed
), LJ_TSTR
, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), LJ_GC_WHITES
, DISPATCH_GOT(lj_gc_barrieruv
), GG_DISP2G
);
7077 dasm_put(Dst
, 4632, LJ_ENDIAN_SELECT(-8,-4), Dt7(->uvptr
), DtA(->v
));
7080 dasm_put(Dst
, 4655, LJ_ENDIAN_SELECT(-8,-4), Dt7(->uvptr
), DtA(->v
), LJ_ENDIAN_SELECT(4,0));
7084 dasm_put(Dst
, 4679, Dt1(->openupval
), (-(BCBIAS_J
*4 >> 16) & 65535), DISPATCH_GOT(lj_func_closeuv
), Dt1(->base
), Dt1(->base
));
7088 dasm_put(Dst
, 4710, DISPATCH_GOT(lj_func_newL_gc
), LJ_ENDIAN_SELECT(-8,-4), Dt1(->base
), Dt1(->base
), LJ_TFUNC
, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4));
7091 /* -- Table ops --------------------------------------------------------- */
7095 dasm_put(Dst
, 4743, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), Dt1(->base
));
7096 if (op
== BC_TNEW
) {
7097 dasm_put(Dst
, 4755, DISPATCH_GOT(lj_tab_new
));
7099 dasm_put(Dst
, 4766, DISPATCH_GOT(lj_tab_dup
));
7101 dasm_put(Dst
, 4774, Dt1(->base
), LJ_TTAB
, LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), DISPATCH_GOT(lj_gc_step_fixtop
));
7106 dasm_put(Dst
, 4804, LJ_ENDIAN_SELECT(-8,-4), Dt7(->env
));
7107 if (op
== BC_GGET
) {
7108 dasm_put(Dst
, 4812);
7110 dasm_put(Dst
, 4815);
7112 dasm_put(Dst
, 4818);
7116 dasm_put(Dst
, 4820, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, LJ_TISNUM
, LJ_TSTR
, Dt6(->asize
), Dt6(->array
), LJ_ENDIAN_SELECT(4,0), Dt6(->metatable
), Dt6(->nomm
), 1<<MM_index
);
7117 dasm_put(Dst
, 4895, LJ_ENDIAN_SELECT(0,4));
7120 dasm_put(Dst
, 4901, LJ_ENDIAN_SELECT(4,0), LJ_TTAB
, LJ_ENDIAN_SELECT(0,4), Dt6(->hmask
), Dt5(->hash
), Dt6(->node
), offsetof(Node
, key
)+LJ_ENDIAN_SELECT(4,0), offsetof(Node
, key
)+LJ_ENDIAN_SELECT(0,4), DtB(->next
), offsetof(Node
, val
)+LJ_ENDIAN_SELECT(4,0), -LJ_TSTR
, Dt6(->metatable
), offsetof(Node
, val
)+LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4));
7121 dasm_put(Dst
, 4970, LJ_TNIL
, Dt6(->nomm
), 1<<MM_index
);
7124 dasm_put(Dst
, 4987, LJ_ENDIAN_SELECT(4,0), LJ_TTAB
, LJ_ENDIAN_SELECT(0,4), Dt6(->asize
), Dt6(->array
), LJ_ENDIAN_SELECT(4,0), Dt6(->metatable
), Dt6(->nomm
), 1<<MM_index
);
7128 dasm_put(Dst
, 5044, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_TTAB
, LJ_TISNUM
, LJ_TSTR
, Dt6(->asize
), Dt6(->array
), Dt6(->marked
), LJ_ENDIAN_SELECT(4,0), LJ_GC_BLACK
, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_newindex
);
7129 dasm_put(Dst
, 5117, LJ_ENDIAN_SELECT(0,4), DISPATCH_GL(gc
.grayagain
), ~LJ_GC_BLACK
& 255, DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
7132 dasm_put(Dst
, 5145, LJ_ENDIAN_SELECT(4,0), LJ_TTAB
, LJ_ENDIAN_SELECT(0,4), Dt6(->hmask
), Dt5(->hash
), Dt6(->node
), Dt6(->nomm
), offsetof(Node
, key
)+LJ_ENDIAN_SELECT(4,0), offsetof(Node
, key
)+LJ_ENDIAN_SELECT(0,4), LJ_TSTR
, DtB(->next
), offsetof(Node
, val
)+LJ_ENDIAN_SELECT(4,0), Dt6(->marked
), Dt6(->metatable
), LJ_GC_BLACK
);
7133 dasm_put(Dst
, 5203, DtB(->val
), Dt6(->nomm
), 1<<MM_newindex
, Dt6(->metatable
), DISPATCH_GL(tmptv
), Dt6(->nomm
), 1<<MM_newindex
, LJ_TSTR
, DISPATCH_GOT(lj_tab_newkey
), LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), Dt1(->base
), Dt1(->base
));
7134 dasm_put(Dst
, 5265, DISPATCH_GL(gc
.grayagain
), ~LJ_GC_BLACK
& 255, DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
7137 dasm_put(Dst
, 5282, LJ_ENDIAN_SELECT(4,0), LJ_TTAB
, LJ_ENDIAN_SELECT(0,4), Dt6(->asize
), Dt6(->array
), LJ_ENDIAN_SELECT(4,0), Dt6(->marked
), LJ_GC_BLACK
, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_newindex
, DISPATCH_GL(gc
.grayagain
));
7138 dasm_put(Dst
, 5349, ~LJ_GC_BLACK
& 255, DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
7142 dasm_put(Dst
, 5360, -8+LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(0,4), Dt6(->asize
), Dt6(->marked
), Dt6(->array
), LJ_GC_BLACK
, DISPATCH_GOT(lj_tab_reasize
), Dt1(->base
), Dt1(->base
), DISPATCH_GL(gc
.grayagain
), ~LJ_GC_BLACK
& 255, DISPATCH_GL(gc
.grayagain
), Dt6(->marked
));
7143 dasm_put(Dst
, 5433, Dt6(->gclist
));
7146 /* -- Calls and vararg handling ----------------------------------------- */
7149 dasm_put(Dst
, 5438);
7152 dasm_put(Dst
, 5443, LJ_TFUNC
, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(-4,-8), Dt7(->pc
));
7156 dasm_put(Dst
, 5472);
7159 dasm_put(Dst
, 5474, LJ_TFUNC
, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(-4,-8), FRAME_TYPE
, Dt7(->ffid
), FRAME_VARG
, LJ_ENDIAN_SELECT(-8,-4), Dt7(->pc
), -8+LJ_ENDIAN_SELECT(-8,-4), Dt7(->pc
));
7160 dasm_put(Dst
, 5543, PC2PROTO(k
), FRAME_TYPEP
, LJ_ENDIAN_SELECT(-4,-8), FRAME_TYPE
);
7164 dasm_put(Dst
, 5559, LJ_TFUNC
, -24+LJ_ENDIAN_SELECT(4,0), -24+LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(-4,-8), Dt7(->pc
));
7170 dasm_put(Dst
, 5594, -16+LJ_ENDIAN_SELECT(0,4), -8+LJ_ENDIAN_SELECT(0,4), Dt6(->asize
), Dt6(->array
), LJ_ENDIAN_SELECT(4,0), -4+LJ_ENDIAN_SELECT(2,0), (-(BCBIAS_J
*4 >> 16) & 65535), -8+LJ_ENDIAN_SELECT(0,4), Dt6(->hmask
), Dt6(->node
), LJ_ENDIAN_SELECT(4,0), -4+LJ_ENDIAN_SELECT(2,0), DtB(->key
), (-(BCBIAS_J
*4 >> 16) & 65535));
7171 dasm_put(Dst
, 5676, -8+LJ_ENDIAN_SELECT(0,4));
7175 dasm_put(Dst
, 5679, -24+LJ_ENDIAN_SELECT(4,0), -24+LJ_ENDIAN_SELECT(0,4), -16+LJ_ENDIAN_SELECT(4,0), -8+LJ_ENDIAN_SELECT(4,0), LJ_TFUNC
, -LJ_TTAB
, Dt8(->ffid
), -LJ_TNIL
, -FF_next_N
, (-(BCBIAS_J
*4 >> 16) & 65535), -8+LJ_ENDIAN_SELECT(0,4), BC_JMP
, BC_ITERC
, -4+LJ_ENDIAN_SELECT(0,3), LJ_ENDIAN_SELECT(0,3));
7179 dasm_put(Dst
, 5736, LJ_ENDIAN_SELECT(-4,-8), FRAME_VARG
, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), Dt1(->maxstack
), DISPATCH_GOT(lj_state_growstack
), Dt1(->top
), Dt1(->base
), Dt1(->base
));
7180 dasm_put(Dst
, 5823);
7183 /* -- Returns ----------------------------------------------------------- */
7186 dasm_put(Dst
, 5825);
7190 dasm_put(Dst
, 5827, LJ_ENDIAN_SELECT(-4,-8), FRAME_TYPE
, FRAME_VARG
, LJ_ENDIAN_SELECT(-8,-4), Dt7(->pc
), PC2PROTO(k
), LJ_ENDIAN_SELECT(4,0), FRAME_TYPEP
, LJ_ENDIAN_SELECT(-4,-8));
7193 case BC_RET0
: case BC_RET1
:
7194 dasm_put(Dst
, 5899, LJ_ENDIAN_SELECT(-4,-8), FRAME_TYPE
, FRAME_VARG
);
7195 if (op
== BC_RET1
) {
7196 dasm_put(Dst
, 5912);
7198 dasm_put(Dst
, 5914);
7199 if (op
== BC_RET1
) {
7200 dasm_put(Dst
, 5919);
7202 dasm_put(Dst
, 5921, LJ_ENDIAN_SELECT(-8,-4), Dt7(->pc
), PC2PROTO(k
));
7203 if (op
== BC_RET1
) {
7204 dasm_put(Dst
, 5949, LJ_ENDIAN_SELECT(4,0));
7206 dasm_put(Dst
, 5952, -8+LJ_ENDIAN_SELECT(4,0));
7210 /* -- Loops and branches ------------------------------------------------ */
7214 dasm_put(Dst
, 5955, GG_DISP2HOT
, -HOTCOUNT_LOOP
, GG_DISP2HOT
);
7225 vk
= (op
== BC_IFORL
|| op
== BC_JFORL
);
7226 dasm_put(Dst
, 5967);
7228 dasm_put(Dst
, 5969, FORL_IDX
*8, FORL_STEP
*8, FORL_STOP
*8, FORL_STEP
*8+LJ_ENDIAN_SELECT(4,0), FORL_IDX
*8);
7230 dasm_put(Dst
, 5981, FORL_IDX
*8+LJ_ENDIAN_SELECT(4,0), FORL_STEP
*8+LJ_ENDIAN_SELECT(4,0), FORL_STOP
*8+LJ_ENDIAN_SELECT(4,0), LJ_TISNUM
, LJ_TISNUM
, LJ_TISNUM
, FORL_IDX
*8, FORL_STOP
*8);
7232 if (op
!= BC_JFORL
) {
7233 dasm_put(Dst
, 6002, (-(BCBIAS_J
*4 >> 16) & 65535));
7235 dasm_put(Dst
, 6006, FORL_EXT
*8);
7236 if (op
== BC_JFORI
) {
7237 dasm_put(Dst
, 6011, -4+LJ_ENDIAN_SELECT(2,0), BC_JLOOP
);
7238 } else if (op
== BC_JFORL
) {
7239 dasm_put(Dst
, 6025, BC_JLOOP
);
7241 dasm_put(Dst
, 6035);
7242 if (op
== BC_FORI
) {
7243 dasm_put(Dst
, 6039);
7245 dasm_put(Dst
, 6042);
7247 dasm_put(Dst
, 6045);
7249 dasm_put(Dst
, 6048);
7254 dasm_put(Dst
, 6060, GG_DISP2HOT
, -HOTCOUNT_LOOP
, GG_DISP2HOT
);
7263 dasm_put(Dst
, 6072, LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4));
7264 if (op
== BC_JITERL
) {
7265 dasm_put(Dst
, 6080, -8+LJ_ENDIAN_SELECT(4,0), BC_JLOOP
, -8+LJ_ENDIAN_SELECT(0,4));
7267 dasm_put(Dst
, 6087, (-(BCBIAS_J
*4 >> 16) & 65535), -8+LJ_ENDIAN_SELECT(4,0), -8+LJ_ENDIAN_SELECT(0,4));
7269 dasm_put(Dst
, 6097);
7274 dasm_put(Dst
, 6110, GG_DISP2HOT
, -HOTCOUNT_LOOP
, GG_DISP2HOT
);
7279 dasm_put(Dst
, 6122);
7284 dasm_put(Dst
, 6134, DISPATCH_J(trace
), DISPATCH_GL(vmstate
), DISPATCH_GL(jit_base
), DISPATCH_GL(jit_L
), DtD(->mcode
), GG_DISP2G
+32768);
7289 dasm_put(Dst
, 6152, (-(BCBIAS_J
*4 >> 16) & 65535));
7292 /* -- Function headers -------------------------------------------------- */
7296 dasm_put(Dst
, 6169, GG_DISP2HOT
, -HOTCOUNT_CALL
, GG_DISP2HOT
);
7298 case BC_FUNCV
: /* NYI: compiled vararg functions. */
7306 dasm_put(Dst
, 6181, Dt1(->maxstack
), -4+PC2PROTO(numparams
), -4+PC2PROTO(k
));
7307 if (op
!= BC_JFUNCF
) {
7308 dasm_put(Dst
, 6192);
7310 dasm_put(Dst
, 6195);
7311 if (op
== BC_JFUNCF
) {
7312 dasm_put(Dst
, 6201, BC_JLOOP
);
7314 dasm_put(Dst
, 6206);
7316 dasm_put(Dst
, 6216, LJ_ENDIAN_SELECT(4,0));
7323 dasm_put(Dst
, 6223);
7324 break; /* NYI: compiled vararg functions. */
7327 dasm_put(Dst
, 6225, Dt1(->maxstack
), LJ_ENDIAN_SELECT(0,4), 8+FRAME_VARG
, -4+PC2PROTO(k
), LJ_ENDIAN_SELECT(4,0), -4+PC2PROTO(numparams
), LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(0,4), 8+LJ_ENDIAN_SELECT(0,4), 8+LJ_ENDIAN_SELECT(4,0), LJ_ENDIAN_SELECT(4,0));
7332 if (op
== BC_FUNCC
) {
7333 dasm_put(Dst
, 6280, Dt8(->f
));
7335 dasm_put(Dst
, 6283, DISPATCH_GL(wrapf
));
7337 dasm_put(Dst
, 6286, Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), ~LJ_VMST_C
);
7338 if (op
== BC_FUNCCW
) {
7339 dasm_put(Dst
, 6298, Dt8(->f
));
7341 dasm_put(Dst
, 6301, DISPATCH_GL(vmstate
), Dt1(->base
), Dt1(->top
), ~LJ_VMST_INTERP
, LJ_ENDIAN_SELECT(-4,-8), DISPATCH_GL(vmstate
));
7344 /* ---------------------------------------------------------------------- */
7347 fprintf(stderr
, "Error: undefined opcode BC_%s\n", bc_names
[op
]);
7353 static int build_backend(BuildCtx
*ctx
)
7357 dasm_growpc(Dst
, BC__MAX
);
7359 build_subroutines(ctx
);
7361 dasm_put(Dst
, 6322);
7362 for (op
= 0; op
< BC__MAX
; op
++)
7363 build_ins(ctx
, (BCOp
)op
, op
);
7368 /* Emit pseudo frame-info for all assembler functions. */
7369 static void emit_asm_debug(BuildCtx
*ctx
)
7371 int fcofs
= (int)((uint8_t *)ctx
->glob
[GLOB_vm_ffi_call
] - ctx
->code
);
7373 switch (ctx
->mode
) {
7375 fprintf(ctx
->fp
, "\t.section .debug_frame,\"\",@progbits\n");
7378 "\t.4byte .LECIE0-.LSCIE0\n"
7380 "\t.4byte 0xffffffff\n"
7386 "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n"
7391 "\t.4byte .LEFDE0-.LASFDE0\n"
7393 "\t.4byte .Lframe0\n"
7394 "\t.4byte .Lbegin\n"
7396 "\t.byte 0xe\n\t.uleb128 %d\n"
7397 "\t.byte 0x9f\n\t.sleb128 1\n"
7398 "\t.byte 0x9e\n\t.sleb128 2\n",
7399 fcofs
, CFRAME_SIZE
);
7400 for (i
= 23; i
>= 16; i
--)
7401 fprintf(ctx
->fp
, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i
, 26-i
);
7402 for (i
= 30; i
>= 20; i
-= 2)
7403 fprintf(ctx
->fp
, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i
, 42-i
);
7410 "\t.4byte .LEFDE1-.LASFDE1\n"
7412 "\t.4byte .Lframe0\n"
7413 "\t.4byte lj_vm_ffi_call\n"
7415 "\t.byte 0x9f\n\t.uleb128 1\n"
7416 "\t.byte 0x90\n\t.uleb128 2\n"
7417 "\t.byte 0xd\n\t.uleb128 0x10\n"
7419 ".LEFDE1:\n\n", (int)ctx
->codesz
- fcofs
);
7421 fprintf(ctx
->fp
, "\t.section .eh_frame,\"aw\",@progbits\n");
7423 "\t.globl lj_err_unwind_dwarf\n"
7425 "\t.4byte .LECIE1-.LSCIE1\n"
7429 "\t.string \"zPR\"\n"
7433 "\t.uleb128 6\n" /* augmentation length */
7435 "\t.4byte lj_err_unwind_dwarf\n"
7437 "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n"
7442 "\t.4byte .LEFDE2-.LASFDE2\n"
7444 "\t.4byte .LASFDE2-.Lframe1\n"
7445 "\t.4byte .Lbegin\n"
7447 "\t.uleb128 0\n" /* augmentation length */
7448 "\t.byte 0xe\n\t.uleb128 %d\n"
7449 "\t.byte 0x9f\n\t.sleb128 1\n"
7450 "\t.byte 0x9e\n\t.sleb128 2\n",
7451 fcofs
, CFRAME_SIZE
);
7452 for (i
= 23; i
>= 16; i
--)
7453 fprintf(ctx
->fp
, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i
, 26-i
);
7454 for (i
= 30; i
>= 20; i
-= 2)
7455 fprintf(ctx
->fp
, "\t.byte %d\n\t.uleb128 %d\n", 0x80+32+i
, 42-i
);
7462 "\t.4byte .LECIE2-.LSCIE2\n"
7466 "\t.string \"zR\"\n"
7470 "\t.uleb128 1\n" /* augmentation length */
7472 "\t.byte 0xc\n\t.uleb128 29\n\t.uleb128 0\n"
7477 "\t.4byte .LEFDE3-.LASFDE3\n"
7479 "\t.4byte .LASFDE3-.Lframe2\n"
7480 "\t.4byte lj_vm_ffi_call\n"
7482 "\t.uleb128 0\n" /* augmentation length */
7483 "\t.byte 0x9f\n\t.uleb128 1\n"
7484 "\t.byte 0x90\n\t.uleb128 2\n"
7485 "\t.byte 0xd\n\t.uleb128 0x10\n"
7487 ".LEFDE3:\n\n", (int)ctx
->codesz
- fcofs
);