2 ** This file has been pre-processed with DynASM.
3 ** http://luajit.org/dynasm.html
4 ** DynASM version 1.3.0, DynASM ppc version 1.3.0
5 ** DO NOT EDIT! The original file is in "buildvm_ppcspe.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
[4992] = {
5019 GLOB_vm_unwind_c_eh
,
5021 GLOB_vm_unwind_ff_eh
,
5022 GLOB_vm_growstack_c
,
5023 GLOB_vm_growstack_l
,
5027 GLOB_vm_call_dispatch
,
5029 GLOB_vm_call_dispatch_f
,
5049 GLOB_vmeta_arith_vn
,
5050 GLOB_vmeta_arith_nv
,
5052 GLOB_vmeta_arith_vv
,
5063 GLOB_ff_getmetatable
,
5064 GLOB_ff_setmetatable
,
5075 GLOB_ff_coroutine_resume
,
5076 GLOB_ff_coroutine_wrap_aux
,
5077 GLOB_ff_coroutine_yield
,
5108 GLOB_ff_string_byte
,
5109 GLOB_ff_string_char
,
5113 GLOB_ff_string_reverse
,
5114 GLOB_ff_string_lower
,
5115 GLOB_ff_string_upper
,
5126 GLOB_ff_bit_arshift
,
5136 GLOB_vm_exit_handler
,
5137 GLOB_vm_exit_interp
,
5153 static const char *const globnames
[] = {
5172 "vm_call_dispatch_f",
5218 "ff_coroutine_resume",
5219 "ff_coroutine_wrap_aux",
5220 "ff_coroutine_yield",
5256 "ff_string_reverse",
5296 static const char *const extnames
[] = {
5297 "lj_state_growstack",
5310 "lj_ffh_coroutine_wrap_err",
5341 "lj_gc_step_fixtop",
5346 #define Dt1(_V) (int)(ptrdiff_t)&(((lua_State *)0)_V)
5347 #define Dt2(_V) (int)(ptrdiff_t)&(((global_State *)0)_V)
5348 #define Dt3(_V) (int)(ptrdiff_t)&(((TValue *)0)_V)
5349 #define Dt4(_V) (int)(ptrdiff_t)&(((GCobj *)0)_V)
5350 #define Dt5(_V) (int)(ptrdiff_t)&(((GCstr *)0)_V)
5351 #define Dt6(_V) (int)(ptrdiff_t)&(((GCtab *)0)_V)
5352 #define Dt7(_V) (int)(ptrdiff_t)&(((GCfuncL *)0)_V)
5353 #define Dt8(_V) (int)(ptrdiff_t)&(((GCfuncC *)0)_V)
5354 #define Dt9(_V) (int)(ptrdiff_t)&(((GCproto *)0)_V)
5355 #define DtA(_V) (int)(ptrdiff_t)&(((GCupval *)0)_V)
5356 #define DtB(_V) (int)(ptrdiff_t)&(((Node *)0)_V)
5357 #define DtC(_V) (int)(ptrdiff_t)&(((int *)0)_V)
5358 #define DtD(_V) (int)(ptrdiff_t)&(((GCtrace *)0)_V)
5359 #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field))
5360 #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field))
5361 #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto))
5363 /* Generate subroutines used by opcodes and other parts of the VM. */
5364 /* The .code_sub section should be last to help static branch prediction. */
5365 static void build_subroutines(BuildCtx
*ctx
)
5368 dasm_put(Dst
, 1, FRAME_P
, LJ_TTRUE
, FRAME_TYPE
, FRAME_C
, ~LJ_VMST_C
, Dt1(->base
), DISPATCH_GL(vmstate
), 31-3, Dt1(->top
));
5369 dasm_put(Dst
, 55, Dt1(->cframe
), Dt1(->maxstack
), Dt1(->top
), 31-3, Dt1(->top
), ~LJ_VMST_C
, Dt1(->glref
), Dt2(->vmstate
));
5370 dasm_put(Dst
, 133, LJ_TISNUM
+1, LJ_TFUNC
, LJ_TTAB
, Dt1(->base
), Dt1(->glref
), LJ_TSTR
, LJ_TFALSE
, LJ_TNIL
, ~LJ_VMST_INTERP
, GG_G2DISP
, DISPATCH_GL(vmstate
), LUA_MINSTACK
, Dt1(->base
), Dt1(->top
), 32-3);
5371 dasm_put(Dst
, 188, Dt1(->base
), Dt1(->top
), Dt7(->pc
), Dt1(->glref
), Dt1(->status
), FRAME_CP
, CFRAME_RESUME
, GG_G2DISP
, Dt1(->cframe
), Dt1(->base
), LJ_TISNUM
+1, Dt1(->top
), LJ_TFUNC
, LJ_TTAB
, LJ_TSTR
, Dt1(->status
), FRAME_TYPE
, ~LJ_VMST_INTERP
, LJ_TNIL
, DISPATCH_GL(vmstate
));
5372 dasm_put(Dst
, 279, FRAME_CP
, FRAME_C
, Dt1(->cframe
), Dt1(->cframe
), Dt1(->glref
), GG_G2DISP
, Dt1(->base
), LJ_TISNUM
+1, Dt1(->top
), LJ_TFUNC
, LJ_TTAB
, LJ_TSTR
, ~LJ_VMST_INTERP
, LJ_TNIL
, DISPATCH_GL(vmstate
));
5373 dasm_put(Dst
, 376, Dt7(->pc
), Dt1(->stack
), Dt1(->top
), Dt1(->cframe
), Dt1(->cframe
), Dt1(->glref
), FRAME_CP
, GG_G2DISP
, Dt7(->pc
), PC2PROTO(k
), Dt1(->base
));
5374 dasm_put(Dst
, 481, DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv2
), DISPATCH_GL(tmptv
), Dt1(->base
), FRAME_CONT
, Dt1(->top
), DISPATCH_GL(tmptv
));
5375 dasm_put(Dst
, 556, DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv2
), DISPATCH_GL(tmptv
), Dt1(->base
), FRAME_CONT
, Dt1(->top
), Dt1(->base
));
5376 dasm_put(Dst
, 637, -(BCBIAS_J
*4 >> 16), LJ_TTRUE
, LJ_TFALSE
, Dt1(->base
));
5377 dasm_put(Dst
, 706, Dt1(->base
), FRAME_CONT
);
5378 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5381 dasm_put(Dst
, 730, Dt1(->base
));
5382 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5387 dasm_put(Dst
, 748, Dt1(->base
), Dt7(->pc
), Dt1(->base
), Dt1(->base
));
5393 dasm_put(Dst
, 800, BC_JFORI
);
5397 dasm_put(Dst
, 805, BC_JFORI
);
5399 dasm_put(Dst
, 808, BC_FORI
, ~LJ_TNUMX
, 31-3, Dt8(->upvalue
), Dt6(->metatable
), DISPATCH_GL(gcroot
[GCROOT_MMNAME
+MM_metatable
]));
5400 dasm_put(Dst
, 873, Dt6(->hmask
), Dt5(->hash
), Dt6(->node
), 31-5, 31-3, DtB(->key
), DtB(->val
), DtB(->next
), LJ_TUDATA
, 31-2, 4*~LJ_TNUMX
, DISPATCH_GL(gcroot
[GCROOT_BASEMT
]));
5401 dasm_put(Dst
, 929, Dt6(->metatable
), Dt6(->marked
), LJ_GC_BLACK
, Dt6(->metatable
), DISPATCH_GL(gc
.grayagain
), DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
5402 dasm_put(Dst
, 989, DISPATCH_GL(gcroot
[GCROOT_BASEMT_NUM
]), Dt1(->base
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), Dt1(->base
), Dt1(->top
), (2+1)*8);
5403 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5404 dasm_put(Dst
, 1062, Dt6(->metatable
), Dt8(->upvalue
[0]));
5406 dasm_put(Dst
, 1071, Dt8(->upvalue
[0]));
5408 dasm_put(Dst
, 1075, (3+1)*8, Dt6(->asize
), Dt6(->array
), 31-3, (0+1)*8, (2+1)*8, Dt6(->hmask
), (0+1)*8, (0+1)*8);
5409 dasm_put(Dst
, 1139);
5410 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5411 dasm_put(Dst
, 1152, Dt6(->metatable
), Dt8(->upvalue
[0]));
5413 dasm_put(Dst
, 1161, Dt8(->upvalue
[0]));
5415 dasm_put(Dst
, 1165, (3+1)*8, DISPATCH_GL(hookmask
), 32-HOOK_ACTIVE_SHIFT
, 8+FRAME_PCALL
, DISPATCH_GL(hookmask
), 32-HOOK_ACTIVE_SHIFT
, 16+FRAME_PCALL
, LJ_TTHREAD
, Dt1(->status
), Dt1(->cframe
), Dt1(->top
));
5416 dasm_put(Dst
, 1226, LUA_YIELD
, Dt1(->base
), Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), Dt1(->top
), Dt1(->base
), LUA_YIELD
, Dt1(->top
), ~LJ_VMST_INTERP
, Dt1(->base
), DISPATCH_GL(vmstate
), Dt1(->maxstack
));
5417 dasm_put(Dst
, 1289, Dt1(->top
), FRAME_TYPE
, LJ_TTRUE
, FRAME_TYPE
, LJ_TFALSE
, Dt1(->top
), (2+1)*8, 32-3);
5418 dasm_put(Dst
, 1349, Dt8(->upvalue
[0].gcr
), Dt1(->status
), Dt1(->cframe
), Dt1(->top
), LUA_YIELD
, Dt1(->base
), Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), Dt1(->top
), Dt1(->base
), LUA_YIELD
, Dt1(->top
), ~LJ_VMST_INTERP
);
5419 dasm_put(Dst
, 1408, Dt1(->base
), DISPATCH_GL(vmstate
), Dt1(->maxstack
), Dt1(->top
), FRAME_TYPE
, 32-3, Dt1(->cframe
));
5420 dasm_put(Dst
, 1465, Dt1(->base
), CFRAME_RESUME
, Dt1(->top
), LUA_YIELD
, Dt1(->cframe
), Dt1(->status
), (1+1)*8, FRAME_TYPE
);
5421 dasm_put(Dst
, 1530);
5422 dasm_put(Dst
, 1599);
5423 dasm_put(Dst
, 1662);
5424 dasm_put(Dst
, 1727);
5425 dasm_put(Dst
, 1797, Dt8(->upvalue
[0]), DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv
), (2+1)*8, (2+1)*8);
5426 dasm_put(Dst
, 1869, Dt5(->len
));
5427 dasm_put(Dst
, 1936, Dt5(->len
), (0+1)*8, Dt5([1]), (1+1)*8, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), DISPATCH_GL(tmptv
), Dt1(->base
), Dt1(->base
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
));
5428 dasm_put(Dst
, 1996, Dt5(->len
), sizeof(GCstr
)-1, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
));
5429 dasm_put(Dst
, 2062, Dt5(->len
), DISPATCH_GL(tmpbuf
.sz
), Dt5([1]), DISPATCH_GL(tmpbuf
.buf
), DISPATCH_GL(strempty
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
));
5430 dasm_put(Dst
, 2121, DISPATCH_GL(tmpbuf
.sz
), Dt5(->len
), sizeof(GCstr
), DISPATCH_GL(tmpbuf
.buf
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), DISPATCH_GL(tmpbuf
.sz
), Dt5(->len
), sizeof(GCstr
), DISPATCH_GL(tmpbuf
.buf
));
5431 dasm_put(Dst
, 2180, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), DISPATCH_GL(tmpbuf
.sz
), Dt5(->len
), sizeof(GCstr
), DISPATCH_GL(tmpbuf
.buf
));
5432 dasm_put(Dst
, 2247);
5433 dasm_put(Dst
, 2318);
5434 dasm_put(Dst
, 2406, Dt8(->f
), 8*LUA_MINSTACK
, Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), Dt1(->base
), 31-3, Dt1(->top
), Dt7(->pc
));
5435 dasm_put(Dst
, 2485, FRAME_TYPE
, LUA_MINSTACK
, Dt1(->base
), Dt1(->base
), Dt1(->top
), Dt1(->base
), Dt1(->top
));
5437 dasm_put(Dst
, 2527);
5439 dasm_put(Dst
, 2529, DISPATCH_GL(hookmask
), HOOK_ACTIVE
, GG_DISP2STATIC
, DISPATCH_GL(hookmask
), DISPATCH_GL(hookcount
), HOOK_ACTIVE
, 31-LUA_HOOKLINE
, DISPATCH_GL(hookcount
), Dt1(->base
), Dt1(->base
));
5440 dasm_put(Dst
, 2576, GG_DISP2STATIC
);
5442 dasm_put(Dst
, 2594);
5444 dasm_put(Dst
, 2596);
5446 dasm_put(Dst
, 2599);
5448 dasm_put(Dst
, 2602);
5450 dasm_put(Dst
, 2604);
5452 dasm_put(Dst
, 2607, Dt1(->base
), Dt1(->top
), Dt1(->base
), Dt1(->top
));
5454 dasm_put(Dst
, 2629);
5456 dasm_put(Dst
, 2631);
5458 dasm_put(Dst
, 2633);
5460 dasm_put(Dst
, 2635);
5462 dasm_put(Dst
, 2719);
5464 dasm_put(Dst
, 2742);
5466 dasm_put(Dst
, 2745);
5468 dasm_put(Dst
, 2747);
5470 dasm_put(Dst
, 2749);
5472 dasm_put(Dst
, 2751);
5474 dasm_put(Dst
, 2753);
5476 dasm_put(Dst
, 2816);
5480 /* Generate the code for a single instruction. */
5481 static void build_ins(BuildCtx
*ctx
, BCOp op
, int defop
)
5484 dasm_put(Dst
, 2818, defop
);
5488 /* -- Comparison ops ---------------------------------------------------- */
5490 /* Remember: all ops branch for a true comparison, fall through otherwise. */
5492 case BC_ISLT
: case BC_ISGE
: case BC_ISLE
: case BC_ISGT
:
5493 dasm_put(Dst
, 2820, -(BCBIAS_J
*4 >> 16));
5494 if (op
== BC_ISLE
|| op
== BC_ISGT
) {
5495 dasm_put(Dst
, 2834);
5497 if (op
== BC_ISLT
|| op
== BC_ISLE
) {
5498 dasm_put(Dst
, 2837);
5500 dasm_put(Dst
, 2839);
5502 dasm_put(Dst
, 2841);
5505 case BC_ISEQV
: case BC_ISNEV
:
5506 vk
= op
== BC_ISEQV
;
5507 dasm_put(Dst
, 2852, -(BCBIAS_J
*4 >> 16));
5509 dasm_put(Dst
, 2866);
5511 dasm_put(Dst
, 2868);
5513 dasm_put(Dst
, 2870, ~LJ_TISPRI
, ~LJ_TISTABUD
);
5515 dasm_put(Dst
, 2892);
5517 dasm_put(Dst
, 2894);
5519 dasm_put(Dst
, 2896);
5521 dasm_put(Dst
, 2898);
5523 dasm_put(Dst
, 2900);
5525 dasm_put(Dst
, 2902, Dt6(->metatable
), 1-vk
, Dt6(->nomm
), 1<<MM_eq
);
5528 case BC_ISEQS
: case BC_ISNES
:
5529 vk
= op
== BC_ISEQS
;
5530 dasm_put(Dst
, 2923, 32-1, -(BCBIAS_J
*4 >> 16));
5532 dasm_put(Dst
, 2937);
5534 dasm_put(Dst
, 2939);
5536 dasm_put(Dst
, 2941);
5539 case BC_ISEQN
: case BC_ISNEN
:
5540 vk
= op
== BC_ISEQN
;
5541 dasm_put(Dst
, 2952, -(BCBIAS_J
*4 >> 16));
5543 dasm_put(Dst
, 2966);
5545 dasm_put(Dst
, 2969);
5547 dasm_put(Dst
, 2971);
5549 dasm_put(Dst
, 2983);
5553 case BC_ISEQP
: case BC_ISNEP
:
5554 vk
= op
== BC_ISEQP
;
5555 dasm_put(Dst
, 2989, 32-3, -(BCBIAS_J
*4 >> 16));
5557 dasm_put(Dst
, 3001);
5559 dasm_put(Dst
, 3003);
5561 dasm_put(Dst
, 3005);
5564 /* -- Unary test and copy ops ------------------------------------------- */
5566 case BC_ISTC
: case BC_ISFC
: case BC_IST
: case BC_ISF
:
5567 dasm_put(Dst
, 3016);
5568 if (op
== BC_IST
|| op
== BC_ISF
) {
5569 dasm_put(Dst
, 3022, -(BCBIAS_J
*4 >> 16));
5571 dasm_put(Dst
, 3027);
5573 dasm_put(Dst
, 3029);
5576 if (op
== BC_ISTC
) {
5577 dasm_put(Dst
, 3031);
5579 dasm_put(Dst
, 3034);
5581 dasm_put(Dst
, 3037, -(BCBIAS_J
*4 >> 16));
5583 dasm_put(Dst
, 3044);
5586 /* -- Unary ops --------------------------------------------------------- */
5589 dasm_put(Dst
, 3055);
5592 dasm_put(Dst
, 3068, LJ_TTRUE
);
5595 dasm_put(Dst
, 3084);
5598 dasm_put(Dst
, 3101, Dt5(->len
));
5599 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5600 dasm_put(Dst
, 3125, Dt6(->metatable
));
5602 dasm_put(Dst
, 3132);
5603 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5604 dasm_put(Dst
, 3138, Dt6(->nomm
), 1<<MM_len
);
5608 /* -- Binary ops -------------------------------------------------------- */
5611 case BC_ADDVN
: case BC_ADDNV
: case BC_ADDVV
:
5612 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5615 dasm_put(Dst
, 3148);
5618 dasm_put(Dst
, 3154);
5621 dasm_put(Dst
, 3160);
5624 dasm_put(Dst
, 3167);
5626 case BC_SUBVN
: case BC_SUBNV
: case BC_SUBVV
:
5627 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5630 dasm_put(Dst
, 3180);
5633 dasm_put(Dst
, 3186);
5636 dasm_put(Dst
, 3192);
5639 dasm_put(Dst
, 3199);
5641 case BC_MULVN
: case BC_MULNV
: case BC_MULVV
:
5642 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5645 dasm_put(Dst
, 3212);
5648 dasm_put(Dst
, 3218);
5651 dasm_put(Dst
, 3224);
5654 dasm_put(Dst
, 3231);
5656 case BC_DIVVN
: case BC_DIVNV
: case BC_DIVVV
:
5657 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5660 dasm_put(Dst
, 3244);
5663 dasm_put(Dst
, 3250);
5666 dasm_put(Dst
, 3256);
5669 dasm_put(Dst
, 3263);
5672 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5675 dasm_put(Dst
, 3276);
5678 dasm_put(Dst
, 3282);
5681 dasm_put(Dst
, 3288);
5684 dasm_put(Dst
, 3295);
5686 case BC_MODNV
: case BC_MODVV
:
5687 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5690 dasm_put(Dst
, 3313);
5693 dasm_put(Dst
, 3319);
5696 dasm_put(Dst
, 3325);
5699 dasm_put(Dst
, 3332);
5702 dasm_put(Dst
, 3335);
5706 dasm_put(Dst
, 3357, Dt1(->base
), 32-3, Dt1(->base
));
5709 /* -- Constant ops ------------------------------------------------------ */
5712 dasm_put(Dst
, 3387, 32-1);
5716 dasm_put(Dst
, 3404, 32-1, LJ_TCDATA
);
5720 dasm_put(Dst
, 3423, 32-3);
5723 dasm_put(Dst
, 3439);
5726 dasm_put(Dst
, 3452, 32-3);
5729 dasm_put(Dst
, 3467);
5732 /* -- Upvalue and function ops ------------------------------------------ */
5735 dasm_put(Dst
, 3486, 32-1, offsetof(GCfuncL
, uvptr
), DtA(->v
));
5738 dasm_put(Dst
, 3507, 32-1, offsetof(GCfuncL
, uvptr
), DtA(->marked
), DtA(->v
), LJ_GC_BLACK
, DtA(->closed
), -(LJ_TISNUM
+1), LJ_TISGCV
- (LJ_TISNUM
+1), Dt4(->gch
.marked
), LJ_GC_WHITES
, GG_DISP2G
);
5741 dasm_put(Dst
, 3559, 32-1, 32-1, offsetof(GCfuncL
, uvptr
), DtA(->marked
), DtA(->v
), LJ_GC_BLACK
, Dt5(->marked
), DtA(->closed
), LJ_GC_WHITES
, GG_DISP2G
);
5744 dasm_put(Dst
, 3608, 32-1, offsetof(GCfuncL
, uvptr
), DtA(->v
));
5747 dasm_put(Dst
, 3629, 32-1, offsetof(GCfuncL
, uvptr
), 32-3, DtA(->v
));
5751 dasm_put(Dst
, 3652, Dt1(->openupval
), 32-1, -(BCBIAS_J
*4 >> 16), Dt1(->base
), Dt1(->base
));
5755 dasm_put(Dst
, 3682, 32-1, Dt1(->base
), Dt1(->base
));
5758 /* -- Table ops --------------------------------------------------------- */
5762 dasm_put(Dst
, 3708, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), Dt1(->base
));
5763 if (op
== BC_TNEW
) {
5764 dasm_put(Dst
, 3721);
5766 dasm_put(Dst
, 3729, 32-1);
5768 dasm_put(Dst
, 3736, Dt1(->base
));
5773 dasm_put(Dst
, 3759, 32-1, Dt7(->env
));
5774 if (op
== BC_GGET
) {
5775 dasm_put(Dst
, 3767);
5777 dasm_put(Dst
, 3770);
5782 dasm_put(Dst
, 3773, Dt6(->asize
), Dt6(->array
), 31-3, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_index
);
5785 dasm_put(Dst
, 3831, 32-1, Dt6(->hmask
), Dt5(->hash
), Dt6(->node
), 31-5, 31-3, DtB(->key
), DtB(->val
), DtB(->next
), Dt6(->metatable
), Dt6(->nomm
), 1<<MM_index
);
5786 dasm_put(Dst
, 3895);
5789 dasm_put(Dst
, 3900, 32-3, Dt6(->asize
), Dt6(->array
), Dt6(->metatable
), Dt6(->nomm
), 1<<MM_index
);
5793 dasm_put(Dst
, 3944, Dt6(->asize
), Dt6(->array
), 31-3, Dt6(->marked
), LJ_GC_BLACK
, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_newindex
);
5794 dasm_put(Dst
, 4011, DISPATCH_GL(gc
.grayagain
), DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
5797 dasm_put(Dst
, 4023, 32-1, Dt6(->hmask
), Dt5(->hash
), Dt6(->node
), Dt6(->nomm
), 31-5, 31-3, Dt6(->marked
), DtB(->key
), DtB(->val
), LJ_GC_BLACK
, DtB(->val
), Dt6(->metatable
));
5798 dasm_put(Dst
, 4084, Dt6(->nomm
), 1<<MM_newindex
, DtB(->next
), Dt6(->metatable
), DISPATCH_GL(tmptv
), Dt1(->base
), Dt6(->nomm
), 1<<MM_newindex
, Dt1(->base
), DISPATCH_GL(gc
.grayagain
), DISPATCH_GL(gc
.grayagain
));
5799 dasm_put(Dst
, 4135, Dt6(->marked
), Dt6(->gclist
));
5802 dasm_put(Dst
, 4142, 32-3, Dt6(->asize
), Dt6(->array
), Dt6(->marked
), LJ_GC_BLACK
, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_newindex
, DISPATCH_GL(gc
.grayagain
), DISPATCH_GL(gc
.grayagain
), Dt6(->marked
));
5803 dasm_put(Dst
, 4202, Dt6(->gclist
));
5807 dasm_put(Dst
, 4207, 32-3, Dt6(->asize
), 31-3, Dt6(->marked
), Dt6(->array
), LJ_GC_BLACK
, Dt1(->base
), DISPATCH_GL(gc
.grayagain
), DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
5808 dasm_put(Dst
, 4276);
5811 /* -- Calls and vararg handling ----------------------------------------- */
5814 dasm_put(Dst
, 4279);
5817 dasm_put(Dst
, 4281, Dt7(->pc
));
5821 dasm_put(Dst
, 4301);
5824 dasm_put(Dst
, 4303, FRAME_TYPE
, Dt7(->ffid
), FRAME_VARG
, Dt7(->pc
), -4-8, Dt7(->pc
), PC2PROTO(k
), FRAME_TYPEP
);
5825 dasm_put(Dst
, 4368, FRAME_TYPE
);
5829 dasm_put(Dst
, 4375, Dt7(->pc
));
5835 dasm_put(Dst
, 4401, Dt6(->asize
), Dt6(->array
), 31-3, -(BCBIAS_J
*4 >> 16), Dt6(->hmask
), Dt6(->node
), 31-5, 31-3, DtB(->key
), -(BCBIAS_J
*4 >> 16));
5836 dasm_put(Dst
, 4480);
5840 dasm_put(Dst
, 4484, LJ_TTAB
, LJ_TFUNC
, LJ_TNIL
, Dt8(->ffid
), FF_next_N
, 32-1, -(BCBIAS_J
*4 >> 16), BC_JMP
, BC_ITERC
, -(BCBIAS_J
*4 >> 16));
5844 dasm_put(Dst
, 4535, FRAME_VARG
, Dt1(->maxstack
), Dt1(->top
), Dt1(->base
), 32-3, Dt1(->base
));
5845 dasm_put(Dst
, 4615);
5848 /* -- Returns ----------------------------------------------------------- */
5851 dasm_put(Dst
, 4621);
5855 dasm_put(Dst
, 4623, FRAME_TYPE
, FRAME_VARG
, Dt7(->pc
), PC2PROTO(k
), FRAME_TYPEP
);
5858 case BC_RET0
: case BC_RET1
:
5859 dasm_put(Dst
, 4693, FRAME_TYPE
, FRAME_VARG
);
5860 if (op
== BC_RET1
) {
5861 dasm_put(Dst
, 4706);
5863 dasm_put(Dst
, 4709, Dt7(->pc
), PC2PROTO(k
));
5866 /* -- Loops and branches ------------------------------------------------ */
5870 dasm_put(Dst
, 4737);
5881 vk
= (op
== BC_IFORL
|| op
== BC_JFORL
);
5882 dasm_put(Dst
, 4739, FORL_IDX
*8, FORL_STEP
*8, FORL_STOP
*8);
5884 dasm_put(Dst
, 4747);
5887 dasm_put(Dst
, 4755, FORL_IDX
*8);
5889 dasm_put(Dst
, 4759, FORL_EXT
*8);
5890 if (op
!= BC_JFORL
) {
5891 dasm_put(Dst
, 4767, 32-1);
5892 if (op
== BC_JFORI
) {
5893 dasm_put(Dst
, 4771, -(BCBIAS_J
*4 >> 16));
5895 dasm_put(Dst
, 4774, -(BCBIAS_J
*4 >> 16));
5898 if (op
== BC_FORI
) {
5899 dasm_put(Dst
, 4777);
5900 } else if (op
== BC_IFORL
) {
5901 dasm_put(Dst
, 4779);
5903 dasm_put(Dst
, 4781, BC_JLOOP
);
5905 dasm_put(Dst
, 4784);
5910 dasm_put(Dst
, 4799);
5919 dasm_put(Dst
, 4801);
5920 if (op
== BC_JITERL
) {
5921 dasm_put(Dst
, 4807);
5923 dasm_put(Dst
, 4809, 32-1, -(BCBIAS_J
*4 >> 16));
5925 dasm_put(Dst
, 4816);
5930 dasm_put(Dst
, 4828);
5935 dasm_put(Dst
, 4830);
5940 dasm_put(Dst
, 4841);
5945 dasm_put(Dst
, 4843, 32-1, -(BCBIAS_J
*4 >> 16));
5948 /* -- Function headers -------------------------------------------------- */
5952 dasm_put(Dst
, 4859);
5954 case BC_FUNCV
: /* NYI: compiled vararg functions. */
5962 dasm_put(Dst
, 4861, Dt1(->maxstack
), -4+PC2PROTO(numparams
), -4+PC2PROTO(k
), 31-3);
5963 if (op
== BC_JFUNCF
) {
5964 dasm_put(Dst
, 4879);
5966 dasm_put(Dst
, 4881);
5968 dasm_put(Dst
, 4890);
5975 dasm_put(Dst
, 4896);
5976 break; /* NYI: compiled vararg functions. */
5979 dasm_put(Dst
, 4898, Dt1(->maxstack
), 8+FRAME_VARG
, -4+PC2PROTO(k
), -4+PC2PROTO(numparams
));
5984 if (op
== BC_FUNCC
) {
5985 dasm_put(Dst
, 4948, Dt8(->f
));
5987 dasm_put(Dst
, 4951, DISPATCH_GL(wrapf
));
5989 dasm_put(Dst
, 4954, Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), ~LJ_VMST_C
);
5990 if (op
== BC_FUNCCW
) {
5991 dasm_put(Dst
, 4967, Dt8(->f
));
5993 dasm_put(Dst
, 4970, DISPATCH_GL(vmstate
), Dt1(->top
), 31-3, Dt1(->base
), ~LJ_VMST_INTERP
, DISPATCH_GL(vmstate
));
5996 /* ---------------------------------------------------------------------- */
5999 fprintf(stderr
, "Error: undefined opcode BC_%s\n", bc_names
[op
]);
6005 static int build_backend(BuildCtx
*ctx
)
6009 dasm_growpc(Dst
, BC__MAX
);
6011 build_subroutines(ctx
);
6013 dasm_put(Dst
, 4991);
6014 for (op
= 0; op
< BC__MAX
; op
++)
6015 build_ins(ctx
, (BCOp
)op
, op
);
6020 /* Emit pseudo frame-info for all assembler functions. */
6021 static void emit_asm_debug(BuildCtx
*ctx
)
6024 switch (ctx
->mode
) {
6026 fprintf(ctx
->fp
, "\t.section .debug_frame,\"\",@progbits\n");
6029 "\t.long .LECIE0-.LSCIE0\n"
6031 "\t.long 0xffffffff\n"
6037 "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n"
6042 "\t.long .LEFDE0-.LASFDE0\n"
6044 "\t.long .Lframe0\n"
6047 "\t.byte 0xe\n\t.uleb128 %d\n"
6048 "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n",
6049 (int)ctx
->codesz
, CFRAME_SIZE
);
6050 for (i
= 14; i
<= 31; i
++)
6052 "\t.byte %d\n\t.uleb128 %d\n"
6053 "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n",
6054 0x80+i
, 1+2*(31-i
), 1200+i
, 2+2*(31-i
));
6058 fprintf(ctx
->fp
, "\t.section .eh_frame,\"a\",@progbits\n");
6061 "\t.long .LECIE1-.LSCIE1\n"
6065 "\t.string \"zPR\"\n"
6069 "\t.uleb128 6\n" /* augmentation length */
6070 "\t.byte 0x1b\n" /* pcrel|sdata4 */
6071 "\t.long lj_err_unwind_dwarf-.\n"
6072 "\t.byte 0x1b\n" /* pcrel|sdata4 */
6073 "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n"
6078 "\t.long .LEFDE1-.LASFDE1\n"
6080 "\t.long .LASFDE1-.Lframe1\n"
6081 "\t.long .Lbegin-.\n"
6083 "\t.uleb128 0\n" /* augmentation length */
6084 "\t.byte 0xe\n\t.uleb128 %d\n"
6085 "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n",
6086 (int)ctx
->codesz
, CFRAME_SIZE
);
6087 for (i
= 14; i
<= 31; i
++)
6089 "\t.byte %d\n\t.uleb128 %d\n"
6090 "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n",
6091 0x80+i
, 1+2*(31-i
), 1200+i
, 2+2*(31-i
));