aboutsummaryrefslogtreecommitdiff
path: root/src/vm_x86.dasc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/vm_x86.dasc131
1 files changed, 131 insertions, 0 deletions
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index c8095db2..0c4b0ce6 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -911,6 +911,19 @@ static void build_subroutines(BuildCtx *ctx)
911 | mov NARGS:RD, 2+1 // 2 args for func(t, k). 911 | mov NARGS:RD, 2+1 // 2 args for func(t, k).
912 | jmp ->vm_call_dispatch_f 912 | jmp ->vm_call_dispatch_f
913 | 913 |
914 |->vmeta_tgetr:
915 | mov FCARG1, TAB:RB
916 | mov RB, BASE // Save BASE.
917 | mov FCARG2, RC // Caveat: FCARG2 == BASE
918 | call extern lj_tab_getinth@8 // (GCtab *t, int32_t key)
919 | // cTValue * or NULL returned in eax (RC).
920 | movzx RA, PC_RA
921 | mov BASE, RB // Restore BASE.
922 | test RC, RC
923 | jnz ->BC_TGETR_Z
924 | mov dword [BASE+RA*8+4], LJ_TNIL
925 | jmp ->BC_TGETR2_Z
926 |
914 |//----------------------------------------------------------------------- 927 |//-----------------------------------------------------------------------
915 | 928 |
916 |->vmeta_tsets: 929 |->vmeta_tsets:
@@ -998,6 +1011,33 @@ static void build_subroutines(BuildCtx *ctx)
998 | mov NARGS:RD, 3+1 // 3 args for func(t, k, v). 1011 | mov NARGS:RD, 3+1 // 3 args for func(t, k, v).
999 | jmp ->vm_call_dispatch_f 1012 | jmp ->vm_call_dispatch_f
1000 | 1013 |
1014 |->vmeta_tsetr:
1015 |.if X64WIN
1016 | mov L:CARG1d, SAVE_L
1017 | mov CARG3d, RC
1018 | mov L:CARG1d->base, BASE
1019 | xchg CARG2d, TAB:RB // Caveat: CARG2d == BASE.
1020 |.elif X64
1021 | mov L:CARG1d, SAVE_L
1022 | mov CARG2d, TAB:RB
1023 | mov L:CARG1d->base, BASE
1024 | mov RB, BASE // Save BASE.
1025 | mov CARG3d, RC // Caveat: CARG3d == BASE.
1026 |.else
1027 | mov L:RA, SAVE_L
1028 | mov ARG2, TAB:RB
1029 | mov RB, BASE // Save BASE.
1030 | mov ARG3, RC
1031 | mov ARG1, L:RA
1032 | mov L:RA->base, BASE
1033 |.endif
1034 | mov SAVE_PC, PC
1035 | call extern lj_tab_setinth // (lua_State *L, GCtab *t, int32_t key)
1036 | // TValue * returned in eax (RC).
1037 | movzx RA, PC_RA
1038 | mov BASE, RB // Restore BASE.
1039 | jmp ->BC_TSETR_Z
1040 |
1001 |//-- Comparison metamethods --------------------------------------------- 1041 |//-- Comparison metamethods ---------------------------------------------
1002 | 1042 |
1003 |->vmeta_comp: 1043 |->vmeta_comp:
@@ -1092,6 +1132,26 @@ static void build_subroutines(BuildCtx *ctx)
1092 | jmp <3 1132 | jmp <3
1093 |.endif 1133 |.endif
1094 | 1134 |
1135 |->vmeta_istype:
1136 |.if X64
1137 | mov L:CARG1d, SAVE_L
1138 | mov L:CARG1d->base, BASE // Caveat: CARG2d/CARG3d may be BASE.
1139 | mov CARG2d, RA
1140 | movzx CARG3d, PC_RD
1141 | mov L:RB, L:CARG1d
1142 |.else
1143 | movzx RD, PC_RD
1144 | mov ARG2, RA
1145 | mov L:RB, SAVE_L
1146 | mov ARG3, RD
1147 | mov ARG1, L:RB
1148 | mov L:RB->base, BASE
1149 |.endif
1150 | mov SAVE_PC, PC
1151 | call extern lj_meta_istype // (lua_State *L, BCReg ra, BCReg tp)
1152 | mov BASE, L:RB->base
1153 | jmp <6
1154 |
1095 |//-- Arithmetic metamethods --------------------------------------------- 1155 |//-- Arithmetic metamethods ---------------------------------------------
1096 | 1156 |
1097 |->vmeta_arith_vno: 1157 |->vmeta_arith_vno:
@@ -3827,6 +3887,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
3827 | ins_next 3887 | ins_next
3828 break; 3888 break;
3829 3889
3890 case BC_ISTYPE:
3891 | ins_AD // RA = src, RD = -type
3892 | add RD, [BASE+RA*8+4]
3893 | jne ->vmeta_istype
3894 | ins_next
3895 break;
3896 case BC_ISNUM:
3897 | ins_AD // RA = src, RD = -(TISNUM-1)
3898 | checknum RA, ->vmeta_istype
3899 | ins_next
3900 break;
3901
3830 /* -- Unary ops --------------------------------------------------------- */ 3902 /* -- Unary ops --------------------------------------------------------- */
3831 3903
3832 case BC_MOV: 3904 case BC_MOV:
@@ -4502,6 +4574,32 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
4502 | mov dword [BASE+RA*8+4], LJ_TNIL 4574 | mov dword [BASE+RA*8+4], LJ_TNIL
4503 | jmp <1 4575 | jmp <1
4504 break; 4576 break;
4577 case BC_TGETR:
4578 | ins_ABC // RA = dst, RB = table, RC = key
4579 | mov TAB:RB, [BASE+RB*8]
4580 |.if DUALNUM
4581 | mov RC, dword [BASE+RC*8]
4582 |.else
4583 | cvttsd2si RC, qword [BASE+RC*8]
4584 |.endif
4585 | cmp RC, TAB:RB->asize
4586 | jae ->vmeta_tgetr // Not in array part? Use fallback.
4587 | shl RC, 3
4588 | add RC, TAB:RB->array
4589 | // Get array slot.
4590 |->BC_TGETR_Z:
4591 |.if X64
4592 | mov RBa, [RC]
4593 | mov [BASE+RA*8], RBa
4594 |.else
4595 | mov RB, [RC]
4596 | mov RC, [RC+4]
4597 | mov [BASE+RA*8], RB
4598 | mov [BASE+RA*8+4], RC
4599 |.endif
4600 |->BC_TGETR2_Z:
4601 | ins_next
4602 break;
4505 4603
4506 case BC_TSETV: 4604 case BC_TSETV:
4507 | ins_ABC // RA = src, RB = table, RC = key 4605 | ins_ABC // RA = src, RB = table, RC = key
@@ -4688,6 +4786,39 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
4688 | movzx RA, PC_RA // Restore RA. 4786 | movzx RA, PC_RA // Restore RA.
4689 | jmp <2 4787 | jmp <2
4690 break; 4788 break;
4789 case BC_TSETR:
4790 | ins_ABC // RA = src, RB = table, RC = key
4791 | mov TAB:RB, [BASE+RB*8]
4792 |.if DUALNUM
4793 | mov RC, dword [BASE+RC*8]
4794 |.else
4795 | cvttsd2si RC, qword [BASE+RC*8]
4796 |.endif
4797 | test byte TAB:RB->marked, LJ_GC_BLACK // isblack(table)
4798 | jnz >7
4799 |2:
4800 | cmp RC, TAB:RB->asize
4801 | jae ->vmeta_tsetr
4802 | shl RC, 3
4803 | add RC, TAB:RB->array
4804 | // Set array slot.
4805 |->BC_TSETR_Z:
4806 |.if X64
4807 | mov RBa, [BASE+RA*8]
4808 | mov [RC], RBa
4809 |.else
4810 | mov RB, [BASE+RA*8+4]
4811 | mov RA, [BASE+RA*8]
4812 | mov [RC+4], RB
4813 | mov [RC], RA
4814 |.endif
4815 | ins_next
4816 |
4817 |7: // Possible table write barrier for the value. Skip valiswhite check.
4818 | barrierback TAB:RB, RA
4819 | movzx RA, PC_RA // Restore RA.
4820 | jmp <2
4821 break;
4691 4822
4692 case BC_TSETM: 4823 case BC_TSETM:
4693 | ins_AD // RA = base (table at base-1), RD = num const (start index) 4824 | ins_AD // RA = base (table at base-1), RD = num const (start index)