aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2010-09-09 12:28:17 +0200
committerMike Pall <mike>2010-09-09 12:28:17 +0200
commit96957a4551a464160be2c1450f39744ac8313364 (patch)
tree652fd8bc3b4c0f75173d74fb3f8f060e5af9f6b4 /src
parentfd63b05253f11d7e436c3685827fce9b64725da6 (diff)
downloadluajit-96957a4551a464160be2c1450f39744ac8313364.tar.gz
luajit-96957a4551a464160be2c1450f39744ac8313364.tar.bz2
luajit-96957a4551a464160be2c1450f39744ac8313364.zip
Turn some lua_State fields into 32 bit pointers.
lua_State now fits into one cache line on x64.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_x64.h287
-rw-r--r--src/buildvm_x64win.h291
-rw-r--r--src/buildvm_x86.h280
-rw-r--r--src/lib_base.c2
-rw-r--r--src/lj_api.c4
-rw-r--r--src/lj_dispatch.c3
-rw-r--r--src/lj_err.c21
-rw-r--r--src/lj_gc.c12
-rw-r--r--src/lj_obj.h4
-rw-r--r--src/lj_record.c3
-rw-r--r--src/lj_snap.c6
-rw-r--r--src/lj_state.c34
-rw-r--r--src/lj_state.h9
13 files changed, 473 insertions, 483 deletions
diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h
index f2816d14..4474ae1b 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[14100] = { 15static const unsigned char build_actionlist[14095] = {
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,
@@ -616,84 +616,84 @@ static const unsigned char build_actionlist[14100] = {
616 15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,3,131,189,233,0, 616 15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,3,131,189,233,0,
617 15,132,244,1,255,139,141,233,252,246,129,233,235,15,132,244,38,15,182,75, 617 15,132,244,1,255,139,141,233,252,246,129,233,235,15,132,244,38,15,182,75,
618 252,253,252,233,244,1,248,7,128,165,233,235,65,139,142,233,65,137,174,233, 618 252,253,252,233,244,1,248,7,128,165,233,235,65,139,142,233,65,137,174,233,
619 137,141,233,15,182,75,252,253,252,233,244,2,255,68,137,60,36,255,252,242, 619 137,141,233,15,182,75,252,253,252,233,244,2,255,68,137,60,36,69,139,60,199,
620 69,15,45,60,199,255,248,1,141,12,202,139,105,252,248,252,246,133,233,235, 620 248,1,141,12,202,139,105,252,248,252,246,133,233,235,15,133,244,253,248,2,
621 15,133,244,253,248,2,139,68,36,4,131,232,1,15,132,244,250,68,1,252,248,59, 621 139,68,36,4,131,232,1,15,132,244,250,68,1,252,248,59,133,233,15,131,244,251,
622 133,233,15,131,244,251,68,41,252,248,65,193,231,3,68,3,189,233,248,3,139, 622 68,41,252,248,65,193,231,3,68,3,189,233,248,3,139,41,65,137,47,139,105,4,
623 41,65,137,47,139,105,4,131,193,8,65,137,111,4,65,131,199,8,131,232,1,15,133, 623 131,193,8,65,137,111,4,65,131,199,8,131,232,1,15,133,244,3,248,4,68,139,60,
624 244,3,248,4,68,139,60,36,139,3,15,182,204,15,182,232,131,195,4,193,232,16, 624 36,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,
625 65,252,255,36,252,238,248,5,139,124,36,24,137,151,233,137,252,238,137,194, 625 248,5,139,124,36,24,137,151,233,137,252,238,137,194,137,252,253,137,92,36,
626 137,252,253,137,92,36,28,232,251,1,33,139,149,233,15,182,75,252,253,252,233, 626 28,232,251,1,33,139,149,233,15,182,75,252,253,252,233,244,1,248,7,255,128,
627 244,1,248,7,255,128,165,233,235,65,139,134,233,65,137,174,233,137,133,233, 627 165,233,235,65,139,134,233,65,137,174,233,137,133,233,252,233,244,2,255,3,
628 252,233,244,2,255,3,68,36,4,255,129,124,253,202,4,239,139,44,202,15,133,244, 628 68,36,4,255,129,124,253,202,4,239,139,44,202,15,133,244,51,141,84,202,8,137,
629 51,141,84,202,8,137,90,252,252,139,157,233,139,11,15,182,252,233,15,182,205, 629 90,252,252,139,157,233,139,11,15,182,252,233,15,182,205,131,195,4,65,252,
630 131,195,4,65,252,255,36,252,238,255,141,76,202,8,65,137,215,139,105,252,248, 630 255,36,252,238,255,141,76,202,8,65,137,215,139,105,252,248,129,121,253,252,
631 129,121,253,252,252,239,15,133,244,28,248,52,139,90,252,252,252,247,195,237, 631 252,239,15,133,244,28,248,52,139,90,252,252,252,247,195,237,15,133,244,253,
632 15,133,244,253,248,1,137,106,252,248,137,68,36,4,131,232,1,15,132,244,249, 632 248,1,137,106,252,248,137,68,36,4,131,232,1,15,132,244,249,248,2,139,41,65,
633 248,2,139,41,65,137,47,139,105,4,65,137,111,4,65,131,199,8,131,193,8,131, 633 137,47,139,105,4,65,137,111,4,65,131,199,8,131,193,8,131,232,1,15,133,244,
634 232,1,15,133,244,2,139,106,252,248,248,3,139,68,36,4,128,189,233,1,15,135, 634 2,139,106,252,248,248,3,139,68,36,4,128,189,233,1,15,135,244,251,248,4,139,
635 244,251,248,4,139,157,233,139,11,15,182,252,233,15,182,205,131,195,4,65,252,
636 255,36,252,238,248,5,255,252,247,195,237,15,133,244,4,15,182,75,252,253,72,
637 252,247,209,141,12,202,68,139,121,252,248,69,139,191,233,69,139,191,233,252,
638 233,244,4,248,7,129,252,235,239,252,247,195,237,15,133,244,254,41,218,65,
639 137,215,139,90,252,252,252,233,244,1,248,8,129,195,239,252,233,244,1,255,
640 141,76,202,8,139,105,232,139,65,252,236,137,41,137,65,4,139,105,252,240,139,
641 65,252,244,137,105,8,137,65,12,139,105,224,139,65,228,137,105,252,248,137,
642 65,252,252,129,252,248,239,184,237,15,133,244,28,137,202,137,90,252,252,139,
643 157,233,139,11,15,182,252,233,15,182,205,131,195,4,65,252,255,36,252,238, 635 157,233,139,11,15,182,252,233,15,182,205,131,195,4,65,252,255,36,252,238,
644 255,15,182,252,236,139,66,252,248,141,12,202,139,128,233,15,182,128,233,68, 636 248,5,255,252,247,195,237,15,133,244,4,15,182,75,252,253,72,252,247,209,141,
645 137,60,36,68,141,188,253,194,233,68,43,122,252,252,133,252,237,15,132,244, 637 12,202,68,139,121,252,248,69,139,191,233,69,139,191,233,252,233,244,4,248,
646 251,141,108,252,233,252,248,65,57,215,15,131,244,248,248,1,65,139,71,252, 638 7,129,252,235,239,252,247,195,237,15,133,244,254,41,218,65,137,215,139,90,
647 248,137,1,65,139,71,252,252,65,131,199,8,137,65,4,131,193,8,57,252,233,15, 639 252,252,252,233,244,1,248,8,129,195,239,252,233,244,1,255,141,76,202,8,139,
648 131,244,249,65,57,215,15,130,244,1,248,2,199,65,4,237,131,193,8,57,252,233, 640 105,232,139,65,252,236,137,41,137,65,4,139,105,252,240,139,65,252,244,137,
649 15,130,244,2,248,3,68,139,60,36,139,3,15,182,204,15,182,232,131,195,4,193, 641 105,8,137,65,12,139,105,224,139,65,228,137,105,252,248,137,65,252,252,129,
650 232,16,65,252,255,36,252,238,248,5,199,68,36,4,1,0,0,0,137,208,68,41,252, 642 252,248,239,184,237,15,133,244,28,137,202,137,90,252,252,139,157,233,139,
651 248,15,134,244,3,255,137,197,193,252,237,3,131,197,1,137,108,36,4,139,108, 643 11,15,182,252,233,15,182,205,131,195,4,65,252,255,36,252,238,255,15,182,252,
652 36,24,1,200,59,133,233,15,135,244,253,248,6,65,139,71,252,248,137,1,65,139, 644 236,139,66,252,248,141,12,202,139,128,233,15,182,128,233,68,137,60,36,68,
653 71,252,252,65,131,199,8,137,65,4,131,193,8,65,57,215,15,130,244,6,252,233, 645 141,188,253,194,233,68,43,122,252,252,133,252,237,15,132,244,251,141,108,
654 244,3,248,7,137,149,233,137,141,233,137,92,36,28,65,41,215,139,116,36,4,131, 646 252,233,252,248,65,57,215,15,131,244,248,248,1,65,139,71,252,248,137,1,65,
655 252,238,1,137,252,239,232,251,1,0,139,149,233,139,141,233,65,1,215,252,233, 647 139,71,252,252,65,131,199,8,137,65,4,131,193,8,57,252,233,15,131,244,249,
656 244,6,255,193,225,3,255,248,1,139,90,252,252,137,68,36,4,252,247,195,237, 648 65,57,215,15,130,244,1,248,2,199,65,4,237,131,193,8,57,252,233,15,130,244,
657 15,133,244,253,255,248,13,65,137,215,131,232,1,15,132,244,249,248,2,65,139, 649 2,248,3,68,139,60,36,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,
658 44,15,65,137,111,252,248,65,139,108,15,4,65,137,111,252,252,65,131,199,8, 650 252,255,36,252,238,248,5,199,68,36,4,1,0,0,0,137,208,68,41,252,248,15,134,
659 131,232,1,15,133,244,2,248,3,139,68,36,4,15,182,107,252,255,248,5,57,197, 651 244,3,255,137,197,193,252,237,3,131,197,1,137,108,36,4,139,108,36,24,1,200,
660 15,135,244,252,255,139,108,10,4,137,106,252,252,139,44,10,137,106,252,248, 652 59,133,233,15,135,244,253,248,6,65,139,71,252,248,137,1,65,139,71,252,252,
661 255,248,5,56,67,252,255,15,135,244,252,255,15,182,75,252,253,72,252,247,209, 653 65,131,199,8,137,65,4,131,193,8,65,57,215,15,130,244,6,252,233,244,3,248,
662 141,20,202,68,139,122,252,248,69,139,191,233,69,139,191,233,139,3,15,182, 654 7,137,149,233,137,141,233,137,92,36,28,65,41,215,139,116,36,4,131,252,238,
663 204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,6,255,65,199, 655 1,137,252,239,232,251,1,0,139,149,233,139,141,233,65,1,215,252,233,244,6,
664 71,252,252,237,65,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252, 656 255,193,225,3,255,248,1,139,90,252,252,137,68,36,4,252,247,195,237,15,133,
665 233,244,5,248,7,141,171,233,252,247,197,237,15,133,244,14,41,252,234,255, 657 244,253,255,248,13,65,137,215,131,232,1,15,132,244,249,248,2,65,139,44,15,
666 1,252,233,255,137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1, 658 65,137,111,252,248,65,139,108,15,4,65,137,111,252,252,65,131,199,8,131,232,
667 15,132,244,140,255,141,12,202,255,129,121,253,4,239,15,135,244,53,129,121, 659 1,15,133,244,2,248,3,139,68,36,4,15,182,107,252,255,248,5,57,197,15,135,244,
668 253,12,239,15,135,244,53,255,139,105,20,255,129,252,253,239,15,135,244,53, 660 252,255,139,108,10,4,137,106,252,252,139,44,10,137,106,252,248,255,248,5,
669 255,252,242,15,16,1,252,242,15,16,73,8,255,252,242,15,88,65,16,252,242,15, 661 56,67,252,255,15,135,244,252,255,15,182,75,252,253,72,252,247,209,141,20,
670 17,1,133,252,237,15,136,244,249,255,15,140,244,249,255,102,15,46,200,248, 662 202,68,139,122,252,248,69,139,191,233,69,139,191,233,139,3,15,182,204,15,
671 1,252,242,15,17,65,24,255,221,65,8,221,1,255,220,65,16,221,17,221,81,24,133, 663 182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,6,255,65,199,71,252,
672 252,237,15,136,244,247,255,221,81,24,15,140,244,247,255,217,201,248,1,255, 664 252,237,65,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,
673 15,183,67,252,254,255,15,131,244,248,141,156,253,131,233,255,141,156,253, 665 5,248,7,141,171,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,
674 131,233,15,183,67,252,254,15,131,245,255,15,130,244,248,141,156,253,131,233, 666 255,137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244,
675 255,248,3,102,15,46,193,252,233,244,1,255,141,12,202,139,105,4,129,252,253, 667 140,255,141,12,202,255,129,121,253,4,239,15,135,244,53,129,121,253,12,239,
676 239,15,132,244,247,255,137,105,252,252,139,41,137,105,252,248,252,233,245, 668 15,135,244,53,255,139,105,20,255,129,252,253,239,15,135,244,53,255,252,242,
677 255,141,156,253,131,233,139,1,137,105,252,252,137,65,252,248,255,65,139,142, 669 15,16,1,252,242,15,16,73,8,255,252,242,15,88,65,16,252,242,15,17,1,133,252,
678 233,139,4,129,72,139,128,233,139,108,36,24,65,137,150,233,65,137,174,233, 670 237,15,136,244,249,255,15,140,244,249,255,102,15,46,200,248,1,252,242,15,
679 76,137,36,36,76,137,108,36,8,72,131,252,236,16,252,255,224,255,141,156,253, 671 17,65,24,255,221,65,8,221,1,255,220,65,16,221,17,221,81,24,133,252,237,15,
680 131,233,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252, 672 136,244,247,255,221,81,24,15,140,244,247,255,217,201,248,1,255,15,183,67,
681 238,255,137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132, 673 252,254,255,15,131,244,248,141,156,253,131,233,255,141,156,253,131,233,15,
682 244,142,255,68,139,187,233,139,108,36,24,141,12,202,59,141,233,15,135,244, 674 183,67,252,254,15,131,245,255,15,130,244,248,141,156,253,131,233,255,248,
683 23,15,182,139,233,57,200,15,134,244,249,248,2,255,15,183,67,252,254,252,233, 675 3,102,15,46,193,252,233,244,1,255,141,12,202,139,105,4,129,252,253,239,15,
684 245,255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233, 676 132,244,247,255,137,105,252,252,139,41,137,105,252,248,252,233,245,255,141,
685 244,2,255,141,44,197,237,141,4,194,68,139,122,252,248,137,104,252,252,68, 677 156,253,131,233,139,1,137,105,252,252,137,65,252,248,255,65,139,142,233,139,
686 137,120,252,248,139,108,36,24,141,12,200,59,141,233,15,135,244,22,137,209, 678 4,129,72,139,128,233,139,108,36,24,65,137,150,233,65,137,174,233,76,137,36,
687 137,194,15,182,171,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209, 679 36,76,137,108,36,8,72,131,252,236,16,252,255,224,255,141,156,253,131,233,
688 15,131,244,249,68,139,121,252,248,68,137,56,68,139,121,252,252,68,137,120, 680 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255,
689 4,131,192,8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,68,139, 681 137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244,142,
690 187,233,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252, 682 255,68,139,187,233,139,108,36,24,141,12,202,59,141,233,15,135,244,23,15,182,
691 238,255,248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244, 683 139,233,57,200,15,134,244,249,248,2,255,15,183,67,252,254,252,233,245,255,
692 2,255,139,106,252,248,76,139,189,233,139,108,36,24,141,68,194,252,248,137, 684 248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2,
693 149,233,141,136,233,59,141,233,137,133,233,255,137,252,239,255,76,137,252, 685 255,141,44,197,237,141,4,194,68,139,122,252,248,137,104,252,252,68,137,120,
694 254,137,252,239,255,15,135,244,21,65,199,134,233,237,255,65,252,255,215,255, 686 252,248,139,108,36,24,141,12,200,59,141,233,15,135,244,22,137,209,137,194,
695 65,252,255,150,233,255,65,199,134,233,237,139,149,233,141,12,194,252,247, 687 15,182,171,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244,
696 217,3,141,233,139,90,252,252,252,233,244,12,255,254,0 688 249,68,139,121,252,248,68,137,56,68,139,121,252,252,68,137,120,4,131,192,
689 8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,68,139,187,233,
690 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255,
691 248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255,
692 139,106,252,248,76,139,189,233,139,108,36,24,141,68,194,252,248,137,149,233,
693 141,136,233,59,141,233,137,133,233,255,137,252,239,255,76,137,252,254,137,
694 252,239,255,15,135,244,21,65,199,134,233,237,255,65,252,255,215,255,65,252,
695 255,150,233,255,65,199,134,233,237,139,149,233,141,12,194,252,247,217,3,141,
696 233,139,90,252,252,252,233,244,12,255,254,0
697}; 697};
698 698
699enum { 699enum {
@@ -1962,13 +1962,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
1962 break; 1962 break;
1963 1963
1964 case BC_TSETM: 1964 case BC_TSETM:
1965 dasm_put(Dst, 12502); 1965 dasm_put(Dst, 12502, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
1966 if (sse) { 1966 dasm_put(Dst, 12658, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
1967 dasm_put(Dst, 12507);
1968 } else {
1969 }
1970 dasm_put(Dst, 12515, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
1971 dasm_put(Dst, 12663, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
1972 break; 1967 break;
1973 1968
1974 /* -- Calls and vararg handling ----------------------------------------- */ 1969 /* -- Calls and vararg handling ----------------------------------------- */
@@ -1976,60 +1971,60 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
1976 case BC_CALL: case BC_CALLM: 1971 case BC_CALL: case BC_CALLM:
1977 dasm_put(Dst, 10113); 1972 dasm_put(Dst, 10113);
1978 if (op == BC_CALLM) { 1973 if (op == BC_CALLM) {
1979 dasm_put(Dst, 12683); 1974 dasm_put(Dst, 12678);
1980 } 1975 }
1981 dasm_put(Dst, 12688, LJ_TFUNC, Dt7(->pc)); 1976 dasm_put(Dst, 12683, LJ_TFUNC, Dt7(->pc));
1982 break; 1977 break;
1983 1978
1984 case BC_CALLMT: 1979 case BC_CALLMT:
1985 dasm_put(Dst, 12683); 1980 dasm_put(Dst, 12678);
1986 break; 1981 break;
1987 case BC_CALLT: 1982 case BC_CALLT:
1988 dasm_put(Dst, 12731, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->pc)); 1983 dasm_put(Dst, 12726, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->pc));
1989 dasm_put(Dst, 12855, FRAME_TYPE, Dt7(->pc), PC2PROTO(k), FRAME_VARG, FRAME_TYPEP, FRAME_VARG); 1984 dasm_put(Dst, 12850, FRAME_TYPE, Dt7(->pc), PC2PROTO(k), FRAME_VARG, FRAME_TYPEP, FRAME_VARG);
1990 break; 1985 break;
1991 1986
1992 case BC_ITERC: 1987 case BC_ITERC:
1993 dasm_put(Dst, 12929, LJ_TFUNC, 2+1, Dt7(->pc)); 1988 dasm_put(Dst, 12924, LJ_TFUNC, 2+1, Dt7(->pc));
1994 break; 1989 break;
1995 1990
1996 case BC_VARG: 1991 case BC_VARG:
1997 dasm_put(Dst, 13011, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL); 1992 dasm_put(Dst, 13006, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL);
1998 dasm_put(Dst, 13165, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); 1993 dasm_put(Dst, 13160, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top));
1999 break; 1994 break;
2000 1995
2001 /* -- Returns ----------------------------------------------------------- */ 1996 /* -- Returns ----------------------------------------------------------- */
2002 1997
2003 case BC_RETM: 1998 case BC_RETM:
2004 dasm_put(Dst, 12683); 1999 dasm_put(Dst, 12678);
2005 break; 2000 break;
2006 2001
2007 case BC_RET: case BC_RET0: case BC_RET1: 2002 case BC_RET: case BC_RET0: case BC_RET1:
2008 if (op != BC_RET0) { 2003 if (op != BC_RET0) {
2009 dasm_put(Dst, 13270); 2004 dasm_put(Dst, 13265);
2010 } 2005 }
2011 dasm_put(Dst, 13274, FRAME_TYPE); 2006 dasm_put(Dst, 13269, FRAME_TYPE);
2012 switch (op) { 2007 switch (op) {
2013 case BC_RET: 2008 case BC_RET:
2014 dasm_put(Dst, 13293); 2009 dasm_put(Dst, 13288);
2015 break; 2010 break;
2016 case BC_RET1: 2011 case BC_RET1:
2017 dasm_put(Dst, 13357); 2012 dasm_put(Dst, 13352);
2018 /* fallthrough */ 2013 /* fallthrough */
2019 case BC_RET0: 2014 case BC_RET0:
2020 dasm_put(Dst, 13373); 2015 dasm_put(Dst, 13368);
2021 default: 2016 default:
2022 break; 2017 break;
2023 } 2018 }
2024 dasm_put(Dst, 13384, Dt7(->pc), PC2PROTO(k)); 2019 dasm_put(Dst, 13379, Dt7(->pc), PC2PROTO(k));
2025 if (op == BC_RET) { 2020 if (op == BC_RET) {
2026 dasm_put(Dst, 13432, LJ_TNIL); 2021 dasm_put(Dst, 13427, LJ_TNIL);
2027 } else { 2022 } else {
2028 dasm_put(Dst, 13443, LJ_TNIL); 2023 dasm_put(Dst, 13438, LJ_TNIL);
2029 } 2024 }
2030 dasm_put(Dst, 13450, -FRAME_VARG, FRAME_TYPEP); 2025 dasm_put(Dst, 13445, -FRAME_VARG, FRAME_TYPEP);
2031 if (op != BC_RET0) { 2026 if (op != BC_RET0) {
2032 dasm_put(Dst, 13474); 2027 dasm_put(Dst, 13469);
2033 } 2028 }
2034 dasm_put(Dst, 4599); 2029 dasm_put(Dst, 4599);
2035 break; 2030 break;
@@ -2039,7 +2034,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2039 2034
2040 case BC_FORL: 2035 case BC_FORL:
2041#if LJ_HASJIT 2036#if LJ_HASJIT
2042 dasm_put(Dst, 13478, HOTCOUNT_PCMASK, GG_DISP2HOT); 2037 dasm_put(Dst, 13473, HOTCOUNT_PCMASK, GG_DISP2HOT);
2043#endif 2038#endif
2044 break; 2039 break;
2045 2040
@@ -2051,57 +2046,57 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2051 case BC_FORI: 2046 case BC_FORI:
2052 case BC_IFORL: 2047 case BC_IFORL:
2053 vk = (op == BC_IFORL || op == BC_JFORL); 2048 vk = (op == BC_IFORL || op == BC_JFORL);
2054 dasm_put(Dst, 13499); 2049 dasm_put(Dst, 13494);
2055 if (!vk) { 2050 if (!vk) {
2056 dasm_put(Dst, 13503, LJ_TISNUM, LJ_TISNUM); 2051 dasm_put(Dst, 13498, LJ_TISNUM, LJ_TISNUM);
2057 } 2052 }
2058 dasm_put(Dst, 13522); 2053 dasm_put(Dst, 13517);
2059 if (!vk) { 2054 if (!vk) {
2060 dasm_put(Dst, 13526, LJ_TISNUM); 2055 dasm_put(Dst, 13521, LJ_TISNUM);
2061 } 2056 }
2062 if (sse) { 2057 if (sse) {
2063 dasm_put(Dst, 13535); 2058 dasm_put(Dst, 13530);
2064 if (vk) { 2059 if (vk) {
2065 dasm_put(Dst, 13547); 2060 dasm_put(Dst, 13542);
2066 } else { 2061 } else {
2067 dasm_put(Dst, 13566); 2062 dasm_put(Dst, 13561);
2068 } 2063 }
2069 dasm_put(Dst, 13571); 2064 dasm_put(Dst, 13566);
2070 } else { 2065 } else {
2071 dasm_put(Dst, 13584); 2066 dasm_put(Dst, 13579);
2072 if (vk) { 2067 if (vk) {
2073 dasm_put(Dst, 13590); 2068 dasm_put(Dst, 13585);
2074 } else { 2069 } else {
2075 dasm_put(Dst, 13606); 2070 dasm_put(Dst, 13601);
2076 } 2071 }
2077 dasm_put(Dst, 13614); 2072 dasm_put(Dst, 13609);
2078 if (cmov) { 2073 if (cmov) {
2079 dasm_put(Dst, 9528); 2074 dasm_put(Dst, 9528);
2080 } else { 2075 } else {
2081 dasm_put(Dst, 9534); 2076 dasm_put(Dst, 9534);
2082 } 2077 }
2083 if (!cmov) { 2078 if (!cmov) {
2084 dasm_put(Dst, 13619); 2079 dasm_put(Dst, 13614);
2085 } 2080 }
2086 } 2081 }
2087 if (op == BC_FORI) { 2082 if (op == BC_FORI) {
2088 dasm_put(Dst, 13625, -BCBIAS_J*4); 2083 dasm_put(Dst, 13620, -BCBIAS_J*4);
2089 } else if (op == BC_JFORI) { 2084 } else if (op == BC_JFORI) {
2090 dasm_put(Dst, 13635, -BCBIAS_J*4, BC_JLOOP); 2085 dasm_put(Dst, 13630, -BCBIAS_J*4, BC_JLOOP);
2091 } else if (op == BC_IFORL) { 2086 } else if (op == BC_IFORL) {
2092 dasm_put(Dst, 13649, -BCBIAS_J*4); 2087 dasm_put(Dst, 13644, -BCBIAS_J*4);
2093 } else { 2088 } else {
2094 dasm_put(Dst, 13645, BC_JLOOP); 2089 dasm_put(Dst, 13640, BC_JLOOP);
2095 } 2090 }
2096 dasm_put(Dst, 9563); 2091 dasm_put(Dst, 9563);
2097 if (sse) { 2092 if (sse) {
2098 dasm_put(Dst, 13659); 2093 dasm_put(Dst, 13654);
2099 } 2094 }
2100 break; 2095 break;
2101 2096
2102 case BC_ITERL: 2097 case BC_ITERL:
2103#if LJ_HASJIT 2098#if LJ_HASJIT
2104 dasm_put(Dst, 13478, HOTCOUNT_PCMASK, GG_DISP2HOT); 2099 dasm_put(Dst, 13473, HOTCOUNT_PCMASK, GG_DISP2HOT);
2105#endif 2100#endif
2106 break; 2101 break;
2107 2102
@@ -2110,18 +2105,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2110 break; 2105 break;
2111#endif 2106#endif
2112 case BC_IITERL: 2107 case BC_IITERL:
2113 dasm_put(Dst, 13670, LJ_TNIL); 2108 dasm_put(Dst, 13665, LJ_TNIL);
2114 if (op == BC_JITERL) { 2109 if (op == BC_JITERL) {
2115 dasm_put(Dst, 13685, BC_JLOOP); 2110 dasm_put(Dst, 13680, BC_JLOOP);
2116 } else { 2111 } else {
2117 dasm_put(Dst, 13699, -BCBIAS_J*4); 2112 dasm_put(Dst, 13694, -BCBIAS_J*4);
2118 } 2113 }
2119 dasm_put(Dst, 9867); 2114 dasm_put(Dst, 9867);
2120 break; 2115 break;
2121 2116
2122 case BC_LOOP: 2117 case BC_LOOP:
2123#if LJ_HASJIT 2118#if LJ_HASJIT
2124 dasm_put(Dst, 13478, HOTCOUNT_PCMASK, GG_DISP2HOT); 2119 dasm_put(Dst, 13473, HOTCOUNT_PCMASK, GG_DISP2HOT);
2125#endif 2120#endif
2126 break; 2121 break;
2127 2122
@@ -2131,12 +2126,12 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2131 2126
2132 case BC_JLOOP: 2127 case BC_JLOOP:
2133#if LJ_HASJIT 2128#if LJ_HASJIT
2134 dasm_put(Dst, 13715, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); 2129 dasm_put(Dst, 13710, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L));
2135#endif 2130#endif
2136 break; 2131 break;
2137 2132
2138 case BC_JMP: 2133 case BC_JMP:
2139 dasm_put(Dst, 13756, -BCBIAS_J*4); 2134 dasm_put(Dst, 13751, -BCBIAS_J*4);
2140 break; 2135 break;
2141 2136
2142 /* -- Function headers -------------------------------------------------- */ 2137 /* -- Function headers -------------------------------------------------- */
@@ -2150,7 +2145,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2150 2145
2151 case BC_FUNCF: 2146 case BC_FUNCF:
2152#if LJ_HASJIT 2147#if LJ_HASJIT
2153 dasm_put(Dst, 13782, HOTCOUNT_PCMASK, GG_DISP2HOT); 2148 dasm_put(Dst, 13777, HOTCOUNT_PCMASK, GG_DISP2HOT);
2154#endif 2149#endif
2155 case BC_FUNCV: /* NYI: compiled vararg functions. */ 2150 case BC_FUNCV: /* NYI: compiled vararg functions. */
2156 break; 2151 break;
@@ -2160,13 +2155,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2160 break; 2155 break;
2161#endif 2156#endif
2162 case BC_IFUNCF: 2157 case BC_IFUNCF:
2163 dasm_put(Dst, 13803, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams)); 2158 dasm_put(Dst, 13798, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams));
2164 if (op == BC_JFUNCF) { 2159 if (op == BC_JFUNCF) {
2165 dasm_put(Dst, 13834, BC_JLOOP); 2160 dasm_put(Dst, 13829, BC_JLOOP);
2166 } else { 2161 } else {
2167 dasm_put(Dst, 9565); 2162 dasm_put(Dst, 9565);
2168 } 2163 }
2169 dasm_put(Dst, 13843, LJ_TNIL); 2164 dasm_put(Dst, 13838, LJ_TNIL);
2170 break; 2165 break;
2171 2166
2172 case BC_JFUNCV: 2167 case BC_JFUNCV:
@@ -2177,30 +2172,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2177 break; /* NYI: compiled vararg functions. */ 2172 break; /* NYI: compiled vararg functions. */
2178 2173
2179 case BC_IFUNCV: 2174 case BC_IFUNCV:
2180 dasm_put(Dst, 13865, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL); 2175 dasm_put(Dst, 13860, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL);
2181 if (op == BC_JFUNCV) { 2176 if (op == BC_JFUNCV) {
2182 dasm_put(Dst, 13834, BC_JLOOP); 2177 dasm_put(Dst, 13829, BC_JLOOP);
2183 } else { 2178 } else {
2184 dasm_put(Dst, 13962, -4+PC2PROTO(k)); 2179 dasm_put(Dst, 13957, -4+PC2PROTO(k));
2185 } 2180 }
2186 dasm_put(Dst, 13987, LJ_TNIL); 2181 dasm_put(Dst, 13982, LJ_TNIL);
2187 break; 2182 break;
2188 2183
2189 case BC_FUNCC: 2184 case BC_FUNCC:
2190 case BC_FUNCCW: 2185 case BC_FUNCCW:
2191 dasm_put(Dst, 14009, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top)); 2186 dasm_put(Dst, 14004, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top));
2192 if (op == BC_FUNCC) { 2187 if (op == BC_FUNCC) {
2193 dasm_put(Dst, 14039); 2188 dasm_put(Dst, 14034);
2194 } else { 2189 } else {
2195 dasm_put(Dst, 14043); 2190 dasm_put(Dst, 14038);
2196 } 2191 }
2197 dasm_put(Dst, 14051, DISPATCH_GL(vmstate), ~LJ_VMST_C); 2192 dasm_put(Dst, 14046, DISPATCH_GL(vmstate), ~LJ_VMST_C);
2198 if (op == BC_FUNCC) { 2193 if (op == BC_FUNCC) {
2199 dasm_put(Dst, 14061); 2194 dasm_put(Dst, 14056);
2200 } else { 2195 } else {
2201 dasm_put(Dst, 14066, DISPATCH_GL(wrapf)); 2196 dasm_put(Dst, 14061, DISPATCH_GL(wrapf));
2202 } 2197 }
2203 dasm_put(Dst, 14072, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top)); 2198 dasm_put(Dst, 14067, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top));
2204 break; 2199 break;
2205 2200
2206 /* ---------------------------------------------------------------------- */ 2201 /* ---------------------------------------------------------------------- */
@@ -2228,7 +2223,7 @@ static int build_backend(BuildCtx *ctx)
2228 2223
2229 build_subroutines(ctx, cmov, sse); 2224 build_subroutines(ctx, cmov, sse);
2230 2225
2231 dasm_put(Dst, 14098); 2226 dasm_put(Dst, 14093);
2232 for (op = 0; op < BC__MAX; op++) 2227 for (op = 0; op < BC__MAX; op++)
2233 build_ins(ctx, (BCOp)op, op, cmov, sse); 2228 build_ins(ctx, (BCOp)op, op, cmov, sse);
2234 2229
diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h
index 5e70ad88..87f72a79 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[14047] = { 15static const unsigned char build_actionlist[14042] = {
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,
@@ -617,85 +617,85 @@ static const unsigned char build_actionlist[14047] = {
617 16,252,255,36,252,235,248,3,131,189,233,0,15,132,244,1,255,139,141,233,252, 617 16,252,255,36,252,235,248,3,131,189,233,0,15,132,244,1,255,139,141,233,252,
618 246,129,233,235,15,132,244,38,15,182,78,252,253,252,233,244,1,248,7,128,165, 618 246,129,233,235,15,132,244,38,15,182,78,252,253,252,233,244,1,248,7,128,165,
619 233,235,139,139,233,137,171,233,137,141,233,15,182,78,252,253,252,233,244, 619 233,235,139,139,233,137,171,233,137,141,233,15,182,78,252,253,252,233,244,
620 2,255,137,124,36,80,255,252,242,15,45,60,199,255,248,1,141,12,202,139,105, 620 2,255,137,124,36,80,139,60,199,248,1,141,12,202,139,105,252,248,252,246,133,
621 252,248,252,246,133,233,235,15,133,244,253,248,2,139,68,36,84,131,232,1,15, 621 233,235,15,133,244,253,248,2,139,68,36,84,131,232,1,15,132,244,250,1,252,
622 132,244,250,1,252,248,59,133,233,15,131,244,251,41,252,248,193,231,3,3,189, 622 248,59,133,233,15,131,244,251,41,252,248,193,231,3,3,189,233,248,3,139,41,
623 233,248,3,139,41,137,47,139,105,4,131,193,8,137,111,4,131,199,8,131,232,1, 623 137,47,139,105,4,131,193,8,137,111,4,131,199,8,131,232,1,15,133,244,3,248,
624 15,133,244,3,248,4,139,124,36,80,139,6,15,182,204,15,182,232,131,198,4,193, 624 4,139,124,36,80,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,
625 232,16,252,255,36,252,235,248,5,139,76,36,96,137,145,233,137,252,234,65,137, 625 36,252,235,248,5,139,76,36,96,137,145,233,137,252,234,65,137,192,137,205,
626 192,137,205,137,116,36,100,232,251,1,33,139,149,233,15,182,78,252,253,252, 626 137,116,36,100,232,251,1,33,139,149,233,15,182,78,252,253,252,233,244,1,248,
627 233,244,1,248,7,255,128,165,233,235,139,131,233,137,171,233,137,133,233,252, 627 7,255,128,165,233,235,139,131,233,137,171,233,137,133,233,252,233,244,2,255,
628 233,244,2,255,3,68,36,84,255,129,124,253,202,4,239,139,44,202,15,133,244, 628 3,68,36,84,255,129,124,253,202,4,239,139,44,202,15,133,244,51,141,84,202,
629 51,141,84,202,8,137,114,252,252,139,181,233,139,14,15,182,252,233,15,182, 629 8,137,114,252,252,139,181,233,139,14,15,182,252,233,15,182,205,131,198,4,
630 205,131,198,4,252,255,36,252,235,255,141,76,202,8,137,215,139,105,252,248, 630 252,255,36,252,235,255,141,76,202,8,137,215,139,105,252,248,129,121,253,252,
631 129,121,253,252,252,239,15,133,244,28,248,52,139,114,252,252,252,247,198, 631 252,239,15,133,244,28,248,52,139,114,252,252,252,247,198,237,15,133,244,253,
632 237,15,133,244,253,248,1,137,106,252,248,137,68,36,84,131,232,1,15,132,244, 632 248,1,137,106,252,248,137,68,36,84,131,232,1,15,132,244,249,248,2,139,41,
633 249,248,2,139,41,137,47,139,105,4,137,111,4,131,199,8,131,193,8,131,232,1, 633 137,47,139,105,4,137,111,4,131,199,8,131,193,8,131,232,1,15,133,244,2,139,
634 15,133,244,2,139,106,252,248,248,3,139,68,36,84,128,189,233,1,15,135,244, 634 106,252,248,248,3,139,68,36,84,128,189,233,1,15,135,244,251,248,4,139,181,
635 251,248,4,139,181,233,139,14,15,182,252,233,15,182,205,131,198,4,252,255, 635 233,139,14,15,182,252,233,15,182,205,131,198,4,252,255,36,252,235,248,5,255,
636 36,252,235,248,5,255,252,247,198,237,15,133,244,4,15,182,78,252,253,72,252, 636 252,247,198,237,15,133,244,4,15,182,78,252,253,72,252,247,209,141,12,202,
637 247,209,141,12,202,139,121,252,248,139,191,233,139,191,233,252,233,244,4, 637 139,121,252,248,139,191,233,139,191,233,252,233,244,4,248,7,129,252,238,239,
638 248,7,129,252,238,239,252,247,198,237,15,133,244,254,41,252,242,137,215,139, 638 252,247,198,237,15,133,244,254,41,252,242,137,215,139,114,252,252,252,233,
639 114,252,252,252,233,244,1,248,8,129,198,239,252,233,244,1,255,141,76,202, 639 244,1,248,8,129,198,239,252,233,244,1,255,141,76,202,8,139,105,232,139,65,
640 8,139,105,232,139,65,252,236,137,41,137,65,4,139,105,252,240,139,65,252,244, 640 252,236,137,41,137,65,4,139,105,252,240,139,65,252,244,137,105,8,137,65,12,
641 137,105,8,137,65,12,139,105,224,139,65,228,137,105,252,248,137,65,252,252, 641 139,105,224,139,65,228,137,105,252,248,137,65,252,252,129,252,248,239,184,
642 129,252,248,239,184,237,15,133,244,28,137,202,137,114,252,252,139,181,233, 642 237,15,133,244,28,137,202,137,114,252,252,139,181,233,139,14,15,182,252,233,
643 139,14,15,182,252,233,15,182,205,131,198,4,252,255,36,252,235,255,15,182, 643 15,182,205,131,198,4,252,255,36,252,235,255,15,182,252,236,139,66,252,248,
644 252,236,139,66,252,248,141,12,202,139,128,233,15,182,128,233,137,124,36,80, 644 141,12,202,139,128,233,15,182,128,233,137,124,36,80,141,188,253,194,233,43,
645 141,188,253,194,233,43,122,252,252,133,252,237,15,132,244,251,141,108,252, 645 122,252,252,133,252,237,15,132,244,251,141,108,252,233,252,248,57,215,15,
646 233,252,248,57,215,15,131,244,248,248,1,139,71,252,248,137,1,139,71,252,252, 646 131,244,248,248,1,139,71,252,248,137,1,139,71,252,252,131,199,8,137,65,4,
647 131,199,8,137,65,4,131,193,8,57,252,233,15,131,244,249,57,215,15,130,244, 647 131,193,8,57,252,233,15,131,244,249,57,215,15,130,244,1,248,2,199,65,4,237,
648 1,248,2,199,65,4,237,131,193,8,57,252,233,15,130,244,2,248,3,139,124,36,80, 648 131,193,8,57,252,233,15,130,244,2,248,3,139,124,36,80,139,6,15,182,204,15,
649 139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,248,5, 649 182,232,131,198,4,193,232,16,252,255,36,252,235,248,5,199,68,36,84,1,0,0,
650 199,68,36,84,1,0,0,0,137,208,41,252,248,15,134,244,3,255,137,197,193,252, 650 0,137,208,41,252,248,15,134,244,3,255,137,197,193,252,237,3,131,197,1,137,
651 237,3,131,197,1,137,108,36,84,139,108,36,96,1,200,59,133,233,15,135,244,253, 651 108,36,84,139,108,36,96,1,200,59,133,233,15,135,244,253,248,6,139,71,252,
652 248,6,139,71,252,248,137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57, 652 248,137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57,215,15,130,244,6,
653 215,15,130,244,6,252,233,244,3,248,7,137,149,233,137,141,233,137,116,36,100, 653 252,233,244,3,248,7,137,149,233,137,141,233,137,116,36,100,41,215,139,84,
654 41,215,139,84,36,84,131,252,234,1,137,252,233,232,251,1,0,139,149,233,139, 654 36,84,131,252,234,1,137,252,233,232,251,1,0,139,149,233,139,141,233,1,215,
655 141,233,1,215,252,233,244,6,255,193,225,3,255,248,1,139,114,252,252,137,68, 655 252,233,244,6,255,193,225,3,255,248,1,139,114,252,252,137,68,36,84,252,247,
656 36,84,252,247,198,237,15,133,244,253,255,248,13,137,215,131,232,1,15,132, 656 198,237,15,133,244,253,255,248,13,137,215,131,232,1,15,132,244,249,248,2,
657 244,249,248,2,139,44,15,137,111,252,248,139,108,15,4,137,111,252,252,131, 657 139,44,15,137,111,252,248,139,108,15,4,137,111,252,252,131,199,8,131,232,
658 199,8,131,232,1,15,133,244,2,248,3,139,68,36,84,15,182,110,252,255,248,5, 658 1,15,133,244,2,248,3,139,68,36,84,15,182,110,252,255,248,5,57,197,15,135,
659 57,197,15,135,244,252,255,139,108,10,4,137,106,252,252,139,44,10,137,106, 659 244,252,255,139,108,10,4,137,106,252,252,139,44,10,137,106,252,248,255,248,
660 252,248,255,248,5,56,70,252,255,15,135,244,252,255,15,182,78,252,253,72,252, 660 5,56,70,252,255,15,135,244,252,255,15,182,78,252,253,72,252,247,209,141,20,
661 247,209,141,20,202,139,122,252,248,139,191,233,139,191,233,139,6,15,182,204, 661 202,139,122,252,248,139,191,233,139,191,233,139,6,15,182,204,15,182,232,131,
662 15,182,232,131,198,4,193,232,16,252,255,36,252,235,248,6,255,199,71,252,252, 662 198,4,193,232,16,252,255,36,252,235,248,6,255,199,71,252,252,237,131,199,
663 237,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248, 663 8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248,7,141,174,233,
664 7,141,174,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255, 664 252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255,137,252,245,209,
665 137,252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,140, 665 252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,140,255,141,12,202,
666 255,141,12,202,255,129,121,253,4,239,15,135,244,53,129,121,253,12,239,15, 666 255,129,121,253,4,239,15,135,244,53,129,121,253,12,239,15,135,244,53,255,
667 135,244,53,255,139,105,20,255,129,252,253,239,15,135,244,53,255,252,242,15, 667 139,105,20,255,129,252,253,239,15,135,244,53,255,252,242,15,16,1,252,242,
668 16,1,252,242,15,16,73,8,255,252,242,15,88,65,16,252,242,15,17,1,133,252,237, 668 15,16,73,8,255,252,242,15,88,65,16,252,242,15,17,1,133,252,237,15,136,244,
669 15,136,244,249,255,15,140,244,249,255,102,15,46,200,248,1,252,242,15,17,65, 669 249,255,15,140,244,249,255,102,15,46,200,248,1,252,242,15,17,65,24,255,221,
670 24,255,221,65,8,221,1,255,220,65,16,221,17,221,81,24,133,252,237,15,136,244, 670 65,8,221,1,255,220,65,16,221,17,221,81,24,133,252,237,15,136,244,247,255,
671 247,255,221,81,24,15,140,244,247,255,217,201,248,1,255,15,183,70,252,254, 671 221,81,24,15,140,244,247,255,217,201,248,1,255,15,183,70,252,254,255,15,131,
672 255,15,131,244,248,141,180,253,134,233,255,141,180,253,134,233,15,183,70, 672 244,248,141,180,253,134,233,255,141,180,253,134,233,15,183,70,252,254,15,
673 252,254,15,131,245,255,15,130,244,248,141,180,253,134,233,255,248,3,102,15, 673 131,245,255,15,130,244,248,141,180,253,134,233,255,248,3,102,15,46,193,252,
674 46,193,252,233,244,1,255,141,12,202,139,105,4,129,252,253,239,15,132,244, 674 233,244,1,255,141,12,202,139,105,4,129,252,253,239,15,132,244,247,255,137,
675 247,255,137,105,252,252,139,41,137,105,252,248,252,233,245,255,141,180,253, 675 105,252,252,139,41,137,105,252,248,252,233,245,255,141,180,253,134,233,139,
676 134,233,139,1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,72, 676 1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,72,139,128,233,
677 139,128,233,139,108,36,96,137,147,233,137,171,233,76,137,100,36,80,76,137, 677 139,108,36,96,137,147,233,137,171,233,76,137,100,36,80,76,137,108,36,32,76,
678 108,36,32,76,137,116,36,24,76,137,124,36,16,72,137,225,72,129,252,236,239, 678 137,116,36,24,76,137,124,36,16,72,137,225,72,129,252,236,239,102,15,127,49,
679 102,15,127,49,102,15,127,185,233,102,68,15,127,129,233,102,68,15,127,137, 679 102,15,127,185,233,102,68,15,127,129,233,102,68,15,127,137,233,102,68,15,
680 233,102,68,15,127,145,233,102,68,15,127,153,233,102,68,15,127,161,233,102, 680 127,145,233,102,68,15,127,153,233,102,68,15,127,161,233,102,68,15,127,169,
681 68,15,127,169,233,102,68,15,127,177,233,102,68,15,127,185,233,252,255,224, 681 233,102,68,15,127,177,233,102,68,15,127,185,233,252,255,224,255,141,180,253,
682 255,141,180,253,134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16, 682 134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,
683 252,255,36,252,235,255,137,252,245,209,252,237,129,229,239,102,131,172,253, 683 255,137,252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,
684 43,233,1,15,132,244,142,255,139,190,233,139,108,36,96,141,12,202,59,141,233, 684 142,255,139,190,233,139,108,36,96,141,12,202,59,141,233,15,135,244,23,15,
685 15,135,244,23,15,182,142,233,57,200,15,134,244,249,248,2,255,15,183,70,252, 685 182,142,233,57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,
686 254,252,233,245,255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134, 686 255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,
687 244,3,252,233,244,2,255,141,44,197,237,141,4,194,139,122,252,248,137,104, 687 2,255,141,44,197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252,
688 252,252,137,120,252,248,139,108,36,96,141,12,200,59,141,233,15,135,244,22, 688 248,139,108,36,96,141,12,200,59,141,233,15,135,244,22,137,209,137,194,15,
689 137,209,137,194,15,182,174,233,133,252,237,15,132,244,248,248,1,131,193,8, 689 182,174,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244,
690 57,209,15,131,244,249,139,121,252,248,137,56,139,121,252,252,137,120,4,131, 690 249,139,121,252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252,
691 192,8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,139,190,233, 691 252,237,131,252,237,1,15,133,244,1,248,2,255,139,190,233,139,6,15,182,204,
692 139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,255,248, 692 15,182,232,131,198,4,193,232,16,252,255,36,252,235,255,248,3,199,64,4,237,
693 3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255,139, 693 131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255,139,106,252,248,72,
694 106,252,248,72,139,189,233,139,108,36,96,141,68,194,252,248,137,149,233,141, 694 139,189,233,139,108,36,96,141,68,194,252,248,137,149,233,141,136,233,59,141,
695 136,233,59,141,233,137,133,233,255,137,252,233,255,72,137,252,250,137,252, 695 233,137,133,233,255,137,252,233,255,72,137,252,250,137,252,233,255,15,135,
696 233,255,15,135,244,21,199,131,233,237,255,252,255,215,255,252,255,147,233, 696 244,21,199,131,233,237,255,252,255,215,255,252,255,147,233,255,199,131,233,
697 255,199,131,233,237,139,149,233,141,12,194,252,247,217,3,141,233,139,114, 697 237,139,149,233,141,12,194,252,247,217,3,141,233,139,114,252,252,252,233,
698 252,252,252,233,244,12,255,254,0 698 244,12,255,254,0
699}; 699};
700 700
701enum { 701enum {
@@ -1965,13 +1965,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
1965 break; 1965 break;
1966 1966
1967 case BC_TSETM: 1967 case BC_TSETM:
1968 dasm_put(Dst, 12443); 1968 dasm_put(Dst, 12443, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
1969 if (sse) { 1969 dasm_put(Dst, 12590, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
1970 dasm_put(Dst, 12448);
1971 } else {
1972 }
1973 dasm_put(Dst, 12455, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
1974 dasm_put(Dst, 12595, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
1975 break; 1970 break;
1976 1971
1977 /* -- Calls and vararg handling ----------------------------------------- */ 1972 /* -- Calls and vararg handling ----------------------------------------- */
@@ -1979,60 +1974,60 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
1979 case BC_CALL: case BC_CALLM: 1974 case BC_CALL: case BC_CALLM:
1980 dasm_put(Dst, 10113); 1975 dasm_put(Dst, 10113);
1981 if (op == BC_CALLM) { 1976 if (op == BC_CALLM) {
1982 dasm_put(Dst, 12613); 1977 dasm_put(Dst, 12608);
1983 } 1978 }
1984 dasm_put(Dst, 12618, LJ_TFUNC, Dt7(->pc)); 1979 dasm_put(Dst, 12613, LJ_TFUNC, Dt7(->pc));
1985 break; 1980 break;
1986 1981
1987 case BC_CALLMT: 1982 case BC_CALLMT:
1988 dasm_put(Dst, 12613); 1983 dasm_put(Dst, 12608);
1989 break; 1984 break;
1990 case BC_CALLT: 1985 case BC_CALLT:
1991 dasm_put(Dst, 12660, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->pc)); 1986 dasm_put(Dst, 12655, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->pc));
1992 dasm_put(Dst, 12779, FRAME_TYPE, Dt7(->pc), PC2PROTO(k), FRAME_VARG, FRAME_TYPEP, FRAME_VARG); 1987 dasm_put(Dst, 12774, FRAME_TYPE, Dt7(->pc), PC2PROTO(k), FRAME_VARG, FRAME_TYPEP, FRAME_VARG);
1993 break; 1988 break;
1994 1989
1995 case BC_ITERC: 1990 case BC_ITERC:
1996 dasm_put(Dst, 12850, LJ_TFUNC, 2+1, Dt7(->pc)); 1991 dasm_put(Dst, 12845, LJ_TFUNC, 2+1, Dt7(->pc));
1997 break; 1992 break;
1998 1993
1999 case BC_VARG: 1994 case BC_VARG:
2000 dasm_put(Dst, 12931, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL); 1995 dasm_put(Dst, 12926, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL);
2001 dasm_put(Dst, 13076, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); 1996 dasm_put(Dst, 13071, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top));
2002 break; 1997 break;
2003 1998
2004 /* -- Returns ----------------------------------------------------------- */ 1999 /* -- Returns ----------------------------------------------------------- */
2005 2000
2006 case BC_RETM: 2001 case BC_RETM:
2007 dasm_put(Dst, 12613); 2002 dasm_put(Dst, 12608);
2008 break; 2003 break;
2009 2004
2010 case BC_RET: case BC_RET0: case BC_RET1: 2005 case BC_RET: case BC_RET0: case BC_RET1:
2011 if (op != BC_RET0) { 2006 if (op != BC_RET0) {
2012 dasm_put(Dst, 13175); 2007 dasm_put(Dst, 13170);
2013 } 2008 }
2014 dasm_put(Dst, 13179, FRAME_TYPE); 2009 dasm_put(Dst, 13174, FRAME_TYPE);
2015 switch (op) { 2010 switch (op) {
2016 case BC_RET: 2011 case BC_RET:
2017 dasm_put(Dst, 13198); 2012 dasm_put(Dst, 13193);
2018 break; 2013 break;
2019 case BC_RET1: 2014 case BC_RET1:
2020 dasm_put(Dst, 13256); 2015 dasm_put(Dst, 13251);
2021 /* fallthrough */ 2016 /* fallthrough */
2022 case BC_RET0: 2017 case BC_RET0:
2023 dasm_put(Dst, 13272); 2018 dasm_put(Dst, 13267);
2024 default: 2019 default:
2025 break; 2020 break;
2026 } 2021 }
2027 dasm_put(Dst, 13283, Dt7(->pc), PC2PROTO(k)); 2022 dasm_put(Dst, 13278, Dt7(->pc), PC2PROTO(k));
2028 if (op == BC_RET) { 2023 if (op == BC_RET) {
2029 dasm_put(Dst, 13327, LJ_TNIL); 2024 dasm_put(Dst, 13322, LJ_TNIL);
2030 } else { 2025 } else {
2031 dasm_put(Dst, 13336, LJ_TNIL); 2026 dasm_put(Dst, 13331, LJ_TNIL);
2032 } 2027 }
2033 dasm_put(Dst, 13343, -FRAME_VARG, FRAME_TYPEP); 2028 dasm_put(Dst, 13338, -FRAME_VARG, FRAME_TYPEP);
2034 if (op != BC_RET0) { 2029 if (op != BC_RET0) {
2035 dasm_put(Dst, 13367); 2030 dasm_put(Dst, 13362);
2036 } 2031 }
2037 dasm_put(Dst, 4573); 2032 dasm_put(Dst, 4573);
2038 break; 2033 break;
@@ -2042,7 +2037,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2042 2037
2043 case BC_FORL: 2038 case BC_FORL:
2044#if LJ_HASJIT 2039#if LJ_HASJIT
2045 dasm_put(Dst, 13371, HOTCOUNT_PCMASK, GG_DISP2HOT); 2040 dasm_put(Dst, 13366, HOTCOUNT_PCMASK, GG_DISP2HOT);
2046#endif 2041#endif
2047 break; 2042 break;
2048 2043
@@ -2054,57 +2049,57 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2054 case BC_FORI: 2049 case BC_FORI:
2055 case BC_IFORL: 2050 case BC_IFORL:
2056 vk = (op == BC_IFORL || op == BC_JFORL); 2051 vk = (op == BC_IFORL || op == BC_JFORL);
2057 dasm_put(Dst, 13392); 2052 dasm_put(Dst, 13387);
2058 if (!vk) { 2053 if (!vk) {
2059 dasm_put(Dst, 13396, LJ_TISNUM, LJ_TISNUM); 2054 dasm_put(Dst, 13391, LJ_TISNUM, LJ_TISNUM);
2060 } 2055 }
2061 dasm_put(Dst, 13415); 2056 dasm_put(Dst, 13410);
2062 if (!vk) { 2057 if (!vk) {
2063 dasm_put(Dst, 13419, LJ_TISNUM); 2058 dasm_put(Dst, 13414, LJ_TISNUM);
2064 } 2059 }
2065 if (sse) { 2060 if (sse) {
2066 dasm_put(Dst, 13428); 2061 dasm_put(Dst, 13423);
2067 if (vk) { 2062 if (vk) {
2068 dasm_put(Dst, 13440); 2063 dasm_put(Dst, 13435);
2069 } else { 2064 } else {
2070 dasm_put(Dst, 13459); 2065 dasm_put(Dst, 13454);
2071 } 2066 }
2072 dasm_put(Dst, 13464); 2067 dasm_put(Dst, 13459);
2073 } else { 2068 } else {
2074 dasm_put(Dst, 13477); 2069 dasm_put(Dst, 13472);
2075 if (vk) { 2070 if (vk) {
2076 dasm_put(Dst, 13483); 2071 dasm_put(Dst, 13478);
2077 } else { 2072 } else {
2078 dasm_put(Dst, 13499); 2073 dasm_put(Dst, 13494);
2079 } 2074 }
2080 dasm_put(Dst, 13507); 2075 dasm_put(Dst, 13502);
2081 if (cmov) { 2076 if (cmov) {
2082 dasm_put(Dst, 9536); 2077 dasm_put(Dst, 9536);
2083 } else { 2078 } else {
2084 dasm_put(Dst, 9542); 2079 dasm_put(Dst, 9542);
2085 } 2080 }
2086 if (!cmov) { 2081 if (!cmov) {
2087 dasm_put(Dst, 13512); 2082 dasm_put(Dst, 13507);
2088 } 2083 }
2089 } 2084 }
2090 if (op == BC_FORI) { 2085 if (op == BC_FORI) {
2091 dasm_put(Dst, 13518, -BCBIAS_J*4); 2086 dasm_put(Dst, 13513, -BCBIAS_J*4);
2092 } else if (op == BC_JFORI) { 2087 } else if (op == BC_JFORI) {
2093 dasm_put(Dst, 13528, -BCBIAS_J*4, BC_JLOOP); 2088 dasm_put(Dst, 13523, -BCBIAS_J*4, BC_JLOOP);
2094 } else if (op == BC_IFORL) { 2089 } else if (op == BC_IFORL) {
2095 dasm_put(Dst, 13542, -BCBIAS_J*4); 2090 dasm_put(Dst, 13537, -BCBIAS_J*4);
2096 } else { 2091 } else {
2097 dasm_put(Dst, 13538, BC_JLOOP); 2092 dasm_put(Dst, 13533, BC_JLOOP);
2098 } 2093 }
2099 dasm_put(Dst, 9571); 2094 dasm_put(Dst, 9571);
2100 if (sse) { 2095 if (sse) {
2101 dasm_put(Dst, 13552); 2096 dasm_put(Dst, 13547);
2102 } 2097 }
2103 break; 2098 break;
2104 2099
2105 case BC_ITERL: 2100 case BC_ITERL:
2106#if LJ_HASJIT 2101#if LJ_HASJIT
2107 dasm_put(Dst, 13371, HOTCOUNT_PCMASK, GG_DISP2HOT); 2102 dasm_put(Dst, 13366, HOTCOUNT_PCMASK, GG_DISP2HOT);
2108#endif 2103#endif
2109 break; 2104 break;
2110 2105
@@ -2113,18 +2108,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2113 break; 2108 break;
2114#endif 2109#endif
2115 case BC_IITERL: 2110 case BC_IITERL:
2116 dasm_put(Dst, 13563, LJ_TNIL); 2111 dasm_put(Dst, 13558, LJ_TNIL);
2117 if (op == BC_JITERL) { 2112 if (op == BC_JITERL) {
2118 dasm_put(Dst, 13578, BC_JLOOP); 2113 dasm_put(Dst, 13573, BC_JLOOP);
2119 } else { 2114 } else {
2120 dasm_put(Dst, 13592, -BCBIAS_J*4); 2115 dasm_put(Dst, 13587, -BCBIAS_J*4);
2121 } 2116 }
2122 dasm_put(Dst, 9871); 2117 dasm_put(Dst, 9871);
2123 break; 2118 break;
2124 2119
2125 case BC_LOOP: 2120 case BC_LOOP:
2126#if LJ_HASJIT 2121#if LJ_HASJIT
2127 dasm_put(Dst, 13371, HOTCOUNT_PCMASK, GG_DISP2HOT); 2122 dasm_put(Dst, 13366, HOTCOUNT_PCMASK, GG_DISP2HOT);
2128#endif 2123#endif
2129 break; 2124 break;
2130 2125
@@ -2134,12 +2129,12 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2134 2129
2135 case BC_JLOOP: 2130 case BC_JLOOP:
2136#if LJ_HASJIT 2131#if LJ_HASJIT
2137 dasm_put(Dst, 13608, 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); 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);
2138#endif 2133#endif
2139 break; 2134 break;
2140 2135
2141 case BC_JMP: 2136 case BC_JMP:
2142 dasm_put(Dst, 13717, -BCBIAS_J*4); 2137 dasm_put(Dst, 13712, -BCBIAS_J*4);
2143 break; 2138 break;
2144 2139
2145 /* -- Function headers -------------------------------------------------- */ 2140 /* -- Function headers -------------------------------------------------- */
@@ -2153,7 +2148,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2153 2148
2154 case BC_FUNCF: 2149 case BC_FUNCF:
2155#if LJ_HASJIT 2150#if LJ_HASJIT
2156 dasm_put(Dst, 13742, HOTCOUNT_PCMASK, GG_DISP2HOT); 2151 dasm_put(Dst, 13737, HOTCOUNT_PCMASK, GG_DISP2HOT);
2157#endif 2152#endif
2158 case BC_FUNCV: /* NYI: compiled vararg functions. */ 2153 case BC_FUNCV: /* NYI: compiled vararg functions. */
2159 break; 2154 break;
@@ -2163,13 +2158,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2163 break; 2158 break;
2164#endif 2159#endif
2165 case BC_IFUNCF: 2160 case BC_IFUNCF:
2166 dasm_put(Dst, 13763, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams)); 2161 dasm_put(Dst, 13758, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams));
2167 if (op == BC_JFUNCF) { 2162 if (op == BC_JFUNCF) {
2168 dasm_put(Dst, 13793, BC_JLOOP); 2163 dasm_put(Dst, 13788, BC_JLOOP);
2169 } else { 2164 } else {
2170 dasm_put(Dst, 9573); 2165 dasm_put(Dst, 9573);
2171 } 2166 }
2172 dasm_put(Dst, 13802, LJ_TNIL); 2167 dasm_put(Dst, 13797, LJ_TNIL);
2173 break; 2168 break;
2174 2169
2175 case BC_JFUNCV: 2170 case BC_JFUNCV:
@@ -2180,30 +2175,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2180 break; /* NYI: compiled vararg functions. */ 2175 break; /* NYI: compiled vararg functions. */
2181 2176
2182 case BC_IFUNCV: 2177 case BC_IFUNCV:
2183 dasm_put(Dst, 13824, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL); 2178 dasm_put(Dst, 13819, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL);
2184 if (op == BC_JFUNCV) { 2179 if (op == BC_JFUNCV) {
2185 dasm_put(Dst, 13793, BC_JLOOP); 2180 dasm_put(Dst, 13788, BC_JLOOP);
2186 } else { 2181 } else {
2187 dasm_put(Dst, 13915, -4+PC2PROTO(k)); 2182 dasm_put(Dst, 13910, -4+PC2PROTO(k));
2188 } 2183 }
2189 dasm_put(Dst, 13938, LJ_TNIL); 2184 dasm_put(Dst, 13933, LJ_TNIL);
2190 break; 2185 break;
2191 2186
2192 case BC_FUNCC: 2187 case BC_FUNCC:
2193 case BC_FUNCCW: 2188 case BC_FUNCCW:
2194 dasm_put(Dst, 13960, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top)); 2189 dasm_put(Dst, 13955, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top));
2195 if (op == BC_FUNCC) { 2190 if (op == BC_FUNCC) {
2196 dasm_put(Dst, 13990); 2191 dasm_put(Dst, 13985);
2197 } else { 2192 } else {
2198 dasm_put(Dst, 13994); 2193 dasm_put(Dst, 13989);
2199 } 2194 }
2200 dasm_put(Dst, 14002, DISPATCH_GL(vmstate), ~LJ_VMST_C); 2195 dasm_put(Dst, 13997, DISPATCH_GL(vmstate), ~LJ_VMST_C);
2201 if (op == BC_FUNCC) { 2196 if (op == BC_FUNCC) {
2202 dasm_put(Dst, 14011); 2197 dasm_put(Dst, 14006);
2203 } else { 2198 } else {
2204 dasm_put(Dst, 14015, DISPATCH_GL(wrapf)); 2199 dasm_put(Dst, 14010, DISPATCH_GL(wrapf));
2205 } 2200 }
2206 dasm_put(Dst, 14020, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top)); 2201 dasm_put(Dst, 14015, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top));
2207 break; 2202 break;
2208 2203
2209 /* ---------------------------------------------------------------------- */ 2204 /* ---------------------------------------------------------------------- */
@@ -2231,7 +2226,7 @@ static int build_backend(BuildCtx *ctx)
2231 2226
2232 build_subroutines(ctx, cmov, sse); 2227 build_subroutines(ctx, cmov, sse);
2233 2228
2234 dasm_put(Dst, 14045); 2229 dasm_put(Dst, 14040);
2235 for (op = 0; op < BC__MAX; op++) 2230 for (op = 0; op < BC__MAX; op++)
2236 build_ins(ctx, (BCOp)op, op, cmov, sse); 2231 build_ins(ctx, (BCOp)op, op, cmov, sse);
2237 2232
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h
index bb1645ab..10392991 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[15252] = { 15static const unsigned char build_actionlist[15235] = {
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,
@@ -675,80 +675,80 @@ static const unsigned char build_actionlist[15252] = {
675 255,36,171,248,3,131,189,233,0,15,132,244,1,255,139,141,233,252,246,129,233, 675 255,36,171,248,3,131,189,233,0,15,132,244,1,255,139,141,233,252,246,129,233,
676 235,15,132,244,38,15,182,78,252,253,252,233,244,1,248,7,128,165,233,235,139, 676 235,15,132,244,38,15,182,78,252,253,252,233,244,1,248,7,128,165,233,235,139,
677 139,233,137,171,233,137,141,233,15,182,78,252,253,252,233,244,2,255,137,124, 677 139,233,137,171,233,137,141,233,15,182,78,252,253,252,233,244,2,255,137,124,
678 36,16,255,252,242,15,45,60,199,255,221,4,199,219,92,36,12,139,124,36,12,255, 678 36,16,139,60,199,248,1,141,12,202,139,105,252,248,252,246,133,233,235,15,
679 248,1,141,12,202,139,105,252,248,252,246,133,233,235,15,133,244,253,248,2, 679 133,244,253,248,2,139,68,36,20,131,232,1,15,132,244,250,1,252,248,59,133,
680 139,68,36,20,131,232,1,15,132,244,250,1,252,248,59,133,233,15,131,244,251, 680 233,15,131,244,251,41,252,248,193,231,3,3,189,233,248,3,139,41,137,47,139,
681 41,252,248,193,231,3,3,189,233,248,3,139,41,137,47,139,105,4,131,193,8,137, 681 105,4,131,193,8,137,111,4,131,199,8,131,232,1,15,133,244,3,248,4,139,124,
682 111,4,131,199,8,131,232,1,15,133,244,3,248,4,139,124,36,16,139,6,15,182,204,
683 15,182,232,131,198,4,193,232,16,252,255,36,171,248,5,137,108,36,4,139,108,
684 36,48,137,149,233,137,68,36,8,137,44,36,137,116,36,24,232,251,1,33,139,149,
685 233,15,182,78,252,253,252,233,244,1,248,7,255,128,165,233,235,139,131,233,
686 137,171,233,137,133,233,252,233,244,2,255,3,68,36,20,255,129,124,253,202,
687 4,239,139,44,202,15,133,244,51,141,84,202,8,137,114,252,252,139,181,233,139,
688 14,15,182,252,233,15,182,205,131,198,4,252,255,36,171,255,141,76,202,8,137,
689 215,139,105,252,248,129,121,253,252,252,239,15,133,244,28,248,52,139,114,
690 252,252,252,247,198,237,15,133,244,253,248,1,137,106,252,248,137,68,36,20,
691 131,232,1,15,132,244,249,248,2,139,41,137,47,139,105,4,137,111,4,131,199,
692 8,131,193,8,131,232,1,15,133,244,2,139,106,252,248,248,3,139,68,36,20,128,
693 189,233,1,15,135,244,251,248,4,139,181,233,139,14,15,182,252,233,15,182,205,
694 131,198,4,252,255,36,171,248,5,255,252,247,198,237,15,133,244,4,15,182,78,
695 252,253,252,247,209,141,12,202,139,121,252,248,139,191,233,139,191,233,252,
696 233,244,4,248,7,129,252,238,239,252,247,198,237,15,133,244,254,41,252,242,
697 137,215,139,114,252,252,252,233,244,1,248,8,129,198,239,252,233,244,1,255,
698 141,76,202,8,139,105,232,139,65,252,236,137,41,137,65,4,139,105,252,240,139,
699 65,252,244,137,105,8,137,65,12,139,105,224,139,65,228,137,105,252,248,137,
700 65,252,252,129,252,248,239,184,237,15,133,244,28,137,202,137,114,252,252,
701 139,181,233,139,14,15,182,252,233,15,182,205,131,198,4,252,255,36,171,255,
702 15,182,252,236,139,66,252,248,141,12,202,139,128,233,15,182,128,233,137,124,
703 36,16,141,188,253,194,233,43,122,252,252,133,252,237,15,132,244,251,141,108,
704 252,233,252,248,57,215,15,131,244,248,248,1,139,71,252,248,137,1,139,71,252,
705 252,131,199,8,137,65,4,131,193,8,57,252,233,15,131,244,249,57,215,15,130,
706 244,1,248,2,199,65,4,237,131,193,8,57,252,233,15,130,244,2,248,3,139,124,
707 36,16,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248, 682 36,16,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,
708 5,199,68,36,20,1,0,0,0,137,208,41,252,248,15,134,244,3,255,137,197,193,252, 683 5,137,108,36,4,139,108,36,48,137,149,233,137,68,36,8,137,44,36,137,116,36,
709 237,3,131,197,1,137,108,36,20,139,108,36,48,1,200,59,133,233,15,135,244,253, 684 24,232,251,1,33,139,149,233,15,182,78,252,253,252,233,244,1,248,7,255,128,
710 248,6,139,71,252,248,137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57, 685 165,233,235,139,131,233,137,171,233,137,133,233,252,233,244,2,255,3,68,36,
711 215,15,130,244,6,252,233,244,3,248,7,137,149,233,137,141,233,137,116,36,24, 686 20,255,129,124,253,202,4,239,139,44,202,15,133,244,51,141,84,202,8,137,114,
712 41,215,139,84,36,20,131,252,234,1,137,252,233,232,251,1,0,139,149,233,139, 687 252,252,139,181,233,139,14,15,182,252,233,15,182,205,131,198,4,252,255,36,
713 141,233,1,215,252,233,244,6,255,193,225,3,255,248,1,139,114,252,252,137,68, 688 171,255,141,76,202,8,137,215,139,105,252,248,129,121,253,252,252,239,15,133,
714 36,20,252,247,198,237,15,133,244,253,255,248,13,137,215,131,232,1,15,132, 689 244,28,248,52,139,114,252,252,252,247,198,237,15,133,244,253,248,1,137,106,
715 244,249,248,2,139,44,15,137,111,252,248,139,108,15,4,137,111,252,252,131, 690 252,248,137,68,36,20,131,232,1,15,132,244,249,248,2,139,41,137,47,139,105,
716 199,8,131,232,1,15,133,244,2,248,3,139,68,36,20,15,182,110,252,255,248,5, 691 4,137,111,4,131,199,8,131,193,8,131,232,1,15,133,244,2,139,106,252,248,248,
717 57,197,15,135,244,252,255,139,108,10,4,137,106,252,252,139,44,10,137,106, 692 3,139,68,36,20,128,189,233,1,15,135,244,251,248,4,139,181,233,139,14,15,182,
718 252,248,255,248,5,56,70,252,255,15,135,244,252,255,15,182,78,252,253,252, 693 252,233,15,182,205,131,198,4,252,255,36,171,248,5,255,252,247,198,237,15,
719 247,209,141,20,202,139,122,252,248,139,191,233,139,191,233,139,6,15,182,204, 694 133,244,4,15,182,78,252,253,252,247,209,141,12,202,139,121,252,248,139,191,
720 15,182,232,131,198,4,193,232,16,252,255,36,171,248,6,255,199,71,252,252,237, 695 233,139,191,233,252,233,244,4,248,7,129,252,238,239,252,247,198,237,15,133,
721 131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248,7,141, 696 244,254,41,252,242,137,215,139,114,252,252,252,233,244,1,248,8,129,198,239,
722 174,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255,137,252, 697 252,233,244,1,255,141,76,202,8,139,105,232,139,65,252,236,137,41,137,65,4,
723 245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,140,255,141, 698 139,105,252,240,139,65,252,244,137,105,8,137,65,12,139,105,224,139,65,228,
724 12,202,255,129,121,253,4,239,15,135,244,53,129,121,253,12,239,15,135,244, 699 137,105,252,248,137,65,252,252,129,252,248,239,184,237,15,133,244,28,137,
725 53,255,139,105,20,255,129,252,253,239,15,135,244,53,255,252,242,15,16,1,252, 700 202,137,114,252,252,139,181,233,139,14,15,182,252,233,15,182,205,131,198,
726 242,15,16,73,8,255,252,242,15,88,65,16,252,242,15,17,1,133,252,237,15,136, 701 4,252,255,36,171,255,15,182,252,236,139,66,252,248,141,12,202,139,128,233,
727 244,249,255,15,140,244,249,255,102,15,46,200,248,1,252,242,15,17,65,24,255, 702 15,182,128,233,137,124,36,16,141,188,253,194,233,43,122,252,252,133,252,237,
728 221,65,8,221,1,255,220,65,16,221,17,221,81,24,133,252,237,15,136,244,247, 703 15,132,244,251,141,108,252,233,252,248,57,215,15,131,244,248,248,1,139,71,
729 255,221,81,24,15,140,244,247,255,217,201,248,1,255,15,183,70,252,254,255, 704 252,248,137,1,139,71,252,252,131,199,8,137,65,4,131,193,8,57,252,233,15,131,
730 15,131,244,248,141,180,253,134,233,255,141,180,253,134,233,15,183,70,252, 705 244,249,57,215,15,130,244,1,248,2,199,65,4,237,131,193,8,57,252,233,15,130,
731 254,15,131,245,255,15,130,244,248,141,180,253,134,233,255,248,3,102,15,46, 706 244,2,248,3,139,124,36,16,139,6,15,182,204,15,182,232,131,198,4,193,232,16,
732 193,252,233,244,1,255,141,12,202,139,105,4,129,252,253,239,15,132,244,247, 707 252,255,36,171,248,5,199,68,36,20,1,0,0,0,137,208,41,252,248,15,134,244,3,
733 255,137,105,252,252,139,41,137,105,252,248,252,233,245,255,141,180,253,134, 708 255,137,197,193,252,237,3,131,197,1,137,108,36,20,139,108,36,48,1,200,59,
734 233,139,1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,139,128, 709 133,233,15,135,244,253,248,6,139,71,252,248,137,1,139,71,252,252,131,199,
735 233,139,108,36,48,137,147,233,137,171,233,252,255,224,255,141,180,253,134, 710 8,137,65,4,131,193,8,57,215,15,130,244,6,252,233,244,3,248,7,137,149,233,
736 233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255,137, 711 137,141,233,137,116,36,24,41,215,139,84,36,20,131,252,234,1,137,252,233,232,
737 252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,142,255, 712 251,1,0,139,149,233,139,141,233,1,215,252,233,244,6,255,193,225,3,255,248,
738 139,190,233,139,108,36,48,141,12,202,59,141,233,15,135,244,23,15,182,142, 713 1,139,114,252,252,137,68,36,20,252,247,198,237,15,133,244,253,255,248,13,
739 233,57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255,248, 714 137,215,131,232,1,15,132,244,249,248,2,139,44,15,137,111,252,248,139,108,
740 3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2,255, 715 15,4,137,111,252,252,131,199,8,131,232,1,15,133,244,2,248,3,139,68,36,20,
741 141,44,197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252,248, 716 15,182,110,252,255,248,5,57,197,15,135,244,252,255,139,108,10,4,137,106,252,
742 139,108,36,48,141,12,200,59,141,233,15,135,244,22,137,209,137,194,15,182, 717 252,139,44,10,137,106,252,248,255,248,5,56,70,252,255,15,135,244,252,255,
743 174,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244,249, 718 15,182,78,252,253,252,247,209,141,20,202,139,122,252,248,139,191,233,139,
744 139,121,252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252,252, 719 191,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,
745 237,131,252,237,1,15,133,244,1,248,2,255,139,190,233,139,6,15,182,204,15, 720 6,255,199,71,252,252,237,131,199,8,255,199,68,194,252,244,237,255,131,192,
746 182,232,131,198,4,193,232,16,252,255,36,171,255,248,3,199,64,4,237,131,192, 721 1,252,233,244,5,248,7,141,174,233,252,247,197,237,15,133,244,14,41,252,234,
747 8,131,252,237,1,15,133,244,3,252,233,244,2,255,139,106,252,248,139,189,233, 722 255,1,252,233,255,137,252,245,209,252,237,129,229,239,102,131,172,253,43,
748 139,108,36,48,141,68,194,252,248,137,149,233,141,136,233,59,141,233,137,133, 723 233,1,15,132,244,140,255,141,12,202,255,129,121,253,4,239,15,135,244,53,129,
749 233,255,137,44,36,255,137,124,36,4,137,44,36,255,15,135,244,21,199,131,233, 724 121,253,12,239,15,135,244,53,255,139,105,20,255,129,252,253,239,15,135,244,
750 237,255,252,255,215,255,252,255,147,233,255,199,131,233,237,139,149,233,141, 725 53,255,252,242,15,16,1,252,242,15,16,73,8,255,252,242,15,88,65,16,252,242,
751 12,194,252,247,217,3,141,233,139,114,252,252,252,233,244,12,255,254,0 726 15,17,1,133,252,237,15,136,244,249,255,15,140,244,249,255,102,15,46,200,248,
727 1,252,242,15,17,65,24,255,221,65,8,221,1,255,220,65,16,221,17,221,81,24,133,
728 252,237,15,136,244,247,255,221,81,24,15,140,244,247,255,217,201,248,1,255,
729 15,183,70,252,254,255,15,131,244,248,141,180,253,134,233,255,141,180,253,
730 134,233,15,183,70,252,254,15,131,245,255,15,130,244,248,141,180,253,134,233,
731 255,248,3,102,15,46,193,252,233,244,1,255,141,12,202,139,105,4,129,252,253,
732 239,15,132,244,247,255,137,105,252,252,139,41,137,105,252,248,252,233,245,
733 255,141,180,253,134,233,139,1,137,105,252,252,137,65,252,248,255,139,139,
734 233,139,4,129,139,128,233,139,108,36,48,137,147,233,137,171,233,252,255,224,
735 255,141,180,253,134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,
736 252,255,36,171,255,137,252,245,209,252,237,129,229,239,102,131,172,253,43,
737 233,1,15,132,244,142,255,139,190,233,139,108,36,48,141,12,202,59,141,233,
738 15,135,244,23,15,182,142,233,57,200,15,134,244,249,248,2,255,15,183,70,252,
739 254,252,233,245,255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,
740 244,3,252,233,244,2,255,141,44,197,237,141,4,194,139,122,252,248,137,104,
741 252,252,137,120,252,248,139,108,36,48,141,12,200,59,141,233,15,135,244,22,
742 137,209,137,194,15,182,174,233,133,252,237,15,132,244,248,248,1,131,193,8,
743 57,209,15,131,244,249,139,121,252,248,137,56,139,121,252,252,137,120,4,131,
744 192,8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,139,190,233,
745 139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255,248,3,
746 199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255,139,106,
747 252,248,139,189,233,139,108,36,48,141,68,194,252,248,137,149,233,141,136,
748 233,59,141,233,137,133,233,255,137,44,36,255,137,124,36,4,137,44,36,255,15,
749 135,244,21,199,131,233,237,255,252,255,215,255,252,255,147,233,255,199,131,
750 233,237,139,149,233,141,12,194,252,247,217,3,141,233,139,114,252,252,252,
751 233,244,12,255,254,0
752}; 752};
753 753
754enum { 754enum {
@@ -2089,14 +2089,8 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2089 break; 2089 break;
2090 2090
2091 case BC_TSETM: 2091 case BC_TSETM:
2092 dasm_put(Dst, 13730); 2092 dasm_put(Dst, 13730, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
2093 if (sse) { 2093 dasm_put(Dst, 13879, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
2094 dasm_put(Dst, 13735);
2095 } else {
2096 dasm_put(Dst, 13742);
2097 }
2098 dasm_put(Dst, 13754, Dt6(->marked), LJ_GC_BLACK, Dt6(->asize), Dt6(->array), Dt1(->base), Dt1(->base));
2099 dasm_put(Dst, 13896, Dt6(->marked), cast_byte(~LJ_GC_BLACK), DISPATCH_GL(gc.grayagain), DISPATCH_GL(gc.grayagain), Dt6(->gclist));
2100 break; 2094 break;
2101 2095
2102 /* -- Calls and vararg handling ----------------------------------------- */ 2096 /* -- Calls and vararg handling ----------------------------------------- */
@@ -2104,60 +2098,60 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2104 case BC_CALL: case BC_CALLM: 2098 case BC_CALL: case BC_CALLM:
2105 dasm_put(Dst, 11397); 2099 dasm_put(Dst, 11397);
2106 if (op == BC_CALLM) { 2100 if (op == BC_CALLM) {
2107 dasm_put(Dst, 13914); 2101 dasm_put(Dst, 13897);
2108 } 2102 }
2109 dasm_put(Dst, 13919, LJ_TFUNC, Dt7(->pc)); 2103 dasm_put(Dst, 13902, LJ_TFUNC, Dt7(->pc));
2110 break; 2104 break;
2111 2105
2112 case BC_CALLMT: 2106 case BC_CALLMT:
2113 dasm_put(Dst, 13914); 2107 dasm_put(Dst, 13897);
2114 break; 2108 break;
2115 case BC_CALLT: 2109 case BC_CALLT:
2116 dasm_put(Dst, 13960, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->pc)); 2110 dasm_put(Dst, 13943, LJ_TFUNC, FRAME_TYPE, Dt7(->ffid), Dt7(->pc));
2117 dasm_put(Dst, 14078, FRAME_TYPE, Dt7(->pc), PC2PROTO(k), FRAME_VARG, FRAME_TYPEP, FRAME_VARG); 2111 dasm_put(Dst, 14061, FRAME_TYPE, Dt7(->pc), PC2PROTO(k), FRAME_VARG, FRAME_TYPEP, FRAME_VARG);
2118 break; 2112 break;
2119 2113
2120 case BC_ITERC: 2114 case BC_ITERC:
2121 dasm_put(Dst, 14148, LJ_TFUNC, 2+1, Dt7(->pc)); 2115 dasm_put(Dst, 14131, LJ_TFUNC, 2+1, Dt7(->pc));
2122 break; 2116 break;
2123 2117
2124 case BC_VARG: 2118 case BC_VARG:
2125 dasm_put(Dst, 14228, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL); 2119 dasm_put(Dst, 14211, Dt7(->pc), PC2PROTO(numparams), (8+FRAME_VARG), LJ_TNIL);
2126 dasm_put(Dst, 14372, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top)); 2120 dasm_put(Dst, 14355, Dt1(->maxstack), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->top));
2127 break; 2121 break;
2128 2122
2129 /* -- Returns ----------------------------------------------------------- */ 2123 /* -- Returns ----------------------------------------------------------- */
2130 2124
2131 case BC_RETM: 2125 case BC_RETM:
2132 dasm_put(Dst, 13914); 2126 dasm_put(Dst, 13897);
2133 break; 2127 break;
2134 2128
2135 case BC_RET: case BC_RET0: case BC_RET1: 2129 case BC_RET: case BC_RET0: case BC_RET1:
2136 if (op != BC_RET0) { 2130 if (op != BC_RET0) {
2137 dasm_put(Dst, 14471); 2131 dasm_put(Dst, 14454);
2138 } 2132 }
2139 dasm_put(Dst, 14475, FRAME_TYPE); 2133 dasm_put(Dst, 14458, FRAME_TYPE);
2140 switch (op) { 2134 switch (op) {
2141 case BC_RET: 2135 case BC_RET:
2142 dasm_put(Dst, 14494); 2136 dasm_put(Dst, 14477);
2143 break; 2137 break;
2144 case BC_RET1: 2138 case BC_RET1:
2145 dasm_put(Dst, 14552); 2139 dasm_put(Dst, 14535);
2146 /* fallthrough */ 2140 /* fallthrough */
2147 case BC_RET0: 2141 case BC_RET0:
2148 dasm_put(Dst, 14568); 2142 dasm_put(Dst, 14551);
2149 default: 2143 default:
2150 break; 2144 break;
2151 } 2145 }
2152 dasm_put(Dst, 14579, Dt7(->pc), PC2PROTO(k)); 2146 dasm_put(Dst, 14562, Dt7(->pc), PC2PROTO(k));
2153 if (op == BC_RET) { 2147 if (op == BC_RET) {
2154 dasm_put(Dst, 14621, LJ_TNIL); 2148 dasm_put(Dst, 14604, LJ_TNIL);
2155 } else { 2149 } else {
2156 dasm_put(Dst, 14630, LJ_TNIL); 2150 dasm_put(Dst, 14613, LJ_TNIL);
2157 } 2151 }
2158 dasm_put(Dst, 14637, -FRAME_VARG, FRAME_TYPEP); 2152 dasm_put(Dst, 14620, -FRAME_VARG, FRAME_TYPEP);
2159 if (op != BC_RET0) { 2153 if (op != BC_RET0) {
2160 dasm_put(Dst, 14661); 2154 dasm_put(Dst, 14644);
2161 } 2155 }
2162 dasm_put(Dst, 4683); 2156 dasm_put(Dst, 4683);
2163 break; 2157 break;
@@ -2167,7 +2161,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2167 2161
2168 case BC_FORL: 2162 case BC_FORL:
2169#if LJ_HASJIT 2163#if LJ_HASJIT
2170 dasm_put(Dst, 14665, HOTCOUNT_PCMASK, GG_DISP2HOT); 2164 dasm_put(Dst, 14648, HOTCOUNT_PCMASK, GG_DISP2HOT);
2171#endif 2165#endif
2172 break; 2166 break;
2173 2167
@@ -2179,57 +2173,57 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2179 case BC_FORI: 2173 case BC_FORI:
2180 case BC_IFORL: 2174 case BC_IFORL:
2181 vk = (op == BC_IFORL || op == BC_JFORL); 2175 vk = (op == BC_IFORL || op == BC_JFORL);
2182 dasm_put(Dst, 14686); 2176 dasm_put(Dst, 14669);
2183 if (!vk) { 2177 if (!vk) {
2184 dasm_put(Dst, 14690, LJ_TISNUM, LJ_TISNUM); 2178 dasm_put(Dst, 14673, LJ_TISNUM, LJ_TISNUM);
2185 } 2179 }
2186 dasm_put(Dst, 14709); 2180 dasm_put(Dst, 14692);
2187 if (!vk) { 2181 if (!vk) {
2188 dasm_put(Dst, 14713, LJ_TISNUM); 2182 dasm_put(Dst, 14696, LJ_TISNUM);
2189 } 2183 }
2190 if (sse) { 2184 if (sse) {
2191 dasm_put(Dst, 14722); 2185 dasm_put(Dst, 14705);
2192 if (vk) { 2186 if (vk) {
2193 dasm_put(Dst, 14734); 2187 dasm_put(Dst, 14717);
2194 } else { 2188 } else {
2195 dasm_put(Dst, 14753); 2189 dasm_put(Dst, 14736);
2196 } 2190 }
2197 dasm_put(Dst, 14758); 2191 dasm_put(Dst, 14741);
2198 } else { 2192 } else {
2199 dasm_put(Dst, 14771); 2193 dasm_put(Dst, 14754);
2200 if (vk) { 2194 if (vk) {
2201 dasm_put(Dst, 14777); 2195 dasm_put(Dst, 14760);
2202 } else { 2196 } else {
2203 dasm_put(Dst, 14793); 2197 dasm_put(Dst, 14776);
2204 } 2198 }
2205 dasm_put(Dst, 14801); 2199 dasm_put(Dst, 14784);
2206 if (cmov) { 2200 if (cmov) {
2207 dasm_put(Dst, 10812); 2201 dasm_put(Dst, 10812);
2208 } else { 2202 } else {
2209 dasm_put(Dst, 10818); 2203 dasm_put(Dst, 10818);
2210 } 2204 }
2211 if (!cmov) { 2205 if (!cmov) {
2212 dasm_put(Dst, 14806); 2206 dasm_put(Dst, 14789);
2213 } 2207 }
2214 } 2208 }
2215 if (op == BC_FORI) { 2209 if (op == BC_FORI) {
2216 dasm_put(Dst, 14812, -BCBIAS_J*4); 2210 dasm_put(Dst, 14795, -BCBIAS_J*4);
2217 } else if (op == BC_JFORI) { 2211 } else if (op == BC_JFORI) {
2218 dasm_put(Dst, 14822, -BCBIAS_J*4, BC_JLOOP); 2212 dasm_put(Dst, 14805, -BCBIAS_J*4, BC_JLOOP);
2219 } else if (op == BC_IFORL) { 2213 } else if (op == BC_IFORL) {
2220 dasm_put(Dst, 14836, -BCBIAS_J*4); 2214 dasm_put(Dst, 14819, -BCBIAS_J*4);
2221 } else { 2215 } else {
2222 dasm_put(Dst, 14832, BC_JLOOP); 2216 dasm_put(Dst, 14815, BC_JLOOP);
2223 } 2217 }
2224 dasm_put(Dst, 10847); 2218 dasm_put(Dst, 10847);
2225 if (sse) { 2219 if (sse) {
2226 dasm_put(Dst, 14846); 2220 dasm_put(Dst, 14829);
2227 } 2221 }
2228 break; 2222 break;
2229 2223
2230 case BC_ITERL: 2224 case BC_ITERL:
2231#if LJ_HASJIT 2225#if LJ_HASJIT
2232 dasm_put(Dst, 14665, HOTCOUNT_PCMASK, GG_DISP2HOT); 2226 dasm_put(Dst, 14648, HOTCOUNT_PCMASK, GG_DISP2HOT);
2233#endif 2227#endif
2234 break; 2228 break;
2235 2229
@@ -2238,18 +2232,18 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2238 break; 2232 break;
2239#endif 2233#endif
2240 case BC_IITERL: 2234 case BC_IITERL:
2241 dasm_put(Dst, 14857, LJ_TNIL); 2235 dasm_put(Dst, 14840, LJ_TNIL);
2242 if (op == BC_JITERL) { 2236 if (op == BC_JITERL) {
2243 dasm_put(Dst, 14872, BC_JLOOP); 2237 dasm_put(Dst, 14855, BC_JLOOP);
2244 } else { 2238 } else {
2245 dasm_put(Dst, 14886, -BCBIAS_J*4); 2239 dasm_put(Dst, 14869, -BCBIAS_J*4);
2246 } 2240 }
2247 dasm_put(Dst, 11144); 2241 dasm_put(Dst, 11144);
2248 break; 2242 break;
2249 2243
2250 case BC_LOOP: 2244 case BC_LOOP:
2251#if LJ_HASJIT 2245#if LJ_HASJIT
2252 dasm_put(Dst, 14665, HOTCOUNT_PCMASK, GG_DISP2HOT); 2246 dasm_put(Dst, 14648, HOTCOUNT_PCMASK, GG_DISP2HOT);
2253#endif 2247#endif
2254 break; 2248 break;
2255 2249
@@ -2259,12 +2253,12 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2259 2253
2260 case BC_JLOOP: 2254 case BC_JLOOP:
2261#if LJ_HASJIT 2255#if LJ_HASJIT
2262 dasm_put(Dst, 14902, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); 2256 dasm_put(Dst, 14885, DISPATCH_J(trace), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L));
2263#endif 2257#endif
2264 break; 2258 break;
2265 2259
2266 case BC_JMP: 2260 case BC_JMP:
2267 dasm_put(Dst, 14925, -BCBIAS_J*4); 2261 dasm_put(Dst, 14908, -BCBIAS_J*4);
2268 break; 2262 break;
2269 2263
2270 /* -- Function headers -------------------------------------------------- */ 2264 /* -- Function headers -------------------------------------------------- */
@@ -2278,7 +2272,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2278 2272
2279 case BC_FUNCF: 2273 case BC_FUNCF:
2280#if LJ_HASJIT 2274#if LJ_HASJIT
2281 dasm_put(Dst, 14949, HOTCOUNT_PCMASK, GG_DISP2HOT); 2275 dasm_put(Dst, 14932, HOTCOUNT_PCMASK, GG_DISP2HOT);
2282#endif 2276#endif
2283 case BC_FUNCV: /* NYI: compiled vararg functions. */ 2277 case BC_FUNCV: /* NYI: compiled vararg functions. */
2284 break; 2278 break;
@@ -2288,13 +2282,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2288 break; 2282 break;
2289#endif 2283#endif
2290 case BC_IFUNCF: 2284 case BC_IFUNCF:
2291 dasm_put(Dst, 14970, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams)); 2285 dasm_put(Dst, 14953, -4+PC2PROTO(k), Dt1(->maxstack), -4+PC2PROTO(numparams));
2292 if (op == BC_JFUNCF) { 2286 if (op == BC_JFUNCF) {
2293 dasm_put(Dst, 15000, BC_JLOOP); 2287 dasm_put(Dst, 14983, BC_JLOOP);
2294 } else { 2288 } else {
2295 dasm_put(Dst, 10849); 2289 dasm_put(Dst, 10849);
2296 } 2290 }
2297 dasm_put(Dst, 15009, LJ_TNIL); 2291 dasm_put(Dst, 14992, LJ_TNIL);
2298 break; 2292 break;
2299 2293
2300 case BC_JFUNCV: 2294 case BC_JFUNCV:
@@ -2305,30 +2299,30 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse)
2305 break; /* NYI: compiled vararg functions. */ 2299 break; /* NYI: compiled vararg functions. */
2306 2300
2307 case BC_IFUNCV: 2301 case BC_IFUNCV:
2308 dasm_put(Dst, 15031, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL); 2302 dasm_put(Dst, 15014, FRAME_VARG, Dt1(->maxstack), -4+PC2PROTO(numparams), LJ_TNIL);
2309 if (op == BC_JFUNCV) { 2303 if (op == BC_JFUNCV) {
2310 dasm_put(Dst, 15000, BC_JLOOP); 2304 dasm_put(Dst, 14983, BC_JLOOP);
2311 } else { 2305 } else {
2312 dasm_put(Dst, 15122, -4+PC2PROTO(k)); 2306 dasm_put(Dst, 15105, -4+PC2PROTO(k));
2313 } 2307 }
2314 dasm_put(Dst, 15144, LJ_TNIL); 2308 dasm_put(Dst, 15127, LJ_TNIL);
2315 break; 2309 break;
2316 2310
2317 case BC_FUNCC: 2311 case BC_FUNCC:
2318 case BC_FUNCCW: 2312 case BC_FUNCCW:
2319 dasm_put(Dst, 15166, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top)); 2313 dasm_put(Dst, 15149, Dt8(->f), Dt1(->base), 8*LUA_MINSTACK, Dt1(->maxstack), Dt1(->top));
2320 if (op == BC_FUNCC) { 2314 if (op == BC_FUNCC) {
2321 dasm_put(Dst, 15195); 2315 dasm_put(Dst, 15178);
2322 } else { 2316 } else {
2323 dasm_put(Dst, 15199); 2317 dasm_put(Dst, 15182);
2324 } 2318 }
2325 dasm_put(Dst, 15207, DISPATCH_GL(vmstate), ~LJ_VMST_C); 2319 dasm_put(Dst, 15190, DISPATCH_GL(vmstate), ~LJ_VMST_C);
2326 if (op == BC_FUNCC) { 2320 if (op == BC_FUNCC) {
2327 dasm_put(Dst, 15216); 2321 dasm_put(Dst, 15199);
2328 } else { 2322 } else {
2329 dasm_put(Dst, 15220, DISPATCH_GL(wrapf)); 2323 dasm_put(Dst, 15203, DISPATCH_GL(wrapf));
2330 } 2324 }
2331 dasm_put(Dst, 15225, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top)); 2325 dasm_put(Dst, 15208, DISPATCH_GL(vmstate), ~LJ_VMST_INTERP, Dt1(->base), Dt1(->top));
2332 break; 2326 break;
2333 2327
2334 /* ---------------------------------------------------------------------- */ 2328 /* ---------------------------------------------------------------------- */
@@ -2356,7 +2350,7 @@ static int build_backend(BuildCtx *ctx)
2356 2350
2357 build_subroutines(ctx, cmov, sse); 2351 build_subroutines(ctx, cmov, sse);
2358 2352
2359 dasm_put(Dst, 15250); 2353 dasm_put(Dst, 15233);
2360 for (op = 0; op < BC__MAX; op++) 2354 for (op = 0; op < BC__MAX; op++)
2361 build_ins(ctx, (BCOp)op, op, cmov, sse); 2355 build_ins(ctx, (BCOp)op, op, cmov, sse);
2362 2356
diff --git a/src/lib_base.c b/src/lib_base.c
index 9127b0d5..e5f71d9c 100644
--- a/src/lib_base.c
+++ b/src/lib_base.c
@@ -459,7 +459,7 @@ LJLIB_CF(coroutine_status)
459 if (co == L) s = "running"; 459 if (co == L) s = "running";
460 else if (co->status == LUA_YIELD) s = "suspended"; 460 else if (co->status == LUA_YIELD) s = "suspended";
461 else if (co->status != 0) s = "dead"; 461 else if (co->status != 0) s = "dead";
462 else if (co->base > co->stack+1) s = "normal"; 462 else if (co->base > tvref(co->stack)+1) s = "normal";
463 else if (co->top == co->base) s = "dead"; 463 else if (co->top == co->base) s = "dead";
464 else s = "suspended"; 464 else s = "suspended";
465 lua_pushstring(L, s); 465 lua_pushstring(L, s);
diff --git a/src/lj_api.c b/src/lj_api.c
index b9bac1d4..852c8c8b 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -121,9 +121,9 @@ LUA_API int lua_gettop(lua_State *L)
121LUA_API void lua_settop(lua_State *L, int idx) 121LUA_API void lua_settop(lua_State *L, int idx)
122{ 122{
123 if (idx >= 0) { 123 if (idx >= 0) {
124 api_check(L, idx <= L->maxstack - L->base); 124 api_check(L, idx <= tvref(L->maxstack) - L->base);
125 if (L->base + idx > L->top) { 125 if (L->base + idx > L->top) {
126 if (L->base + idx >= L->maxstack) 126 if (L->base + idx >= tvref(L->maxstack))
127 lj_state_growstack(L, (MSize)idx - (MSize)(L->top - L->base)); 127 lj_state_growstack(L, (MSize)idx - (MSize)(L->top - L->base));
128 do { setnilV(L->top++); } while (L->top < L->base + idx); 128 do { setnilV(L->top++); } while (L->top < L->base + idx);
129 } else { 129 } else {
diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c
index 5ced161b..491c5aa3 100644
--- a/src/lj_dispatch.c
+++ b/src/lj_dispatch.c
@@ -319,7 +319,8 @@ static void callhook(lua_State *L, int event, BCLine line)
319 lj_trace_abort(g); /* Abort recording on any hook call. */ 319 lj_trace_abort(g); /* Abort recording on any hook call. */
320 ar.event = event; 320 ar.event = event;
321 ar.currentline = line; 321 ar.currentline = line;
322 ar.i_ci = cast_int((L->base-1) - L->stack); /* Top frame, nextframe=NULL. */ 322 /* Top frame, nextframe = NULL. */
323 ar.i_ci = cast_int((L->base-1) - tvref(L->stack));
323 lj_state_checkstack(L, 1+LUA_MINSTACK); 324 lj_state_checkstack(L, 1+LUA_MINSTACK);
324 hook_enter(g); 325 hook_enter(g);
325 hookf(L, &ar); 326 hookf(L, &ar);
diff --git a/src/lj_err.c b/src/lj_err.c
index 9ae376ff..9c6de3aa 100644
--- a/src/lj_err.c
+++ b/src/lj_err.c
@@ -283,7 +283,7 @@ static TValue *findlocal(lua_State *L, const lua_Debug *ar,
283{ 283{
284 uint32_t offset = (uint32_t)ar->i_ci & 0xffff; 284 uint32_t offset = (uint32_t)ar->i_ci & 0xffff;
285 uint32_t size = (uint32_t)ar->i_ci >> 16; 285 uint32_t size = (uint32_t)ar->i_ci >> 16;
286 TValue *frame = L->stack + offset; 286 TValue *frame = tvref(L->stack) + offset;
287 TValue *nextframe = size ? frame + size : NULL; 287 TValue *nextframe = size ? frame + size : NULL;
288 GCfunc *fn = frame_func(frame); 288 GCfunc *fn = frame_func(frame);
289 BCPos pc = currentpc(L, fn, nextframe); 289 BCPos pc = currentpc(L, fn, nextframe);
@@ -335,9 +335,10 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
335 uint32_t offset = (uint32_t)ar->i_ci & 0xffff; 335 uint32_t offset = (uint32_t)ar->i_ci & 0xffff;
336 uint32_t size = (uint32_t)ar->i_ci >> 16; 336 uint32_t size = (uint32_t)ar->i_ci >> 16;
337 lua_assert(offset != 0); 337 lua_assert(offset != 0);
338 frame = L->stack + offset; 338 frame = tvref(L->stack) + offset;
339 if (size) nextframe = frame + size; 339 if (size) nextframe = frame + size;
340 lua_assert(frame<=L->maxstack && (!nextframe || nextframe<=L->maxstack)); 340 lua_assert(frame <= tvref(L->maxstack) &&
341 (!nextframe || nextframe <= tvref(L->maxstack)));
341 fn = frame_func(frame); 342 fn = frame_func(frame);
342 lua_assert(fn->c.gct == ~LJ_TFUNC); 343 lua_assert(fn->c.gct == ~LJ_TFUNC);
343 } 344 }
@@ -399,9 +400,9 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
399 400
400cTValue *lj_err_getframe(lua_State *L, int level, int *size) 401cTValue *lj_err_getframe(lua_State *L, int level, int *size)
401{ 402{
402 cTValue *frame, *nextframe; 403 cTValue *frame, *nextframe, *bot = tvref(L->stack);
403 /* Traverse frames backwards. */ 404 /* Traverse frames backwards. */
404 for (nextframe = frame = L->base-1; frame > L->stack; ) { 405 for (nextframe = frame = L->base-1; frame > bot; ) {
405 if (frame_gc(frame) == obj2gco(L)) 406 if (frame_gc(frame) == obj2gco(L))
406 level++; /* Skip dummy frames. See lj_meta_call(). */ 407 level++; /* Skip dummy frames. See lj_meta_call(). */
407 if (level-- == 0) { 408 if (level-- == 0) {
@@ -426,7 +427,7 @@ LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
426 int size; 427 int size;
427 cTValue *frame = lj_err_getframe(L, level, &size); 428 cTValue *frame = lj_err_getframe(L, level, &size);
428 if (frame) { 429 if (frame) {
429 ar->i_ci = (size << 16) + cast_int(frame - L->stack); 430 ar->i_ci = (size << 16) + cast_int(frame - tvref(L->stack));
430 return 1; 431 return 1;
431 } else { 432 } else {
432 ar->i_ci = level - size; 433 ar->i_ci = level - size;
@@ -465,7 +466,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode)
465 return cf; 466 return cf;
466 } 467 }
467 } 468 }
468 if (frame <= L->stack) 469 if (frame <= tvref(L->stack))
469 break; 470 break;
470 switch (frame_typep(frame)) { 471 switch (frame_typep(frame)) {
471 case FRAME_LUA: /* Lua frame. */ 472 case FRAME_LUA: /* Lua frame. */
@@ -524,7 +525,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode)
524 /* No C frame. */ 525 /* No C frame. */
525 if (errcode) { 526 if (errcode) {
526 L->cframe = NULL; 527 L->cframe = NULL;
527 L->base = L->stack+1; 528 L->base = tvref(L->stack)+1;
528 unwindstack(L, L->base); 529 unwindstack(L, L->base);
529 if (G(L)->panic) 530 if (G(L)->panic)
530 G(L)->panic(L); 531 G(L)->panic(L);
@@ -749,9 +750,9 @@ LJ_NOINLINE void lj_err_mem(lua_State *L)
749/* Find error function for runtime errors. Requires an extra stack traversal. */ 750/* Find error function for runtime errors. Requires an extra stack traversal. */
750static ptrdiff_t finderrfunc(lua_State *L) 751static ptrdiff_t finderrfunc(lua_State *L)
751{ 752{
752 TValue *frame = L->base-1; 753 cTValue *frame = L->base-1, *bot = tvref(L->stack);
753 void *cf = L->cframe; 754 void *cf = L->cframe;
754 while (frame > L->stack) { 755 while (frame > bot) {
755 lua_assert(cf != NULL); 756 lua_assert(cf != NULL);
756 while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ 757 while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */
757 if (frame >= restorestack(L, -cframe_nres(cf))) 758 if (frame >= restorestack(L, -cframe_nres(cf)))
diff --git a/src/lj_gc.c b/src/lj_gc.c
index 8147cb55..3e3d1ec5 100644
--- a/src/lj_gc.c
+++ b/src/lj_gc.c
@@ -267,9 +267,9 @@ static void gc_traverse_proto(global_State *g, GCproto *pt)
267/* Traverse the frame structure of a stack. */ 267/* Traverse the frame structure of a stack. */
268static MSize gc_traverse_frames(global_State *g, lua_State *th) 268static MSize gc_traverse_frames(global_State *g, lua_State *th)
269{ 269{
270 TValue *frame, *top = th->top-1; 270 TValue *frame, *top = th->top-1, *bot = tvref(th->stack);
271 /* Note: extra vararg frame not skipped, marks function twice (harmless). */ 271 /* Note: extra vararg frame not skipped, marks function twice (harmless). */
272 for (frame = th->base-1; frame > th->stack; frame = frame_prev(frame)) { 272 for (frame = th->base-1; frame > bot; frame = frame_prev(frame)) {
273 GCfunc *fn = frame_func(frame); 273 GCfunc *fn = frame_func(frame);
274 TValue *ftop = frame; 274 TValue *ftop = frame;
275 if (isluafunc(fn)) ftop += funcproto(fn)->framesize; 275 if (isluafunc(fn)) ftop += funcproto(fn)->framesize;
@@ -277,18 +277,18 @@ static MSize gc_traverse_frames(global_State *g, lua_State *th)
277 gc_markobj(g, frame_gc(frame)); /* Need to mark hidden function (or L). */ 277 gc_markobj(g, frame_gc(frame)); /* 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 > th->maxstack) top = th->maxstack; 280 if (top > tvref(th->maxstack)) top = tvref(th->maxstack);
281 return (MSize)(top - th->stack); /* Return minimum needed stack size. */ 281 return (MSize)(top - bot); /* Return minimum needed stack size. */
282} 282}
283 283
284/* Traverse a thread object. */ 284/* Traverse a thread object. */
285static void gc_traverse_thread(global_State *g, lua_State *th) 285static void gc_traverse_thread(global_State *g, lua_State *th)
286{ 286{
287 TValue *o, *top = th->top; 287 TValue *o, *top = th->top;
288 for (o = th->stack+1; o < top; o++) 288 for (o = tvref(th->stack)+1; o < top; o++)
289 gc_marktv(g, o); 289 gc_marktv(g, o);
290 if (g->gc.state == GCSatomic) { 290 if (g->gc.state == GCSatomic) {
291 top = th->stack + th->stacksize; 291 top = tvref(th->stack) + th->stacksize;
292 for (; o < top; o++) /* Clear unmarked slots. */ 292 for (; o < top; o++) /* Clear unmarked slots. */
293 setnilV(o); 293 setnilV(o);
294 } 294 }
diff --git a/src/lj_obj.h b/src/lj_obj.h
index 5eaa7145..4baa62d8 100644
--- a/src/lj_obj.h
+++ b/src/lj_obj.h
@@ -525,8 +525,8 @@ struct lua_State {
525 GCRef gclist; /* GC chain. */ 525 GCRef gclist; /* GC chain. */
526 TValue *base; /* Base of currently executing function. */ 526 TValue *base; /* Base of currently executing function. */
527 TValue *top; /* First free slot in the stack. */ 527 TValue *top; /* First free slot in the stack. */
528 TValue *maxstack; /* Last free slot in the stack. */ 528 MRef maxstack; /* Last free slot in the stack. */
529 TValue *stack; /* Stack base. */ 529 MRef stack; /* Stack base. */
530 GCRef openupval; /* List of open upvalues in the stack. */ 530 GCRef openupval; /* List of open upvalues in the stack. */
531 GCRef env; /* Thread environment (table of globals). */ 531 GCRef env; /* Thread environment (table of globals). */
532 void *cframe; /* End of C stack frame chain. */ 532 void *cframe; /* End of C stack frame chain. */
diff --git a/src/lj_record.c b/src/lj_record.c
index 2fba6b6b..2e411632 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -1062,7 +1062,8 @@ static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val)
1062 uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff); 1062 uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff);
1063 if (!uvp->closed) { 1063 if (!uvp->closed) {
1064 /* In current stack? */ 1064 /* In current stack? */
1065 if (uvval(uvp) >= J->L->stack && uvval(uvp) < J->L->maxstack) { 1065 if (uvval(uvp) >= tvref(J->L->stack) &&
1066 uvval(uvp) < tvref(J->L->maxstack)) {
1066 int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot)); 1067 int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot));
1067 if (slot >= 0) { /* Aliases an SSA slot? */ 1068 if (slot >= 0) { /* Aliases an SSA slot? */
1068 slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */ 1069 slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */
diff --git a/src/lj_snap.c b/src/lj_snap.c
index 96badaaa..7c26bfb9 100644
--- a/src/lj_snap.c
+++ b/src/lj_snap.c
@@ -231,7 +231,7 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
231 setcframe_pc(cframe_raw(L->cframe), pc+1); 231 setcframe_pc(cframe_raw(L->cframe), pc+1);
232 232
233 /* Make sure the stack is big enough for the slots from the snapshot. */ 233 /* Make sure the stack is big enough for the slots from the snapshot. */
234 if (LJ_UNLIKELY(L->base + nslots > L->maxstack)) { 234 if (LJ_UNLIKELY(L->base + nslots > tvref(L->maxstack))) {
235 L->top = curr_topL(L); 235 L->top = curr_topL(L);
236 lj_state_growstack(L, nslots - curr_proto(L)->framesize); 236 lj_state_growstack(L, nslots - curr_proto(L)->framesize);
237 } 237 }
@@ -255,10 +255,10 @@ const BCIns *lj_snap_restore(jit_State *J, void *exptr)
255 if (isluafunc(fn)) { 255 if (isluafunc(fn)) {
256 MSize framesize = funcproto(fn)->framesize; 256 MSize framesize = funcproto(fn)->framesize;
257 L->base = ++o; 257 L->base = ++o;
258 if (LJ_UNLIKELY(o + framesize > L->maxstack)) { /* Grow again? */ 258 if (LJ_UNLIKELY(o + framesize > tvref(L->maxstack))) {
259 ptrdiff_t fsave = savestack(L, frame); 259 ptrdiff_t fsave = savestack(L, frame);
260 L->top = o; 260 L->top = o;
261 lj_state_growstack(L, framesize); 261 lj_state_growstack(L, framesize); /* Grow again. */
262 frame = restorestack(L, fsave); 262 frame = restorestack(L, fsave);
263 } 263 }
264 } 264 }
diff --git a/src/lj_state.c b/src/lj_state.c
index 87f2cfe9..f7647f33 100644
--- a/src/lj_state.c
+++ b/src/lj_state.c
@@ -52,16 +52,18 @@
52/* Resize stack slots and adjust pointers in state. */ 52/* Resize stack slots and adjust pointers in state. */
53static void resizestack(lua_State *L, MSize n) 53static void resizestack(lua_State *L, MSize n)
54{ 54{
55 TValue *st, *oldst = L->stack; 55 TValue *st, *oldst = tvref(L->stack);
56 ptrdiff_t delta; 56 ptrdiff_t delta;
57 MSize oldsize = L->stacksize; 57 MSize oldsize = L->stacksize;
58 MSize realsize = n + 1 + LJ_STACK_EXTRA; 58 MSize realsize = n + 1 + LJ_STACK_EXTRA;
59 GCobj *up; 59 GCobj *up;
60 lua_assert((MSize)(L->maxstack-L->stack) == L->stacksize-LJ_STACK_EXTRA-1); 60 lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1);
61 lj_mem_reallocvec(L, L->stack, L->stacksize, realsize, TValue); 61 st = (TValue *)lj_mem_realloc(L, tvref(L->stack),
62 st = L->stack; 62 (MSize)(L->stacksize*sizeof(TValue)),
63 (MSize)(realsize*sizeof(TValue)));
64 setmref(L->stack, st);
63 delta = (char *)st - (char *)oldst; 65 delta = (char *)st - (char *)oldst;
64 L->maxstack = st + n; 66 setmref(L->maxstack, st + n);
65 while (oldsize < realsize) /* Clear new slots. */ 67 while (oldsize < realsize) /* Clear new slots. */
66 setnilV(st + oldsize++); 68 setnilV(st + oldsize++);
67 L->stacksize = realsize; 69 L->stacksize = realsize;
@@ -76,7 +78,7 @@ static void resizestack(lua_State *L, MSize n)
76/* Relimit stack after error, in case the limit was overdrawn. */ 78/* Relimit stack after error, in case the limit was overdrawn. */
77void lj_state_relimitstack(lua_State *L) 79void lj_state_relimitstack(lua_State *L)
78{ 80{
79 if (L->stacksize > LJ_STACK_MAXEX && L->top - L->stack < LJ_STACK_MAX-1) 81 if (L->stacksize > LJ_STACK_MAXEX && L->top-tvref(L->stack) < LJ_STACK_MAX-1)
80 resizestack(L, LJ_STACK_MAX); 82 resizestack(L, LJ_STACK_MAX);
81} 83}
82 84
@@ -118,11 +120,11 @@ void LJ_FASTCALL lj_state_growstack1(lua_State *L)
118/* Allocate basic stack for new state. */ 120/* Allocate basic stack for new state. */
119static void stack_init(lua_State *L1, lua_State *L) 121static void stack_init(lua_State *L1, lua_State *L)
120{ 122{
121 TValue *st, *stend; 123 TValue *stend, *st = lj_mem_newvec(L, LJ_STACK_START+LJ_STACK_EXTRA, TValue);
122 L1->stack = st = lj_mem_newvec(L, LJ_STACK_START + LJ_STACK_EXTRA, TValue); 124 setmref(L1->stack, st);
123 L1->stacksize = LJ_STACK_START + LJ_STACK_EXTRA; 125 L1->stacksize = LJ_STACK_START + LJ_STACK_EXTRA;
124 stend = st + L1->stacksize; 126 stend = st + L1->stacksize;
125 L1->maxstack = stend - LJ_STACK_EXTRA - 1; 127 setmref(L1->maxstack, stend - LJ_STACK_EXTRA - 1);
126 L1->base = L1->top = st+1; 128 L1->base = L1->top = st+1;
127 setthreadV(L1, st, L1); /* Needed for curr_funcisL() on empty stack. */ 129 setthreadV(L1, st, L1); /* Needed for curr_funcisL() on empty stack. */
128 while (st < stend) /* Clear new slots. */ 130 while (st < stend) /* Clear new slots. */
@@ -162,14 +164,14 @@ static void close_state(lua_State *L)
162 } else 164 } else
163#endif 165#endif
164 { 166 {
165 lj_func_closeuv(L, L->stack); 167 lj_func_closeuv(L, tvref(L->stack));
166 lj_gc_freeall(g); 168 lj_gc_freeall(g);
167 lua_assert(gcref(g->gc.root) == obj2gco(L)); 169 lua_assert(gcref(g->gc.root) == obj2gco(L));
168 lua_assert(g->strnum == 0); 170 lua_assert(g->strnum == 0);
169 lj_trace_freestate(g); 171 lj_trace_freestate(g);
170 lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); 172 lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
171 lj_str_freebuf(g, &g->tmpbuf); 173 lj_str_freebuf(g, &g->tmpbuf);
172 lj_mem_freevec(g, L->stack, L->stacksize, TValue); 174 lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue);
173 lua_assert(g->gc.total == sizeof(GG_State)); 175 lua_assert(g->gc.total == sizeof(GG_State));
174 g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); 176 g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0);
175 } 177 }
@@ -234,7 +236,7 @@ LUA_API void lua_close(lua_State *L)
234{ 236{
235 global_State *g = G(L); 237 global_State *g = G(L);
236 L = mainthread(g); /* Only the main thread can be closed. */ 238 L = mainthread(g); /* Only the main thread can be closed. */
237 lj_func_closeuv(L, L->stack); 239 lj_func_closeuv(L, tvref(L->stack));
238 lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */ 240 lj_gc_separateudata(g, 1); /* Separate udata which have GC metamethods. */
239#if LJ_HASJIT 241#if LJ_HASJIT
240 G2J(g)->flags &= ~JIT_F_ON; 242 G2J(g)->flags &= ~JIT_F_ON;
@@ -245,7 +247,7 @@ LUA_API void lua_close(lua_State *L)
245 hook_enter(g); 247 hook_enter(g);
246 L->status = 0; 248 L->status = 0;
247 L->cframe = NULL; 249 L->cframe = NULL;
248 L->base = L->top = L->stack + 1; 250 L->base = L->top = tvref(L->stack) + 1;
249 } while (lj_vm_cpcall(L, NULL, NULL, cpfinalize) != 0); 251 } while (lj_vm_cpcall(L, NULL, NULL, cpfinalize) != 0);
250 close_state(L); 252 close_state(L);
251} 253}
@@ -257,7 +259,7 @@ lua_State *lj_state_new(lua_State *L)
257 L1->dummy_ffid = FF_C; 259 L1->dummy_ffid = FF_C;
258 L1->status = 0; 260 L1->status = 0;
259 L1->stacksize = 0; 261 L1->stacksize = 0;
260 L1->stack = NULL; 262 setmref(L1->stack, NULL);
261 L1->cframe = NULL; 263 L1->cframe = NULL;
262 /* NOBARRIER: The lua_State is new (marked white). */ 264 /* NOBARRIER: The lua_State is new (marked white). */
263 setgcrefnull(L1->openupval); 265 setgcrefnull(L1->openupval);
@@ -271,9 +273,9 @@ lua_State *lj_state_new(lua_State *L)
271void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) 273void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L)
272{ 274{
273 lua_assert(L != mainthread(g)); 275 lua_assert(L != mainthread(g));
274 lj_func_closeuv(L, L->stack); 276 lj_func_closeuv(L, tvref(L->stack));
275 lua_assert(gcref(L->openupval) == NULL); 277 lua_assert(gcref(L->openupval) == NULL);
276 lj_mem_freevec(g, L->stack, L->stacksize, TValue); 278 lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue);
277 lj_mem_freet(g, L); 279 lj_mem_freet(g, L);
278} 280}
279 281
diff --git a/src/lj_state.h b/src/lj_state.h
index cd2f216d..d5b9d888 100644
--- a/src/lj_state.h
+++ b/src/lj_state.h
@@ -9,10 +9,10 @@
9#include "lj_obj.h" 9#include "lj_obj.h"
10 10
11#define incr_top(L) \ 11#define incr_top(L) \
12 (++L->top >= L->maxstack && (lj_state_growstack1(L), 0)) 12 (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0))
13 13
14#define savestack(L, p) ((char *)(p) - (char *)L->stack) 14#define savestack(L, p) ((char *)(p) - mref(L->stack, char))
15#define restorestack(L, n) ((TValue *)((char *)L->stack + (n))) 15#define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n)))
16 16
17LJ_FUNC void lj_state_relimitstack(lua_State *L); 17LJ_FUNC void lj_state_relimitstack(lua_State *L);
18LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); 18LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used);
@@ -21,7 +21,8 @@ LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L);
21 21
22static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) 22static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need)
23{ 23{
24 if ((MSize)((char *)L->maxstack-(char *)L->top) <= need*(MSize)sizeof(TValue)) 24 if ((MSize)(mref(L->maxstack, char) - (char *)L->top) <=
25 need*(MSize)sizeof(TValue))
25 lj_state_growstack(L, need); 26 lj_state_growstack(L, need);
26} 27}
27 28