diff options
author | Mike Pall <mike> | 2009-12-17 22:08:20 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2009-12-17 22:08:20 +0100 |
commit | 6adab430afd9804d616b49658d09ab25c9380725 (patch) | |
tree | 155629b9598bc975c93454fd0ae6e88edfbad3c2 | |
parent | 1353acacb16fe988a9c68f1e6ccafb5ac28686e8 (diff) | |
download | luajit-6adab430afd9804d616b49658d09ab25c9380725.tar.gz luajit-6adab430afd9804d616b49658d09ab25c9380725.tar.bz2 luajit-6adab430afd9804d616b49658d09ab25c9380725.zip |
Adapt primary inbound calls in x64 interpreter.
Change argument order for lj_vm_cpcall() to simplify x64 interpreter.
-rw-r--r-- | src/buildvm_x86.dasc | 145 | ||||
-rw-r--r-- | src/buildvm_x86.h | 556 | ||||
-rw-r--r-- | src/lj_api.c | 4 | ||||
-rw-r--r-- | src/lj_opt_loop.c | 2 | ||||
-rw-r--r-- | src/lj_record.c | 2 | ||||
-rw-r--r-- | src/lj_state.c | 4 | ||||
-rw-r--r-- | src/lj_trace.c | 2 | ||||
-rw-r--r-- | src/lj_vm.h | 4 |
8 files changed, 402 insertions, 317 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index c781725f..384af0d2 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
@@ -21,14 +21,17 @@ | |||
21 | |.define BASE, edx // Not C callee-save, refetched anyway. | 21 | |.define BASE, edx // Not C callee-save, refetched anyway. |
22 | |.if not X64 or X64WIN | 22 | |.if not X64 or X64WIN |
23 | |.define KBASE, edi // Must be C callee-save. | 23 | |.define KBASE, edi // Must be C callee-save. |
24 | |.define KBASEa, KBASE | ||
24 | |.define PC, esi // Must be C callee-save. | 25 | |.define PC, esi // Must be C callee-save. |
25 | |.else | 26 | |.else |
26 | |.define KBASE, r13d // Must be C callee-save. | 27 | |.define KBASE, r13d // Must be C callee-save. |
28 | |.define KBASEa, r13 | ||
27 | |.define PC, r12d // Must be C callee-save. | 29 | |.define PC, r12d // Must be C callee-save. |
28 | |.endif | 30 | |.endif |
29 | |.define DISPATCH, ebx // Must be C callee-save. | 31 | |.define DISPATCH, ebx // Must be C callee-save. |
30 | | | 32 | | |
31 | |.define RA, ecx | 33 | |.define RA, ecx |
34 | |.if X64; .define RAa, rcx; .else; .define RAa, RA; .endif | ||
32 | |.define RAL, cl | 35 | |.define RAL, cl |
33 | |.define RB, ebp // Must be ebp (C callee-save). | 36 | |.define RB, ebp // Must be ebp (C callee-save). |
34 | |.define RC, eax // Must be eax (fcomparepp and others). | 37 | |.define RC, eax // Must be eax (fcomparepp and others). |
@@ -37,6 +40,7 @@ | |||
37 | |.define RCL, al | 40 | |.define RCL, al |
38 | |.define OP, RB | 41 | |.define OP, RB |
39 | |.define RD, RC | 42 | |.define RD, RC |
43 | |.if X64; .define RDa, rax; .else; .define RDa, RD; .endif | ||
40 | |.define RDL, RCL | 44 | |.define RDL, RCL |
41 | | | 45 | | |
42 | |.if not X64 | 46 | |.if not X64 |
@@ -133,9 +137,9 @@ | |||
133 | |.define INARG_BASE, SAVE_CFRAME // Overwritten by SAVE_CFRAME! | 137 | |.define INARG_BASE, SAVE_CFRAME // Overwritten by SAVE_CFRAME! |
134 | | | 138 | | |
135 | |// Arguments for vm_cpcall. | 139 | |// Arguments for vm_cpcall. |
136 | |.define INARG_CP_UD, SAVE_ERRF | 140 | |.define INARG_CP_CALL, SAVE_ERRF |
137 | |.define INARG_CP_FUNC, SAVE_NRES | 141 | |.define INARG_CP_UD, SAVE_NRES |
138 | |.define INARG_CP_CALL, SAVE_CFRAME | 142 | |.define INARG_CP_FUNC, SAVE_CFRAME |
139 | | | 143 | | |
140 | |//----------------------------------------------------------------------- | 144 | |//----------------------------------------------------------------------- |
141 | |.elif X64WIN // x64/Windows stack layout | 145 | |.elif X64WIN // x64/Windows stack layout |
@@ -408,15 +412,20 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
408 | |->gate_cwrap: // Call gate for wrapped C functions. | 412 | |->gate_cwrap: // Call gate for wrapped C functions. |
409 | | // RA = new base, RB = CFUNC, RC = nargs+1, (BASE = old base), PC = return | 413 | | // RA = new base, RB = CFUNC, RC = nargs+1, (BASE = old base), PC = return |
410 | | mov [RA-4], PC | 414 | | mov [RA-4], PC |
411 | | mov KBASE, CFUNC:RB->f | 415 | | mov KBASEa, CFUNC:RB->f |
412 | | mov L:RB, SAVE_L | 416 | | mov L:RB, SAVE_L |
413 | | lea RC, [RA+NARGS:RC*8-8] | 417 | | lea RC, [RA+NARGS:RC*8-8] |
414 | | mov L:RB->base, RA | 418 | | mov L:RB->base, RA |
415 | | lea RA, [RC+8*LUA_MINSTACK] | 419 | | lea RA, [RC+8*LUA_MINSTACK] |
416 | | mov ARG2, KBASE | ||
417 | | mov ARG1, L:RB | ||
418 | | mov L:RB->top, RC | 420 | | mov L:RB->top, RC |
419 | | cmp RA, L:RB->maxstack | 421 | | cmp RA, L:RB->maxstack |
422 | |.if X64 | ||
423 | | mov CARG2, KBASEa | ||
424 | | mov CARG1d, L:RB // Caveat: CARG1d may be RA. | ||
425 | |.else | ||
426 | | mov ARG2, KBASEa | ||
427 | | mov ARG1, L:RB | ||
428 | |.endif | ||
420 | | ja ->gate_c_growstack // Need to grow stack. | 429 | | ja ->gate_c_growstack // Need to grow stack. |
421 | | set_vmstate C | 430 | | set_vmstate C |
422 | | // (lua_State *L, lua_CFunction f) | 431 | | // (lua_State *L, lua_CFunction f) |
@@ -437,17 +446,21 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
437 | |->gate_c: // Call gate for C functions. | 446 | |->gate_c: // Call gate for C functions. |
438 | | // RA = new base, RB = CFUNC, RC = nargs+1, (BASE = old base), PC = return | 447 | | // RA = new base, RB = CFUNC, RC = nargs+1, (BASE = old base), PC = return |
439 | | mov [RA-4], PC | 448 | | mov [RA-4], PC |
440 | | mov KBASE, CFUNC:RB->f | 449 | | mov KBASEa, CFUNC:RB->f |
441 | | mov L:RB, SAVE_L | 450 | | mov L:RB, SAVE_L |
442 | | lea RC, [RA+NARGS:RC*8-8] | 451 | | lea RC, [RA+NARGS:RC*8-8] |
443 | | mov L:RB->base, RA | 452 | | mov L:RB->base, RA |
444 | | lea RA, [RC+8*LUA_MINSTACK] | 453 | | lea RA, [RC+8*LUA_MINSTACK] |
445 | | mov ARG1, L:RB | ||
446 | | mov L:RB->top, RC | 454 | | mov L:RB->top, RC |
447 | | cmp RA, L:RB->maxstack | 455 | | cmp RA, L:RB->maxstack |
456 | |.if X64 | ||
457 | | mov CARG1d, L:RB // Caveat: CARG1d may be RA. | ||
458 | |.else | ||
459 | | mov ARG1, L:RB | ||
460 | |.endif | ||
448 | | ja ->gate_c_growstack // Need to grow stack. | 461 | | ja ->gate_c_growstack // Need to grow stack. |
449 | | set_vmstate C | 462 | | set_vmstate C |
450 | | call KBASE // (lua_State *L) | 463 | | call KBASEa // (lua_State *L) |
451 | | set_vmstate INTERP | 464 | | set_vmstate INTERP |
452 | | // nresults returned in eax (RD). | 465 | | // nresults returned in eax (RD). |
453 | | mov BASE, L:RB->base | 466 | | mov BASE, L:RB->base |
@@ -498,8 +511,8 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
498 | | mov L:RB->top, BASE | 511 | | mov L:RB->top, BASE |
499 | | | 512 | | |
500 | |->vm_leave_cp: | 513 | |->vm_leave_cp: |
501 | | mov RA, SAVE_CFRAME // Restore previous C frame. | 514 | | mov RAa, SAVE_CFRAME // Restore previous C frame. |
502 | | mov L:RB->cframe, RA | 515 | | mov L:RB->cframe, RAa |
503 | | xor eax, eax // Ok return status for vm_pcall. | 516 | | xor eax, eax // Ok return status for vm_pcall. |
504 | | | 517 | | |
505 | |->vm_leave_unw: | 518 | |->vm_leave_unw: |
@@ -530,27 +543,44 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
530 | | // - A return back from a lua_call() with (high) nresults adjustment. | 543 | | // - A return back from a lua_call() with (high) nresults adjustment. |
531 | | mov L:RB->top, BASE // Save current top held in BASE (yes). | 544 | | mov L:RB->top, BASE // Save current top held in BASE (yes). |
532 | | mov NRESULTS, RD // Need to fill only remainder with nil. | 545 | | mov NRESULTS, RD // Need to fill only remainder with nil. |
546 | |.if X64 | ||
547 | | mov CARG2d, RA // Caveat: CARG1d may be RA. | ||
548 | | mov CARG1d, L:RB | ||
549 | |.else | ||
533 | | mov ARG2, RA // Grow by wanted nresults+1. | 550 | | mov ARG2, RA // Grow by wanted nresults+1. |
534 | | mov ARG1, L:RB | 551 | | mov ARG1, L:RB |
552 | |.endif | ||
535 | | call extern lj_state_growstack // (lua_State *L, int n) | 553 | | call extern lj_state_growstack // (lua_State *L, int n) |
536 | | mov BASE, L:RB->top // Need the (realloced) L->top in BASE. | 554 | | mov BASE, L:RB->top // Need the (realloced) L->top in BASE. |
537 | | jmp <3 | 555 | | jmp <3 |
538 | | | 556 | | |
539 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. | 557 | |->vm_unwind_c: // Unwind C stack, return from vm_pcall. |
540 | | // (void *cframe, int errcode) | 558 | | // (void *cframe, int errcode) |
559 | |.if X64 | ||
560 | | and CARG1, CFRAME_RAWMASK | ||
561 | | mov eax, CARG2d // Error return status for vm_pcall. | ||
562 | | mov rsp, CARG1 | ||
563 | |.else | ||
541 | | mov ecx, [esp+4] | 564 | | mov ecx, [esp+4] |
542 | | mov eax, [esp+8] // Error return status for vm_pcall. | 565 | | mov eax, [esp+8] // Error return status for vm_pcall. |
543 | | and ecx, CFRAME_RAWMASK | 566 | | and ecx, CFRAME_RAWMASK |
544 | | mov esp, ecx | 567 | | mov esp, ecx |
568 | |.endif | ||
545 | | mov L:RB, SAVE_L | 569 | | mov L:RB, SAVE_L |
546 | | mov GL:RB, L:RB->glref | 570 | | mov GL:RB, L:RB->glref |
547 | | mov dword GL:RB->vmstate, ~LJ_VMST_C | 571 | | mov dword GL:RB->vmstate, ~LJ_VMST_C |
548 | | jmp ->vm_leave_unw | 572 | | jmp ->vm_leave_unw |
549 | | | 573 | | |
550 | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. | 574 | |->vm_unwind_ff: // Unwind C stack, return from ff pcall. |
575 | | // (void *cframe) | ||
576 | |.if X64 | ||
577 | | and CARG1, CFRAME_RAWMASK | ||
578 | | mov rsp, CARG1 | ||
579 | |.else | ||
551 | | mov ecx, [esp+4] | 580 | | mov ecx, [esp+4] |
552 | | and ecx, CFRAME_RAWMASK | 581 | | and ecx, CFRAME_RAWMASK |
553 | | mov esp, ecx | 582 | | mov esp, ecx |
583 | |.endif | ||
554 | | mov L:RB, SAVE_L | 584 | | mov L:RB, SAVE_L |
555 | | mov RA, -8 // Results start at BASE+RA = BASE-8. | 585 | | mov RA, -8 // Results start at BASE+RA = BASE-8. |
556 | | mov RD, 1+1 // Really 1+2 results, incr. later. | 586 | | mov RD, 1+1 // Really 1+2 results, incr. later. |
@@ -578,7 +608,11 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
578 | |//-- Grow stack on-demand ----------------------------------------------- | 608 | |//-- Grow stack on-demand ----------------------------------------------- |
579 | | | 609 | | |
580 | |->gate_c_growstack: // Grow stack for C function. | 610 | |->gate_c_growstack: // Grow stack for C function. |
611 | |.if X64 | ||
612 | | mov CARG2d, LUA_MINSTACK | ||
613 | |.else | ||
581 | | mov ARG2, LUA_MINSTACK | 614 | | mov ARG2, LUA_MINSTACK |
615 | |.endif | ||
582 | | jmp >1 | 616 | | jmp >1 |
583 | | | 617 | | |
584 | |->gate_lv_growstack: // Grow stack for vararg Lua function. | 618 | |->gate_lv_growstack: // Grow stack for vararg Lua function. |
@@ -598,8 +632,13 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
598 | | mov L:RB->base, BASE | 632 | | mov L:RB->base, BASE |
599 | | mov L:RB->top, RC | 633 | | mov L:RB->top, RC |
600 | | mov SAVE_PC, PC | 634 | | mov SAVE_PC, PC |
635 | |.if X64 | ||
636 | | mov CARG2d, RA | ||
637 | | mov CARG1d, L:RB // Caveat: CARG1d may be RA. | ||
638 | |.else | ||
601 | | mov ARG2, RA | 639 | | mov ARG2, RA |
602 | | mov ARG1, L:RB | 640 | | mov ARG1, L:RB |
641 | |.endif | ||
603 | |1: | 642 | |1: |
604 | | // L:RB = L, L->base = new base, L->top = top | 643 | | // L:RB = L, L->base = new base, L->top = top |
605 | | // SAVE_PC = initial PC+1 (undefined for C functions) | 644 | | // SAVE_PC = initial PC+1 (undefined for C functions) |
@@ -619,18 +658,28 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
619 | |//----------------------------------------------------------------------- | 658 | |//----------------------------------------------------------------------- |
620 | | | 659 | | |
621 | |->vm_resume: // Setup C frame and resume thread. | 660 | |->vm_resume: // Setup C frame and resume thread. |
622 | | // (lua_State *L, StkId base, int nres1 = 0, ptrdiff_t ef = 0) | 661 | | // (lua_State *L, TValue *base, int nres1 = 0, ptrdiff_t ef = 0) |
623 | | saveregs | 662 | | saveregs |
663 | |.if X64 | ||
664 | | mov L:RB, CARG1d // Caveat: CARG1d may be RA. | ||
665 | | mov SAVE_L, CARG1d | ||
666 | | mov RA, CARG2d | ||
667 | |.else | ||
668 | | mov L:RB, SAVE_L | ||
669 | | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! | ||
670 | |.endif | ||
624 | | mov PC, FRAME_C | 671 | | mov PC, FRAME_C |
625 | | xor RD, RD | 672 | | xor RD, RD |
626 | | mov L:RB, SAVE_L | ||
627 | | lea KBASE, [esp+CFRAME_RESUME] | 673 | | lea KBASE, [esp+CFRAME_RESUME] |
628 | | mov RA, INARG_BASE | ||
629 | | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. | 674 | | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. |
630 | | add DISPATCH, GG_G2DISP | 675 | | add DISPATCH, GG_G2DISP |
631 | | mov L:RB->cframe, KBASE | 676 | | mov L:RB->cframe, KBASE |
632 | | mov SAVE_CFRAME, RD // Caveat: overlaps INARG_BASE! | ||
633 | | mov SAVE_PC, RD // Any value outside of bytecode is ok. | 677 | | mov SAVE_PC, RD // Any value outside of bytecode is ok. |
678 | | mov SAVE_CFRAME, RDa | ||
679 | |.if X64 | ||
680 | | mov SAVE_NRES, RD | ||
681 | | mov SAVE_ERRF, RD | ||
682 | |.endif | ||
634 | | cmp byte L:RB->status, RDL | 683 | | cmp byte L:RB->status, RDL |
635 | | je >3 // Initial resume (like a call). | 684 | | je >3 // Initial resume (like a call). |
636 | | | 685 | | |
@@ -650,25 +699,39 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
650 | | jmp ->vm_return | 699 | | jmp ->vm_return |
651 | | | 700 | | |
652 | |->vm_pcall: // Setup protected C frame and enter VM. | 701 | |->vm_pcall: // Setup protected C frame and enter VM. |
653 | | // (lua_State *L, StkId base, int nres1, ptrdiff_t ef) | 702 | | // (lua_State *L, TValue *base, int nres1, ptrdiff_t ef) |
654 | | saveregs | 703 | | saveregs |
655 | | mov PC, FRAME_CP | 704 | | mov PC, FRAME_CP |
705 | |.if X64 | ||
706 | | mov SAVE_ERRF, CARG4d | ||
707 | |.endif | ||
656 | | jmp >1 | 708 | | jmp >1 |
657 | | | 709 | | |
658 | |->vm_call: // Setup C frame and enter VM. | 710 | |->vm_call: // Setup C frame and enter VM. |
659 | | // (lua_State *L, StkId base, int nres1) | 711 | | // (lua_State *L, TValue *base, int nres1) |
660 | | saveregs | 712 | | saveregs |
661 | | mov PC, FRAME_C | 713 | | mov PC, FRAME_C |
662 | | | 714 | | |
663 | |1: // Entry point for vm_pcall above (PC = ftype). | 715 | |1: // Entry point for vm_pcall above (PC = ftype). |
716 | |.if X64 | ||
717 | | mov SAVE_NRES, CARG3d | ||
718 | | mov L:RB, CARG1d // Caveat: CARG1d may be RA. | ||
719 | | mov SAVE_L, CARG1d | ||
720 | | mov RA, CARG2d | ||
721 | |.else | ||
664 | | mov L:RB, SAVE_L | 722 | | mov L:RB, SAVE_L |
665 | | mov RA, INARG_BASE | 723 | | mov RA, INARG_BASE // Caveat: overlaps SAVE_CFRAME! |
724 | |.endif | ||
666 | | | 725 | | |
667 | |2: // Entry point for vm_cpcall below (RA = base, RB = L, PC = ftype). | 726 | |2: // Entry point for vm_cpcall below (RA = base, RB = L, PC = ftype). |
668 | | mov KBASE, L:RB->cframe // Add our C frame to cframe chain. | 727 | | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. |
669 | | mov SAVE_CFRAME, KBASE // Caveat: overlaps INARG_BASE! | 728 | | mov SAVE_CFRAME, KBASEa |
670 | | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. | 729 | | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. |
730 | |.if X64 | ||
731 | | mov L:RB->cframe, rsp | ||
732 | |.else | ||
671 | | mov L:RB->cframe, esp | 733 | | mov L:RB->cframe, esp |
734 | |.endif | ||
672 | | | 735 | | |
673 | | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. | 736 | | mov DISPATCH, L:RB->glref // Setup pointer to dispatch table. |
674 | | add DISPATCH, GG_G2DISP | 737 | | add DISPATCH, GG_G2DISP |
@@ -691,31 +754,44 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
691 | | // RA = new base, RB = LFUNC/CFUNC, RC = nargs+1. | 754 | | // RA = new base, RB = LFUNC/CFUNC, RC = nargs+1. |
692 | | | 755 | | |
693 | |->vm_cpcall: // Setup protected C frame, call C. | 756 | |->vm_cpcall: // Setup protected C frame, call C. |
694 | | // (lua_State *L, lua_CPFunction cp, lua_CFunction func, void *ud) | 757 | | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) |
695 | | saveregs | 758 | | saveregs |
759 | |.if X64 | ||
760 | | mov L:RB, CARG1d // Caveat: CARG1d may be RA. | ||
761 | | mov SAVE_L, CARG1d | ||
762 | |.else | ||
696 | | mov L:RB, SAVE_L | 763 | | mov L:RB, SAVE_L |
697 | | mov RC, INARG_CP_UD | 764 | | // Caveat: INARG_CP_* and SAVE_CFRAME/SAVE_NRES/SAVE_ERRF overlap! |
765 | | mov RC, INARG_CP_UD // Get args before they are overwritten. | ||
698 | | mov RA, INARG_CP_FUNC | 766 | | mov RA, INARG_CP_FUNC |
699 | | mov BASE, INARG_CP_CALL | 767 | | mov BASE, INARG_CP_CALL |
768 | |.endif | ||
700 | | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. | 769 | | mov SAVE_PC, L:RB // Any value outside of bytecode is ok. |
701 | | | 770 | | |
702 | | // Caveat: INARG_P_* and INARG_CP_* overlap! | ||
703 | | mov KBASE, L:RB->stack // Compute -savestack(L, L->top). | 771 | | mov KBASE, L:RB->stack // Compute -savestack(L, L->top). |
704 | | sub KBASE, L:RB->top | 772 | | sub KBASE, L:RB->top |
705 | | mov SAVE_ERRF, 0 // No error function. | 773 | | mov SAVE_ERRF, 0 // No error function. |
706 | | mov SAVE_NRES, KBASE // Neg. delta means cframe w/o frame. | 774 | | mov SAVE_NRES, KBASE // Neg. delta means cframe w/o frame. |
707 | | // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe). | 775 | | // Handler may change cframe_nres(L->cframe) or cframe_errfunc(L->cframe). |
708 | | | 776 | | |
709 | | mov ARG3, RC | 777 | |.if X64 |
778 | | mov KBASEa, L:RB->cframe // Add our C frame to cframe chain. | ||
779 | | mov SAVE_CFRAME, KBASEa | ||
780 | | mov L:RB->cframe, rsp | ||
781 | | | ||
782 | | call CARG4 // (lua_State *L, lua_CFunction func, void *ud) | ||
783 | |.else | ||
784 | | mov ARG3, RC // Have to copy args downwards. | ||
710 | | mov ARG2, RA | 785 | | mov ARG2, RA |
711 | | mov ARG1, L:RB | 786 | | mov ARG1, L:RB |
712 | | | 787 | | |
713 | | mov KBASE, L:RB->cframe // Add our C frame to cframe chain. | 788 | | mov KBASE, L:RB->cframe // Add our C frame to cframe chain. |
714 | | mov SAVE_CFRAME, KBASE // Caveat: overlaps INARG_CP_CALL! | 789 | | mov SAVE_CFRAME, KBASE |
715 | | mov L:RB->cframe, esp | 790 | | mov L:RB->cframe, esp |
716 | | | 791 | | |
717 | | call BASE // (lua_State *L, lua_CFunction func, void *ud) | 792 | | call BASE // (lua_State *L, lua_CFunction func, void *ud) |
718 | | // StkId (new base) or NULL returned in eax (RC). | 793 | |.endif |
794 | | // TValue * (new base) or NULL returned in eax (RC). | ||
719 | | test RC, RC | 795 | | test RC, RC |
720 | | jz ->vm_leave_cp // No base? Just remove C frame. | 796 | | jz ->vm_leave_cp // No base? Just remove C frame. |
721 | | mov RA, RC | 797 | | mov RA, RC |
@@ -737,11 +813,16 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
737 | | mov dword [RA+RD*8-4], LJ_TNIL // Ensure one valid arg. | 813 | | mov dword [RA+RD*8-4], LJ_TNIL // Ensure one valid arg. |
738 | | mov RC, RA // ... in [RC] | 814 | | mov RC, RA // ... in [RC] |
739 | | mov PC, [RB-12] // Restore PC from [cont|PC]. | 815 | | mov PC, [RB-12] // Restore PC from [cont|PC]. |
816 | | mov RA, dword [RB-16] | ||
817 | |.if X64 | ||
818 | | lea KBASEa, qword [=>0] | ||
819 | | add RAa, KBASEa | ||
820 | |.endif | ||
740 | | mov LFUNC:KBASE, [BASE-8] | 821 | | mov LFUNC:KBASE, [BASE-8] |
741 | | mov PROTO:KBASE, LFUNC:KBASE->pt | 822 | | mov PROTO:KBASE, LFUNC:KBASE->pt |
742 | | mov KBASE, PROTO:KBASE->k | 823 | | mov KBASE, PROTO:KBASE->k |
743 | | // BASE = base, RC = result, RB = meta base | 824 | | // BASE = base, RC = result, RB = meta base |
744 | | jmp dword [RB-16] // Jump to continuation. | 825 | | jmp RAa // Jump to continuation. |
745 | | | 826 | | |
746 | |->cont_cat: // BASE = base, RC = result, RB = mbase | 827 | |->cont_cat: // BASE = base, RC = result, RB = mbase |
747 | | movzx RA, PC_RB | 828 | | movzx RA, PC_RB |
@@ -1028,7 +1109,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
1028 | | mov ARG1, L:RB | 1109 | | mov ARG1, L:RB |
1029 | | mov SAVE_PC, PC | 1110 | | mov SAVE_PC, PC |
1030 | | mov L:RB->base, BASE | 1111 | | mov L:RB->base, BASE |
1031 | | call extern lj_meta_for // (lua_State *L, StkId base) | 1112 | | call extern lj_meta_for // (lua_State *L, TValue *base) |
1032 | | mov BASE, L:RB->base | 1113 | | mov BASE, L:RB->base |
1033 | | mov RC, [PC-4] | 1114 | | mov RC, [PC-4] |
1034 | | movzx RA, RCH | 1115 | | movzx RA, RCH |
@@ -1447,7 +1528,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
1447 | | xor RA, RA | 1528 | | xor RA, RA |
1448 | | mov ARG4, RA | 1529 | | mov ARG4, RA |
1449 | | mov ARG3, RA | 1530 | | mov ARG3, RA |
1450 | | call ->vm_resume // (lua_State *L, StkId base, 0, 0) | 1531 | | call ->vm_resume // (lua_State *L, TValue *base, 0, 0) |
1451 | | set_vmstate INTERP | 1532 | | set_vmstate INTERP |
1452 | | | 1533 | | |
1453 | | mov L:RB, SAVE_L | 1534 | | mov L:RB, SAVE_L |
@@ -2123,6 +2204,9 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
2123 | |// The 16 bit exit number is stored with two (sign-extended) push imm8. | 2204 | |// The 16 bit exit number is stored with two (sign-extended) push imm8. |
2124 | |->vm_exit_handler: | 2205 | |->vm_exit_handler: |
2125 | #if LJ_HASJIT | 2206 | #if LJ_HASJIT |
2207 | |.if X64 | ||
2208 | | int3 // NYI | ||
2209 | |.else | ||
2126 | | push ebp; lea ebp, [esp+12]; push ebp | 2210 | | push ebp; lea ebp, [esp+12]; push ebp |
2127 | | push ebx; push edx; push ecx; push eax | 2211 | | push ebx; push edx; push ecx; push eax |
2128 | | movzx RC, byte [ebp-4] // Reconstruct exit number. | 2212 | | movzx RC, byte [ebp-4] // Reconstruct exit number. |
@@ -2159,6 +2243,7 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
2159 | | mov BASE, L:RB->base | 2243 | | mov BASE, L:RB->base |
2160 | | mov PC, SAVE_PC | 2244 | | mov PC, SAVE_PC |
2161 | | mov SAVE_L, L:RB // Needed for on-trace resume/yield. | 2245 | | mov SAVE_L, L:RB // Needed for on-trace resume/yield. |
2246 | |.endif | ||
2162 | #endif | 2247 | #endif |
2163 | |->vm_exit_interp: | 2248 | |->vm_exit_interp: |
2164 | #if LJ_HASJIT | 2249 | #if LJ_HASJIT |
@@ -2875,7 +2960,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov) | |||
2875 | | mov ARG2, RA | 2960 | | mov ARG2, RA |
2876 | | mov ARG1, L:RB | 2961 | | mov ARG1, L:RB |
2877 | | mov L:RB->base, BASE | 2962 | | mov L:RB->base, BASE |
2878 | | call extern lj_func_closeuv // (lua_State *L, StkId level) | 2963 | | call extern lj_func_closeuv // (lua_State *L, TValue *level) |
2879 | | mov BASE, L:RB->base | 2964 | | mov BASE, L:RB->base |
2880 | |1: | 2965 | |1: |
2881 | | ins_next | 2966 | | ins_next |
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h index 8608bf07..83b1ed98 100644 --- a/src/buildvm_x86.h +++ b/src/buildvm_x86.h | |||
@@ -12,7 +12,7 @@ | |||
12 | #define DASM_SECTION_CODE_OP 0 | 12 | #define DASM_SECTION_CODE_OP 0 |
13 | #define DASM_SECTION_CODE_SUB 1 | 13 | #define DASM_SECTION_CODE_SUB 1 |
14 | #define DASM_MAXSECTION 2 | 14 | #define DASM_MAXSECTION 2 |
15 | static const unsigned char build_actionlist[12298] = { | 15 | static const unsigned char build_actionlist[12300] = { |
16 | 254,1,248,10,137,202,139,173,233,137,114,252,252,15,182,141,233,139,181,233, | 16 | 254,1,248,10,137,202,139,173,233,137,114,252,252,15,182,141,233,139,181,233, |
17 | 139,189,233,139,108,36,48,141,12,202,141,68,194,252,252,59,141,233,15,135, | 17 | 139,189,233,139,108,36,48,141,12,202,141,68,194,252,252,59,141,233,15,135, |
18 | 244,11,248,9,189,237,248,1,137,40,137,104,8,131,192,16,57,200,15,130,244, | 18 | 244,11,248,9,189,237,248,1,137,40,137,104,8,131,192,16,57,200,15,130,244, |
@@ -24,11 +24,11 @@ static const unsigned char build_actionlist[12298] = { | |||
24 | 252,252,137,56,131,192,8,199,65,252,252,237,131,252,238,1,15,133,244,1,248, | 24 | 252,252,137,56,131,192,8,199,65,252,252,237,131,252,238,1,15,133,244,1,248, |
25 | 2,15,182,141,233,139,181,233,255,139,189,233,141,12,202,252,233,244,9,248, | 25 | 2,15,182,141,233,139,181,233,255,139,189,233,141,12,202,252,233,244,9,248, |
26 | 14,137,113,252,252,139,189,233,139,108,36,48,141,68,193,252,248,137,141,233, | 26 | 14,137,113,252,252,139,189,233,139,108,36,48,141,68,193,252,248,137,141,233, |
27 | 141,136,233,137,124,36,4,137,44,36,137,133,233,59,141,233,15,135,244,15,199, | 27 | 141,136,233,137,133,233,59,141,233,137,124,36,4,137,44,36,15,135,244,15,199, |
28 | 131,233,237,252,255,147,233,199,131,233,237,139,149,233,141,12,194,252,247, | 28 | 131,233,237,252,255,147,233,199,131,233,237,139,149,233,141,12,194,252,247, |
29 | 217,3,141,233,248,16,131,192,1,137,68,36,20,252,247,198,237,255,15,132,244, | 29 | 217,3,141,233,248,16,131,192,1,137,68,36,20,252,247,198,237,255,15,132,244, |
30 | 17,252,233,244,18,248,19,137,113,252,252,139,189,233,139,108,36,48,141,68, | 30 | 17,252,233,244,18,248,19,137,113,252,252,139,189,233,139,108,36,48,141,68, |
31 | 193,252,248,137,141,233,141,136,233,137,44,36,137,133,233,59,141,233,15,135, | 31 | 193,252,248,137,141,233,141,136,233,137,133,233,59,141,233,137,44,36,15,135, |
32 | 244,15,199,131,233,237,252,255,215,199,131,233,237,139,149,233,141,12,194, | 32 | 244,15,199,131,233,237,252,255,215,199,131,233,237,139,149,233,141,12,194, |
33 | 252,247,217,3,141,233,248,16,131,192,1,137,68,36,20,252,247,198,237,255,15, | 33 | 252,247,217,3,141,233,248,16,131,192,1,137,68,36,20,252,247,198,237,255,15, |
34 | 132,244,17,248,18,252,247,198,237,15,132,244,20,199,131,233,237,131,230,252, | 34 | 132,244,17,248,18,252,247,198,237,15,132,244,20,199,131,233,237,131,230,252, |
@@ -50,9 +50,9 @@ static const unsigned char build_actionlist[12298] = { | |||
50 | 181,233,139,108,36,48,248,11,131,232,4,41,209,193,252,233,3,131,198,4,137, | 50 | 181,233,139,108,36,48,248,11,131,232,4,41,209,193,252,233,3,131,198,4,137, |
51 | 149,233,137,133,233,137,116,36,24,137,76,36,4,137,44,36,248,1,232,251,1,0, | 51 | 149,233,137,133,233,137,116,36,24,137,76,36,4,137,44,36,248,1,232,251,1,0, |
52 | 139,141,233,139,133,233,139,105,252,248,139,113,252,252,41,200,193,232,3, | 52 | 139,141,233,139,133,233,139,105,252,248,139,113,252,252,41,200,193,232,3, |
53 | 131,192,1,252,255,165,233,248,26,255,85,87,86,83,131,252,236,28,190,237,49, | 53 | 131,192,1,252,255,165,233,248,26,255,85,87,86,83,131,252,236,28,139,108,36, |
54 | 192,139,108,36,48,141,188,253,36,233,139,76,36,52,139,157,233,129,195,239, | 54 | 48,139,76,36,52,190,237,49,192,141,188,253,36,233,139,157,233,129,195,239, |
55 | 137,189,233,137,68,36,52,137,68,36,24,56,133,233,15,132,244,249,199,131,233, | 55 | 137,189,233,137,68,36,24,137,68,36,52,56,133,233,15,132,244,249,199,131,233, |
56 | 237,136,133,233,139,149,233,139,133,233,41,200,193,232,3,131,192,1,41,209, | 56 | 237,136,133,233,139,149,233,139,133,233,41,200,193,232,3,131,192,1,41,209, |
57 | 139,114,252,252,137,68,36,20,252,247,198,237,15,132,244,17,252,233,244,18, | 57 | 139,114,252,252,137,68,36,20,252,247,198,237,15,132,244,17,252,233,244,18, |
58 | 248,27,85,87,86,83,131,252,236,28,190,237,255,252,233,244,247,248,28,85,87, | 58 | 248,27,85,87,86,83,131,252,236,28,190,237,255,252,233,244,247,248,28,85,87, |
@@ -60,27 +60,27 @@ static const unsigned char build_actionlist[12298] = { | |||
60 | 233,137,124,36,52,137,108,36,24,137,165,233,139,157,233,129,195,239,248,3, | 60 | 233,137,124,36,52,137,108,36,24,137,165,233,139,157,233,129,195,239,248,3, |
61 | 199,131,233,237,139,149,233,1,206,41,214,139,133,233,41,200,193,232,3,131, | 61 | 199,131,233,237,139,149,233,1,206,41,214,139,133,233,41,200,193,232,3,131, |
62 | 192,1,139,105,252,248,129,121,253,252,252,239,15,133,244,29,252,255,165,233, | 62 | 192,1,139,105,252,248,129,121,253,252,252,239,15,133,244,29,252,255,165,233, |
63 | 248,30,255,85,87,86,83,131,252,236,28,139,108,36,48,139,68,36,60,139,76,36, | 63 | 248,30,255,85,87,86,83,131,252,236,28,139,108,36,48,139,68,36,56,139,76,36, |
64 | 56,139,84,36,52,137,108,36,24,139,189,233,43,189,233,199,68,36,60,0,0,0,0, | 64 | 52,139,84,36,60,137,108,36,24,139,189,233,43,189,233,199,68,36,60,0,0,0,0, |
65 | 137,124,36,56,137,68,36,8,137,76,36,4,137,44,36,139,189,233,137,124,36,52, | 65 | 137,124,36,56,137,68,36,8,137,76,36,4,137,44,36,139,189,233,137,124,36,52, |
66 | 137,165,233,252,255,210,133,192,15,132,244,21,137,193,190,237,252,233,244, | 66 | 137,165,233,252,255,210,133,192,15,132,244,21,137,193,190,237,252,233,244, |
67 | 2,248,25,1,209,131,230,252,248,137,213,41,252,242,199,68,193,252,252,237, | 67 | 2,248,25,1,209,131,230,252,248,137,213,41,252,242,199,68,193,252,252,237, |
68 | 137,200,139,117,252,244,139,122,252,248,139,191,233,139,191,233,252,255,101, | 68 | 137,200,139,117,252,244,139,77,252,240,139,122,252,248,139,191,233,139,191, |
69 | 252,240,248,31,15,182,78,252,255,131,252,237,16,141,12,202,41,252,233,15, | 69 | 233,252,255,225,248,31,15,182,78,252,255,131,252,237,16,141,12,202,41,252, |
70 | 132,244,32,252,247,217,193,252,233,3,137,76,36,8,139,72,4,139,0,137,77,4, | 70 | 233,15,132,244,32,252,247,217,193,252,233,3,137,76,36,8,139,72,4,139,0,137, |
71 | 137,69,0,137,108,36,4,252,233,244,33,248,34,137,68,36,16,199,68,36,20,237, | 71 | 77,4,137,69,0,137,108,36,4,252,233,244,33,248,34,137,68,36,16,199,68,36,20, |
72 | 255,141,68,36,16,128,126,252,252,235,15,133,244,247,141,139,233,137,41,199, | 72 | 237,255,141,68,36,16,128,126,252,252,235,15,133,244,247,141,139,233,137,41, |
73 | 65,4,237,137,205,252,233,244,248,248,35,15,182,70,252,254,137,68,36,12,219, | 73 | 199,65,4,237,137,205,252,233,244,248,248,35,15,182,70,252,254,137,68,36,12, |
74 | 68,36,12,221,92,36,16,141,68,36,16,252,233,244,247,248,36,15,182,70,252,254, | 74 | 219,68,36,12,221,92,36,16,141,68,36,16,252,233,244,247,248,36,15,182,70,252, |
75 | 141,4,194,248,1,15,182,110,252,255,141,44,252,234,248,2,137,108,36,4,139, | 75 | 254,141,4,194,248,1,15,182,110,252,255,141,44,252,234,248,2,137,108,36,4, |
76 | 108,36,48,137,68,36,8,137,44,36,137,116,36,24,137,149,233,232,251,1,1,139, | 76 | 139,108,36,48,137,68,36,8,137,44,36,137,116,36,24,137,149,233,232,251,1,1, |
77 | 149,233,133,192,15,132,244,249,248,32,15,182,78,252,253,139,104,4,139,0,137, | 77 | 139,149,233,133,192,15,132,244,249,248,32,15,182,78,252,253,139,104,4,139, |
78 | 108,202,4,137,4,202,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252, | 78 | 0,137,108,202,4,137,4,202,139,6,15,182,204,15,182,232,131,198,4,193,232,16, |
79 | 255,36,171,248,3,139,141,233,255,137,113,252,244,141,177,233,41,214,139,105, | 79 | 252,255,36,171,248,3,139,141,233,255,137,113,252,244,141,177,233,41,214,139, |
80 | 252,248,184,3,0,0,0,252,255,165,233,248,37,137,68,36,16,199,68,36,20,237, | 80 | 105,252,248,184,3,0,0,0,252,255,165,233,248,37,137,68,36,16,199,68,36,20, |
81 | 141,68,36,16,128,126,252,252,235,15,133,244,247,141,139,233,137,41,199,65, | 81 | 237,141,68,36,16,128,126,252,252,235,15,133,244,247,141,139,233,137,41,199, |
82 | 4,237,137,205,252,233,244,248,248,38,15,182,70,252,254,137,68,36,12,219,68, | 82 | 65,4,237,137,205,252,233,244,248,248,38,15,182,70,252,254,137,68,36,12,219, |
83 | 36,12,221,92,36,16,141,68,36,16,252,233,244,247,248,39,15,182,70,252,254, | 83 | 68,36,12,221,92,36,16,141,68,36,16,252,233,244,247,248,39,15,182,70,252,254, |
84 | 141,4,194,248,1,15,182,110,252,255,141,44,252,234,248,2,137,108,36,4,139, | 84 | 141,4,194,248,1,15,182,110,252,255,141,44,252,234,248,2,137,108,36,4,139, |
85 | 108,36,48,137,68,36,8,137,44,36,137,116,36,24,137,149,233,232,251,1,2,139, | 85 | 108,36,48,137,68,36,8,137,44,36,137,116,36,24,137,149,233,232,251,1,2,139, |
86 | 149,233,133,192,15,132,244,249,255,15,182,78,252,253,139,108,202,4,139,12, | 86 | 149,233,133,192,15,132,244,249,255,15,182,78,252,253,139,108,202,4,139,12, |
@@ -963,140 +963,140 @@ static void build_subroutines(BuildCtx *ctx, int cmov) | |||
963 | dasm_put(Dst, 766, FRAME_C, CFRAME_RESUME, Dt1(->glref), GG_G2DISP, Dt1(->cframe), Dt1(->status), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->status), Dt1(->base), Dt1(->top), FRAME_TYPE, FRAME_CP); | 963 | dasm_put(Dst, 766, FRAME_C, CFRAME_RESUME, Dt1(->glref), GG_G2DISP, Dt1(->cframe), Dt1(->status), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->status), Dt1(->base), Dt1(->top), FRAME_TYPE, FRAME_CP); |
964 | dasm_put(Dst, 871, FRAME_C, Dt1(->cframe), Dt1(->cframe), Dt1(->glref), GG_G2DISP, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), LJ_TFUNC, Dt7(->gate)); | 964 | dasm_put(Dst, 871, FRAME_C, Dt1(->cframe), Dt1(->cframe), Dt1(->glref), GG_G2DISP, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top), LJ_TFUNC, Dt7(->gate)); |
965 | dasm_put(Dst, 964, Dt1(->stack), Dt1(->top), Dt1(->cframe), Dt1(->cframe), FRAME_CP, LJ_TNIL, Dt7(->pt), Dt9(->k), LJ_TSTR); | 965 | dasm_put(Dst, 964, Dt1(->stack), Dt1(->top), Dt1(->cframe), Dt1(->cframe), FRAME_CP, LJ_TNIL, Dt7(->pt), Dt9(->k), LJ_TSTR); |
966 | dasm_put(Dst, 1151, BC_GGET, DISPATCH_GL(tmptv), LJ_TTAB, Dt1(->base), Dt1(->base), Dt1(->top)); | 966 | dasm_put(Dst, 1153, BC_GGET, DISPATCH_GL(tmptv), LJ_TTAB, Dt1(->base), Dt1(->base), Dt1(->top)); |
967 | dasm_put(Dst, 1307, FRAME_CONT, Dt7(->gate), LJ_TSTR, BC_GSET, DISPATCH_GL(tmptv), LJ_TTAB, Dt1(->base), Dt1(->base)); | 967 | dasm_put(Dst, 1309, FRAME_CONT, Dt7(->gate), LJ_TSTR, BC_GSET, DISPATCH_GL(tmptv), LJ_TTAB, Dt1(->base), Dt1(->base)); |
968 | dasm_put(Dst, 1454, Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base), -BCBIAS_J*4, LJ_TISTRUECOND); | 968 | dasm_put(Dst, 1456, Dt1(->top), FRAME_CONT, Dt7(->gate), Dt1(->base), Dt1(->base), -BCBIAS_J*4, LJ_TISTRUECOND); |
969 | dasm_put(Dst, 1648, LJ_TISTRUECOND, Dt1(->base)); | 969 | dasm_put(Dst, 1650, LJ_TISTRUECOND, Dt1(->base)); |
970 | dasm_put(Dst, 1740, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base)); | 970 | dasm_put(Dst, 1742, Dt1(->base), Dt1(->base), FRAME_CONT, LJ_TFUNC, Dt7(->gate), Dt1(->base), Dt1(->base), Dt1(->base), Dt1(->base)); |
971 | dasm_put(Dst, 1919, Dt7(->gate), Dt1(->base), Dt1(->base), GG_DISP_STATIC*4, 1+1, LJ_TISTRUECOND); | 971 | dasm_put(Dst, 1921, Dt7(->gate), Dt1(->base), Dt1(->base), GG_DISP_STATIC*4, 1+1, LJ_TISTRUECOND); |
972 | dasm_put(Dst, 2066, 1+1, ~LJ_TNUMX); | 972 | dasm_put(Dst, 2068, 1+1, ~LJ_TNUMX); |
973 | if (cmov) { | 973 | if (cmov) { |
974 | dasm_put(Dst, 2095); | 974 | dasm_put(Dst, 2097); |
975 | } else { | 975 | } else { |
976 | dasm_put(Dst, 2099); | 976 | dasm_put(Dst, 2101); |
977 | } | 977 | } |
978 | dasm_put(Dst, 2108, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL, DISPATCH_GL(mmname)+4*MM_metatable, LJ_TTAB, Dt6(->hmask)); | 978 | dasm_put(Dst, 2110, ((char *)(&((GCfuncC *)0)->upvalue)), LJ_TSTR, 1+1, LJ_TTAB, Dt6(->metatable), LJ_TNIL, DISPATCH_GL(mmname)+4*MM_metatable, LJ_TTAB, Dt6(->hmask)); |
979 | dasm_put(Dst, 2195, Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next), LJ_TNIL); | 979 | dasm_put(Dst, 2197, Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), DtB(->next), LJ_TNIL); |
980 | dasm_put(Dst, 2250, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT]), 2+1, LJ_TTAB); | 980 | dasm_put(Dst, 2252, LJ_TUDATA, LJ_TISNUM, LJ_TNUMX, DISPATCH_GL(gcroot[GCROOT_BASEMT]), 2+1, LJ_TTAB); |
981 | dasm_put(Dst, 2321, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); | 981 | dasm_put(Dst, 2323, Dt6(->metatable), LJ_TTAB, Dt6(->metatable), LJ_TTAB, Dt6(->marked), LJ_GC_BLACK, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); |
982 | dasm_put(Dst, 2386, 2+1, LJ_TTAB, 1+1, LJ_TISNUM, 1+1); | 982 | dasm_put(Dst, 2388, 2+1, LJ_TTAB, 1+1, LJ_TISNUM, 1+1); |
983 | dasm_put(Dst, 2493, LJ_TSTR, LJ_TSTR, LJ_TISNUM, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM]), DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold)); | 983 | dasm_put(Dst, 2495, LJ_TSTR, LJ_TSTR, LJ_TISNUM, DISPATCH_GL(gcroot[GCROOT_BASEMT_NUM]), DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold)); |
984 | dasm_put(Dst, 2554, Dt1(->base), Dt1(->base), 1+1, LJ_TTAB, Dt1(->base), Dt1(->base), 1+2); | 984 | dasm_put(Dst, 2556, Dt1(->base), Dt1(->base), 1+1, LJ_TTAB, Dt1(->base), Dt1(->base), 1+2); |
985 | dasm_put(Dst, 2700, LJ_TNIL, LJ_TNIL, 1+1, LJ_TTAB, Dt8(->upvalue[0]), LJ_TFUNC, LJ_TNIL); | 985 | dasm_put(Dst, 2702, LJ_TNIL, LJ_TNIL, 1+1, LJ_TTAB, Dt8(->upvalue[0]), LJ_TFUNC, LJ_TNIL); |
986 | dasm_put(Dst, 2761, 1+3, 1+1, LJ_TTAB, LJ_TISNUM, Dt6(->asize), Dt6(->array), LJ_TNIL); | 986 | dasm_put(Dst, 2763, 1+3, 1+1, LJ_TTAB, LJ_TISNUM, Dt6(->asize), Dt6(->array), LJ_TNIL); |
987 | dasm_put(Dst, 2841, Dt6(->hmask), 1+0, 1+1, LJ_TTAB, Dt8(->upvalue[0])); | 987 | dasm_put(Dst, 2843, Dt6(->hmask), 1+0, 1+1, LJ_TTAB, Dt8(->upvalue[0])); |
988 | dasm_put(Dst, 2922, LJ_TFUNC, 1+3, 1+1, 8+FRAME_PCALL, DISPATCH_GL(hookmask), HOOK_ACTIVE, LJ_TFUNC, Dt7(->gate)); | 988 | dasm_put(Dst, 2924, LJ_TFUNC, 1+3, 1+1, 8+FRAME_PCALL, DISPATCH_GL(hookmask), HOOK_ACTIVE, LJ_TFUNC, Dt7(->gate)); |
989 | dasm_put(Dst, 3001, 2+1, LJ_TFUNC, LJ_TFUNC, 2*8+FRAME_PCALL, 2*8, 1+1); | 989 | dasm_put(Dst, 3003, 2+1, LJ_TFUNC, LJ_TFUNC, 2*8+FRAME_PCALL, 2*8, 1+1); |
990 | dasm_put(Dst, 3086, LJ_TTHREAD, Dt1(->cframe), Dt1(->status), LUA_YIELD, Dt1(->top), Dt1(->base), Dt1(->maxstack)); | 990 | dasm_put(Dst, 3088, LJ_TTHREAD, Dt1(->cframe), Dt1(->status), LUA_YIELD, Dt1(->top), Dt1(->base), Dt1(->maxstack)); |
991 | dasm_put(Dst, 3157, Dt1(->top), Dt1(->base), Dt1(->top), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), LUA_YIELD, Dt1(->base), Dt1(->top)); | 991 | dasm_put(Dst, 3159, Dt1(->top), Dt1(->base), Dt1(->top), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), LUA_YIELD, Dt1(->base), Dt1(->top)); |
992 | dasm_put(Dst, 3265, Dt1(->top), Dt1(->maxstack), LJ_TTRUE, FRAME_TYPE, LJ_TFALSE, Dt1(->top)); | 992 | dasm_put(Dst, 3267, Dt1(->top), Dt1(->maxstack), LJ_TTRUE, FRAME_TYPE, LJ_TFALSE, Dt1(->top)); |
993 | dasm_put(Dst, 3371, Dt1(->top), 1+2, Dt1(->top), Dt1(->base), Dt8(->upvalue[0].gcr), Dt1(->cframe), Dt1(->status), LUA_YIELD); | 993 | dasm_put(Dst, 3373, Dt1(->top), 1+2, Dt1(->top), Dt1(->base), Dt8(->upvalue[0].gcr), Dt1(->cframe), Dt1(->status), LUA_YIELD); |
994 | dasm_put(Dst, 3463, Dt1(->top), Dt1(->base), Dt1(->maxstack), Dt1(->top), Dt1(->base), Dt1(->top)); | 994 | dasm_put(Dst, 3465, Dt1(->top), Dt1(->base), Dt1(->maxstack), Dt1(->top), Dt1(->base), Dt1(->top)); |
995 | dasm_put(Dst, 3571, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), LUA_YIELD, Dt1(->base), Dt1(->top), Dt1(->top), Dt1(->maxstack)); | 995 | dasm_put(Dst, 3573, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), LUA_YIELD, Dt1(->base), Dt1(->top), Dt1(->top), Dt1(->maxstack)); |
996 | dasm_put(Dst, 3663, FRAME_TYPE, Dt1(->top), Dt1(->base), Dt1(->cframe), CFRAME_CANYIELD, Dt1(->base), Dt1(->top), Dt1(->cframe), LUA_YIELD); | 996 | dasm_put(Dst, 3665, FRAME_TYPE, Dt1(->top), Dt1(->base), Dt1(->cframe), CFRAME_CANYIELD, Dt1(->base), Dt1(->top), Dt1(->cframe), LUA_YIELD); |
997 | dasm_put(Dst, 3762, Dt1(->status), 1+1, LJ_TISNUM, 1+1, FRAME_TYPE); | 997 | dasm_put(Dst, 3764, Dt1(->status), 1+1, LJ_TISNUM, 1+1, FRAME_TYPE); |
998 | dasm_put(Dst, 3829, LJ_TNIL, 1+1, LJ_TISNUM, 1+1); | 998 | dasm_put(Dst, 3831, LJ_TNIL, 1+1, LJ_TISNUM, 1+1); |
999 | dasm_put(Dst, 3914, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); | 999 | dasm_put(Dst, 3916, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); |
1000 | dasm_put(Dst, 3971, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); | 1000 | dasm_put(Dst, 3973, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); |
1001 | dasm_put(Dst, 4038, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); | 1001 | dasm_put(Dst, 4040, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); |
1002 | dasm_put(Dst, 4095, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1, LJ_TISNUM); | 1002 | dasm_put(Dst, 4097, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1, LJ_TISNUM); |
1003 | dasm_put(Dst, 4163, 1+1, LJ_TISNUM, 1+1, LJ_TISNUM); | 1003 | dasm_put(Dst, 4165, 1+1, LJ_TISNUM, 1+1, LJ_TISNUM); |
1004 | dasm_put(Dst, 4257, 1+1, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); | 1004 | dasm_put(Dst, 4259, 1+1, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); |
1005 | dasm_put(Dst, 4356, LJ_TISNUM, 1+1, LJ_TISNUM, Dt8(->upvalue[0]), 2+1); | 1005 | dasm_put(Dst, 4358, LJ_TISNUM, 1+1, LJ_TISNUM, Dt8(->upvalue[0]), 2+1); |
1006 | dasm_put(Dst, 4432, LJ_TISNUM, LJ_TISNUM, 2+1, LJ_TISNUM, LJ_TISNUM); | 1006 | dasm_put(Dst, 4434, LJ_TISNUM, LJ_TISNUM, 2+1, LJ_TISNUM, LJ_TISNUM); |
1007 | dasm_put(Dst, 4507, 1+1, LJ_TISNUM, 1+2); | 1007 | dasm_put(Dst, 4509, 1+1, LJ_TISNUM, 1+2); |
1008 | dasm_put(Dst, 4631, 1+1, LJ_TISNUM, 1+2); | 1008 | dasm_put(Dst, 4633, 1+1, LJ_TISNUM, 1+2); |
1009 | dasm_put(Dst, 4740, 2+1, LJ_TISNUM, LJ_TISNUM); | 1009 | dasm_put(Dst, 4742, 2+1, LJ_TISNUM, LJ_TISNUM); |
1010 | dasm_put(Dst, 4819, 2+1, LJ_TISNUM, LJ_TISNUM, 1+1, LJ_TISNUM); | 1010 | dasm_put(Dst, 4821, 2+1, LJ_TISNUM, LJ_TISNUM, 1+1, LJ_TISNUM); |
1011 | dasm_put(Dst, 4877, LJ_TISNUM); | 1011 | dasm_put(Dst, 4879, LJ_TISNUM); |
1012 | if (cmov) { | 1012 | if (cmov) { |
1013 | dasm_put(Dst, 4911); | 1013 | dasm_put(Dst, 4913); |
1014 | } else { | 1014 | } else { |
1015 | dasm_put(Dst, 4919); | 1015 | dasm_put(Dst, 4921); |
1016 | } | 1016 | } |
1017 | dasm_put(Dst, 4940, 1+1, LJ_TISNUM, LJ_TISNUM); | 1017 | dasm_put(Dst, 4942, 1+1, LJ_TISNUM, LJ_TISNUM); |
1018 | if (cmov) { | 1018 | if (cmov) { |
1019 | dasm_put(Dst, 5000); | 1019 | dasm_put(Dst, 5002); |
1020 | } else { | 1020 | } else { |
1021 | dasm_put(Dst, 5008); | 1021 | dasm_put(Dst, 5010); |
1022 | } | 1022 | } |
1023 | dasm_put(Dst, 5029, 1+1, LJ_TSTR, Dt5(->len), 1+1, LJ_TSTR); | 1023 | dasm_put(Dst, 5031, 1+1, LJ_TSTR, Dt5(->len), 1+1, LJ_TSTR); |
1024 | dasm_put(Dst, 5088, Dt5(->len), Dt5([1]), DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), 1+1, LJ_TISNUM); | 1024 | dasm_put(Dst, 5090, Dt5(->len), Dt5([1]), DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), 1+1, LJ_TISNUM); |
1025 | dasm_put(Dst, 5147, Dt1(->base), Dt1(->base), LJ_TSTR, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), 1+2); | 1025 | dasm_put(Dst, 5149, Dt1(->base), Dt1(->base), LJ_TSTR, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), 1+2); |
1026 | dasm_put(Dst, 5272, LJ_TISNUM, LJ_TSTR, LJ_TISNUM, Dt5(->len)); | 1026 | dasm_put(Dst, 5274, LJ_TISNUM, LJ_TSTR, LJ_TISNUM, Dt5(->len)); |
1027 | dasm_put(Dst, 5363, sizeof(GCstr)-1); | 1027 | dasm_put(Dst, 5365, sizeof(GCstr)-1); |
1028 | dasm_put(Dst, 5437, 2+1, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), LJ_TSTR, LJ_TISNUM); | 1028 | dasm_put(Dst, 5439, 2+1, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), LJ_TSTR, LJ_TISNUM); |
1029 | dasm_put(Dst, 5510, Dt5(->len), DISPATCH_GL(tmpbuf.sz), Dt5([1]), DISPATCH_GL(tmpbuf.buf), 1+1, DISPATCH_GL(gc.total)); | 1029 | dasm_put(Dst, 5512, Dt5(->len), DISPATCH_GL(tmpbuf.sz), Dt5([1]), DISPATCH_GL(tmpbuf.buf), 1+1, DISPATCH_GL(gc.total)); |
1030 | dasm_put(Dst, 5577, DISPATCH_GL(gc.threshold), LJ_TSTR, Dt5(->len), DISPATCH_GL(tmpbuf.sz), sizeof(GCstr), DISPATCH_GL(tmpbuf.buf)); | 1030 | dasm_put(Dst, 5579, DISPATCH_GL(gc.threshold), LJ_TSTR, Dt5(->len), DISPATCH_GL(tmpbuf.sz), sizeof(GCstr), DISPATCH_GL(tmpbuf.buf)); |
1031 | dasm_put(Dst, 5658, 1+1, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), LJ_TSTR, Dt5(->len), DISPATCH_GL(tmpbuf.sz)); | 1031 | dasm_put(Dst, 5660, 1+1, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), LJ_TSTR, Dt5(->len), DISPATCH_GL(tmpbuf.sz)); |
1032 | dasm_put(Dst, 5717, sizeof(GCstr), DISPATCH_GL(tmpbuf.buf), 1+1, DISPATCH_GL(gc.total)); | 1032 | dasm_put(Dst, 5719, sizeof(GCstr), DISPATCH_GL(tmpbuf.buf), 1+1, DISPATCH_GL(gc.total)); |
1033 | dasm_put(Dst, 5802, DISPATCH_GL(gc.threshold), LJ_TSTR, Dt5(->len), DISPATCH_GL(tmpbuf.sz), sizeof(GCstr), DISPATCH_GL(tmpbuf.buf)); | 1033 | dasm_put(Dst, 5804, DISPATCH_GL(gc.threshold), LJ_TSTR, Dt5(->len), DISPATCH_GL(tmpbuf.sz), sizeof(GCstr), DISPATCH_GL(tmpbuf.buf)); |
1034 | dasm_put(Dst, 5877, 1+1, LJ_TTAB, 1+1); | 1034 | dasm_put(Dst, 5879, 1+1, LJ_TTAB, 1+1); |
1035 | dasm_put(Dst, 5970, LJ_TISNUM, 1+1, LJ_TISNUM, LJ_TISNUM); | 1035 | dasm_put(Dst, 5972, LJ_TISNUM, 1+1, LJ_TISNUM, LJ_TISNUM); |
1036 | dasm_put(Dst, 6090, 1+1, LJ_TISNUM, LJ_TISNUM, 1+1, LJ_TISNUM); | 1036 | dasm_put(Dst, 6092, 1+1, LJ_TISNUM, LJ_TISNUM, 1+1, LJ_TISNUM); |
1037 | dasm_put(Dst, 6192, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); | 1037 | dasm_put(Dst, 6194, LJ_TISNUM, 1+1, LJ_TISNUM, 1+1); |
1038 | dasm_put(Dst, 6313, LJ_TISNUM, 2+1, LJ_TISNUM, LJ_TISNUM); | 1038 | dasm_put(Dst, 6315, LJ_TISNUM, 2+1, LJ_TISNUM, LJ_TISNUM); |
1039 | dasm_put(Dst, 6443, 2+1, LJ_TISNUM, LJ_TISNUM, 2+1, LJ_TISNUM, LJ_TISNUM); | 1039 | dasm_put(Dst, 6445, 2+1, LJ_TISNUM, LJ_TISNUM, 2+1, LJ_TISNUM, LJ_TISNUM); |
1040 | dasm_put(Dst, 6544, 2+1, LJ_TISNUM, LJ_TISNUM, 2+1, LJ_TISNUM); | 1040 | dasm_put(Dst, 6546, 2+1, LJ_TISNUM, LJ_TISNUM, 2+1, LJ_TISNUM); |
1041 | dasm_put(Dst, 6683, LJ_TISNUM, 1+2, 1+1, Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), Dt8(->f)); | 1041 | dasm_put(Dst, 6685, LJ_TISNUM, 1+2, 1+1, Dt1(->base), 8*LUA_MINSTACK, Dt1(->top), Dt1(->maxstack), Dt8(->f)); |
1042 | dasm_put(Dst, 6810, Dt1(->base), Dt1(->top), Dt7(->gate), LJ_TFUNC, Dt7(->gate), Dt1(->base), LUA_MINSTACK, Dt1(->base)); | 1042 | dasm_put(Dst, 6812, Dt1(->base), Dt1(->top), Dt7(->gate), LJ_TFUNC, Dt7(->gate), Dt1(->base), LUA_MINSTACK, Dt1(->base)); |
1043 | dasm_put(Dst, 6921, Dt1(->top), Dt1(->base), Dt1(->top)); | 1043 | dasm_put(Dst, 6923, Dt1(->top), Dt1(->base), Dt1(->top)); |
1044 | #if LJ_HASJIT | 1044 | #if LJ_HASJIT |
1045 | dasm_put(Dst, 6973, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); | 1045 | dasm_put(Dst, 6975, DISPATCH_GL(hookmask), HOOK_VMEVENT, HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount)); |
1046 | #endif | 1046 | #endif |
1047 | dasm_put(Dst, 7004, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base), GG_DISP_STATIC*4); | 1047 | dasm_put(Dst, 7006, DISPATCH_GL(hookmask), HOOK_ACTIVE, LUA_MASKLINE|LUA_MASKCOUNT, DISPATCH_GL(hookcount), LUA_MASKLINE, Dt1(->base), Dt1(->base), GG_DISP_STATIC*4); |
1048 | #if LJ_HASJIT | 1048 | #if LJ_HASJIT |
1049 | dasm_put(Dst, 7095, GG_DISP2J, DISPATCH_J(L), Dt1(->base)); | 1049 | dasm_put(Dst, 7097, GG_DISP2J, DISPATCH_J(L), Dt1(->base)); |
1050 | #endif | 1050 | #endif |
1051 | dasm_put(Dst, 7128); | 1051 | dasm_put(Dst, 7130); |
1052 | #if LJ_HASJIT | 1052 | #if LJ_HASJIT |
1053 | dasm_put(Dst, 7131, GG_DISP2J, DISPATCH_J(L), Dt1(->base), Dt1(->base)); | 1053 | dasm_put(Dst, 7133, GG_DISP2J, DISPATCH_J(L), Dt1(->base), Dt1(->base)); |
1054 | #endif | 1054 | #endif |
1055 | dasm_put(Dst, 7181); | 1055 | dasm_put(Dst, 7183); |
1056 | #if LJ_HASJIT | 1056 | #if LJ_HASJIT |
1057 | dasm_put(Dst, 7184, DISPATCH_GL(vmstate), DISPATCH_GL(vmstate), ~LJ_VMST_EXIT, DISPATCH_J(exitno), DISPATCH_J(parent), 8*8+16, DISPATCH_J(flags), JIT_F_SSE2, DISPATCH_GL(jit_L), DISPATCH_GL(jit_base), DISPATCH_J(L), Dt1(->base), GG_DISP2J, Dt1(->base)); | 1057 | dasm_put(Dst, 7186, DISPATCH_GL(vmstate), DISPATCH_GL(vmstate), ~LJ_VMST_EXIT, DISPATCH_J(exitno), DISPATCH_J(parent), 8*8+16, DISPATCH_J(flags), JIT_F_SSE2, DISPATCH_GL(jit_L), DISPATCH_GL(jit_base), DISPATCH_J(L), Dt1(->base), GG_DISP2J, Dt1(->base)); |
1058 | #endif | 1058 | #endif |
1059 | dasm_put(Dst, 7334); | 1059 | dasm_put(Dst, 7336); |
1060 | #if LJ_HASJIT | 1060 | #if LJ_HASJIT |
1061 | dasm_put(Dst, 7337, Dt7(->pt), Dt9(->k), DISPATCH_GL(jit_L), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP); | 1061 | dasm_put(Dst, 7339, Dt7(->pt), Dt9(->k), DISPATCH_GL(jit_L), DISPATCH_GL(vmstate), ~LJ_VMST_INTERP); |
1062 | #endif | 1062 | #endif |
1063 | dasm_put(Dst, 7377); | 1063 | dasm_put(Dst, 7379); |
1064 | if (cmov) { | 1064 | if (cmov) { |
1065 | dasm_put(Dst, 7641); | 1065 | dasm_put(Dst, 7643); |
1066 | } else { | 1066 | } else { |
1067 | dasm_put(Dst, 7645); | 1067 | dasm_put(Dst, 7647); |
1068 | } | 1068 | } |
1069 | dasm_put(Dst, 7654); | 1069 | dasm_put(Dst, 7656); |
1070 | dasm_put(Dst, 7723); | 1070 | dasm_put(Dst, 7725); |
1071 | dasm_put(Dst, 7825); | 1071 | dasm_put(Dst, 7827); |
1072 | if (cmov) { | 1072 | if (cmov) { |
1073 | dasm_put(Dst, 7838); | 1073 | dasm_put(Dst, 7840); |
1074 | } else { | 1074 | } else { |
1075 | dasm_put(Dst, 7842); | 1075 | dasm_put(Dst, 7844); |
1076 | } | 1076 | } |
1077 | dasm_put(Dst, 7851); | 1077 | dasm_put(Dst, 7853); |
1078 | if (cmov) { | 1078 | if (cmov) { |
1079 | dasm_put(Dst, 7641); | 1079 | dasm_put(Dst, 7643); |
1080 | } else { | 1080 | } else { |
1081 | dasm_put(Dst, 7869); | 1081 | dasm_put(Dst, 7871); |
1082 | } | 1082 | } |
1083 | dasm_put(Dst, 7876); | 1083 | dasm_put(Dst, 7878); |
1084 | dasm_put(Dst, 7991); | 1084 | dasm_put(Dst, 7993); |
1085 | dasm_put(Dst, 8084); | 1085 | dasm_put(Dst, 8086); |
1086 | dasm_put(Dst, 8180); | 1086 | dasm_put(Dst, 8182); |
1087 | if (cmov) { | 1087 | if (cmov) { |
1088 | dasm_put(Dst, 8239); | 1088 | dasm_put(Dst, 8241); |
1089 | } else { | 1089 | } else { |
1090 | dasm_put(Dst, 8258); | 1090 | dasm_put(Dst, 8260); |
1091 | } | 1091 | } |
1092 | dasm_put(Dst, 8299); | 1092 | dasm_put(Dst, 8301); |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | /* Generate the code for a single instruction. */ | 1095 | /* Generate the code for a single instruction. */ |
1096 | static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov) | 1096 | static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov) |
1097 | { | 1097 | { |
1098 | int vk = 0; | 1098 | int vk = 0; |
1099 | dasm_put(Dst, 1452, defop); | 1099 | dasm_put(Dst, 1454, defop); |
1100 | 1100 | ||
1101 | switch (op) { | 1101 | switch (op) { |
1102 | 1102 | ||
@@ -1105,403 +1105,403 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov) | |||
1105 | /* Remember: all ops branch for a true comparison, fall through otherwise. */ | 1105 | /* Remember: all ops branch for a true comparison, fall through otherwise. */ |
1106 | 1106 | ||
1107 | case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: | 1107 | case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: |
1108 | dasm_put(Dst, 8356, LJ_TISNUM, LJ_TISNUM); | 1108 | dasm_put(Dst, 8358, LJ_TISNUM, LJ_TISNUM); |
1109 | if (cmov) { | 1109 | if (cmov) { |
1110 | dasm_put(Dst, 8386); | 1110 | dasm_put(Dst, 8388); |
1111 | } else { | 1111 | } else { |
1112 | dasm_put(Dst, 8392); | 1112 | dasm_put(Dst, 8394); |
1113 | } | 1113 | } |
1114 | switch (op) { | 1114 | switch (op) { |
1115 | case BC_ISLT: | 1115 | case BC_ISLT: |
1116 | dasm_put(Dst, 8399); | 1116 | dasm_put(Dst, 8401); |
1117 | break; | 1117 | break; |
1118 | case BC_ISGE: | 1118 | case BC_ISGE: |
1119 | dasm_put(Dst, 8404); | 1119 | dasm_put(Dst, 8406); |
1120 | break; | 1120 | break; |
1121 | case BC_ISLE: | 1121 | case BC_ISLE: |
1122 | dasm_put(Dst, 5872); | 1122 | dasm_put(Dst, 5874); |
1123 | break; | 1123 | break; |
1124 | case BC_ISGT: | 1124 | case BC_ISGT: |
1125 | dasm_put(Dst, 8409); | 1125 | dasm_put(Dst, 8411); |
1126 | break; | 1126 | break; |
1127 | default: break; /* Shut up GCC. */ | 1127 | default: break; /* Shut up GCC. */ |
1128 | } | 1128 | } |
1129 | dasm_put(Dst, 8414, -BCBIAS_J*4); | 1129 | dasm_put(Dst, 8416, -BCBIAS_J*4); |
1130 | break; | 1130 | break; |
1131 | 1131 | ||
1132 | case BC_ISEQV: case BC_ISNEV: | 1132 | case BC_ISEQV: case BC_ISNEV: |
1133 | vk = op == BC_ISEQV; | 1133 | vk = op == BC_ISEQV; |
1134 | dasm_put(Dst, 8447, LJ_TISNUM, LJ_TISNUM); | 1134 | dasm_put(Dst, 8449, LJ_TISNUM, LJ_TISNUM); |
1135 | if (cmov) { | 1135 | if (cmov) { |
1136 | dasm_put(Dst, 8386); | 1136 | dasm_put(Dst, 8388); |
1137 | } else { | 1137 | } else { |
1138 | dasm_put(Dst, 8392); | 1138 | dasm_put(Dst, 8394); |
1139 | } | 1139 | } |
1140 | iseqne_fp: | 1140 | iseqne_fp: |
1141 | if (vk) { | 1141 | if (vk) { |
1142 | dasm_put(Dst, 8479); | 1142 | dasm_put(Dst, 8481); |
1143 | } else { | 1143 | } else { |
1144 | dasm_put(Dst, 8488); | 1144 | dasm_put(Dst, 8490); |
1145 | } | 1145 | } |
1146 | iseqne_end: | 1146 | iseqne_end: |
1147 | if (vk) { | 1147 | if (vk) { |
1148 | dasm_put(Dst, 8497, -BCBIAS_J*4); | 1148 | dasm_put(Dst, 8499, -BCBIAS_J*4); |
1149 | } else { | 1149 | } else { |
1150 | dasm_put(Dst, 8512, -BCBIAS_J*4); | 1150 | dasm_put(Dst, 8514, -BCBIAS_J*4); |
1151 | } | 1151 | } |
1152 | dasm_put(Dst, 7162); | 1152 | dasm_put(Dst, 7164); |
1153 | if (op == BC_ISEQV || op == BC_ISNEV) { | 1153 | if (op == BC_ISEQV || op == BC_ISNEV) { |
1154 | dasm_put(Dst, 8527, LJ_TISPRI, LJ_TISTABUD, Dt6(->metatable), Dt6(->nomm), 1<<MM_eq); | 1154 | dasm_put(Dst, 8529, LJ_TISPRI, LJ_TISTABUD, Dt6(->metatable), Dt6(->nomm), 1<<MM_eq); |
1155 | if (vk) { | 1155 | if (vk) { |
1156 | dasm_put(Dst, 8585); | 1156 | dasm_put(Dst, 8587); |
1157 | } else { | 1157 | } else { |
1158 | dasm_put(Dst, 8589); | 1158 | dasm_put(Dst, 8591); |
1159 | } | 1159 | } |
1160 | dasm_put(Dst, 8595); | 1160 | dasm_put(Dst, 8597); |
1161 | } | 1161 | } |
1162 | break; | 1162 | break; |
1163 | case BC_ISEQS: case BC_ISNES: | 1163 | case BC_ISEQS: case BC_ISNES: |
1164 | vk = op == BC_ISEQS; | 1164 | vk = op == BC_ISEQS; |
1165 | dasm_put(Dst, 8600, LJ_TSTR); | 1165 | dasm_put(Dst, 8602, LJ_TSTR); |
1166 | iseqne_test: | 1166 | iseqne_test: |
1167 | if (vk) { | 1167 | if (vk) { |
1168 | dasm_put(Dst, 8483); | 1168 | dasm_put(Dst, 8485); |
1169 | } else { | 1169 | } else { |
1170 | dasm_put(Dst, 8175); | 1170 | dasm_put(Dst, 8177); |
1171 | } | 1171 | } |
1172 | goto iseqne_end; | 1172 | goto iseqne_end; |
1173 | case BC_ISEQN: case BC_ISNEN: | 1173 | case BC_ISEQN: case BC_ISNEN: |
1174 | vk = op == BC_ISEQN; | 1174 | vk = op == BC_ISEQN; |
1175 | dasm_put(Dst, 8623, LJ_TISNUM); | 1175 | dasm_put(Dst, 8625, LJ_TISNUM); |
1176 | if (cmov) { | 1176 | if (cmov) { |
1177 | dasm_put(Dst, 8386); | 1177 | dasm_put(Dst, 8388); |
1178 | } else { | 1178 | } else { |
1179 | dasm_put(Dst, 8392); | 1179 | dasm_put(Dst, 8394); |
1180 | } | 1180 | } |
1181 | goto iseqne_fp; | 1181 | goto iseqne_fp; |
1182 | case BC_ISEQP: case BC_ISNEP: | 1182 | case BC_ISEQP: case BC_ISNEP: |
1183 | vk = op == BC_ISEQP; | 1183 | vk = op == BC_ISEQP; |
1184 | dasm_put(Dst, 8643); | 1184 | dasm_put(Dst, 8645); |
1185 | goto iseqne_test; | 1185 | goto iseqne_test; |
1186 | 1186 | ||
1187 | /* -- Unary test and copy ops ------------------------------------------- */ | 1187 | /* -- Unary test and copy ops ------------------------------------------- */ |
1188 | 1188 | ||
1189 | case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: | 1189 | case BC_ISTC: case BC_ISFC: case BC_IST: case BC_ISF: |
1190 | dasm_put(Dst, 8654, LJ_TISTRUECOND); | 1190 | dasm_put(Dst, 8656, LJ_TISTRUECOND); |
1191 | if (op == BC_IST || op == BC_ISTC) { | 1191 | if (op == BC_IST || op == BC_ISTC) { |
1192 | dasm_put(Dst, 8666); | 1192 | dasm_put(Dst, 8668); |
1193 | } else { | 1193 | } else { |
1194 | dasm_put(Dst, 8671); | 1194 | dasm_put(Dst, 8673); |
1195 | } | 1195 | } |
1196 | if (op == BC_ISTC || op == BC_ISFC) { | 1196 | if (op == BC_ISTC || op == BC_ISFC) { |
1197 | dasm_put(Dst, 8676); | 1197 | dasm_put(Dst, 8678); |
1198 | } | 1198 | } |
1199 | dasm_put(Dst, 8687, -BCBIAS_J*4); | 1199 | dasm_put(Dst, 8689, -BCBIAS_J*4); |
1200 | break; | 1200 | break; |
1201 | 1201 | ||
1202 | /* -- Unary ops --------------------------------------------------------- */ | 1202 | /* -- Unary ops --------------------------------------------------------- */ |
1203 | 1203 | ||
1204 | case BC_MOV: | 1204 | case BC_MOV: |
1205 | dasm_put(Dst, 8718); | 1205 | dasm_put(Dst, 8720); |
1206 | break; | 1206 | break; |
1207 | case BC_NOT: | 1207 | case BC_NOT: |
1208 | dasm_put(Dst, 8751, LJ_TISTRUECOND, LJ_TTRUE); | 1208 | dasm_put(Dst, 8753, LJ_TISTRUECOND, LJ_TTRUE); |
1209 | break; | 1209 | break; |
1210 | case BC_UNM: | 1210 | case BC_UNM: |
1211 | dasm_put(Dst, 8786, LJ_TISNUM); | 1211 | dasm_put(Dst, 8788, LJ_TISNUM); |
1212 | break; | 1212 | break; |
1213 | case BC_LEN: | 1213 | case BC_LEN: |
1214 | dasm_put(Dst, 8823, LJ_TSTR, Dt5(->len), LJ_TTAB); | 1214 | dasm_put(Dst, 8825, LJ_TSTR, Dt5(->len), LJ_TTAB); |
1215 | break; | 1215 | break; |
1216 | 1216 | ||
1217 | /* -- Binary ops -------------------------------------------------------- */ | 1217 | /* -- Binary ops -------------------------------------------------------- */ |
1218 | 1218 | ||
1219 | 1219 | ||
1220 | case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: | 1220 | case BC_ADDVN: case BC_ADDNV: case BC_ADDVV: |
1221 | dasm_put(Dst, 8902); | 1221 | dasm_put(Dst, 8904); |
1222 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | 1222 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); |
1223 | switch (vk) { | 1223 | switch (vk) { |
1224 | case 0: | 1224 | case 0: |
1225 | dasm_put(Dst, 8910, LJ_TISNUM); | 1225 | dasm_put(Dst, 8912, LJ_TISNUM); |
1226 | break; | 1226 | break; |
1227 | case 1: | 1227 | case 1: |
1228 | dasm_put(Dst, 8929, LJ_TISNUM); | 1228 | dasm_put(Dst, 8931, LJ_TISNUM); |
1229 | break; | 1229 | break; |
1230 | default: | 1230 | default: |
1231 | dasm_put(Dst, 8948, LJ_TISNUM, LJ_TISNUM); | 1231 | dasm_put(Dst, 8950, LJ_TISNUM, LJ_TISNUM); |
1232 | break; | 1232 | break; |
1233 | } | 1233 | } |
1234 | dasm_put(Dst, 8801); | 1234 | dasm_put(Dst, 8803); |
1235 | break; | 1235 | break; |
1236 | case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: | 1236 | case BC_SUBVN: case BC_SUBNV: case BC_SUBVV: |
1237 | dasm_put(Dst, 8902); | 1237 | dasm_put(Dst, 8904); |
1238 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | 1238 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); |
1239 | switch (vk) { | 1239 | switch (vk) { |
1240 | case 0: | 1240 | case 0: |
1241 | dasm_put(Dst, 8977, LJ_TISNUM); | 1241 | dasm_put(Dst, 8979, LJ_TISNUM); |
1242 | break; | 1242 | break; |
1243 | case 1: | 1243 | case 1: |
1244 | dasm_put(Dst, 8996, LJ_TISNUM); | 1244 | dasm_put(Dst, 8998, LJ_TISNUM); |
1245 | break; | 1245 | break; |
1246 | default: | 1246 | default: |
1247 | dasm_put(Dst, 9015, LJ_TISNUM, LJ_TISNUM); | 1247 | dasm_put(Dst, 9017, LJ_TISNUM, LJ_TISNUM); |
1248 | break; | 1248 | break; |
1249 | } | 1249 | } |
1250 | dasm_put(Dst, 8801); | 1250 | dasm_put(Dst, 8803); |
1251 | break; | 1251 | break; |
1252 | case BC_MULVN: case BC_MULNV: case BC_MULVV: | 1252 | case BC_MULVN: case BC_MULNV: case BC_MULVV: |
1253 | dasm_put(Dst, 8902); | 1253 | dasm_put(Dst, 8904); |
1254 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | 1254 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); |
1255 | switch (vk) { | 1255 | switch (vk) { |
1256 | case 0: | 1256 | case 0: |
1257 | dasm_put(Dst, 9044, LJ_TISNUM); | 1257 | dasm_put(Dst, 9046, LJ_TISNUM); |
1258 | break; | 1258 | break; |
1259 | case 1: | 1259 | case 1: |
1260 | dasm_put(Dst, 9063, LJ_TISNUM); | 1260 | dasm_put(Dst, 9065, LJ_TISNUM); |
1261 | break; | 1261 | break; |
1262 | default: | 1262 | default: |
1263 | dasm_put(Dst, 9082, LJ_TISNUM, LJ_TISNUM); | 1263 | dasm_put(Dst, 9084, LJ_TISNUM, LJ_TISNUM); |
1264 | break; | 1264 | break; |
1265 | } | 1265 | } |
1266 | dasm_put(Dst, 8801); | 1266 | dasm_put(Dst, 8803); |
1267 | break; | 1267 | break; |
1268 | case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: | 1268 | case BC_DIVVN: case BC_DIVNV: case BC_DIVVV: |
1269 | dasm_put(Dst, 8902); | 1269 | dasm_put(Dst, 8904); |
1270 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | 1270 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); |
1271 | switch (vk) { | 1271 | switch (vk) { |
1272 | case 0: | 1272 | case 0: |
1273 | dasm_put(Dst, 9111, LJ_TISNUM); | 1273 | dasm_put(Dst, 9113, LJ_TISNUM); |
1274 | break; | 1274 | break; |
1275 | case 1: | 1275 | case 1: |
1276 | dasm_put(Dst, 9130, LJ_TISNUM); | 1276 | dasm_put(Dst, 9132, LJ_TISNUM); |
1277 | break; | 1277 | break; |
1278 | default: | 1278 | default: |
1279 | dasm_put(Dst, 9149, LJ_TISNUM, LJ_TISNUM); | 1279 | dasm_put(Dst, 9151, LJ_TISNUM, LJ_TISNUM); |
1280 | break; | 1280 | break; |
1281 | } | 1281 | } |
1282 | dasm_put(Dst, 8801); | 1282 | dasm_put(Dst, 8803); |
1283 | break; | 1283 | break; |
1284 | case BC_MODVN: | 1284 | case BC_MODVN: |
1285 | dasm_put(Dst, 8902); | 1285 | dasm_put(Dst, 8904); |
1286 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | 1286 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); |
1287 | switch (vk) { | 1287 | switch (vk) { |
1288 | case 0: | 1288 | case 0: |
1289 | dasm_put(Dst, 9178, LJ_TISNUM); | 1289 | dasm_put(Dst, 9180, LJ_TISNUM); |
1290 | break; | 1290 | break; |
1291 | case 1: | 1291 | case 1: |
1292 | dasm_put(Dst, 9197, LJ_TISNUM); | 1292 | dasm_put(Dst, 9199, LJ_TISNUM); |
1293 | break; | 1293 | break; |
1294 | default: | 1294 | default: |
1295 | dasm_put(Dst, 9216, LJ_TISNUM, LJ_TISNUM); | 1295 | dasm_put(Dst, 9218, LJ_TISNUM, LJ_TISNUM); |
1296 | break; | 1296 | break; |
1297 | } | 1297 | } |
1298 | dasm_put(Dst, 9245); | 1298 | dasm_put(Dst, 9247); |
1299 | break; | 1299 | break; |
1300 | case BC_MODNV: case BC_MODVV: | 1300 | case BC_MODNV: case BC_MODVV: |
1301 | dasm_put(Dst, 8902); | 1301 | dasm_put(Dst, 8904); |
1302 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | 1302 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); |
1303 | switch (vk) { | 1303 | switch (vk) { |
1304 | case 0: | 1304 | case 0: |
1305 | dasm_put(Dst, 9178, LJ_TISNUM); | 1305 | dasm_put(Dst, 9180, LJ_TISNUM); |
1306 | break; | 1306 | break; |
1307 | case 1: | 1307 | case 1: |
1308 | dasm_put(Dst, 9197, LJ_TISNUM); | 1308 | dasm_put(Dst, 9199, LJ_TISNUM); |
1309 | break; | 1309 | break; |
1310 | default: | 1310 | default: |
1311 | dasm_put(Dst, 9216, LJ_TISNUM, LJ_TISNUM); | 1311 | dasm_put(Dst, 9218, LJ_TISNUM, LJ_TISNUM); |
1312 | break; | 1312 | break; |
1313 | } | 1313 | } |
1314 | dasm_put(Dst, 9272); | 1314 | dasm_put(Dst, 9274); |
1315 | break; | 1315 | break; |
1316 | case BC_POW: | 1316 | case BC_POW: |
1317 | dasm_put(Dst, 8902); | 1317 | dasm_put(Dst, 8904); |
1318 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); | 1318 | vk = ((int)op - BC_ADDVN) / (BC_ADDNV-BC_ADDVN); |
1319 | switch (vk) { | 1319 | switch (vk) { |
1320 | case 0: | 1320 | case 0: |
1321 | dasm_put(Dst, 9178, LJ_TISNUM); | 1321 | dasm_put(Dst, 9180, LJ_TISNUM); |
1322 | break; | 1322 | break; |
1323 | case 1: | 1323 | case 1: |
1324 | dasm_put(Dst, 9197, LJ_TISNUM); | 1324 | dasm_put(Dst, 9199, LJ_TISNUM); |
1325 | break; | 1325 | break; |
1326 | default: | 1326 | default: |
1327 | dasm_put(Dst, 9216, LJ_TISNUM, LJ_TISNUM); | 1327 | dasm_put(Dst, 9218, LJ_TISNUM, LJ_TISNUM); |
1328 | break; | 1328 | break; |
1329 | } | 1329 | } |
1330 | dasm_put(Dst, 9277); | 1330 | dasm_put(Dst, 9279); |
1331 | break; | 1331 | break; |
1332 | 1332 | ||
1333 | case BC_CAT: | 1333 | case BC_CAT: |
1334 | dasm_put(Dst, 9302, Dt1(->base), Dt1(->base)); | 1334 | dasm_put(Dst, 9304, Dt1(->base), Dt1(->base)); |
1335 | break; | 1335 | break; |
1336 | 1336 | ||
1337 | /* -- Constant ops ------------------------------------------------------ */ | 1337 | /* -- Constant ops ------------------------------------------------------ */ |
1338 | 1338 | ||
1339 | case BC_KSTR: | 1339 | case BC_KSTR: |
1340 | dasm_put(Dst, 9396, LJ_TSTR); | 1340 | dasm_put(Dst, 9398, LJ_TSTR); |
1341 | break; | 1341 | break; |
1342 | case BC_KSHORT: | 1342 | case BC_KSHORT: |
1343 | dasm_put(Dst, 9429); | 1343 | dasm_put(Dst, 9431); |
1344 | break; | 1344 | break; |
1345 | case BC_KNUM: | 1345 | case BC_KNUM: |
1346 | dasm_put(Dst, 9455); | 1346 | dasm_put(Dst, 9457); |
1347 | break; | 1347 | break; |
1348 | case BC_KPRI: | 1348 | case BC_KPRI: |
1349 | dasm_put(Dst, 9480); | 1349 | dasm_put(Dst, 9482); |
1350 | break; | 1350 | break; |
1351 | case BC_KNIL: | 1351 | case BC_KNIL: |
1352 | dasm_put(Dst, 9506, LJ_TNIL); | 1352 | dasm_put(Dst, 9508, LJ_TNIL); |
1353 | break; | 1353 | break; |
1354 | 1354 | ||
1355 | /* -- Upvalue and function ops ------------------------------------------ */ | 1355 | /* -- Upvalue and function ops ------------------------------------------ */ |
1356 | 1356 | ||
1357 | case BC_UGET: | 1357 | case BC_UGET: |
1358 | dasm_put(Dst, 9552, offsetof(GCfuncL, uvptr), DtA(->v)); | 1358 | dasm_put(Dst, 9554, offsetof(GCfuncL, uvptr), DtA(->v)); |
1359 | break; | 1359 | break; |
1360 | case BC_USETV: | 1360 | case BC_USETV: |
1361 | #define TV2MARKOFS \ | 1361 | #define TV2MARKOFS \ |
1362 | ((int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)) | 1362 | ((int32_t)offsetof(GCupval, marked)-(int32_t)offsetof(GCupval, tv)) |
1363 | dasm_put(Dst, 9596, offsetof(GCfuncL, uvptr), DtA(->closed), DtA(->v), TV2MARKOFS, LJ_GC_BLACK, LJ_TISGCV, LJ_TISNUM - LJ_TISGCV, Dt4(->gch.marked), LJ_GC_WHITES, GG_DISP2G); | 1363 | dasm_put(Dst, 9598, offsetof(GCfuncL, uvptr), DtA(->closed), DtA(->v), TV2MARKOFS, LJ_GC_BLACK, LJ_TISGCV, LJ_TISNUM - LJ_TISGCV, Dt4(->gch.marked), LJ_GC_WHITES, GG_DISP2G); |
1364 | dasm_put(Dst, 9686); | 1364 | dasm_put(Dst, 9688); |
1365 | break; | 1365 | break; |
1366 | #undef TV2MARKOFS | 1366 | #undef TV2MARKOFS |
1367 | case BC_USETS: | 1367 | case BC_USETS: |
1368 | dasm_put(Dst, 9698, offsetof(GCfuncL, uvptr), DtA(->v), LJ_TSTR, DtA(->marked), LJ_GC_BLACK, Dt4(->gch.marked), LJ_GC_WHITES, DtA(->closed), GG_DISP2G); | 1368 | dasm_put(Dst, 9700, offsetof(GCfuncL, uvptr), DtA(->v), LJ_TSTR, DtA(->marked), LJ_GC_BLACK, Dt4(->gch.marked), LJ_GC_WHITES, DtA(->closed), GG_DISP2G); |
1369 | break; | 1369 | break; |
1370 | case BC_USETN: | 1370 | case BC_USETN: |
1371 | dasm_put(Dst, 9789, offsetof(GCfuncL, uvptr), DtA(->v)); | 1371 | dasm_put(Dst, 9791, offsetof(GCfuncL, uvptr), DtA(->v)); |
1372 | break; | 1372 | break; |
1373 | case BC_USETP: | 1373 | case BC_USETP: |
1374 | dasm_put(Dst, 9825, offsetof(GCfuncL, uvptr), DtA(->v)); | 1374 | dasm_put(Dst, 9827, offsetof(GCfuncL, uvptr), DtA(->v)); |
1375 | break; | 1375 | break; |
1376 | case BC_UCLO: | 1376 | case BC_UCLO: |
1377 | dasm_put(Dst, 9862, -BCBIAS_J*4, Dt1(->openupval), Dt1(->base), Dt1(->base)); | 1377 | dasm_put(Dst, 9864, -BCBIAS_J*4, Dt1(->openupval), Dt1(->base), Dt1(->base)); |
1378 | break; | 1378 | break; |
1379 | 1379 | ||
1380 | case BC_FNEW: | 1380 | case BC_FNEW: |
1381 | dasm_put(Dst, 9920, Dt1(->base), Dt1(->base), LJ_TFUNC); | 1381 | dasm_put(Dst, 9922, Dt1(->base), Dt1(->base), LJ_TFUNC); |
1382 | break; | 1382 | break; |
1383 | 1383 | ||
1384 | /* -- Table ops --------------------------------------------------------- */ | 1384 | /* -- Table ops --------------------------------------------------------- */ |
1385 | 1385 | ||
1386 | case BC_TNEW: | 1386 | case BC_TNEW: |
1387 | dasm_put(Dst, 9991, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), Dt1(->base), Dt1(->base), LJ_TTAB); | 1387 | dasm_put(Dst, 9993, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), Dt1(->base), Dt1(->base), LJ_TTAB); |
1388 | break; | 1388 | break; |
1389 | case BC_TDUP: | 1389 | case BC_TDUP: |
1390 | dasm_put(Dst, 10102, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), Dt1(->base), Dt1(->base), LJ_TTAB); | 1390 | dasm_put(Dst, 10104, DISPATCH_GL(gc.total), DISPATCH_GL(gc.threshold), Dt1(->base), Dt1(->base), LJ_TTAB); |
1391 | break; | 1391 | break; |
1392 | 1392 | ||
1393 | case BC_GGET: | 1393 | case BC_GGET: |
1394 | dasm_put(Dst, 10194, Dt7(->env)); | 1394 | dasm_put(Dst, 10196, Dt7(->env)); |
1395 | break; | 1395 | break; |
1396 | case BC_GSET: | 1396 | case BC_GSET: |
1397 | dasm_put(Dst, 10212, Dt7(->env)); | 1397 | dasm_put(Dst, 10214, Dt7(->env)); |
1398 | break; | 1398 | break; |
1399 | 1399 | ||
1400 | case BC_TGETV: | 1400 | case BC_TGETV: |
1401 | dasm_put(Dst, 10230, LJ_TTAB, LJ_TISNUM); | 1401 | dasm_put(Dst, 10232, LJ_TTAB, LJ_TISNUM); |
1402 | if (cmov) { | 1402 | if (cmov) { |
1403 | dasm_put(Dst, 8386); | 1403 | dasm_put(Dst, 8388); |
1404 | } else { | 1404 | } else { |
1405 | dasm_put(Dst, 8392); | 1405 | dasm_put(Dst, 8394); |
1406 | } | 1406 | } |
1407 | dasm_put(Dst, 10272, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_index); | 1407 | dasm_put(Dst, 10274, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_index); |
1408 | dasm_put(Dst, 10367, LJ_TSTR); | 1408 | dasm_put(Dst, 10369, LJ_TSTR); |
1409 | break; | 1409 | break; |
1410 | case BC_TGETS: | 1410 | case BC_TGETS: |
1411 | dasm_put(Dst, 10385, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), LJ_TNIL); | 1411 | dasm_put(Dst, 10387, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), LJ_TNIL); |
1412 | dasm_put(Dst, 10469, LJ_TNIL, DtB(->next), Dt6(->metatable), Dt6(->nomm), 1<<MM_index); | 1412 | dasm_put(Dst, 10471, LJ_TNIL, DtB(->next), Dt6(->metatable), Dt6(->nomm), 1<<MM_index); |
1413 | break; | 1413 | break; |
1414 | case BC_TGETB: | 1414 | case BC_TGETB: |
1415 | dasm_put(Dst, 10540, LJ_TTAB, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_index); | 1415 | dasm_put(Dst, 10542, LJ_TTAB, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_index); |
1416 | dasm_put(Dst, 8892); | 1416 | dasm_put(Dst, 8894); |
1417 | break; | 1417 | break; |
1418 | 1418 | ||
1419 | case BC_TSETV: | 1419 | case BC_TSETV: |
1420 | dasm_put(Dst, 10639, LJ_TTAB, LJ_TISNUM); | 1420 | dasm_put(Dst, 10641, LJ_TTAB, LJ_TISNUM); |
1421 | if (cmov) { | 1421 | if (cmov) { |
1422 | dasm_put(Dst, 8386); | 1422 | dasm_put(Dst, 8388); |
1423 | } else { | 1423 | } else { |
1424 | dasm_put(Dst, 8392); | 1424 | dasm_put(Dst, 8394); |
1425 | } | 1425 | } |
1426 | dasm_put(Dst, 10681, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable)); | 1426 | dasm_put(Dst, 10683, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable)); |
1427 | dasm_put(Dst, 10767, Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); | 1427 | dasm_put(Dst, 10769, Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); |
1428 | break; | 1428 | break; |
1429 | case BC_TSETS: | 1429 | case BC_TSETS: |
1430 | dasm_put(Dst, 10829, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->nomm), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), LJ_TNIL); | 1430 | dasm_put(Dst, 10831, LJ_TTAB, Dt6(->hmask), Dt5(->hash), sizeof(Node), Dt6(->nomm), Dt6(->node), DtB(->key.it), LJ_TSTR, DtB(->key.gcr), LJ_TNIL); |
1431 | dasm_put(Dst, 10904, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, DtB(->next)); | 1431 | dasm_put(Dst, 10906, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable), Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, DtB(->next)); |
1432 | dasm_put(Dst, 10994, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); | 1432 | dasm_put(Dst, 10996, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, LJ_TSTR, Dt1(->base), Dt1(->base), Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); |
1433 | break; | 1433 | break; |
1434 | case BC_TSETB: | 1434 | case BC_TSETB: |
1435 | dasm_put(Dst, 11090, LJ_TTAB, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable)); | 1435 | dasm_put(Dst, 11092, LJ_TTAB, Dt6(->asize), Dt6(->array), LJ_TNIL, Dt6(->marked), LJ_GC_BLACK, Dt6(->metatable)); |
1436 | dasm_put(Dst, 11188, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); | 1436 | dasm_put(Dst, 11190, Dt6(->metatable), Dt6(->nomm), 1<<MM_newindex, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); |
1437 | break; | 1437 | break; |
1438 | 1438 | ||
1439 | case BC_TSETM: | 1439 | case BC_TSETM: |
1440 | dasm_put(Dst, 11234, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base)); | 1440 | dasm_put(Dst, 11236, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base)); |
1441 | dasm_put(Dst, 11391, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); | 1441 | dasm_put(Dst, 11393, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist)); |
1442 | break; | 1442 | break; |
1443 | 1443 | ||
1444 | /* -- Calls and vararg handling ----------------------------------------- */ | 1444 | /* -- Calls and vararg handling ----------------------------------------- */ |
1445 | 1445 | ||
1446 | case BC_CALL: case BC_CALLM: | 1446 | case BC_CALL: case BC_CALLM: |
1447 | dasm_put(Dst, 8906); | 1447 | dasm_put(Dst, 8908); |
1448 | if (op == BC_CALLM) { | 1448 | if (op == BC_CALLM) { |
1449 | dasm_put(Dst, 11409); | 1449 | dasm_put(Dst, 11411); |
1450 | } | 1450 | } |
1451 | dasm_put(Dst, 11414, LJ_TFUNC, Dt7(->gate)); | 1451 | dasm_put(Dst, 11416, LJ_TFUNC, Dt7(->gate)); |
1452 | break; | 1452 | break; |
1453 | 1453 | ||
1454 | case BC_CALLMT: | 1454 | case BC_CALLMT: |
1455 | dasm_put(Dst, 11409); | 1455 | dasm_put(Dst, 11411); |
1456 | break; | 1456 | break; |
1457 | case BC_CALLT: | 1457 | case BC_CALLT: |
1458 | dasm_put(Dst, 11437, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->gate)); | 1458 | dasm_put(Dst, 11439, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->gate)); |
1459 | dasm_put(Dst, 11542, FRAME_TYPE, Dt7(->pt), Dt9(->k)); | 1459 | dasm_put(Dst, 11544, FRAME_TYPE, Dt7(->pt), Dt9(->k)); |
1460 | break; | 1460 | break; |
1461 | 1461 | ||
1462 | case BC_ITERC: | 1462 | case BC_ITERC: |
1463 | dasm_put(Dst, 11599, LJ_TFUNC, Dt7(->gate)); | 1463 | dasm_put(Dst, 11601, LJ_TFUNC, Dt7(->gate)); |
1464 | break; | 1464 | break; |
1465 | 1465 | ||
1466 | case BC_VARG: | 1466 | case BC_VARG: |
1467 | dasm_put(Dst, 11661, Dt7(->pt), Dt9(->numparams), (8+FRAME_VARG), LJ_TNIL); | 1467 | dasm_put(Dst, 11663, Dt7(->pt), Dt9(->numparams), (8+FRAME_VARG), LJ_TNIL); |
1468 | dasm_put(Dst, 11805, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); | 1468 | dasm_put(Dst, 11807, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); |
1469 | break; | 1469 | break; |
1470 | 1470 | ||
1471 | /* -- Returns ----------------------------------------------------------- */ | 1471 | /* -- Returns ----------------------------------------------------------- */ |
1472 | 1472 | ||
1473 | case BC_RETM: | 1473 | case BC_RETM: |
1474 | dasm_put(Dst, 11409); | 1474 | dasm_put(Dst, 11411); |
1475 | break; | 1475 | break; |
1476 | 1476 | ||
1477 | case BC_RET: case BC_RET0: case BC_RET1: | 1477 | case BC_RET: case BC_RET0: case BC_RET1: |
1478 | if (op != BC_RET0) { | 1478 | if (op != BC_RET0) { |
1479 | dasm_put(Dst, 11900); | 1479 | dasm_put(Dst, 11902); |
1480 | } | 1480 | } |
1481 | dasm_put(Dst, 11904, FRAME_TYPE); | 1481 | dasm_put(Dst, 11906, FRAME_TYPE); |
1482 | switch (op) { | 1482 | switch (op) { |
1483 | case BC_RET: | 1483 | case BC_RET: |
1484 | dasm_put(Dst, 11923); | 1484 | dasm_put(Dst, 11925); |
1485 | break; | 1485 | break; |
1486 | case BC_RET1: | 1486 | case BC_RET1: |
1487 | dasm_put(Dst, 11981); | 1487 | dasm_put(Dst, 11983); |
1488 | /* fallthrough */ | 1488 | /* fallthrough */ |
1489 | case BC_RET0: | 1489 | case BC_RET0: |
1490 | dasm_put(Dst, 3818); | 1490 | dasm_put(Dst, 3820); |
1491 | default: | 1491 | default: |
1492 | break; | 1492 | break; |
1493 | } | 1493 | } |
1494 | dasm_put(Dst, 11997, Dt7(->pt), Dt9(->k)); | 1494 | dasm_put(Dst, 11999, Dt7(->pt), Dt9(->k)); |
1495 | if (op == BC_RET) { | 1495 | if (op == BC_RET) { |
1496 | dasm_put(Dst, 12039, LJ_TNIL); | 1496 | dasm_put(Dst, 12041, LJ_TNIL); |
1497 | } else { | 1497 | } else { |
1498 | dasm_put(Dst, 12048, LJ_TNIL); | 1498 | dasm_put(Dst, 12050, LJ_TNIL); |
1499 | } | 1499 | } |
1500 | dasm_put(Dst, 12055); | 1500 | dasm_put(Dst, 12057); |
1501 | if (op != BC_RET0) { | 1501 | if (op != BC_RET0) { |
1502 | dasm_put(Dst, 12076); | 1502 | dasm_put(Dst, 12078); |
1503 | } | 1503 | } |
1504 | dasm_put(Dst, 8897); | 1504 | dasm_put(Dst, 8899); |
1505 | break; | 1505 | break; |
1506 | 1506 | ||
1507 | /* -- Loops and branches ------------------------------------------------ */ | 1507 | /* -- Loops and branches ------------------------------------------------ */ |
@@ -1509,7 +1509,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov) | |||
1509 | 1509 | ||
1510 | case BC_FORL: | 1510 | case BC_FORL: |
1511 | #if LJ_HASJIT | 1511 | #if LJ_HASJIT |
1512 | dasm_put(Dst, 12080, HOTCOUNT_PCMASK, GG_DISP2HOT); | 1512 | dasm_put(Dst, 12082, HOTCOUNT_PCMASK, GG_DISP2HOT); |
1513 | #endif | 1513 | #endif |
1514 | break; | 1514 | break; |
1515 | 1515 | ||
@@ -1521,42 +1521,42 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov) | |||
1521 | case BC_FORI: | 1521 | case BC_FORI: |
1522 | case BC_IFORL: | 1522 | case BC_IFORL: |
1523 | vk = (op == BC_IFORL || op == BC_JFORL); | 1523 | vk = (op == BC_IFORL || op == BC_JFORL); |
1524 | dasm_put(Dst, 12101); | 1524 | dasm_put(Dst, 12103); |
1525 | if (!vk) { | 1525 | if (!vk) { |
1526 | dasm_put(Dst, 12105, LJ_TISNUM, LJ_TISNUM); | 1526 | dasm_put(Dst, 12107, LJ_TISNUM, LJ_TISNUM); |
1527 | } | 1527 | } |
1528 | dasm_put(Dst, 12124); | 1528 | dasm_put(Dst, 12126); |
1529 | if (!vk) { | 1529 | if (!vk) { |
1530 | dasm_put(Dst, 12128, LJ_TISNUM); | 1530 | dasm_put(Dst, 12130, LJ_TISNUM); |
1531 | } | 1531 | } |
1532 | dasm_put(Dst, 12137); | 1532 | dasm_put(Dst, 12139); |
1533 | if (vk) { | 1533 | if (vk) { |
1534 | dasm_put(Dst, 12143); | 1534 | dasm_put(Dst, 12145); |
1535 | } | 1535 | } |
1536 | dasm_put(Dst, 12149); | 1536 | dasm_put(Dst, 12151); |
1537 | if (cmov) { | 1537 | if (cmov) { |
1538 | dasm_put(Dst, 8386); | 1538 | dasm_put(Dst, 8388); |
1539 | } else { | 1539 | } else { |
1540 | dasm_put(Dst, 8392); | 1540 | dasm_put(Dst, 8394); |
1541 | } | 1541 | } |
1542 | if (!cmov) { | 1542 | if (!cmov) { |
1543 | dasm_put(Dst, 12164); | 1543 | dasm_put(Dst, 12166); |
1544 | } | 1544 | } |
1545 | if (op == BC_FORI) { | 1545 | if (op == BC_FORI) { |
1546 | dasm_put(Dst, 12170, -BCBIAS_J*4); | 1546 | dasm_put(Dst, 12172, -BCBIAS_J*4); |
1547 | } else if (op == BC_JFORI) { | 1547 | } else if (op == BC_JFORI) { |
1548 | dasm_put(Dst, 12180, -BCBIAS_J*4, BC_JLOOP); | 1548 | dasm_put(Dst, 12182, -BCBIAS_J*4, BC_JLOOP); |
1549 | } else if (op == BC_IFORL) { | 1549 | } else if (op == BC_IFORL) { |
1550 | dasm_put(Dst, 12194, -BCBIAS_J*4); | 1550 | dasm_put(Dst, 12196, -BCBIAS_J*4); |
1551 | } else { | 1551 | } else { |
1552 | dasm_put(Dst, 12190, BC_JLOOP); | 1552 | dasm_put(Dst, 12192, BC_JLOOP); |
1553 | } | 1553 | } |
1554 | dasm_put(Dst, 8426); | 1554 | dasm_put(Dst, 8428); |
1555 | break; | 1555 | break; |
1556 | 1556 | ||
1557 | case BC_ITERL: | 1557 | case BC_ITERL: |
1558 | #if LJ_HASJIT | 1558 | #if LJ_HASJIT |
1559 | dasm_put(Dst, 12080, HOTCOUNT_PCMASK, GG_DISP2HOT); | 1559 | dasm_put(Dst, 12082, HOTCOUNT_PCMASK, GG_DISP2HOT); |
1560 | #endif | 1560 | #endif |
1561 | break; | 1561 | break; |
1562 | 1562 | ||
@@ -1565,33 +1565,33 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov) | |||
1565 | break; | 1565 | break; |
1566 | #endif | 1566 | #endif |
1567 | case BC_IITERL: | 1567 | case BC_IITERL: |
1568 | dasm_put(Dst, 12204, LJ_TNIL); | 1568 | dasm_put(Dst, 12206, LJ_TNIL); |
1569 | if (op == BC_JITERL) { | 1569 | if (op == BC_JITERL) { |
1570 | dasm_put(Dst, 12219, BC_JLOOP); | 1570 | dasm_put(Dst, 12221, BC_JLOOP); |
1571 | } else { | 1571 | } else { |
1572 | dasm_put(Dst, 12233, -BCBIAS_J*4); | 1572 | dasm_put(Dst, 12235, -BCBIAS_J*4); |
1573 | } | 1573 | } |
1574 | dasm_put(Dst, 8697); | 1574 | dasm_put(Dst, 8699); |
1575 | break; | 1575 | break; |
1576 | 1576 | ||
1577 | case BC_LOOP: | 1577 | case BC_LOOP: |
1578 | #if LJ_HASJIT | 1578 | #if LJ_HASJIT |
1579 | dasm_put(Dst, 12080, HOTCOUNT_PCMASK, GG_DISP2HOT); | 1579 | dasm_put(Dst, 12082, HOTCOUNT_PCMASK, GG_DISP2HOT); |
1580 | #endif | 1580 | #endif |
1581 | break; | 1581 | break; |
1582 | 1582 | ||
1583 | case BC_ILOOP: | 1583 | case BC_ILOOP: |
1584 | dasm_put(Dst, 7162); | 1584 | dasm_put(Dst, 7164); |
1585 | break; | 1585 | break; |
1586 | 1586 | ||
1587 | case BC_JLOOP: | 1587 | case BC_JLOOP: |
1588 | #if LJ_HASJIT | 1588 | #if LJ_HASJIT |
1589 | dasm_put(Dst, 12249, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); | 1589 | dasm_put(Dst, 12251, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); |
1590 | #endif | 1590 | #endif |
1591 | break; | 1591 | break; |
1592 | 1592 | ||
1593 | case BC_JMP: | 1593 | case BC_JMP: |
1594 | dasm_put(Dst, 12272, -BCBIAS_J*4); | 1594 | dasm_put(Dst, 12274, -BCBIAS_J*4); |
1595 | break; | 1595 | break; |
1596 | 1596 | ||
1597 | /* ---------------------------------------------------------------------- */ | 1597 | /* ---------------------------------------------------------------------- */ |
@@ -1615,7 +1615,7 @@ static int build_backend(BuildCtx *ctx) | |||
1615 | 1615 | ||
1616 | build_subroutines(ctx, cmov); | 1616 | build_subroutines(ctx, cmov); |
1617 | 1617 | ||
1618 | dasm_put(Dst, 12296); | 1618 | dasm_put(Dst, 12298); |
1619 | for (op = 0; op < BC__MAX; op++) | 1619 | for (op = 0; op < BC__MAX; op++) |
1620 | build_ins(ctx, (BCOp)op, op, cmov); | 1620 | build_ins(ctx, (BCOp)op, op, cmov); |
1621 | 1621 | ||
diff --git a/src/lj_api.c b/src/lj_api.c index 4bac5024..4b7847c8 100644 --- a/src/lj_api.c +++ b/src/lj_api.c | |||
@@ -1034,7 +1034,7 @@ LUA_API int lua_cpcall(lua_State *L, lua_CFunction func, void *ud) | |||
1034 | { | 1034 | { |
1035 | global_State *g = G(L); | 1035 | global_State *g = G(L); |
1036 | uint8_t oldh = hook_save(g); | 1036 | uint8_t oldh = hook_save(g); |
1037 | int status = lj_vm_cpcall(L, cpcall, func, ud); | 1037 | int status = lj_vm_cpcall(L, func, ud, cpcall); |
1038 | if (status) hook_restore(g, oldh); | 1038 | if (status) hook_restore(g, oldh); |
1039 | return status; | 1039 | return status; |
1040 | } | 1040 | } |
@@ -1106,7 +1106,7 @@ LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, | |||
1106 | ls.rdata = data; | 1106 | ls.rdata = data; |
1107 | ls.chunkarg = chunkname ? chunkname : "?"; | 1107 | ls.chunkarg = chunkname ? chunkname : "?"; |
1108 | lj_str_initbuf(L, &ls.sb); | 1108 | lj_str_initbuf(L, &ls.sb); |
1109 | status = lj_vm_cpcall(L, cpparser, NULL, &ls); | 1109 | status = lj_vm_cpcall(L, NULL, &ls, cpparser); |
1110 | g = G(L); | 1110 | g = G(L); |
1111 | lj_str_freebuf(g, &ls.sb); | 1111 | lj_str_freebuf(g, &ls.sb); |
1112 | lj_gc_check(L); | 1112 | lj_gc_check(L); |
diff --git a/src/lj_opt_loop.c b/src/lj_opt_loop.c index 90ab1b6f..a743932d 100644 --- a/src/lj_opt_loop.c +++ b/src/lj_opt_loop.c | |||
@@ -336,7 +336,7 @@ static TValue *cploop_opt(lua_State *L, lua_CFunction dummy, void *ud) | |||
336 | int lj_opt_loop(jit_State *J) | 336 | int lj_opt_loop(jit_State *J) |
337 | { | 337 | { |
338 | IRRef nins = J->cur.nins; | 338 | IRRef nins = J->cur.nins; |
339 | int errcode = lj_vm_cpcall(J->L, cploop_opt, NULL, J); | 339 | int errcode = lj_vm_cpcall(J->L, NULL, J, cploop_opt); |
340 | if (LJ_UNLIKELY(errcode)) { | 340 | if (LJ_UNLIKELY(errcode)) { |
341 | lua_State *L = J->L; | 341 | lua_State *L = J->L; |
342 | if (errcode == LUA_ERRRUN && tvisnum(L->top-1)) { /* Trace error? */ | 342 | if (errcode == LUA_ERRRUN && tvisnum(L->top-1)) { /* Trace error? */ |
diff --git a/src/lj_record.c b/src/lj_record.c index 9b223ff6..9466b529 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -1101,7 +1101,7 @@ static void recff_xpcall(jit_State *J, TRef *res, RecordFFData *rd) | |||
1101 | /* Need to protect rec_call because the recorder may throw. */ | 1101 | /* Need to protect rec_call because the recorder may throw. */ |
1102 | rx.parg = parg; | 1102 | rx.parg = parg; |
1103 | rx.nargs = rd->nargs - 2; | 1103 | rx.nargs = rd->nargs - 2; |
1104 | errcode = lj_vm_cpcall(J->L, recff_xpcall_cp, NULL, &rx); | 1104 | errcode = lj_vm_cpcall(J->L, NULL, &rx, recff_xpcall_cp); |
1105 | /* Always undo Lua stack swap to avoid confusing the interpreter. */ | 1105 | /* Always undo Lua stack swap to avoid confusing the interpreter. */ |
1106 | rd->argv = restorestack(J->L, oargv); /* Stack may have been resized. */ | 1106 | rd->argv = restorestack(J->L, oargv); /* Stack may have been resized. */ |
1107 | copyTV(J->L, &rd->argv[0], &argv0); | 1107 | copyTV(J->L, &rd->argv[0], &argv0); |
diff --git a/src/lj_state.c b/src/lj_state.c index b4bc7a0c..aa22ac34 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
@@ -188,7 +188,7 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | |||
188 | g->gc.stepmul = LUAI_GCMUL; | 188 | g->gc.stepmul = LUAI_GCMUL; |
189 | lj_dispatch_init((GG_State *)L); | 189 | lj_dispatch_init((GG_State *)L); |
190 | L->status = LUA_ERRERR+1; /* Avoid touching the stack upon memory error. */ | 190 | L->status = LUA_ERRERR+1; /* Avoid touching the stack upon memory error. */ |
191 | if (lj_vm_cpcall(L, cpluaopen, NULL, NULL) != 0) { | 191 | if (lj_vm_cpcall(L, NULL, NULL, cpluaopen) != 0) { |
192 | /* Memory allocation error: free partial state. */ | 192 | /* Memory allocation error: free partial state. */ |
193 | close_state(L); | 193 | close_state(L); |
194 | return NULL; | 194 | return NULL; |
@@ -222,7 +222,7 @@ LUA_API void lua_close(lua_State *L) | |||
222 | L->status = 0; | 222 | L->status = 0; |
223 | L->cframe = NULL; | 223 | L->cframe = NULL; |
224 | L->base = L->top = L->stack + 1; | 224 | L->base = L->top = L->stack + 1; |
225 | } while (lj_vm_cpcall(L, cpfinalize, NULL, NULL) != 0); | 225 | } while (lj_vm_cpcall(L, NULL, NULL, cpfinalize) != 0); |
226 | close_state(L); | 226 | close_state(L); |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/src/lj_trace.c b/src/lj_trace.c index a0748b40..54f23cb2 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c | |||
@@ -534,7 +534,7 @@ static TValue *trace_state(lua_State *L, lua_CFunction dummy, void *ud) | |||
534 | /* A bytecode instruction is about to be executed. Record it. */ | 534 | /* A bytecode instruction is about to be executed. Record it. */ |
535 | void lj_trace_ins(jit_State *J) | 535 | void lj_trace_ins(jit_State *J) |
536 | { | 536 | { |
537 | while (lj_vm_cpcall(J->L, trace_state, NULL, (void *)J) != 0) | 537 | while (lj_vm_cpcall(J->L, NULL, (void *)J, trace_state) != 0) |
538 | J->state = LJ_TRACE_ERR; | 538 | J->state = LJ_TRACE_ERR; |
539 | } | 539 | } |
540 | 540 | ||
diff --git a/src/lj_vm.h b/src/lj_vm.h index 095f284a..e4adc8db 100644 --- a/src/lj_vm.h +++ b/src/lj_vm.h | |||
@@ -12,8 +12,8 @@ | |||
12 | LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); | 12 | LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1); |
13 | LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); | 13 | LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); |
14 | typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); | 14 | typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud); |
15 | LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CPFunction cp, lua_CFunction func, | 15 | LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud, |
16 | void *ud); | 16 | lua_CPFunction cp); |
17 | LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); | 17 | LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef); |
18 | LJ_ASMF_NORET void lj_vm_unwind_c(void *cframe, int errcode); | 18 | LJ_ASMF_NORET void lj_vm_unwind_c(void *cframe, int errcode); |
19 | LJ_ASMF_NORET void lj_vm_unwind_ff(void *cframe); | 19 | LJ_ASMF_NORET void lj_vm_unwind_ff(void *cframe); |