aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2010-09-10 11:34:29 +0200
committerMike Pall <mike>2010-09-10 11:34:29 +0200
commit6fd315581c7fae86bbe57840408a249c60a691a9 (patch)
tree5ad790b1a4ef9e7e79485cbf55c6b1557073c06d /src
parent96957a4551a464160be2c1450f39744ac8313364 (diff)
downloadluajit-6fd315581c7fae86bbe57840408a249c60a691a9.tar.gz
luajit-6fd315581c7fae86bbe57840408a249c60a691a9.tar.bz2
luajit-6fd315581c7fae86bbe57840408a249c60a691a9.zip
Optimize BC_VARG: use RC for numparams.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_x64.h216
-rw-r--r--src/buildvm_x64win.h221
-rw-r--r--src/buildvm_x86.dasc7
-rw-r--r--src/buildvm_x86.h211
-rw-r--r--src/lj_gc.c2
-rw-r--r--src/lj_parse.c15
6 files changed, 333 insertions, 339 deletions
diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h
index 4474ae1b..05e796c4 100644
--- a/src/buildvm_x64.h
+++ b/src/buildvm_x64.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
15static const unsigned char build_actionlist[14095] = { 15static const unsigned char build_actionlist[14087] = {
16 254,1,248,10,252,247,195,237,15,132,244,11,131,227,252,248,41,218,72,141, 16 254,1,248,10,252,247,195,237,15,132,244,11,131,227,252,248,41,218,72,141,
17 76,25,252,248,139,90,252,252,199,68,10,4,237,248,12,131,192,1,137,68,36,4, 17 76,25,252,248,139,90,252,252,199,68,10,4,237,248,12,131,192,1,137,68,36,4,
18 252,247,195,237,15,132,244,13,248,14,129,252,243,239,252,247,195,237,15,133, 18 252,247,195,237,15,132,244,13,248,14,129,252,243,239,252,247,195,237,15,133,
@@ -641,59 +641,59 @@ static const unsigned char build_actionlist[14095] = {
641 105,8,137,65,12,139,105,224,139,65,228,137,105,252,248,137,65,252,252,129, 641 105,8,137,65,12,139,105,224,139,65,228,137,105,252,248,137,65,252,252,129,
642 252,248,239,184,237,15,133,244,28,137,202,137,90,252,252,139,157,233,139, 642 252,248,239,184,237,15,133,244,28,137,202,137,90,252,252,139,157,233,139,
643 11,15,182,252,233,15,182,205,131,195,4,65,252,255,36,252,238,255,15,182,252, 643 11,15,182,252,233,15,182,205,131,195,4,65,252,255,36,252,238,255,15,182,252,
644 236,139,66,252,248,141,12,202,139,128,233,15,182,128,233,68,137,60,36,68, 644 236,15,182,192,68,137,60,36,68,141,188,253,194,233,141,12,202,68,43,122,252,
645 141,188,253,194,233,68,43,122,252,252,133,252,237,15,132,244,251,141,108, 645 252,133,252,237,15,132,244,251,141,108,252,233,252,248,65,57,215,15,131,244,
646 252,233,252,248,65,57,215,15,131,244,248,248,1,65,139,71,252,248,137,1,65, 646 248,248,1,65,139,71,252,248,137,1,65,139,71,252,252,65,131,199,8,137,65,4,
647 139,71,252,252,65,131,199,8,137,65,4,131,193,8,57,252,233,15,131,244,249, 647 131,193,8,57,252,233,15,131,244,249,65,57,215,15,130,244,1,248,2,199,65,4,
648 65,57,215,15,130,244,1,248,2,199,65,4,237,131,193,8,57,252,233,15,130,244, 648 237,131,193,8,57,252,233,15,130,244,2,248,3,68,139,60,36,139,3,15,182,204,
649 2,248,3,68,139,60,36,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65, 649 15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,5,199,68,36,4,1,
650 252,255,36,252,238,248,5,199,68,36,4,1,0,0,0,137,208,68,41,252,248,15,134, 650 0,0,0,137,208,68,41,252,248,15,134,244,3,137,197,193,252,237,3,131,197,1,
651 244,3,255,137,197,193,252,237,3,131,197,1,137,108,36,4,139,108,36,24,1,200, 651 137,108,36,4,139,108,36,24,1,200,59,133,233,15,135,244,253,248,6,255,65,139,
652 59,133,233,15,135,244,253,248,6,65,139,71,252,248,137,1,65,139,71,252,252, 652 71,252,248,137,1,65,139,71,252,252,65,131,199,8,137,65,4,131,193,8,65,57,
653 65,131,199,8,137,65,4,131,193,8,65,57,215,15,130,244,6,252,233,244,3,248, 653 215,15,130,244,6,252,233,244,3,248,7,137,149,233,137,141,233,137,92,36,28,
654 7,137,149,233,137,141,233,137,92,36,28,65,41,215,139,116,36,4,131,252,238, 654 65,41,215,139,116,36,4,131,252,238,1,137,252,239,232,251,1,0,139,149,233,
655 1,137,252,239,232,251,1,0,139,149,233,139,141,233,65,1,215,252,233,244,6, 655 139,141,233,65,1,215,252,233,244,6,255,193,225,3,255,248,1,139,90,252,252,
656 255,193,225,3,255,248,1,139,90,252,252,137,68,36,4,252,247,195,237,15,133, 656 137,68,36,4,252,247,195,237,15,133,244,253,255,248,13,65,137,215,131,232,
657 244,253,255,248,13,65,137,215,131,232,1,15,132,244,249,248,2,65,139,44,15, 657 1,15,132,244,249,248,2,65,139,44,15,65,137,111,252,248,65,139,108,15,4,65,
658 65,137,111,252,248,65,139,108,15,4,65,137,111,252,252,65,131,199,8,131,232, 658 137,111,252,252,65,131,199,8,131,232,1,15,133,244,2,248,3,139,68,36,4,15,
659 1,15,133,244,2,248,3,139,68,36,4,15,182,107,252,255,248,5,57,197,15,135,244, 659 182,107,252,255,248,5,57,197,15,135,244,252,255,139,108,10,4,137,106,252,
660 252,255,139,108,10,4,137,106,252,252,139,44,10,137,106,252,248,255,248,5, 660 252,139,44,10,137,106,252,248,255,248,5,56,67,252,255,15,135,244,252,255,
661 56,67,252,255,15,135,244,252,255,15,182,75,252,253,72,252,247,209,141,20, 661 15,182,75,252,253,72,252,247,209,141,20,202,68,139,122,252,248,69,139,191,
662 202,68,139,122,252,248,69,139,191,233,69,139,191,233,139,3,15,182,204,15, 662 233,69,139,191,233,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,
663 182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,6,255,65,199,71,252, 663 255,36,252,238,248,6,255,65,199,71,252,252,237,65,131,199,8,255,199,68,194,
664 252,237,65,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244, 664 252,244,237,255,131,192,1,252,233,244,5,248,7,141,171,233,252,247,197,237,
665 5,248,7,141,171,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233, 665 15,133,244,14,41,252,234,255,1,252,233,255,137,221,209,252,237,129,229,239,
666 255,137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244, 666 102,65,131,172,253,46,233,1,15,132,244,140,255,141,12,202,255,129,121,253,
667 140,255,141,12,202,255,129,121,253,4,239,15,135,244,53,129,121,253,12,239, 667 4,239,15,135,244,53,129,121,253,12,239,15,135,244,53,255,139,105,20,255,129,
668 15,135,244,53,255,139,105,20,255,129,252,253,239,15,135,244,53,255,252,242, 668 252,253,239,15,135,244,53,255,252,242,15,16,1,252,242,15,16,73,8,255,252,
669 15,16,1,252,242,15,16,73,8,255,252,242,15,88,65,16,252,242,15,17,1,133,252, 669 242,15,88,65,16,252,242,15,17,1,133,252,237,15,136,244,249,255,15,140,244,
670 237,15,136,244,249,255,15,140,244,249,255,102,15,46,200,248,1,252,242,15, 670 249,255,102,15,46,200,248,1,252,242,15,17,65,24,255,221,65,8,221,1,255,220,
671 17,65,24,255,221,65,8,221,1,255,220,65,16,221,17,221,81,24,133,252,237,15, 671 65,16,221,17,221,81,24,133,252,237,15,136,244,247,255,221,81,24,15,140,244,
672 136,244,247,255,221,81,24,15,140,244,247,255,217,201,248,1,255,15,183,67, 672 247,255,217,201,248,1,255,15,183,67,252,254,255,15,131,244,248,141,156,253,
673 252,254,255,15,131,244,248,141,156,253,131,233,255,141,156,253,131,233,15, 673 131,233,255,141,156,253,131,233,15,183,67,252,254,15,131,245,255,15,130,244,
674 183,67,252,254,15,131,245,255,15,130,244,248,141,156,253,131,233,255,248, 674 248,141,156,253,131,233,255,248,3,102,15,46,193,252,233,244,1,255,141,12,
675 3,102,15,46,193,252,233,244,1,255,141,12,202,139,105,4,129,252,253,239,15, 675 202,139,105,4,129,252,253,239,15,132,244,247,255,137,105,252,252,139,41,137,
676 132,244,247,255,137,105,252,252,139,41,137,105,252,248,252,233,245,255,141, 676 105,252,248,252,233,245,255,141,156,253,131,233,139,1,137,105,252,252,137,
677 156,253,131,233,139,1,137,105,252,252,137,65,252,248,255,65,139,142,233,139, 677 65,252,248,255,65,139,142,233,139,4,129,72,139,128,233,139,108,36,24,65,137,
678 4,129,72,139,128,233,139,108,36,24,65,137,150,233,65,137,174,233,76,137,36, 678 150,233,65,137,174,233,76,137,36,36,76,137,108,36,8,72,131,252,236,16,252,
679 36,76,137,108,36,8,72,131,252,236,16,252,255,224,255,141,156,253,131,233, 679 255,224,255,141,156,253,131,233,139,3,15,182,204,15,182,232,131,195,4,193,
680 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255, 680 232,16,65,252,255,36,252,238,255,137,221,209,252,237,129,229,239,102,65,131,
681 137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244,142, 681 172,253,46,233,1,15,132,244,142,255,68,139,187,233,139,108,36,24,141,12,202,
682 255,68,139,187,233,139,108,36,24,141,12,202,59,141,233,15,135,244,23,15,182, 682 59,141,233,15,135,244,23,15,182,139,233,57,200,15,134,244,249,248,2,255,15,
683 139,233,57,200,15,134,244,249,248,2,255,15,183,67,252,254,252,233,245,255, 683 183,67,252,254,252,233,245,255,248,3,199,68,194,252,252,237,131,192,1,57,
684 248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2, 684 200,15,134,244,3,252,233,244,2,255,141,44,197,237,141,4,194,68,139,122,252,
685 255,141,44,197,237,141,4,194,68,139,122,252,248,137,104,252,252,68,137,120, 685 248,137,104,252,252,68,137,120,252,248,139,108,36,24,141,12,200,59,141,233,
686 252,248,139,108,36,24,141,12,200,59,141,233,15,135,244,22,137,209,137,194, 686 15,135,244,22,137,209,137,194,15,182,171,233,133,252,237,15,132,244,248,248,
687 15,182,171,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244, 687 1,131,193,8,57,209,15,131,244,249,68,139,121,252,248,68,137,56,68,139,121,
688 249,68,139,121,252,248,68,137,56,68,139,121,252,252,68,137,120,4,131,192, 688 252,252,68,137,120,4,131,192,8,199,65,252,252,237,131,252,237,1,15,133,244,
689 8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,68,139,187,233, 689 1,248,2,255,68,139,187,233,139,3,15,182,204,15,182,232,131,195,4,193,232,
690 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255, 690 16,65,252,255,36,252,238,255,248,3,199,64,4,237,131,192,8,131,252,237,1,15,
691 248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255, 691 133,244,3,252,233,244,2,255,139,106,252,248,76,139,189,233,139,108,36,24,
692 139,106,252,248,76,139,189,233,139,108,36,24,141,68,194,252,248,137,149,233, 692 141,68,194,252,248,137,149,233,141,136,233,59,141,233,137,133,233,255,137,
693 141,136,233,59,141,233,137,133,233,255,137,252,239,255,76,137,252,254,137, 693 252,239,255,76,137,252,254,137,252,239,255,15,135,244,21,65,199,134,233,237,
694 252,239,255,15,135,244,21,65,199,134,233,237,255,65,252,255,215,255,65,252, 694 255,65,252,255,215,255,65,252,255,150,233,255,65,199,134,233,237,139,149,
695 255,150,233,255,65,199,134,233,237,139,149,233,141,12,194,252,247,217,3,141, 695 233,141,12,194,252,247,217,3,141,233,139,90,252,252,252,233,244,12,255,254,
696 233,139,90,252,252,252,233,244,12,255,254,0 696 0
697}; 697};
698 698
699enum { 699enum {
@@ -1989,8 +1989,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
1989 break; 1989 break;
1990 1990
1991 case BC_VARG: 1991 case BC_VARG:
1992 dasm_put(Dst, 13006, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL); 1992 dasm_put(Dst, 13006, (8+FRAME_VARG), LJ_TNIL, Dt1(->maxstack));
1993 dasm_put(Dst, 13160, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); 1993 dasm_put(Dst, 13180, Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top));
1994 break; 1994 break;
1995 1995
1996 /* -- Returns ----------------------------------------------------------- */ 1996 /* -- Returns ----------------------------------------------------------- */
@@ -2001,30 +2001,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2001 2001
2002 case BC_RET: case BC_RET0: case BC_RET1: 2002 case BC_RET: case BC_RET0: case BC_RET1:
2003 if (op != BC_RET0) { 2003 if (op != BC_RET0) {
2004 dasm_put(Dst, 13265); 2004 dasm_put(Dst, 13257);
2005 } 2005 }
2006 dasm_put(Dst, 13269, FRAME_TYPE); 2006 dasm_put(Dst, 13261, FRAME_TYPE);
2007 switch (op) { 2007 switch (op) {
2008 case BC_RET: 2008 case BC_RET:
2009 dasm_put(Dst, 13288); 2009 dasm_put(Dst, 13280);
2010 break; 2010 break;
2011 case BC_RET1: 2011 case BC_RET1:
2012 dasm_put(Dst, 13352); 2012 dasm_put(Dst, 13344);
2013 /* fallthrough */ 2013 /* fallthrough */
2014 case BC_RET0: 2014 case BC_RET0:
2015 dasm_put(Dst, 13368); 2015 dasm_put(Dst, 13360);
2016 default: 2016 default:
2017 break; 2017 break;
2018 } 2018 }
2019 dasm_put(Dst, 13379, Dt7(->pc), PC2PROTO(k)); 2019 dasm_put(Dst, 13371, Dt7(->pc), PC2PROTO(k));
2020 if (op == BC_RET) { 2020 if (op == BC_RET) {
2021 dasm_put(Dst, 13427, LJ_TNIL); 2021 dasm_put(Dst, 13419, LJ_TNIL);
2022 } else { 2022 } else {
2023 dasm_put(Dst, 13438, LJ_TNIL); 2023 dasm_put(Dst, 13430, LJ_TNIL);
2024 } 2024 }
2025 dasm_put(Dst, 13445, -FRAME_VARG, FRAME_TYPEP); 2025 dasm_put(Dst, 13437, -FRAME_VARG, FRAME_TYPEP);
2026 if (op != BC_RET0) { 2026 if (op != BC_RET0) {
2027 dasm_put(Dst, 13469); 2027 dasm_put(Dst, 13461);
2028 } 2028 }
2029 dasm_put(Dst, 4599); 2029 dasm_put(Dst, 4599);
2030 break; 2030 break;
@@ -2034,7 +2034,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2034 2034
2035 case BC_FORL: 2035 case BC_FORL:
2036#if LJ_HASJIT 2036#if LJ_HASJIT
2037 dasm_put(Dst, 13473, HOTCOUNT_PCMASK, GG_DISP2HOT); 2037 dasm_put(Dst, 13465, HOTCOUNT_PCMASK, GG_DISP2HOT);
2038#endif 2038#endif
2039 break; 2039 break;
2040 2040
@@ -2046,57 +2046,57 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2046 case BC_FORI: 2046 case BC_FORI:
2047 case BC_IFORL: 2047 case BC_IFORL:
2048 vk = (op == BC_IFORL || op == BC_JFORL); 2048 vk = (op == BC_IFORL || op == BC_JFORL);
2049 dasm_put(Dst, 13494); 2049 dasm_put(Dst, 13486);
2050 if (!vk) { 2050 if (!vk) {
2051 dasm_put(Dst, 13498, LJ_TISNUM, LJ_TISNUM); 2051 dasm_put(Dst, 13490, LJ_TISNUM, LJ_TISNUM);
2052 } 2052 }
2053 dasm_put(Dst, 13517); 2053 dasm_put(Dst, 13509);
2054 if (!vk) { 2054 if (!vk) {
2055 dasm_put(Dst, 13521, LJ_TISNUM); 2055 dasm_put(Dst, 13513, LJ_TISNUM);
2056 } 2056 }
2057 if (sse) { 2057 if (sse) {
2058 dasm_put(Dst, 13530); 2058 dasm_put(Dst, 13522);
2059 if (vk) { 2059 if (vk) {
2060 dasm_put(Dst, 13542); 2060 dasm_put(Dst, 13534);
2061 } else { 2061 } else {
2062 dasm_put(Dst, 13561); 2062 dasm_put(Dst, 13553);
2063 } 2063 }
2064 dasm_put(Dst, 13566); 2064 dasm_put(Dst, 13558);
2065 } else { 2065 } else {
2066 dasm_put(Dst, 13579); 2066 dasm_put(Dst, 13571);
2067 if (vk) { 2067 if (vk) {
2068 dasm_put(Dst, 13585); 2068 dasm_put(Dst, 13577);
2069 } else { 2069 } else {
2070 dasm_put(Dst, 13601); 2070 dasm_put(Dst, 13593);
2071 } 2071 }
2072 dasm_put(Dst, 13609); 2072 dasm_put(Dst, 13601);
2073 if (cmov) { 2073 if (cmov) {
2074 dasm_put(Dst, 9528); 2074 dasm_put(Dst, 9528);
2075 } else { 2075 } else {
2076 dasm_put(Dst, 9534); 2076 dasm_put(Dst, 9534);
2077 } 2077 }
2078 if (!cmov) { 2078 if (!cmov) {
2079 dasm_put(Dst, 13614); 2079 dasm_put(Dst, 13606);
2080 } 2080 }
2081 } 2081 }
2082 if (op == BC_FORI) { 2082 if (op == BC_FORI) {
2083 dasm_put(Dst, 13620, -BCBIAS_J*4); 2083 dasm_put(Dst, 13612, -BCBIAS_J*4);
2084 } else if (op == BC_JFORI) { 2084 } else if (op == BC_JFORI) {
2085 dasm_put(Dst, 13630, -BCBIAS_J*4, BC_JLOOP); 2085 dasm_put(Dst, 13622, -BCBIAS_J*4, BC_JLOOP);
2086 } else if (op == BC_IFORL) { 2086 } else if (op == BC_IFORL) {
2087 dasm_put(Dst, 13644, -BCBIAS_J*4); 2087 dasm_put(Dst, 13636, -BCBIAS_J*4);
2088 } else { 2088 } else {
2089 dasm_put(Dst, 13640, BC_JLOOP); 2089 dasm_put(Dst, 13632, BC_JLOOP);
2090 } 2090 }
2091 dasm_put(Dst, 9563); 2091 dasm_put(Dst, 9563);
2092 if (sse) { 2092 if (sse) {
2093 dasm_put(Dst, 13654); 2093 dasm_put(Dst, 13646);
2094 } 2094 }
2095 break; 2095 break;
2096 2096
2097 case BC_ITERL: 2097 case BC_ITERL:
2098#if LJ_HASJIT 2098#if LJ_HASJIT
2099 dasm_put(Dst, 13473, HOTCOUNT_PCMASK, GG_DISP2HOT); 2099 dasm_put(Dst, 13465, HOTCOUNT_PCMASK, GG_DISP2HOT);
2100#endif 2100#endif
2101 break; 2101 break;
2102 2102
@@ -2105,18 +2105,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2105 break; 2105 break;
2106#endif 2106#endif
2107 case BC_IITERL: 2107 case BC_IITERL:
2108 dasm_put(Dst, 13665, LJ_TNIL); 2108 dasm_put(Dst, 13657, LJ_TNIL);
2109 if (op == BC_JITERL) { 2109 if (op == BC_JITERL) {
2110 dasm_put(Dst, 13680, BC_JLOOP); 2110 dasm_put(Dst, 13672, BC_JLOOP);
2111 } else { 2111 } else {
2112 dasm_put(Dst, 13694, -BCBIAS_J*4); 2112 dasm_put(Dst, 13686, -BCBIAS_J*4);
2113 } 2113 }
2114 dasm_put(Dst, 9867); 2114 dasm_put(Dst, 9867);
2115 break; 2115 break;
2116 2116
2117 case BC_LOOP: 2117 case BC_LOOP:
2118#if LJ_HASJIT 2118#if LJ_HASJIT
2119 dasm_put(Dst, 13473, HOTCOUNT_PCMASK, GG_DISP2HOT); 2119 dasm_put(Dst, 13465, HOTCOUNT_PCMASK, GG_DISP2HOT);
2120#endif 2120#endif
2121 break; 2121 break;
2122 2122
@@ -2126,12 +2126,12 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2126 2126
2127 case BC_JLOOP: 2127 case BC_JLOOP:
2128#if LJ_HASJIT 2128#if LJ_HASJIT
2129 dasm_put(Dst, 13710, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); 2129 dasm_put(Dst, 13702, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L));
2130#endif 2130#endif
2131 break; 2131 break;
2132 2132
2133 case BC_JMP: 2133 case BC_JMP:
2134 dasm_put(Dst, 13751, -BCBIAS_J*4); 2134 dasm_put(Dst, 13743, -BCBIAS_J*4);
2135 break; 2135 break;
2136 2136
2137 /* -- Function headers -------------------------------------------------- */ 2137 /* -- Function headers -------------------------------------------------- */
@@ -2145,7 +2145,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2145 2145
2146 case BC_FUNCF: 2146 case BC_FUNCF:
2147#if LJ_HASJIT 2147#if LJ_HASJIT
2148 dasm_put(Dst, 13777, HOTCOUNT_PCMASK, GG_DISP2HOT); 2148 dasm_put(Dst, 13769, HOTCOUNT_PCMASK, GG_DISP2HOT);
2149#endif 2149#endif
2150 case BC_FUNCV: /* NYI: compiled vararg functions. */ 2150 case BC_FUNCV: /* NYI: compiled vararg functions. */
2151 break; 2151 break;
@@ -2155,13 +2155,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2155 break; 2155 break;
2156#endif 2156#endif
2157 case BC_IFUNCF: 2157 case BC_IFUNCF:
2158 dasm_put(Dst, 13798, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams)); 2158 dasm_put(Dst, 13790, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams));
2159 if (op == BC_JFUNCF) { 2159 if (op == BC_JFUNCF) {
2160 dasm_put(Dst, 13829, BC_JLOOP); 2160 dasm_put(Dst, 13821, BC_JLOOP);
2161 } else { 2161 } else {
2162 dasm_put(Dst, 9565); 2162 dasm_put(Dst, 9565);
2163 } 2163 }
2164 dasm_put(Dst, 13838, LJ_TNIL); 2164 dasm_put(Dst, 13830, LJ_TNIL);
2165 break; 2165 break;
2166 2166
2167 case BC_JFUNCV: 2167 case BC_JFUNCV:
@@ -2172,30 +2172,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2172 break; /* NYI: compiled vararg functions. */ 2172 break; /* NYI: compiled vararg functions. */
2173 2173
2174 case BC_IFUNCV: 2174 case BC_IFUNCV:
2175 dasm_put(Dst, 13860, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL); 2175 dasm_put(Dst, 13852, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL);
2176 if (op == BC_JFUNCV) { 2176 if (op == BC_JFUNCV) {
2177 dasm_put(Dst, 13829, BC_JLOOP); 2177 dasm_put(Dst, 13821, BC_JLOOP);
2178 } else { 2178 } else {
2179 dasm_put(Dst, 13957, -4+PC2PROTO(k)); 2179 dasm_put(Dst, 13949, -4+PC2PROTO(k));
2180 } 2180 }
2181 dasm_put(Dst, 13982, LJ_TNIL); 2181 dasm_put(Dst, 13974, LJ_TNIL);
2182 break; 2182 break;
2183 2183
2184 case BC_FUNCC: 2184 case BC_FUNCC:
2185 case BC_FUNCCW: 2185 case BC_FUNCCW:
2186 dasm_put(Dst, 14004, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top)); 2186 dasm_put(Dst, 13996, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top));
2187 if (op == BC_FUNCC) { 2187 if (op == BC_FUNCC) {
2188 dasm_put(Dst, 14034); 2188 dasm_put(Dst, 14026);
2189 } else { 2189 } else {
2190 dasm_put(Dst, 14038); 2190 dasm_put(Dst, 14030);
2191 } 2191 }
2192 dasm_put(Dst, 14046, DISPATCH_GL(vmstate), ~LJ_VMST_C); 2192 dasm_put(Dst, 14038, DISPATCH_GL(vmstate), ~LJ_VMST_C);
2193 if (op == BC_FUNCC) { 2193 if (op == BC_FUNCC) {
2194 dasm_put(Dst, 14056); 2194 dasm_put(Dst, 14048);
2195 } else { 2195 } else {
2196 dasm_put(Dst, 14061, DISPATCH_GL(wrapf)); 2196 dasm_put(Dst, 14053, DISPATCH_GL(wrapf));
2197 } 2197 }
2198 dasm_put(Dst, 14067, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top)); 2198 dasm_put(Dst, 14059, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top));
2199 break; 2199 break;
2200 2200
2201 /* ---------------------------------------------------------------------- */ 2201 /* ---------------------------------------------------------------------- */
@@ -2223,7 +2223,7 @@ static int build_backend(BuildCtx *ctx)
2223 2223
2224 build_subroutines(ctx, cmov, sse); 2224 build_subroutines(ctx, cmov, sse);
2225 2225
2226 dasm_put(Dst, 14093); 2226 dasm_put(Dst, 14085);
2227 for (op = 0; op < BC__MAX; op++) 2227 for (op = 0; op < BC__MAX; op++)
2228 build_ins(ctx, (BCOp)op, op, cmov, sse); 2228 build_ins(ctx, (BCOp)op, op, cmov, sse);
2229 2229
diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h
index 87f72a79..f6cc6567 100644
--- a/src/buildvm_x64win.h
+++ b/src/buildvm_x64win.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
15static const unsigned char build_actionlist[14042] = { 15static const unsigned char build_actionlist[14034] = {
16 254,1,248,10,252,247,198,237,15,132,244,11,131,230,252,248,41,252,242,72, 16 254,1,248,10,252,247,198,237,15,132,244,11,131,230,252,248,41,252,242,72,
17 141,76,49,252,248,139,114,252,252,199,68,10,4,237,248,12,131,192,1,137,68, 17 141,76,49,252,248,139,114,252,252,199,68,10,4,237,248,12,131,192,1,137,68,
18 36,84,252,247,198,237,15,132,244,13,248,14,129,252,246,239,252,247,198,237, 18 36,84,252,247,198,237,15,132,244,13,248,14,129,252,246,239,252,247,198,237,
@@ -640,62 +640,61 @@ static const unsigned char build_actionlist[14042] = {
640 252,236,137,41,137,65,4,139,105,252,240,139,65,252,244,137,105,8,137,65,12, 640 252,236,137,41,137,65,4,139,105,252,240,139,65,252,244,137,105,8,137,65,12,
641 139,105,224,139,65,228,137,105,252,248,137,65,252,252,129,252,248,239,184, 641 139,105,224,139,65,228,137,105,252,248,137,65,252,252,129,252,248,239,184,
642 237,15,133,244,28,137,202,137,114,252,252,139,181,233,139,14,15,182,252,233, 642 237,15,133,244,28,137,202,137,114,252,252,139,181,233,139,14,15,182,252,233,
643 15,182,205,131,198,4,252,255,36,252,235,255,15,182,252,236,139,66,252,248, 643 15,182,205,131,198,4,252,255,36,252,235,255,15,182,252,236,15,182,192,137,
644 141,12,202,139,128,233,15,182,128,233,137,124,36,80,141,188,253,194,233,43, 644 124,36,80,141,188,253,194,233,141,12,202,43,122,252,252,133,252,237,15,132,
645 122,252,252,133,252,237,15,132,244,251,141,108,252,233,252,248,57,215,15, 645 244,251,141,108,252,233,252,248,57,215,15,131,244,248,248,1,139,71,252,248,
646 131,244,248,248,1,139,71,252,248,137,1,139,71,252,252,131,199,8,137,65,4, 646 137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57,252,233,15,131,244,249,
647 131,193,8,57,252,233,15,131,244,249,57,215,15,130,244,1,248,2,199,65,4,237, 647 57,215,15,130,244,1,248,2,199,65,4,237,131,193,8,57,252,233,15,130,244,2,
648 131,193,8,57,252,233,15,130,244,2,248,3,139,124,36,80,139,6,15,182,204,15, 648 248,3,139,124,36,80,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,
649 182,232,131,198,4,193,232,16,252,255,36,252,235,248,5,199,68,36,84,1,0,0, 649 255,36,252,235,248,5,199,68,36,84,1,0,0,0,137,208,41,252,248,15,134,244,3,
650 0,137,208,41,252,248,15,134,244,3,255,137,197,193,252,237,3,131,197,1,137, 650 137,197,193,252,237,3,131,197,1,137,108,36,84,139,108,36,96,1,200,59,133,
651 108,36,84,139,108,36,96,1,200,59,133,233,15,135,244,253,248,6,139,71,252, 651 233,15,135,244,253,248,6,255,139,71,252,248,137,1,139,71,252,252,131,199,
652 248,137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57,215,15,130,244,6, 652 8,137,65,4,131,193,8,57,215,15,130,244,6,252,233,244,3,248,7,137,149,233,
653 252,233,244,3,248,7,137,149,233,137,141,233,137,116,36,100,41,215,139,84, 653 137,141,233,137,116,36,100,41,215,139,84,36,84,131,252,234,1,137,252,233,
654 36,84,131,252,234,1,137,252,233,232,251,1,0,139,149,233,139,141,233,1,215, 654 232,251,1,0,139,149,233,139,141,233,1,215,252,233,244,6,255,193,225,3,255,
655 252,233,244,6,255,193,225,3,255,248,1,139,114,252,252,137,68,36,84,252,247, 655 248,1,139,114,252,252,137,68,36,84,252,247,198,237,15,133,244,253,255,248,
656 198,237,15,133,244,253,255,248,13,137,215,131,232,1,15,132,244,249,248,2, 656 13,137,215,131,232,1,15,132,244,249,248,2,139,44,15,137,111,252,248,139,108,
657 139,44,15,137,111,252,248,139,108,15,4,137,111,252,252,131,199,8,131,232, 657 15,4,137,111,252,252,131,199,8,131,232,1,15,133,244,2,248,3,139,68,36,84,
658 1,15,133,244,2,248,3,139,68,36,84,15,182,110,252,255,248,5,57,197,15,135, 658 15,182,110,252,255,248,5,57,197,15,135,244,252,255,139,108,10,4,137,106,252,
659 244,252,255,139,108,10,4,137,106,252,252,139,44,10,137,106,252,248,255,248, 659 252,139,44,10,137,106,252,248,255,248,5,56,70,252,255,15,135,244,252,255,
660 5,56,70,252,255,15,135,244,252,255,15,182,78,252,253,72,252,247,209,141,20, 660 15,182,78,252,253,72,252,247,209,141,20,202,139,122,252,248,139,191,233,139,
661 202,139,122,252,248,139,191,233,139,191,233,139,6,15,182,204,15,182,232,131, 661 191,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,
662 198,4,193,232,16,252,255,36,252,235,248,6,255,199,71,252,252,237,131,199, 662 248,6,255,199,71,252,252,237,131,199,8,255,199,68,194,252,244,237,255,131,
663 8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248,7,141,174,233, 663 192,1,252,233,244,5,248,7,141,174,233,252,247,197,237,15,133,244,14,41,252,
664 252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255,137,252,245,209, 664 234,255,1,252,233,255,137,252,245,209,252,237,129,229,239,102,131,172,253,
665 252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,140,255,141,12,202, 665 43,233,1,15,132,244,140,255,141,12,202,255,129,121,253,4,239,15,135,244,53,
666 255,129,121,253,4,239,15,135,244,53,129,121,253,12,239,15,135,244,53,255, 666 129,121,253,12,239,15,135,244,53,255,139,105,20,255,129,252,253,239,15,135,
667 139,105,20,255,129,252,253,239,15,135,244,53,255,252,242,15,16,1,252,242, 667 244,53,255,252,242,15,16,1,252,242,15,16,73,8,255,252,242,15,88,65,16,252,
668 15,16,73,8,255,252,242,15,88,65,16,252,242,15,17,1,133,252,237,15,136,244, 668 242,15,17,1,133,252,237,15,136,244,249,255,15,140,244,249,255,102,15,46,200,
669 249,255,15,140,244,249,255,102,15,46,200,248,1,252,242,15,17,65,24,255,221, 669 248,1,252,242,15,17,65,24,255,221,65,8,221,1,255,220,65,16,221,17,221,81,
670 65,8,221,1,255,220,65,16,221,17,221,81,24,133,252,237,15,136,244,247,255, 670 24,133,252,237,15,136,244,247,255,221,81,24,15,140,244,247,255,217,201,248,
671 221,81,24,15,140,244,247,255,217,201,248,1,255,15,183,70,252,254,255,15,131, 671 1,255,15,183,70,252,254,255,15,131,244,248,141,180,253,134,233,255,141,180,
672 244,248,141,180,253,134,233,255,141,180,253,134,233,15,183,70,252,254,15, 672 253,134,233,15,183,70,252,254,15,131,245,255,15,130,244,248,141,180,253,134,
673 131,245,255,15,130,244,248,141,180,253,134,233,255,248,3,102,15,46,193,252, 673 233,255,248,3,102,15,46,193,252,233,244,1,255,141,12,202,139,105,4,129,252,
674 233,244,1,255,141,12,202,139,105,4,129,252,253,239,15,132,244,247,255,137, 674 253,239,15,132,244,247,255,137,105,252,252,139,41,137,105,252,248,252,233,
675 105,252,252,139,41,137,105,252,248,252,233,245,255,141,180,253,134,233,139, 675 245,255,141,180,253,134,233,139,1,137,105,252,252,137,65,252,248,255,139,
676 1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,72,139,128,233, 676 139,233,139,4,129,72,139,128,233,139,108,36,96,137,147,233,137,171,233,76,
677 139,108,36,96,137,147,233,137,171,233,76,137,100,36,80,76,137,108,36,32,76, 677 137,100,36,80,76,137,108,36,32,76,137,116,36,24,76,137,124,36,16,72,137,225,
678 137,116,36,24,76,137,124,36,16,72,137,225,72,129,252,236,239,102,15,127,49, 678 72,129,252,236,239,102,15,127,49,102,15,127,185,233,102,68,15,127,129,233,
679 102,15,127,185,233,102,68,15,127,129,233,102,68,15,127,137,233,102,68,15, 679 102,68,15,127,137,233,102,68,15,127,145,233,102,68,15,127,153,233,102,68,
680 127,145,233,102,68,15,127,153,233,102,68,15,127,161,233,102,68,15,127,169, 680 15,127,161,233,102,68,15,127,169,233,102,68,15,127,177,233,102,68,15,127,
681 233,102,68,15,127,177,233,102,68,15,127,185,233,252,255,224,255,141,180,253, 681 185,233,252,255,224,255,141,180,253,134,233,139,6,15,182,204,15,182,232,131,
682 134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235, 682 198,4,193,232,16,252,255,36,252,235,255,137,252,245,209,252,237,129,229,239,
683 255,137,252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244, 683 102,131,172,253,43,233,1,15,132,244,142,255,139,190,233,139,108,36,96,141,
684 142,255,139,190,233,139,108,36,96,141,12,202,59,141,233,15,135,244,23,15, 684 12,202,59,141,233,15,135,244,23,15,182,142,233,57,200,15,134,244,249,248,
685 182,142,233,57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245, 685 2,255,15,183,70,252,254,252,233,245,255,248,3,199,68,194,252,252,237,131,
686 255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244, 686 192,1,57,200,15,134,244,3,252,233,244,2,255,141,44,197,237,141,4,194,139,
687 2,255,141,44,197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252, 687 122,252,248,137,104,252,252,137,120,252,248,139,108,36,96,141,12,200,59,141,
688 248,139,108,36,96,141,12,200,59,141,233,15,135,244,22,137,209,137,194,15, 688 233,15,135,244,22,137,209,137,194,15,182,174,233,133,252,237,15,132,244,248,
689 182,174,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244, 689 248,1,131,193,8,57,209,15,131,244,249,139,121,252,248,137,56,139,121,252,
690 249,139,121,252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252, 690 252,137,120,4,131,192,8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,
691 252,237,131,252,237,1,15,133,244,1,248,2,255,139,190,233,139,6,15,182,204, 691 2,255,139,190,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,
692 15,182,232,131,198,4,193,232,16,252,255,36,252,235,255,248,3,199,64,4,237, 692 36,252,235,255,248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,
693 131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255,139,106,252,248,72, 693 233,244,2,255,139,106,252,248,72,139,189,233,139,108,36,96,141,68,194,252,
694 139,189,233,139,108,36,96,141,68,194,252,248,137,149,233,141,136,233,59,141, 694 248,137,149,233,141,136,233,59,141,233,137,133,233,255,137,252,233,255,72,
695 233,137,133,233,255,137,252,233,255,72,137,252,250,137,252,233,255,15,135, 695 137,252,250,137,252,233,255,15,135,244,21,199,131,233,237,255,252,255,215,
696 244,21,199,131,233,237,255,252,255,215,255,252,255,147,233,255,199,131,233, 696 255,252,255,147,233,255,199,131,233,237,139,149,233,141,12,194,252,247,217,
697 237,139,149,233,141,12,194,252,247,217,3,141,233,139,114,252,252,252,233, 697 3,141,233,139,114,252,252,252,233,244,12,255,254,0
698 244,12,255,254,0
699}; 698};
700 699
701enum { 700enum {
@@ -1992,8 +1991,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
1992 break; 1991 break;
1993 1992
1994 case BC_VARG: 1993 case BC_VARG:
1995 dasm_put(Dst, 12926, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL); 1994 dasm_put(Dst, 12926, (8+FRAME_VARG), LJ_TNIL, Dt1(->maxstack));
1996 dasm_put(Dst, 13071, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); 1995 dasm_put(Dst, 13091, Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top));
1997 break; 1996 break;
1998 1997
1999 /* -- Returns ----------------------------------------------------------- */ 1998 /* -- Returns ----------------------------------------------------------- */
@@ -2004,30 +2003,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2004 2003
2005 case BC_RET: case BC_RET0: case BC_RET1: 2004 case BC_RET: case BC_RET0: case BC_RET1:
2006 if (op != BC_RET0) { 2005 if (op != BC_RET0) {
2007 dasm_put(Dst, 13170); 2006 dasm_put(Dst, 13162);
2008 } 2007 }
2009 dasm_put(Dst, 13174, FRAME_TYPE); 2008 dasm_put(Dst, 13166, FRAME_TYPE);
2010 switch (op) { 2009 switch (op) {
2011 case BC_RET: 2010 case BC_RET:
2012 dasm_put(Dst, 13193); 2011 dasm_put(Dst, 13185);
2013 break; 2012 break;
2014 case BC_RET1: 2013 case BC_RET1:
2015 dasm_put(Dst, 13251); 2014 dasm_put(Dst, 13243);
2016 /* fallthrough */ 2015 /* fallthrough */
2017 case BC_RET0: 2016 case BC_RET0:
2018 dasm_put(Dst, 13267); 2017 dasm_put(Dst, 13259);
2019 default: 2018 default:
2020 break; 2019 break;
2021 } 2020 }
2022 dasm_put(Dst, 13278, Dt7(->pc), PC2PROTO(k)); 2021 dasm_put(Dst, 13270, Dt7(->pc), PC2PROTO(k));
2023 if (op == BC_RET) { 2022 if (op == BC_RET) {
2024 dasm_put(Dst, 13322, LJ_TNIL); 2023 dasm_put(Dst, 13314, LJ_TNIL);
2025 } else { 2024 } else {
2026 dasm_put(Dst, 13331, LJ_TNIL); 2025 dasm_put(Dst, 13323, LJ_TNIL);
2027 } 2026 }
2028 dasm_put(Dst, 13338, -FRAME_VARG, FRAME_TYPEP); 2027 dasm_put(Dst, 13330, -FRAME_VARG, FRAME_TYPEP);
2029 if (op != BC_RET0) { 2028 if (op != BC_RET0) {
2030 dasm_put(Dst, 13362); 2029 dasm_put(Dst, 13354);
2031 } 2030 }
2032 dasm_put(Dst, 4573); 2031 dasm_put(Dst, 4573);
2033 break; 2032 break;
@@ -2037,7 +2036,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2037 2036
2038 case BC_FORL: 2037 case BC_FORL:
2039#if LJ_HASJIT 2038#if LJ_HASJIT
2040 dasm_put(Dst, 13366, HOTCOUNT_PCMASK, GG_DISP2HOT); 2039 dasm_put(Dst, 13358, HOTCOUNT_PCMASK, GG_DISP2HOT);
2041#endif 2040#endif
2042 break; 2041 break;
2043 2042
@@ -2049,57 +2048,57 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2049 case BC_FORI: 2048 case BC_FORI:
2050 case BC_IFORL: 2049 case BC_IFORL:
2051 vk = (op == BC_IFORL || op == BC_JFORL); 2050 vk = (op == BC_IFORL || op == BC_JFORL);
2052 dasm_put(Dst, 13387); 2051 dasm_put(Dst, 13379);
2053 if (!vk) { 2052 if (!vk) {
2054 dasm_put(Dst, 13391, LJ_TISNUM, LJ_TISNUM); 2053 dasm_put(Dst, 13383, LJ_TISNUM, LJ_TISNUM);
2055 } 2054 }
2056 dasm_put(Dst, 13410); 2055 dasm_put(Dst, 13402);
2057 if (!vk) { 2056 if (!vk) {
2058 dasm_put(Dst, 13414, LJ_TISNUM); 2057 dasm_put(Dst, 13406, LJ_TISNUM);
2059 } 2058 }
2060 if (sse) { 2059 if (sse) {
2061 dasm_put(Dst, 13423); 2060 dasm_put(Dst, 13415);
2062 if (vk) { 2061 if (vk) {
2063 dasm_put(Dst, 13435); 2062 dasm_put(Dst, 13427);
2064 } else { 2063 } else {
2065 dasm_put(Dst, 13454); 2064 dasm_put(Dst, 13446);
2066 } 2065 }
2067 dasm_put(Dst, 13459); 2066 dasm_put(Dst, 13451);
2068 } else { 2067 } else {
2069 dasm_put(Dst, 13472); 2068 dasm_put(Dst, 13464);
2070 if (vk) { 2069 if (vk) {
2071 dasm_put(Dst, 13478); 2070 dasm_put(Dst, 13470);
2072 } else { 2071 } else {
2073 dasm_put(Dst, 13494); 2072 dasm_put(Dst, 13486);
2074 } 2073 }
2075 dasm_put(Dst, 13502); 2074 dasm_put(Dst, 13494);
2076 if (cmov) { 2075 if (cmov) {
2077 dasm_put(Dst, 9536); 2076 dasm_put(Dst, 9536);
2078 } else { 2077 } else {
2079 dasm_put(Dst, 9542); 2078 dasm_put(Dst, 9542);
2080 } 2079 }
2081 if (!cmov) { 2080 if (!cmov) {
2082 dasm_put(Dst, 13507); 2081 dasm_put(Dst, 13499);
2083 } 2082 }
2084 } 2083 }
2085 if (op == BC_FORI) { 2084 if (op == BC_FORI) {
2086 dasm_put(Dst, 13513, -BCBIAS_J*4); 2085 dasm_put(Dst, 13505, -BCBIAS_J*4);
2087 } else if (op == BC_JFORI) { 2086 } else if (op == BC_JFORI) {
2088 dasm_put(Dst, 13523, -BCBIAS_J*4, BC_JLOOP); 2087 dasm_put(Dst, 13515, -BCBIAS_J*4, BC_JLOOP);
2089 } else if (op == BC_IFORL) { 2088 } else if (op == BC_IFORL) {
2090 dasm_put(Dst, 13537, -BCBIAS_J*4); 2089 dasm_put(Dst, 13529, -BCBIAS_J*4);
2091 } else { 2090 } else {
2092 dasm_put(Dst, 13533, BC_JLOOP); 2091 dasm_put(Dst, 13525, BC_JLOOP);
2093 } 2092 }
2094 dasm_put(Dst, 9571); 2093 dasm_put(Dst, 9571);
2095 if (sse) { 2094 if (sse) {
2096 dasm_put(Dst, 13547); 2095 dasm_put(Dst, 13539);
2097 } 2096 }
2098 break; 2097 break;
2099 2098
2100 case BC_ITERL: 2099 case BC_ITERL:
2101#if LJ_HASJIT 2100#if LJ_HASJIT
2102 dasm_put(Dst, 13366, HOTCOUNT_PCMASK, GG_DISP2HOT); 2101 dasm_put(Dst, 13358, HOTCOUNT_PCMASK, GG_DISP2HOT);
2103#endif 2102#endif
2104 break; 2103 break;
2105 2104
@@ -2108,18 +2107,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2108 break; 2107 break;
2109#endif 2108#endif
2110 case BC_IITERL: 2109 case BC_IITERL:
2111 dasm_put(Dst, 13558, LJ_TNIL); 2110 dasm_put(Dst, 13550, LJ_TNIL);
2112 if (op == BC_JITERL) { 2111 if (op == BC_JITERL) {
2113 dasm_put(Dst, 13573, BC_JLOOP); 2112 dasm_put(Dst, 13565, BC_JLOOP);
2114 } else { 2113 } else {
2115 dasm_put(Dst, 13587, -BCBIAS_J*4); 2114 dasm_put(Dst, 13579, -BCBIAS_J*4);
2116 } 2115 }
2117 dasm_put(Dst, 9871); 2116 dasm_put(Dst, 9871);
2118 break; 2117 break;
2119 2118
2120 case BC_LOOP: 2119 case BC_LOOP:
2121#if LJ_HASJIT 2120#if LJ_HASJIT
2122 dasm_put(Dst, 13366, HOTCOUNT_PCMASK, GG_DISP2HOT); 2121 dasm_put(Dst, 13358, HOTCOUNT_PCMASK, GG_DISP2HOT);
2123#endif 2122#endif
2124 break; 2123 break;
2125 2124
@@ -2129,12 +2128,12 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2129 2128
2130 case BC_JLOOP: 2129 case BC_JLOOP:
2131#if LJ_HASJIT 2130#if LJ_HASJIT
2132 dasm_put(Dst, 13603, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L), 9*16+4*8, -1*16, -2*16, -3*16, -4*16, -5*16, -6*16, -7*16, -8*16, -9*16); 2131 dasm_put(Dst, 13595, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L), 9*16+4*8, -1*16, -2*16, -3*16, -4*16, -5*16, -6*16, -7*16, -8*16, -9*16);
2133#endif 2132#endif
2134 break; 2133 break;
2135 2134
2136 case BC_JMP: 2135 case BC_JMP:
2137 dasm_put(Dst, 13712, -BCBIAS_J*4); 2136 dasm_put(Dst, 13704, -BCBIAS_J*4);
2138 break; 2137 break;
2139 2138
2140 /* -- Function headers -------------------------------------------------- */ 2139 /* -- Function headers -------------------------------------------------- */
@@ -2148,7 +2147,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2148 2147
2149 case BC_FUNCF: 2148 case BC_FUNCF:
2150#if LJ_HASJIT 2149#if LJ_HASJIT
2151 dasm_put(Dst, 13737, HOTCOUNT_PCMASK, GG_DISP2HOT); 2150 dasm_put(Dst, 13729, HOTCOUNT_PCMASK, GG_DISP2HOT);
2152#endif 2151#endif
2153 case BC_FUNCV: /* NYI: compiled vararg functions. */ 2152 case BC_FUNCV: /* NYI: compiled vararg functions. */
2154 break; 2153 break;
@@ -2158,13 +2157,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2158 break; 2157 break;
2159#endif 2158#endif
2160 case BC_IFUNCF: 2159 case BC_IFUNCF:
2161 dasm_put(Dst, 13758, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams)); 2160 dasm_put(Dst, 13750, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams));
2162 if (op == BC_JFUNCF) { 2161 if (op == BC_JFUNCF) {
2163 dasm_put(Dst, 13788, BC_JLOOP); 2162 dasm_put(Dst, 13780, BC_JLOOP);
2164 } else { 2163 } else {
2165 dasm_put(Dst, 9573); 2164 dasm_put(Dst, 9573);
2166 } 2165 }
2167 dasm_put(Dst, 13797, LJ_TNIL); 2166 dasm_put(Dst, 13789, LJ_TNIL);
2168 break; 2167 break;
2169 2168
2170 case BC_JFUNCV: 2169 case BC_JFUNCV:
@@ -2175,30 +2174,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2175 break; /* NYI: compiled vararg functions. */ 2174 break; /* NYI: compiled vararg functions. */
2176 2175
2177 case BC_IFUNCV: 2176 case BC_IFUNCV:
2178 dasm_put(Dst, 13819, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL); 2177 dasm_put(Dst, 13811, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL);
2179 if (op == BC_JFUNCV) { 2178 if (op == BC_JFUNCV) {
2180 dasm_put(Dst, 13788, BC_JLOOP); 2179 dasm_put(Dst, 13780, BC_JLOOP);
2181 } else { 2180 } else {
2182 dasm_put(Dst, 13910, -4+PC2PROTO(k)); 2181 dasm_put(Dst, 13902, -4+PC2PROTO(k));
2183 } 2182 }
2184 dasm_put(Dst, 13933, LJ_TNIL); 2183 dasm_put(Dst, 13925, LJ_TNIL);
2185 break; 2184 break;
2186 2185
2187 case BC_FUNCC: 2186 case BC_FUNCC:
2188 case BC_FUNCCW: 2187 case BC_FUNCCW:
2189 dasm_put(Dst, 13955, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top)); 2188 dasm_put(Dst, 13947, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top));
2190 if (op == BC_FUNCC) { 2189 if (op == BC_FUNCC) {
2191 dasm_put(Dst, 13985); 2190 dasm_put(Dst, 13977);
2192 } else { 2191 } else {
2193 dasm_put(Dst, 13989); 2192 dasm_put(Dst, 13981);
2194 } 2193 }
2195 dasm_put(Dst, 13997, DISPATCH_GL(vmstate), ~LJ_VMST_C); 2194 dasm_put(Dst, 13989, DISPATCH_GL(vmstate), ~LJ_VMST_C);
2196 if (op == BC_FUNCC) { 2195 if (op == BC_FUNCC) {
2197 dasm_put(Dst, 14006); 2196 dasm_put(Dst, 13998);
2198 } else { 2197 } else {
2199 dasm_put(Dst, 14010, DISPATCH_GL(wrapf)); 2198 dasm_put(Dst, 14002, DISPATCH_GL(wrapf));
2200 } 2199 }
2201 dasm_put(Dst, 14015, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top)); 2200 dasm_put(Dst, 14007, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top));
2202 break; 2201 break;
2203 2202
2204 /* ---------------------------------------------------------------------- */ 2203 /* ---------------------------------------------------------------------- */
@@ -2226,7 +2225,7 @@ static int build_backend(BuildCtx *ctx)
2226 2225
2227 build_subroutines(ctx, cmov, sse); 2226 build_subroutines(ctx, cmov, sse);
2228 2227
2229 dasm_put(Dst, 14040); 2228 dasm_put(Dst, 14032);
2230 for (op = 0; op < BC__MAX; op++) 2229 for (op = 0; op < BC__MAX; op++)
2231 build_ins(ctx, (BCOp)op, op, cmov, sse); 2230 build_ins(ctx, (BCOp)op, op, cmov, sse);
2232 2231
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc
index d7c36d90..598fe087 100644
--- a/src/buildvm_x86.dasc
+++ b/src/buildvm_x86.dasc
@@ -4442,13 +4442,10 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
4442 break; 4442 break;
4443 4443
4444 case BC_VARG: 4444 case BC_VARG:
4445 | ins_AB_ // RA = base, RB = nresults+1, (RC = 1) 4445 | ins_ABC // RA = base, RB = nresults+1, RC = numparams
4446 | mov LFUNC:RC, [BASE-8]
4447 | lea RA, [BASE+RA*8]
4448 | mov RC, LFUNC:RC->pc
4449 | movzx RC, byte [RC+PC2PROTO(numparams)]
4450 | mov TMP1, KBASE // Need one more free register. 4446 | mov TMP1, KBASE // Need one more free register.
4451 | lea KBASE, [BASE+RC*8+(8+FRAME_VARG)] 4447 | lea KBASE, [BASE+RC*8+(8+FRAME_VARG)]
4448 | lea RA, [BASE+RA*8]
4452 | sub KBASE, [BASE-4] 4449 | sub KBASE, [BASE-4]
4453 | // Note: KBASE may now be even _above_ BASE if nargs was < numparams. 4450 | // Note: KBASE may now be even _above_ BASE if nargs was < numparams.
4454 | test RB, RB 4451 | test RB, RB
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h
index 10392991..7624330c 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
15static const unsigned char build_actionlist[15235] = { 15static const unsigned char build_actionlist[15227] = {
16 254,1,248,10,252,247,198,237,15,132,244,11,131,230,252,248,41,252,242,141, 16 254,1,248,10,252,247,198,237,15,132,244,11,131,230,252,248,41,252,242,141,
17 76,49,252,248,139,114,252,252,199,68,10,4,237,248,12,131,192,1,137,68,36, 17 76,49,252,248,139,114,252,252,199,68,10,4,237,248,12,131,192,1,137,68,36,
18 20,252,247,198,237,15,132,244,13,248,14,129,252,246,239,252,247,198,237,15, 18 20,252,247,198,237,15,132,244,13,248,14,129,252,246,239,252,247,198,237,15,
@@ -698,57 +698,56 @@ static const unsigned char build_actionlist[15235] = {
698 139,105,252,240,139,65,252,244,137,105,8,137,65,12,139,105,224,139,65,228, 698 139,105,252,240,139,65,252,244,137,105,8,137,65,12,139,105,224,139,65,228,
699 137,105,252,248,137,65,252,252,129,252,248,239,184,237,15,133,244,28,137, 699 137,105,252,248,137,65,252,252,129,252,248,239,184,237,15,133,244,28,137,
700 202,137,114,252,252,139,181,233,139,14,15,182,252,233,15,182,205,131,198, 700 202,137,114,252,252,139,181,233,139,14,15,182,252,233,15,182,205,131,198,
701 4,252,255,36,171,255,15,182,252,236,139,66,252,248,141,12,202,139,128,233, 701 4,252,255,36,171,255,15,182,252,236,15,182,192,137,124,36,16,141,188,253,
702 15,182,128,233,137,124,36,16,141,188,253,194,233,43,122,252,252,133,252,237, 702 194,233,141,12,202,43,122,252,252,133,252,237,15,132,244,251,141,108,252,
703 15,132,244,251,141,108,252,233,252,248,57,215,15,131,244,248,248,1,139,71, 703 233,252,248,57,215,15,131,244,248,248,1,139,71,252,248,137,1,139,71,252,252,
704 252,248,137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57,252,233,15,131, 704 131,199,8,137,65,4,131,193,8,57,252,233,15,131,244,249,57,215,15,130,244,
705 244,249,57,215,15,130,244,1,248,2,199,65,4,237,131,193,8,57,252,233,15,130, 705 1,248,2,199,65,4,237,131,193,8,57,252,233,15,130,244,2,248,3,139,124,36,16,
706 244,2,248,3,139,124,36,16,139,6,15,182,204,15,182,232,131,198,4,193,232,16, 706 139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,5,199,
707 252,255,36,171,248,5,199,68,36,20,1,0,0,0,137,208,41,252,248,15,134,244,3, 707 68,36,20,1,0,0,0,137,208,41,252,248,15,134,244,3,137,197,193,252,237,3,131,
708 255,137,197,193,252,237,3,131,197,1,137,108,36,20,139,108,36,48,1,200,59, 708 197,1,137,108,36,20,139,108,36,48,1,200,59,133,233,15,135,244,253,248,6,255,
709 133,233,15,135,244,253,248,6,139,71,252,248,137,1,139,71,252,252,131,199, 709 139,71,252,248,137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57,215,15,
710 8,137,65,4,131,193,8,57,215,15,130,244,6,252,233,244,3,248,7,137,149,233, 710 130,244,6,252,233,244,3,248,7,137,149,233,137,141,233,137,116,36,24,41,215,
711 137,141,233,137,116,36,24,41,215,139,84,36,20,131,252,234,1,137,252,233,232, 711 139,84,36,20,131,252,234,1,137,252,233,232,251,1,0,139,149,233,139,141,233,
712 251,1,0,139,149,233,139,141,233,1,215,252,233,244,6,255,193,225,3,255,248, 712 1,215,252,233,244,6,255,193,225,3,255,248,1,139,114,252,252,137,68,36,20,
713 1,139,114,252,252,137,68,36,20,252,247,198,237,15,133,244,253,255,248,13, 713 252,247,198,237,15,133,244,253,255,248,13,137,215,131,232,1,15,132,244,249,
714 137,215,131,232,1,15,132,244,249,248,2,139,44,15,137,111,252,248,139,108, 714 248,2,139,44,15,137,111,252,248,139,108,15,4,137,111,252,252,131,199,8,131,
715 15,4,137,111,252,252,131,199,8,131,232,1,15,133,244,2,248,3,139,68,36,20, 715 232,1,15,133,244,2,248,3,139,68,36,20,15,182,110,252,255,248,5,57,197,15,
716 15,182,110,252,255,248,5,57,197,15,135,244,252,255,139,108,10,4,137,106,252, 716 135,244,252,255,139,108,10,4,137,106,252,252,139,44,10,137,106,252,248,255,
717 252,139,44,10,137,106,252,248,255,248,5,56,70,252,255,15,135,244,252,255, 717 248,5,56,70,252,255,15,135,244,252,255,15,182,78,252,253,252,247,209,141,
718 15,182,78,252,253,252,247,209,141,20,202,139,122,252,248,139,191,233,139, 718 20,202,139,122,252,248,139,191,233,139,191,233,139,6,15,182,204,15,182,232,
719 191,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248, 719 131,198,4,193,232,16,252,255,36,171,248,6,255,199,71,252,252,237,131,199,
720 6,255,199,71,252,252,237,131,199,8,255,199,68,194,252,244,237,255,131,192, 720 8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248,7,141,174,233,
721 1,252,233,244,5,248,7,141,174,233,252,247,197,237,15,133,244,14,41,252,234, 721 252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255,137,252,245,209,
722 255,1,252,233,255,137,252,245,209,252,237,129,229,239,102,131,172,253,43, 722 252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,140,255,141,12,202,
723 233,1,15,132,244,140,255,141,12,202,255,129,121,253,4,239,15,135,244,53,129, 723 255,129,121,253,4,239,15,135,244,53,129,121,253,12,239,15,135,244,53,255,
724 121,253,12,239,15,135,244,53,255,139,105,20,255,129,252,253,239,15,135,244, 724 139,105,20,255,129,252,253,239,15,135,244,53,255,252,242,15,16,1,252,242,
725 53,255,252,242,15,16,1,252,242,15,16,73,8,255,252,242,15,88,65,16,252,242, 725 15,16,73,8,255,252,242,15,88,65,16,252,242,15,17,1,133,252,237,15,136,244,
726 15,17,1,133,252,237,15,136,244,249,255,15,140,244,249,255,102,15,46,200,248, 726 249,255,15,140,244,249,255,102,15,46,200,248,1,252,242,15,17,65,24,255,221,
727 1,252,242,15,17,65,24,255,221,65,8,221,1,255,220,65,16,221,17,221,81,24,133, 727 65,8,221,1,255,220,65,16,221,17,221,81,24,133,252,237,15,136,244,247,255,
728 252,237,15,136,244,247,255,221,81,24,15,140,244,247,255,217,201,248,1,255, 728 221,81,24,15,140,244,247,255,217,201,248,1,255,15,183,70,252,254,255,15,131,
729 15,183,70,252,254,255,15,131,244,248,141,180,253,134,233,255,141,180,253, 729 244,248,141,180,253,134,233,255,141,180,253,134,233,15,183,70,252,254,15,
730 134,233,15,183,70,252,254,15,131,245,255,15,130,244,248,141,180,253,134,233, 730 131,245,255,15,130,244,248,141,180,253,134,233,255,248,3,102,15,46,193,252,
731 255,248,3,102,15,46,193,252,233,244,1,255,141,12,202,139,105,4,129,252,253, 731 233,244,1,255,141,12,202,139,105,4,129,252,253,239,15,132,244,247,255,137,
732 239,15,132,244,247,255,137,105,252,252,139,41,137,105,252,248,252,233,245, 732 105,252,252,139,41,137,105,252,248,252,233,245,255,141,180,253,134,233,139,
733 255,141,180,253,134,233,139,1,137,105,252,252,137,65,252,248,255,139,139, 733 1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,139,128,233,139,
734 233,139,4,129,139,128,233,139,108,36,48,137,147,233,137,171,233,252,255,224, 734 108,36,48,137,147,233,137,171,233,252,255,224,255,141,180,253,134,233,139,
735 255,141,180,253,134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16, 735 6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255,137,252,245,
736 252,255,36,171,255,137,252,245,209,252,237,129,229,239,102,131,172,253,43, 736 209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,142,255,139,190,
737 233,1,15,132,244,142,255,139,190,233,139,108,36,48,141,12,202,59,141,233, 737 233,139,108,36,48,141,12,202,59,141,233,15,135,244,23,15,182,142,233,57,200,
738 15,135,244,23,15,182,142,233,57,200,15,134,244,249,248,2,255,15,183,70,252, 738 15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255,248,3,199,68,194,
739 254,252,233,245,255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134, 739 252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2,255,141,44,197,237,
740 244,3,252,233,244,2,255,141,44,197,237,141,4,194,139,122,252,248,137,104, 740 141,4,194,139,122,252,248,137,104,252,252,137,120,252,248,139,108,36,48,141,
741 252,252,137,120,252,248,139,108,36,48,141,12,200,59,141,233,15,135,244,22, 741 12,200,59,141,233,15,135,244,22,137,209,137,194,15,182,174,233,133,252,237,
742 137,209,137,194,15,182,174,233,133,252,237,15,132,244,248,248,1,131,193,8, 742 15,132,244,248,248,1,131,193,8,57,209,15,131,244,249,139,121,252,248,137,
743 57,209,15,131,244,249,139,121,252,248,137,56,139,121,252,252,137,120,4,131, 743 56,139,121,252,252,137,120,4,131,192,8,199,65,252,252,237,131,252,237,1,15,
744 192,8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,139,190,233, 744 133,244,1,248,2,255,139,190,233,139,6,15,182,204,15,182,232,131,198,4,193,
745 139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255,248,3, 745 232,16,252,255,36,171,255,248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,
746 199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255,139,106, 746 244,3,252,233,244,2,255,139,106,252,248,139,189,233,139,108,36,48,141,68,
747 252,248,139,189,233,139,108,36,48,141,68,194,252,248,137,149,233,141,136, 747 194,252,248,137,149,233,141,136,233,59,141,233,137,133,233,255,137,44,36,
748 233,59,141,233,137,133,233,255,137,44,36,255,137,124,36,4,137,44,36,255,15, 748 255,137,124,36,4,137,44,36,255,15,135,244,21,199,131,233,237,255,252,255,
749 135,244,21,199,131,233,237,255,252,255,215,255,252,255,147,233,255,199,131, 749 215,255,252,255,147,233,255,199,131,233,237,139,149,233,141,12,194,252,247,
750 233,237,139,149,233,141,12,194,252,247,217,3,141,233,139,114,252,252,252, 750 217,3,141,233,139,114,252,252,252,233,244,12,255,254,0
751 233,244,12,255,254,0
752}; 751};
753 752
754enum { 753enum {
@@ -2116,8 +2115,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2116 break; 2115 break;
2117 2116
2118 case BC_VARG: 2117 case BC_VARG:
2119 dasm_put(Dst, 14211, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL); 2118 dasm_put(Dst, 14211, (8+FRAME_VARG), LJ_TNIL, Dt1(->maxstack));
2120 dasm_put(Dst, 14355, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); 2119 dasm_put(Dst, 14375, Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top));
2121 break; 2120 break;
2122 2121
2123 /* -- Returns ----------------------------------------------------------- */ 2122 /* -- Returns ----------------------------------------------------------- */
@@ -2128,30 +2127,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2128 2127
2129 case BC_RET: case BC_RET0: case BC_RET1: 2128 case BC_RET: case BC_RET0: case BC_RET1:
2130 if (op != BC_RET0) { 2129 if (op != BC_RET0) {
2131 dasm_put(Dst, 14454); 2130 dasm_put(Dst, 14446);
2132 } 2131 }
2133 dasm_put(Dst, 14458, FRAME_TYPE); 2132 dasm_put(Dst, 14450, FRAME_TYPE);
2134 switch (op) { 2133 switch (op) {
2135 case BC_RET: 2134 case BC_RET:
2136 dasm_put(Dst, 14477); 2135 dasm_put(Dst, 14469);
2137 break; 2136 break;
2138 case BC_RET1: 2137 case BC_RET1:
2139 dasm_put(Dst, 14535); 2138 dasm_put(Dst, 14527);
2140 /* fallthrough */ 2139 /* fallthrough */
2141 case BC_RET0: 2140 case BC_RET0:
2142 dasm_put(Dst, 14551); 2141 dasm_put(Dst, 14543);
2143 default: 2142 default:
2144 break; 2143 break;
2145 } 2144 }
2146 dasm_put(Dst, 14562, Dt7(->pc), PC2PROTO(k)); 2145 dasm_put(Dst, 14554, Dt7(->pc), PC2PROTO(k));
2147 if (op == BC_RET) { 2146 if (op == BC_RET) {
2148 dasm_put(Dst, 14604, LJ_TNIL); 2147 dasm_put(Dst, 14596, LJ_TNIL);
2149 } else { 2148 } else {
2150 dasm_put(Dst, 14613, LJ_TNIL); 2149 dasm_put(Dst, 14605, LJ_TNIL);
2151 } 2150 }
2152 dasm_put(Dst, 14620, -FRAME_VARG, FRAME_TYPEP); 2151 dasm_put(Dst, 14612, -FRAME_VARG, FRAME_TYPEP);
2153 if (op != BC_RET0) { 2152 if (op != BC_RET0) {
2154 dasm_put(Dst, 14644); 2153 dasm_put(Dst, 14636);
2155 } 2154 }
2156 dasm_put(Dst, 4683); 2155 dasm_put(Dst, 4683);
2157 break; 2156 break;
@@ -2161,7 +2160,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2161 2160
2162 case BC_FORL: 2161 case BC_FORL:
2163#if LJ_HASJIT 2162#if LJ_HASJIT
2164 dasm_put(Dst, 14648, HOTCOUNT_PCMASK, GG_DISP2HOT); 2163 dasm_put(Dst, 14640, HOTCOUNT_PCMASK, GG_DISP2HOT);
2165#endif 2164#endif
2166 break; 2165 break;
2167 2166
@@ -2173,57 +2172,57 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2173 case BC_FORI: 2172 case BC_FORI:
2174 case BC_IFORL: 2173 case BC_IFORL:
2175 vk = (op == BC_IFORL || op == BC_JFORL); 2174 vk = (op == BC_IFORL || op == BC_JFORL);
2176 dasm_put(Dst, 14669); 2175 dasm_put(Dst, 14661);
2177 if (!vk) { 2176 if (!vk) {
2178 dasm_put(Dst, 14673, LJ_TISNUM, LJ_TISNUM); 2177 dasm_put(Dst, 14665, LJ_TISNUM, LJ_TISNUM);
2179 } 2178 }
2180 dasm_put(Dst, 14692); 2179 dasm_put(Dst, 14684);
2181 if (!vk) { 2180 if (!vk) {
2182 dasm_put(Dst, 14696, LJ_TISNUM); 2181 dasm_put(Dst, 14688, LJ_TISNUM);
2183 } 2182 }
2184 if (sse) { 2183 if (sse) {
2185 dasm_put(Dst, 14705); 2184 dasm_put(Dst, 14697);
2186 if (vk) { 2185 if (vk) {
2187 dasm_put(Dst, 14717); 2186 dasm_put(Dst, 14709);
2188 } else { 2187 } else {
2189 dasm_put(Dst, 14736); 2188 dasm_put(Dst, 14728);
2190 } 2189 }
2191 dasm_put(Dst, 14741); 2190 dasm_put(Dst, 14733);
2192 } else { 2191 } else {
2193 dasm_put(Dst, 14754); 2192 dasm_put(Dst, 14746);
2194 if (vk) { 2193 if (vk) {
2195 dasm_put(Dst, 14760); 2194 dasm_put(Dst, 14752);
2196 } else { 2195 } else {
2197 dasm_put(Dst, 14776); 2196 dasm_put(Dst, 14768);
2198 } 2197 }
2199 dasm_put(Dst, 14784); 2198 dasm_put(Dst, 14776);
2200 if (cmov) { 2199 if (cmov) {
2201 dasm_put(Dst, 10812); 2200 dasm_put(Dst, 10812);
2202 } else { 2201 } else {
2203 dasm_put(Dst, 10818); 2202 dasm_put(Dst, 10818);
2204 } 2203 }
2205 if (!cmov) { 2204 if (!cmov) {
2206 dasm_put(Dst, 14789); 2205 dasm_put(Dst, 14781);
2207 } 2206 }
2208 } 2207 }
2209 if (op == BC_FORI) { 2208 if (op == BC_FORI) {
2210 dasm_put(Dst, 14795, -BCBIAS_J*4); 2209 dasm_put(Dst, 14787, -BCBIAS_J*4);
2211 } else if (op == BC_JFORI) { 2210 } else if (op == BC_JFORI) {
2212 dasm_put(Dst, 14805, -BCBIAS_J*4, BC_JLOOP); 2211 dasm_put(Dst, 14797, -BCBIAS_J*4, BC_JLOOP);
2213 } else if (op == BC_IFORL) { 2212 } else if (op == BC_IFORL) {
2214 dasm_put(Dst, 14819, -BCBIAS_J*4); 2213 dasm_put(Dst, 14811, -BCBIAS_J*4);
2215 } else { 2214 } else {
2216 dasm_put(Dst, 14815, BC_JLOOP); 2215 dasm_put(Dst, 14807, BC_JLOOP);
2217 } 2216 }
2218 dasm_put(Dst, 10847); 2217 dasm_put(Dst, 10847);
2219 if (sse) { 2218 if (sse) {
2220 dasm_put(Dst, 14829); 2219 dasm_put(Dst, 14821);
2221 } 2220 }
2222 break; 2221 break;
2223 2222
2224 case BC_ITERL: 2223 case BC_ITERL:
2225#if LJ_HASJIT 2224#if LJ_HASJIT
2226 dasm_put(Dst, 14648, HOTCOUNT_PCMASK, GG_DISP2HOT); 2225 dasm_put(Dst, 14640, HOTCOUNT_PCMASK, GG_DISP2HOT);
2227#endif 2226#endif
2228 break; 2227 break;
2229 2228
@@ -2232,18 +2231,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2232 break; 2231 break;
2233#endif 2232#endif
2234 case BC_IITERL: 2233 case BC_IITERL:
2235 dasm_put(Dst, 14840, LJ_TNIL); 2234 dasm_put(Dst, 14832, LJ_TNIL);
2236 if (op == BC_JITERL) { 2235 if (op == BC_JITERL) {
2237 dasm_put(Dst, 14855, BC_JLOOP); 2236 dasm_put(Dst, 14847, BC_JLOOP);
2238 } else { 2237 } else {
2239 dasm_put(Dst, 14869, -BCBIAS_J*4); 2238 dasm_put(Dst, 14861, -BCBIAS_J*4);
2240 } 2239 }
2241 dasm_put(Dst, 11144); 2240 dasm_put(Dst, 11144);
2242 break; 2241 break;
2243 2242
2244 case BC_LOOP: 2243 case BC_LOOP:
2245#if LJ_HASJIT 2244#if LJ_HASJIT
2246 dasm_put(Dst, 14648, HOTCOUNT_PCMASK, GG_DISP2HOT); 2245 dasm_put(Dst, 14640, HOTCOUNT_PCMASK, GG_DISP2HOT);
2247#endif 2246#endif
2248 break; 2247 break;
2249 2248
@@ -2253,12 +2252,12 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2253 2252
2254 case BC_JLOOP: 2253 case BC_JLOOP:
2255#if LJ_HASJIT 2254#if LJ_HASJIT
2256 dasm_put(Dst, 14885, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); 2255 dasm_put(Dst, 14877, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L));
2257#endif 2256#endif
2258 break; 2257 break;
2259 2258
2260 case BC_JMP: 2259 case BC_JMP:
2261 dasm_put(Dst, 14908, -BCBIAS_J*4); 2260 dasm_put(Dst, 14900, -BCBIAS_J*4);
2262 break; 2261 break;
2263 2262
2264 /* -- Function headers -------------------------------------------------- */ 2263 /* -- Function headers -------------------------------------------------- */
@@ -2272,7 +2271,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2272 2271
2273 case BC_FUNCF: 2272 case BC_FUNCF:
2274#if LJ_HASJIT 2273#if LJ_HASJIT
2275 dasm_put(Dst, 14932, HOTCOUNT_PCMASK, GG_DISP2HOT); 2274 dasm_put(Dst, 14924, HOTCOUNT_PCMASK, GG_DISP2HOT);
2276#endif 2275#endif
2277 case BC_FUNCV: /* NYI: compiled vararg functions. */ 2276 case BC_FUNCV: /* NYI: compiled vararg functions. */
2278 break; 2277 break;
@@ -2282,13 +2281,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2282 break; 2281 break;
2283#endif 2282#endif
2284 case BC_IFUNCF: 2283 case BC_IFUNCF:
2285 dasm_put(Dst, 14953, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams)); 2284 dasm_put(Dst, 14945, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams));
2286 if (op == BC_JFUNCF) { 2285 if (op == BC_JFUNCF) {
2287 dasm_put(Dst, 14983, BC_JLOOP); 2286 dasm_put(Dst, 14975, BC_JLOOP);
2288 } else { 2287 } else {
2289 dasm_put(Dst, 10849); 2288 dasm_put(Dst, 10849);
2290 } 2289 }
2291 dasm_put(Dst, 14992, LJ_TNIL); 2290 dasm_put(Dst, 14984, LJ_TNIL);
2292 break; 2291 break;
2293 2292
2294 case BC_JFUNCV: 2293 case BC_JFUNCV:
@@ -2299,30 +2298,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2299 break; /* NYI: compiled vararg functions. */ 2298 break; /* NYI: compiled vararg functions. */
2300 2299
2301 case BC_IFUNCV: 2300 case BC_IFUNCV:
2302 dasm_put(Dst, 15014, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL); 2301 dasm_put(Dst, 15006, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL);
2303 if (op == BC_JFUNCV) { 2302 if (op == BC_JFUNCV) {
2304 dasm_put(Dst, 14983, BC_JLOOP); 2303 dasm_put(Dst, 14975, BC_JLOOP);
2305 } else { 2304 } else {
2306 dasm_put(Dst, 15105, -4+PC2PROTO(k)); 2305 dasm_put(Dst, 15097, -4+PC2PROTO(k));
2307 } 2306 }
2308 dasm_put(Dst, 15127, LJ_TNIL); 2307 dasm_put(Dst, 15119, LJ_TNIL);
2309 break; 2308 break;
2310 2309
2311 case BC_FUNCC: 2310 case BC_FUNCC:
2312 case BC_FUNCCW: 2311 case BC_FUNCCW:
2313 dasm_put(Dst, 15149, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top)); 2312 dasm_put(Dst, 15141, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top));
2314 if (op == BC_FUNCC) { 2313 if (op == BC_FUNCC) {
2315 dasm_put(Dst, 15178); 2314 dasm_put(Dst, 15170);
2316 } else { 2315 } else {
2317 dasm_put(Dst, 15182); 2316 dasm_put(Dst, 15174);
2318 } 2317 }
2319 dasm_put(Dst, 15190, DISPATCH_GL(vmstate), ~LJ_VMST_C); 2318 dasm_put(Dst, 15182, DISPATCH_GL(vmstate), ~LJ_VMST_C);
2320 if (op == BC_FUNCC) { 2319 if (op == BC_FUNCC) {
2321 dasm_put(Dst, 15199); 2320 dasm_put(Dst, 15191);
2322 } else { 2321 } else {
2323 dasm_put(Dst, 15203, DISPATCH_GL(wrapf)); 2322 dasm_put(Dst, 15195, DISPATCH_GL(wrapf));
2324 } 2323 }
2325 dasm_put(Dst, 15208, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top)); 2324 dasm_put(Dst, 15200, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top));
2326 break; 2325 break;
2327 2326
2328 /* ---------------------------------------------------------------------- */ 2327 /* ---------------------------------------------------------------------- */
@@ -2350,7 +2349,7 @@ static int build_backend(BuildCtx *ctx)
2350 2349
2351 build_subroutines(ctx, cmov, sse); 2350 build_subroutines(ctx, cmov, sse);
2352 2351
2353 dasm_put(Dst, 15233); 2352 dasm_put(Dst, 15225);
2354 for (op = 0; op < BC__MAX; op++) 2353 for (op = 0; op < BC__MAX; op++)
2355 build_ins(ctx, (BCOp)op, op, cmov, sse); 2354 build_ins(ctx, (BCOp)op, op, cmov, sse);
2356 2355
diff --git a/src/lj_gc.c b/src/lj_gc.c
index 3e3d1ec5..e76175fc 100644
--- a/src/lj_gc.c
+++ b/src/lj_gc.c
@@ -274,7 +274,7 @@ static MSize gc_traverse_frames(global_State *g, lua_State *th)
274 TValue *ftop = frame; 274 TValue *ftop = frame;
275 if (isluafunc(fn)) ftop += funcproto(fn)->framesize; 275 if (isluafunc(fn)) ftop += funcproto(fn)->framesize;
276 if (ftop > top) top = ftop; 276 if (ftop > top) top = ftop;
277 gc_markobj(g, frame_gc(frame)); /* Need to mark hidden function (or L). */ 277 gc_markobj(g, fn); /* Need to mark hidden function (or L). */
278 } 278 }
279 top++; /* Correct bias of -1 (frame == base-1). */ 279 top++; /* Correct bias of -1 (frame == base-1). */
280 if (top > tvref(th->maxstack)) top = tvref(th->maxstack); 280 if (top > tvref(th->maxstack)) top = tvref(th->maxstack);
diff --git a/src/lj_parse.c b/src/lj_parse.c
index e1ca2ff7..522f8ef8 100644
--- a/src/lj_parse.c
+++ b/src/lj_parse.c
@@ -116,7 +116,7 @@ typedef struct FuncState {
116 BCPos bclim; /* Limit of bytecode stack. */ 116 BCPos bclim; /* Limit of bytecode stack. */
117 MSize vbase; /* Base of variable stack for this function. */ 117 MSize vbase; /* Base of variable stack for this function. */
118 uint8_t flags; /* Prototype flags. */ 118 uint8_t flags; /* Prototype flags. */
119 uint8_t numparams; /* Number of active local variables. */ 119 uint8_t numparams; /* Number of parameters. */
120 uint8_t framesize; /* Fixed frame size. */ 120 uint8_t framesize; /* Fixed frame size. */
121 uint8_t nuv; /* Number of upvalues */ 121 uint8_t nuv; /* Number of upvalues */
122 VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */ 122 VarIndex varmap[LJ_MAX_LOCVAR]; /* Map from register to variable idx. */
@@ -1397,10 +1397,8 @@ static BCReg parse_params(LexState *ls, int needself)
1397 FuncState *fs = ls->fs; 1397 FuncState *fs = ls->fs;
1398 BCReg nparams = 0; 1398 BCReg nparams = 0;
1399 lex_check(ls, '('); 1399 lex_check(ls, '(');
1400 if (needself) { 1400 if (needself)
1401 var_new_lit(ls, 0, "self"); 1401 var_new_lit(ls, nparams++, "self");
1402 var_add(ls, 1);
1403 }
1404 if (ls->token != ')') { 1402 if (ls->token != ')') {
1405 do { 1403 do {
1406 if (ls->token == TK_name) { 1404 if (ls->token == TK_name) {
@@ -1415,9 +1413,10 @@ static BCReg parse_params(LexState *ls, int needself)
1415 } while (lex_opt(ls, ',')); 1413 } while (lex_opt(ls, ','));
1416 } 1414 }
1417 var_add(ls, nparams); 1415 var_add(ls, nparams);
1418 bcreg_reserve(fs, fs->nactvar); 1416 lua_assert(fs->nactvar == nparams);
1417 bcreg_reserve(fs, nparams);
1419 lex_check(ls, ')'); 1418 lex_check(ls, ')');
1420 return fs->nactvar; 1419 return nparams;
1421} 1420}
1422 1421
1423/* Forward declaration. */ 1422/* Forward declaration. */
@@ -1577,7 +1576,7 @@ static void expr_simple(LexState *ls, ExpDesc *v)
1577 checkcond(ls, fs->flags & PROTO_IS_VARARG, LJ_ERR_XDOTS); 1576 checkcond(ls, fs->flags & PROTO_IS_VARARG, LJ_ERR_XDOTS);
1578 bcreg_reserve(fs, 1); 1577 bcreg_reserve(fs, 1);
1579 base = fs->freereg-1; 1578 base = fs->freereg-1;
1580 expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, 1)); 1579 expr_init(v, VCALL, bcemit_ABC(fs, BC_VARG, base, 2, fs->numparams));
1581 v->u.s.aux = base; 1580 v->u.s.aux = base;
1582 break; 1581 break;
1583 } 1582 }