aboutsummaryrefslogtreecommitdiff
path: root/src/buildvm_x86.dasc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/buildvm_x86.dasc56
1 files changed, 52 insertions, 4 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc
index 9666dfca..3ffabe6f 100644
--- a/src/buildvm_x86.dasc
+++ b/src/buildvm_x86.dasc
@@ -1043,6 +1043,19 @@ static void build_subroutines(BuildCtx *ctx, int cmov, int sse)
1043 | // 0/1 or TValue * (metamethod) returned in eax (RC). 1043 | // 0/1 or TValue * (metamethod) returned in eax (RC).
1044 | jmp <3 1044 | jmp <3
1045 | 1045 |
1046 |->vmeta_equal_cd:
1047#if LJ_HASFFI
1048 | sub PC, 4
1049 | mov L:RB, SAVE_L
1050 | mov L:RB->base, BASE
1051 | mov FCARG1, L:RB
1052 | mov FCARG2, dword [PC-4]
1053 | mov SAVE_PC, PC
1054 | call extern lj_meta_equal_cd@8 // (lua_State *L, BCIns op)
1055 | // 0/1 or TValue * (metamethod) returned in eax (RC).
1056 | jmp <3
1057#endif
1058 |
1046 |//-- Arithmetic metamethods --------------------------------------------- 1059 |//-- Arithmetic metamethods ---------------------------------------------
1047 | 1060 |
1048 |->vmeta_arith_vn: 1061 |->vmeta_arith_vn:
@@ -3593,7 +3606,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
3593 | movzx RD, PC_RD 3606 | movzx RD, PC_RD
3594 | branchPC RD 3607 | branchPC RD
3595 |2: // NE: Fallthrough to next instruction. 3608 |2: // NE: Fallthrough to next instruction.
3609 if (!LJ_HASFFI) {
3610 |3:
3611 }
3596 } else { 3612 } else {
3613 if (!LJ_HASFFI) {
3614 |3:
3615 }
3597 |2: // NE: Branch to the target. 3616 |2: // NE: Branch to the target.
3598 | movzx RD, PC_RD 3617 | movzx RD, PC_RD
3599 | branchPC RD 3618 | branchPC RD
@@ -3603,6 +3622,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
3603 | 3622 |
3604 if (op == BC_ISEQV || op == BC_ISNEV) { 3623 if (op == BC_ISEQV || op == BC_ISNEV) {
3605 |5: // Either or both types are not numbers. 3624 |5: // Either or both types are not numbers.
3625 if (LJ_HASFFI) {
3626 | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd
3627 | checktp RA, LJ_TCDATA; je ->vmeta_equal_cd
3628 }
3606 | checktp RA, RB // Compare types. 3629 | checktp RA, RB // Compare types.
3607 | jne <2 // Not the same type? 3630 | jne <2 // Not the same type?
3608 | cmp RB, LJ_TISPRI 3631 | cmp RB, LJ_TISPRI
@@ -3629,13 +3652,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
3629 | mov RB, 1 // ne = 1 3652 | mov RB, 1 // ne = 1
3630 } 3653 }
3631 | jmp ->vmeta_equal // Handle __eq metamethod. 3654 | jmp ->vmeta_equal // Handle __eq metamethod.
3655 } else if (LJ_HASFFI) {
3656 |3:
3657 | cmp RB, LJ_TCDATA; jne <2
3658 | jmp ->vmeta_equal_cd
3632 } 3659 }
3633 break; 3660 break;
3634 case BC_ISEQS: case BC_ISNES: 3661 case BC_ISEQS: case BC_ISNES:
3635 vk = op == BC_ISEQS; 3662 vk = op == BC_ISEQS;
3636 | ins_AND // RA = src, RD = str const, JMP with RD = target 3663 | ins_AND // RA = src, RD = str const, JMP with RD = target
3664 | mov RB, [BASE+RA*8+4]
3637 | add PC, 4 3665 | add PC, 4
3638 | checkstr RA, >2 3666 | cmp RB, LJ_TSTR; jne >3
3639 | mov RA, [BASE+RA*8] 3667 | mov RA, [BASE+RA*8]
3640 | cmp RA, [KBASE+RD*4] 3668 | cmp RA, [KBASE+RD*4]
3641 iseqne_test: 3669 iseqne_test:
@@ -3648,8 +3676,9 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
3648 case BC_ISEQN: case BC_ISNEN: 3676 case BC_ISEQN: case BC_ISNEN:
3649 vk = op == BC_ISEQN; 3677 vk = op == BC_ISEQN;
3650 | ins_AD // RA = src, RD = num const, JMP with RD = target 3678 | ins_AD // RA = src, RD = num const, JMP with RD = target
3679 | mov RB, [BASE+RA*8+4]
3651 | add PC, 4 3680 | add PC, 4
3652 | checknum RA, >2 3681 | cmp RB, LJ_TISNUM; ja >3
3653 if (sse) { 3682 if (sse) {
3654 | movsd xmm0, qword [KBASE+RD*8] 3683 | movsd xmm0, qword [KBASE+RD*8]
3655 | ucomisd xmm0, qword [BASE+RA*8] 3684 | ucomisd xmm0, qword [BASE+RA*8]
@@ -3662,9 +3691,28 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
3662 case BC_ISEQP: case BC_ISNEP: 3691 case BC_ISEQP: case BC_ISNEP:
3663 vk = op == BC_ISEQP; 3692 vk = op == BC_ISEQP;
3664 | ins_AND // RA = src, RD = primitive type (~), JMP with RD = target 3693 | ins_AND // RA = src, RD = primitive type (~), JMP with RD = target
3694 | mov RB, [BASE+RA*8+4]
3665 | add PC, 4 3695 | add PC, 4
3666 | checktp RA, RD 3696 | cmp RB, RD
3667 goto iseqne_test; 3697 if (!LJ_HASFFI) goto iseqne_test;
3698 if (vk) {
3699 | jne >3
3700 | movzx RD, PC_RD
3701 | branchPC RD
3702 |2:
3703 | ins_next
3704 |3:
3705 | cmp RB, LJ_TCDATA; jne <2
3706 | jmp ->vmeta_equal_cd
3707 } else {
3708 | je >2
3709 | cmp RB, LJ_TCDATA; je ->vmeta_equal_cd
3710 | movzx RD, PC_RD
3711 | branchPC RD
3712 |2:
3713 | ins_next
3714 }
3715 break;
3668 3716
3669 /* -- Unary test and copy ops ------------------------------------------- */ 3717 /* -- Unary test and copy ops ------------------------------------------- */
3670 3718