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
[4995] = {
5022 GLOB_vm_unwind_c_eh
,
5024 GLOB_vm_unwind_ff_eh
,
5025 GLOB_vm_growstack_c
,
5026 GLOB_vm_growstack_l
,
5030 GLOB_vm_call_dispatch
,
5032 GLOB_vm_call_dispatch_f
,
5052 GLOB_vmeta_arith_vn
,
5053 GLOB_vmeta_arith_nv
,
5055 GLOB_vmeta_arith_vv
,
5066 GLOB_ff_getmetatable
,
5067 GLOB_ff_setmetatable
,
5078 GLOB_ff_coroutine_resume
,
5079 GLOB_ff_coroutine_wrap_aux
,
5080 GLOB_ff_coroutine_yield
,
5111 GLOB_ff_string_byte
,
5112 GLOB_ff_string_char
,
5116 GLOB_ff_string_reverse
,
5117 GLOB_ff_string_lower
,
5118 GLOB_ff_string_upper
,
5129 GLOB_ff_bit_arshift
,
5139 GLOB_vm_exit_handler
,
5140 GLOB_vm_exit_interp
,
5154 static const char *const globnames
[] = {
5173 "vm_call_dispatch_f",
5219 "ff_coroutine_resume",
5220 "ff_coroutine_wrap_aux",
5221 "ff_coroutine_yield",
5257 "ff_string_reverse",
5295 static const char *const extnames
[] = {
5296 "lj_state_growstack",
5309 "lj_ffh_coroutine_wrap_err",
5340 "lj_gc_step_fixtop",
5345 #define Dt1(_V) (int)(ptrdiff_t)&(((lua_State *)0)_V)
5346 #define Dt2(_V) (int)(ptrdiff_t)&(((global_State *)0)_V)
5347 #define Dt3(_V) (int)(ptrdiff_t)&(((TValue *)0)_V)
5348 #define Dt4(_V) (int)(ptrdiff_t)&(((GCobj *)0)_V)
5349 #define Dt5(_V) (int)(ptrdiff_t)&(((GCstr *)0)_V)
5350 #define Dt6(_V) (int)(ptrdiff_t)&(((GCtab *)0)_V)
5351 #define Dt7(_V) (int)(ptrdiff_t)&(((GCfuncL *)0)_V)
5352 #define Dt8(_V) (int)(ptrdiff_t)&(((GCfuncC *)0)_V)
5353 #define Dt9(_V) (int)(ptrdiff_t)&(((GCproto *)0)_V)
5354 #define DtA(_V) (int)(ptrdiff_t)&(((GCupval *)0)_V)
5355 #define DtB(_V) (int)(ptrdiff_t)&(((Node *)0)_V)
5356 #define DtC(_V) (int)(ptrdiff_t)&(((int *)0)_V)
5357 #define DtD(_V) (int)(ptrdiff_t)&(((GCtrace *)0)_V)
5358 #define DISPATCH_GL(field) (GG_DISP2G + (int)offsetof(global_State, field))
5359 #define DISPATCH_J(field) (GG_DISP2J + (int)offsetof(jit_State, field))
5360 #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto))
5362 /* Generate subroutines used by opcodes and other parts of the VM. */
5363 /* The .code_sub section should be last to help static branch prediction. */
5364 static void build_subroutines(BuildCtx
*ctx
)
5367 dasm_put(Dst
, 1, FRAME_P
, LJ_TTRUE
, FRAME_TYPE
, FRAME_C
, ~LJ_VMST_C
, Dt1(->base
), DISPATCH_GL(vmstate
), 31-3, Dt1(->top
));
5368 dasm_put(Dst
, 55, Dt1(->cframe
), Dt1(->maxstack
), Dt1(->top
), 31-3, Dt1(->top
), ~LJ_VMST_C
, Dt1(->glref
), Dt2(->vmstate
));
5369 dasm_put(Dst
, 135, 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);
5370 dasm_put(Dst
, 190, 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
));
5371 dasm_put(Dst
, 283, 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
));
5372 dasm_put(Dst
, 384, Dt7(->pc
), Dt1(->stack
), Dt1(->top
), Dt1(->cframe
), Dt1(->cframe
), Dt1(->glref
), FRAME_CP
, GG_G2DISP
, Dt7(->pc
), PC2PROTO(k
), Dt1(->base
));
5373 dasm_put(Dst
, 491, DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv2
), DISPATCH_GL(tmptv
), Dt1(->base
), FRAME_CONT
, Dt1(->top
), DISPATCH_GL(tmptv
));
5374 dasm_put(Dst
, 566, DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv2
), DISPATCH_GL(tmptv
), Dt1(->base
), FRAME_CONT
, Dt1(->top
), Dt1(->base
));
5375 dasm_put(Dst
, 647, -(BCBIAS_J
*4 >> 16), LJ_TTRUE
, LJ_TFALSE
, Dt1(->base
));
5376 dasm_put(Dst
, 716, Dt1(->base
), FRAME_CONT
);
5377 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5380 dasm_put(Dst
, 741, Dt1(->base
));
5381 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5386 dasm_put(Dst
, 759, Dt1(->base
), Dt7(->pc
), Dt1(->base
), Dt1(->base
));
5392 dasm_put(Dst
, 811, BC_JFORI
);
5396 dasm_put(Dst
, 816, BC_JFORI
);
5398 dasm_put(Dst
, 819, BC_FORI
, ~LJ_TNUMX
, 31-3, Dt8(->upvalue
), Dt6(->metatable
), DISPATCH_GL(gcroot
[GCROOT_MMNAME
+MM_metatable
]));
5399 dasm_put(Dst
, 884, 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
]));
5400 dasm_put(Dst
, 940, Dt6(->metatable
), Dt6(->marked
), LJ_GC_BLACK
, Dt6(->metatable
), DISPATCH_GL(gc
.grayagain
), DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
5401 dasm_put(Dst
, 1000, DISPATCH_GL(gcroot
[GCROOT_BASEMT_NUM
]), Dt1(->base
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), Dt1(->base
), Dt1(->top
), (2+1)*8);
5402 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5403 dasm_put(Dst
, 1073, Dt6(->metatable
), Dt8(->upvalue
[0]));
5405 dasm_put(Dst
, 1082, Dt8(->upvalue
[0]));
5407 dasm_put(Dst
, 1086, (3+1)*8, Dt6(->asize
), Dt6(->array
), 31-3, (0+1)*8, (2+1)*8, Dt6(->hmask
), (0+1)*8, (0+1)*8);
5408 dasm_put(Dst
, 1150);
5409 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5410 dasm_put(Dst
, 1163, Dt6(->metatable
), Dt8(->upvalue
[0]));
5412 dasm_put(Dst
, 1172, Dt8(->upvalue
[0]));
5414 dasm_put(Dst
, 1176, (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
));
5415 dasm_put(Dst
, 1237, 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
));
5416 dasm_put(Dst
, 1300, Dt1(->top
), FRAME_TYPE
, LJ_TTRUE
, FRAME_TYPE
, LJ_TFALSE
, Dt1(->top
), (2+1)*8, 32-3);
5417 dasm_put(Dst
, 1360, 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
);
5418 dasm_put(Dst
, 1419, Dt1(->base
), DISPATCH_GL(vmstate
), Dt1(->maxstack
), Dt1(->top
), FRAME_TYPE
, 32-3, Dt1(->cframe
));
5419 dasm_put(Dst
, 1476, Dt1(->base
), CFRAME_RESUME
, Dt1(->top
), LUA_YIELD
, Dt1(->cframe
), Dt1(->status
), (1+1)*8, FRAME_TYPE
);
5420 dasm_put(Dst
, 1541);
5421 dasm_put(Dst
, 1610);
5422 dasm_put(Dst
, 1673);
5423 dasm_put(Dst
, 1738);
5424 dasm_put(Dst
, 1808, Dt8(->upvalue
[0]), DISPATCH_GL(tmptv
), DISPATCH_GL(tmptv
), (2+1)*8, (2+1)*8);
5425 dasm_put(Dst
, 1880, Dt5(->len
));
5426 dasm_put(Dst
, 1947, 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
));
5427 dasm_put(Dst
, 2007, Dt5(->len
), sizeof(GCstr
)-1, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
));
5428 dasm_put(Dst
, 2073, Dt5(->len
), DISPATCH_GL(tmpbuf
.sz
), Dt5([1]), DISPATCH_GL(tmpbuf
.buf
), DISPATCH_GL(strempty
), DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
));
5429 dasm_put(Dst
, 2132, 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
));
5430 dasm_put(Dst
, 2191, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), DISPATCH_GL(tmpbuf
.sz
), Dt5(->len
), sizeof(GCstr
), DISPATCH_GL(tmpbuf
.buf
));
5431 dasm_put(Dst
, 2258);
5432 dasm_put(Dst
, 2329);
5433 dasm_put(Dst
, 2417, Dt8(->f
), 8*LUA_MINSTACK
, Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), Dt1(->base
), 31-3, Dt1(->top
), Dt7(->pc
));
5434 dasm_put(Dst
, 2496, FRAME_TYPE
, LUA_MINSTACK
, Dt1(->base
), Dt1(->base
), Dt1(->top
), Dt1(->base
), Dt1(->top
));
5436 dasm_put(Dst
, 2538);
5438 dasm_put(Dst
, 2540, 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
));
5439 dasm_put(Dst
, 2587, GG_DISP2STATIC
);
5441 dasm_put(Dst
, 2605);
5443 dasm_put(Dst
, 2607);
5445 dasm_put(Dst
, 2610);
5447 dasm_put(Dst
, 2613);
5449 dasm_put(Dst
, 2615);
5451 dasm_put(Dst
, 2618, Dt1(->base
), Dt1(->top
), Dt1(->base
), Dt1(->top
));
5453 dasm_put(Dst
, 2640);
5455 dasm_put(Dst
, 2642);
5457 dasm_put(Dst
, 2644);
5459 dasm_put(Dst
, 2646);
5461 dasm_put(Dst
, 2730);
5463 dasm_put(Dst
, 2753);
5465 dasm_put(Dst
, 2756);
5467 dasm_put(Dst
, 2819);
5471 /* Generate the code for a single instruction. */
5472 static void build_ins(BuildCtx
*ctx
, BCOp op
, int defop
)
5475 dasm_put(Dst
, 2821, defop
);
5479 /* -- Comparison ops ---------------------------------------------------- */
5481 /* Remember: all ops branch for a true comparison, fall through otherwise. */
5483 case BC_ISLT
: case BC_ISGE
: case BC_ISLE
: case BC_ISGT
:
5484 dasm_put(Dst
, 2823, -(BCBIAS_J
*4 >> 16));
5485 if (op
== BC_ISLE
|| op
== BC_ISGT
) {
5486 dasm_put(Dst
, 2837);
5488 if (op
== BC_ISLT
|| op
== BC_ISLE
) {
5489 dasm_put(Dst
, 2840);
5491 dasm_put(Dst
, 2842);
5493 dasm_put(Dst
, 2844);
5496 case BC_ISEQV
: case BC_ISNEV
:
5497 vk
= op
== BC_ISEQV
;
5498 dasm_put(Dst
, 2855, -(BCBIAS_J
*4 >> 16));
5500 dasm_put(Dst
, 2869);
5502 dasm_put(Dst
, 2871);
5504 dasm_put(Dst
, 2873, ~LJ_TISPRI
, ~LJ_TISTABUD
);
5506 dasm_put(Dst
, 2895);
5508 dasm_put(Dst
, 2897);
5510 dasm_put(Dst
, 2899);
5512 dasm_put(Dst
, 2901);
5514 dasm_put(Dst
, 2903);
5516 dasm_put(Dst
, 2905, Dt6(->metatable
), 1-vk
, Dt6(->nomm
), 1<<MM_eq
);
5519 case BC_ISEQS
: case BC_ISNES
:
5520 vk
= op
== BC_ISEQS
;
5521 dasm_put(Dst
, 2926, 32-1, -(BCBIAS_J
*4 >> 16));
5523 dasm_put(Dst
, 2940);
5525 dasm_put(Dst
, 2942);
5527 dasm_put(Dst
, 2944);
5530 case BC_ISEQN
: case BC_ISNEN
:
5531 vk
= op
== BC_ISEQN
;
5532 dasm_put(Dst
, 2955, -(BCBIAS_J
*4 >> 16));
5534 dasm_put(Dst
, 2969);
5536 dasm_put(Dst
, 2972);
5538 dasm_put(Dst
, 2974);
5540 dasm_put(Dst
, 2986);
5544 case BC_ISEQP
: case BC_ISNEP
:
5545 vk
= op
== BC_ISEQP
;
5546 dasm_put(Dst
, 2992, 32-3, -(BCBIAS_J
*4 >> 16));
5548 dasm_put(Dst
, 3004);
5550 dasm_put(Dst
, 3006);
5552 dasm_put(Dst
, 3008);
5555 /* -- Unary test and copy ops ------------------------------------------- */
5557 case BC_ISTC
: case BC_ISFC
: case BC_IST
: case BC_ISF
:
5558 dasm_put(Dst
, 3019);
5559 if (op
== BC_IST
|| op
== BC_ISF
) {
5560 dasm_put(Dst
, 3025, -(BCBIAS_J
*4 >> 16));
5562 dasm_put(Dst
, 3030);
5564 dasm_put(Dst
, 3032);
5567 if (op
== BC_ISTC
) {
5568 dasm_put(Dst
, 3034);
5570 dasm_put(Dst
, 3037);
5572 dasm_put(Dst
, 3040, -(BCBIAS_J
*4 >> 16));
5574 dasm_put(Dst
, 3047);
5577 /* -- Unary ops --------------------------------------------------------- */
5580 dasm_put(Dst
, 3058);
5583 dasm_put(Dst
, 3071, LJ_TTRUE
);
5586 dasm_put(Dst
, 3087);
5589 dasm_put(Dst
, 3104, Dt5(->len
));
5590 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5591 dasm_put(Dst
, 3128, Dt6(->metatable
));
5593 dasm_put(Dst
, 3135);
5594 #ifdef LUAJIT_ENABLE_LUA52COMPAT
5595 dasm_put(Dst
, 3141, Dt6(->nomm
), 1<<MM_len
);
5599 /* -- Binary ops -------------------------------------------------------- */
5602 case BC_ADDVN
: case BC_ADDNV
: case BC_ADDVV
:
5603 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5606 dasm_put(Dst
, 3151);
5609 dasm_put(Dst
, 3157);
5612 dasm_put(Dst
, 3163);
5615 dasm_put(Dst
, 3170);
5617 case BC_SUBVN
: case BC_SUBNV
: case BC_SUBVV
:
5618 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5621 dasm_put(Dst
, 3183);
5624 dasm_put(Dst
, 3189);
5627 dasm_put(Dst
, 3195);
5630 dasm_put(Dst
, 3202);
5632 case BC_MULVN
: case BC_MULNV
: case BC_MULVV
:
5633 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5636 dasm_put(Dst
, 3215);
5639 dasm_put(Dst
, 3221);
5642 dasm_put(Dst
, 3227);
5645 dasm_put(Dst
, 3234);
5647 case BC_DIVVN
: case BC_DIVNV
: case BC_DIVVV
:
5648 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5651 dasm_put(Dst
, 3247);
5654 dasm_put(Dst
, 3253);
5657 dasm_put(Dst
, 3259);
5660 dasm_put(Dst
, 3266);
5663 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5666 dasm_put(Dst
, 3279);
5669 dasm_put(Dst
, 3285);
5672 dasm_put(Dst
, 3291);
5675 dasm_put(Dst
, 3298);
5677 case BC_MODNV
: case BC_MODVV
:
5678 vk
= ((int)op
- BC_ADDVN
) / (BC_ADDNV
-BC_ADDVN
);
5681 dasm_put(Dst
, 3316);
5684 dasm_put(Dst
, 3322);
5687 dasm_put(Dst
, 3328);
5690 dasm_put(Dst
, 3335);
5693 dasm_put(Dst
, 3338);
5697 dasm_put(Dst
, 3360, Dt1(->base
), 32-3, Dt1(->base
));
5700 /* -- Constant ops ------------------------------------------------------ */
5703 dasm_put(Dst
, 3390, 32-1);
5707 dasm_put(Dst
, 3407, 32-1, LJ_TCDATA
);
5711 dasm_put(Dst
, 3426, 32-3);
5714 dasm_put(Dst
, 3442);
5717 dasm_put(Dst
, 3455, 32-3);
5720 dasm_put(Dst
, 3470);
5723 /* -- Upvalue and function ops ------------------------------------------ */
5726 dasm_put(Dst
, 3489, 32-1, offsetof(GCfuncL
, uvptr
), DtA(->v
));
5729 dasm_put(Dst
, 3510, 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
);
5732 dasm_put(Dst
, 3562, 32-1, 32-1, offsetof(GCfuncL
, uvptr
), DtA(->marked
), DtA(->v
), LJ_GC_BLACK
, Dt5(->marked
), DtA(->closed
), LJ_GC_WHITES
, GG_DISP2G
);
5735 dasm_put(Dst
, 3611, 32-1, offsetof(GCfuncL
, uvptr
), DtA(->v
));
5738 dasm_put(Dst
, 3632, 32-1, offsetof(GCfuncL
, uvptr
), 32-3, DtA(->v
));
5742 dasm_put(Dst
, 3655, Dt1(->openupval
), 32-1, -(BCBIAS_J
*4 >> 16), Dt1(->base
), Dt1(->base
));
5746 dasm_put(Dst
, 3685, 32-1, Dt1(->base
), Dt1(->base
));
5749 /* -- Table ops --------------------------------------------------------- */
5753 dasm_put(Dst
, 3711, DISPATCH_GL(gc
.total
), DISPATCH_GL(gc
.threshold
), Dt1(->base
));
5754 if (op
== BC_TNEW
) {
5755 dasm_put(Dst
, 3724);
5757 dasm_put(Dst
, 3732, 32-1);
5759 dasm_put(Dst
, 3739, Dt1(->base
));
5764 dasm_put(Dst
, 3762, 32-1, Dt7(->env
));
5765 if (op
== BC_GGET
) {
5766 dasm_put(Dst
, 3770);
5768 dasm_put(Dst
, 3773);
5773 dasm_put(Dst
, 3776, Dt6(->asize
), Dt6(->array
), 31-3, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_index
);
5776 dasm_put(Dst
, 3834, 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
);
5777 dasm_put(Dst
, 3898);
5780 dasm_put(Dst
, 3903, 32-3, Dt6(->asize
), Dt6(->array
), Dt6(->metatable
), Dt6(->nomm
), 1<<MM_index
);
5784 dasm_put(Dst
, 3947, Dt6(->asize
), Dt6(->array
), 31-3, Dt6(->marked
), LJ_GC_BLACK
, Dt6(->metatable
), Dt6(->nomm
), 1<<MM_newindex
);
5785 dasm_put(Dst
, 4014, DISPATCH_GL(gc
.grayagain
), DISPATCH_GL(gc
.grayagain
), Dt6(->marked
), Dt6(->gclist
));
5788 dasm_put(Dst
, 4026, 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
));
5789 dasm_put(Dst
, 4087, 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
));
5790 dasm_put(Dst
, 4138, Dt6(->marked
), Dt6(->gclist
));
5793 dasm_put(Dst
, 4145, 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
));
5794 dasm_put(Dst
, 4205, Dt6(->gclist
));
5798 dasm_put(Dst
, 4210, 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
));
5799 dasm_put(Dst
, 4279);
5802 /* -- Calls and vararg handling ----------------------------------------- */
5805 dasm_put(Dst
, 4282);
5808 dasm_put(Dst
, 4284, Dt7(->pc
));
5812 dasm_put(Dst
, 4304);
5815 dasm_put(Dst
, 4306, FRAME_TYPE
, Dt7(->ffid
), FRAME_VARG
, Dt7(->pc
), -4-8, Dt7(->pc
), PC2PROTO(k
), FRAME_TYPEP
);
5816 dasm_put(Dst
, 4371, FRAME_TYPE
);
5820 dasm_put(Dst
, 4378, Dt7(->pc
));
5826 dasm_put(Dst
, 4404, Dt6(->asize
), Dt6(->array
), 31-3, -(BCBIAS_J
*4 >> 16), Dt6(->hmask
), Dt6(->node
), 31-5, 31-3, DtB(->key
), -(BCBIAS_J
*4 >> 16));
5827 dasm_put(Dst
, 4483);
5831 dasm_put(Dst
, 4487, 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));
5835 dasm_put(Dst
, 4538, FRAME_VARG
, Dt1(->maxstack
), Dt1(->top
), Dt1(->base
), 32-3, Dt1(->base
));
5836 dasm_put(Dst
, 4618);
5839 /* -- Returns ----------------------------------------------------------- */
5842 dasm_put(Dst
, 4624);
5846 dasm_put(Dst
, 4626, FRAME_TYPE
, FRAME_VARG
, Dt7(->pc
), PC2PROTO(k
), FRAME_TYPEP
);
5849 case BC_RET0
: case BC_RET1
:
5850 dasm_put(Dst
, 4696, FRAME_TYPE
, FRAME_VARG
);
5851 if (op
== BC_RET1
) {
5852 dasm_put(Dst
, 4709);
5854 dasm_put(Dst
, 4712, Dt7(->pc
), PC2PROTO(k
));
5857 /* -- Loops and branches ------------------------------------------------ */
5861 dasm_put(Dst
, 4740);
5872 vk
= (op
== BC_IFORL
|| op
== BC_JFORL
);
5873 dasm_put(Dst
, 4742, FORL_IDX
*8, FORL_STEP
*8, FORL_STOP
*8);
5875 dasm_put(Dst
, 4750);
5878 dasm_put(Dst
, 4758, FORL_IDX
*8);
5880 dasm_put(Dst
, 4762, FORL_EXT
*8);
5881 if (op
!= BC_JFORL
) {
5882 dasm_put(Dst
, 4770, 32-1);
5883 if (op
== BC_JFORI
) {
5884 dasm_put(Dst
, 4774, -(BCBIAS_J
*4 >> 16));
5886 dasm_put(Dst
, 4777, -(BCBIAS_J
*4 >> 16));
5889 if (op
== BC_FORI
) {
5890 dasm_put(Dst
, 4780);
5891 } else if (op
== BC_IFORL
) {
5892 dasm_put(Dst
, 4782);
5894 dasm_put(Dst
, 4784, BC_JLOOP
);
5896 dasm_put(Dst
, 4787);
5901 dasm_put(Dst
, 4802);
5910 dasm_put(Dst
, 4804);
5911 if (op
== BC_JITERL
) {
5912 dasm_put(Dst
, 4810);
5914 dasm_put(Dst
, 4812, 32-1, -(BCBIAS_J
*4 >> 16));
5916 dasm_put(Dst
, 4819);
5921 dasm_put(Dst
, 4831);
5926 dasm_put(Dst
, 4833);
5931 dasm_put(Dst
, 4844);
5936 dasm_put(Dst
, 4846, 32-1, -(BCBIAS_J
*4 >> 16));
5939 /* -- Function headers -------------------------------------------------- */
5943 dasm_put(Dst
, 4862);
5945 case BC_FUNCV
: /* NYI: compiled vararg functions. */
5953 dasm_put(Dst
, 4864, Dt1(->maxstack
), -4+PC2PROTO(numparams
), -4+PC2PROTO(k
), 31-3);
5954 if (op
== BC_JFUNCF
) {
5955 dasm_put(Dst
, 4882);
5957 dasm_put(Dst
, 4884);
5959 dasm_put(Dst
, 4893);
5966 dasm_put(Dst
, 4899);
5967 break; /* NYI: compiled vararg functions. */
5970 dasm_put(Dst
, 4901, Dt1(->maxstack
), 8+FRAME_VARG
, -4+PC2PROTO(k
), -4+PC2PROTO(numparams
));
5975 if (op
== BC_FUNCC
) {
5976 dasm_put(Dst
, 4951, Dt8(->f
));
5978 dasm_put(Dst
, 4954, DISPATCH_GL(wrapf
));
5980 dasm_put(Dst
, 4957, Dt1(->maxstack
), Dt1(->base
), Dt1(->top
), ~LJ_VMST_C
);
5981 if (op
== BC_FUNCCW
) {
5982 dasm_put(Dst
, 4970, Dt8(->f
));
5984 dasm_put(Dst
, 4973, DISPATCH_GL(vmstate
), Dt1(->top
), 31-3, Dt1(->base
), ~LJ_VMST_INTERP
, DISPATCH_GL(vmstate
));
5987 /* ---------------------------------------------------------------------- */
5990 fprintf(stderr
, "Error: undefined opcode BC_%s\n", bc_names
[op
]);
5996 static int build_backend(BuildCtx
*ctx
)
6000 dasm_growpc(Dst
, BC__MAX
);
6002 build_subroutines(ctx
);
6004 dasm_put(Dst
, 4994);
6005 for (op
= 0; op
< BC__MAX
; op
++)
6006 build_ins(ctx
, (BCOp
)op
, op
);
6011 /* Emit pseudo frame-info for all assembler functions. */
6012 static void emit_asm_debug(BuildCtx
*ctx
)
6015 switch (ctx
->mode
) {
6017 fprintf(ctx
->fp
, "\t.section .debug_frame,\"\",@progbits\n");
6020 "\t.long .LECIE0-.LSCIE0\n"
6022 "\t.long 0xffffffff\n"
6028 "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n"
6033 "\t.long .LEFDE0-.LASFDE0\n"
6035 "\t.long .Lframe0\n"
6038 "\t.byte 0xe\n\t.uleb128 %d\n"
6039 "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n"
6040 "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n",
6041 (int)ctx
->codesz
, CFRAME_SIZE
);
6042 for (i
= 14; i
<= 31; i
++)
6044 "\t.byte %d\n\t.uleb128 %d\n"
6045 "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n",
6046 0x80+i
, 1+2*(31-i
), 1200+i
, 2+2*(31-i
));
6050 fprintf(ctx
->fp
, "\t.section .eh_frame,\"a\",@progbits\n");
6053 "\t.long .LECIE1-.LSCIE1\n"
6057 "\t.string \"zPR\"\n"
6061 "\t.uleb128 6\n" /* augmentation length */
6062 "\t.byte 0x1b\n" /* pcrel|sdata4 */
6063 "\t.long lj_err_unwind_dwarf-.\n"
6064 "\t.byte 0x1b\n" /* pcrel|sdata4 */
6065 "\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n"
6070 "\t.long .LEFDE1-.LASFDE1\n"
6072 "\t.long .LASFDE1-.Lframe1\n"
6073 "\t.long .Lbegin-.\n"
6075 "\t.uleb128 0\n" /* augmentation length */
6076 "\t.byte 0xe\n\t.uleb128 %d\n"
6077 "\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 -1\n"
6078 "\t.byte 0x5\n\t.uleb128 70\n\t.sleb128 37\n",
6079 (int)ctx
->codesz
, CFRAME_SIZE
);
6080 for (i
= 14; i
<= 31; i
++)
6082 "\t.byte %d\n\t.uleb128 %d\n"
6083 "\t.byte 5\n\t.uleb128 %d\n\t.uleb128 %d\n",
6084 0x80+i
, 1+2*(31-i
), 1200+i
, 2+2*(31-i
));