aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-27 18:30:38 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-12-27 18:30:38 -0200
commit50e2eb89541bf006525e1b060454203a644368d8 (patch)
treec6b447818def3105bb0fdf5b301cf05b07c54e22
parent94eb37dc736a470ae976c5a0afab7425581aabf5 (diff)
downloadlua-50e2eb89541bf006525e1b060454203a644368d8.tar.gz
lua-50e2eb89541bf006525e1b060454203a644368d8.tar.bz2
lua-50e2eb89541bf006525e1b060454203a644368d8.zip
change in macro 'vmcase', avoding code inside it. (Code inside the
macro harms tools such as debuggers.)
-rw-r--r--lvm.c239
1 files changed, 142 insertions, 97 deletions
diff --git a/lvm.c b/lvm.c
index 8944da01..1b4357fd 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.230 2014/11/21 12:15:00 roberto Exp roberto $ 2** $Id: lvm.c,v 2.231 2014/12/19 13:36:32 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -644,8 +644,8 @@ void luaV_finishOp (lua_State *L) {
644 644
645 645
646#define vmdispatch(o) switch(o) 646#define vmdispatch(o) switch(o)
647#define vmcase(l,b) case l: {b} break; 647#define vmcase(l) case l:
648#define vmcasenb(l,b) case l: {b} /* nb = no break */ 648#define vmbreak break
649 649
650void luaV_execute (lua_State *L) { 650void luaV_execute (lua_State *L) {
651 CallInfo *ci = L->ci; 651 CallInfo *ci = L->ci;
@@ -670,53 +670,64 @@ void luaV_execute (lua_State *L) {
670 lua_assert(base == ci->u.l.base); 670 lua_assert(base == ci->u.l.base);
671 lua_assert(base <= L->top && L->top < L->stack + L->stacksize); 671 lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
672 vmdispatch (GET_OPCODE(i)) { 672 vmdispatch (GET_OPCODE(i)) {
673 vmcase(OP_MOVE, 673 vmcase(OP_MOVE) {
674 setobjs2s(L, ra, RB(i)); 674 setobjs2s(L, ra, RB(i));
675 ) 675 vmbreak;
676 vmcase(OP_LOADK, 676 }
677 vmcase(OP_LOADK) {
677 TValue *rb = k + GETARG_Bx(i); 678 TValue *rb = k + GETARG_Bx(i);
678 setobj2s(L, ra, rb); 679 setobj2s(L, ra, rb);
679 ) 680 vmbreak;
680 vmcase(OP_LOADKX, 681 }
682 vmcase(OP_LOADKX) {
681 TValue *rb; 683 TValue *rb;
682 lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); 684 lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG);
683 rb = k + GETARG_Ax(*ci->u.l.savedpc++); 685 rb = k + GETARG_Ax(*ci->u.l.savedpc++);
684 setobj2s(L, ra, rb); 686 setobj2s(L, ra, rb);
685 ) 687 vmbreak;
686 vmcase(OP_LOADBOOL, 688 }
689 vmcase(OP_LOADBOOL) {
687 setbvalue(ra, GETARG_B(i)); 690 setbvalue(ra, GETARG_B(i));
688 if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ 691 if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */
689 ) 692 vmbreak;
690 vmcase(OP_LOADNIL, 693 }
694 vmcase(OP_LOADNIL) {
691 int b = GETARG_B(i); 695 int b = GETARG_B(i);
692 do { 696 do {
693 setnilvalue(ra++); 697 setnilvalue(ra++);
694 } while (b--); 698 } while (b--);
695 ) 699 vmbreak;
696 vmcase(OP_GETUPVAL, 700 }
701 vmcase(OP_GETUPVAL) {
697 int b = GETARG_B(i); 702 int b = GETARG_B(i);
698 setobj2s(L, ra, cl->upvals[b]->v); 703 setobj2s(L, ra, cl->upvals[b]->v);
699 ) 704 vmbreak;
700 vmcase(OP_GETTABUP, 705 }
706 vmcase(OP_GETTABUP) {
701 int b = GETARG_B(i); 707 int b = GETARG_B(i);
702 Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra)); 708 Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra));
703 ) 709 vmbreak;
704 vmcase(OP_GETTABLE, 710 }
711 vmcase(OP_GETTABLE) {
705 Protect(luaV_gettable(L, RB(i), RKC(i), ra)); 712 Protect(luaV_gettable(L, RB(i), RKC(i), ra));
706 ) 713 vmbreak;
707 vmcase(OP_SETTABUP, 714 }
715 vmcase(OP_SETTABUP) {
708 int a = GETARG_A(i); 716 int a = GETARG_A(i);
709 Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i))); 717 Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i)));
710 ) 718 vmbreak;
711 vmcase(OP_SETUPVAL, 719 }
720 vmcase(OP_SETUPVAL) {
712 UpVal *uv = cl->upvals[GETARG_B(i)]; 721 UpVal *uv = cl->upvals[GETARG_B(i)];
713 setobj(L, uv->v, ra); 722 setobj(L, uv->v, ra);
714 luaC_upvalbarrier(L, uv); 723 luaC_upvalbarrier(L, uv);
715 ) 724 vmbreak;
716 vmcase(OP_SETTABLE, 725 }
726 vmcase(OP_SETTABLE) {
717 Protect(luaV_settable(L, ra, RKB(i), RKC(i))); 727 Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
718 ) 728 vmbreak;
719 vmcase(OP_NEWTABLE, 729 }
730 vmcase(OP_NEWTABLE) {
720 int b = GETARG_B(i); 731 int b = GETARG_B(i);
721 int c = GETARG_C(i); 732 int c = GETARG_C(i);
722 Table *t = luaH_new(L); 733 Table *t = luaH_new(L);
@@ -724,13 +735,15 @@ void luaV_execute (lua_State *L) {
724 if (b != 0 || c != 0) 735 if (b != 0 || c != 0)
725 luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); 736 luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c));
726 checkGC(L, ra + 1); 737 checkGC(L, ra + 1);
727 ) 738 vmbreak;
728 vmcase(OP_SELF, 739 }
740 vmcase(OP_SELF) {
729 StkId rb = RB(i); 741 StkId rb = RB(i);
730 setobjs2s(L, ra+1, rb); 742 setobjs2s(L, ra+1, rb);
731 Protect(luaV_gettable(L, rb, RKC(i), ra)); 743 Protect(luaV_gettable(L, rb, RKC(i), ra));
732 ) 744 vmbreak;
733 vmcase(OP_ADD, 745 }
746 vmcase(OP_ADD) {
734 TValue *rb = RKB(i); 747 TValue *rb = RKB(i);
735 TValue *rc = RKC(i); 748 TValue *rc = RKC(i);
736 lua_Number nb; lua_Number nc; 749 lua_Number nb; lua_Number nc;
@@ -742,8 +755,9 @@ void luaV_execute (lua_State *L) {
742 setfltvalue(ra, luai_numadd(L, nb, nc)); 755 setfltvalue(ra, luai_numadd(L, nb, nc));
743 } 756 }
744 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); } 757 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); }
745 ) 758 vmbreak;
746 vmcase(OP_SUB, 759 }
760 vmcase(OP_SUB) {
747 TValue *rb = RKB(i); 761 TValue *rb = RKB(i);
748 TValue *rc = RKC(i); 762 TValue *rc = RKC(i);
749 lua_Number nb; lua_Number nc; 763 lua_Number nb; lua_Number nc;
@@ -755,8 +769,9 @@ void luaV_execute (lua_State *L) {
755 setfltvalue(ra, luai_numsub(L, nb, nc)); 769 setfltvalue(ra, luai_numsub(L, nb, nc));
756 } 770 }
757 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); } 771 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); }
758 ) 772 vmbreak;
759 vmcase(OP_MUL, 773 }
774 vmcase(OP_MUL) {
760 TValue *rb = RKB(i); 775 TValue *rb = RKB(i);
761 TValue *rc = RKC(i); 776 TValue *rc = RKC(i);
762 lua_Number nb; lua_Number nc; 777 lua_Number nb; lua_Number nc;
@@ -768,8 +783,9 @@ void luaV_execute (lua_State *L) {
768 setfltvalue(ra, luai_nummul(L, nb, nc)); 783 setfltvalue(ra, luai_nummul(L, nb, nc));
769 } 784 }
770 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); } 785 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); }
771 ) 786 vmbreak;
772 vmcase(OP_DIV, /* float division (always with floats) */ 787 }
788 vmcase(OP_DIV) { /* float division (always with floats) */
773 TValue *rb = RKB(i); 789 TValue *rb = RKB(i);
774 TValue *rc = RKC(i); 790 TValue *rc = RKC(i);
775 lua_Number nb; lua_Number nc; 791 lua_Number nb; lua_Number nc;
@@ -777,8 +793,9 @@ void luaV_execute (lua_State *L) {
777 setfltvalue(ra, luai_numdiv(L, nb, nc)); 793 setfltvalue(ra, luai_numdiv(L, nb, nc));
778 } 794 }
779 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); } 795 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); }
780 ) 796 vmbreak;
781 vmcase(OP_BAND, 797 }
798 vmcase(OP_BAND) {
782 TValue *rb = RKB(i); 799 TValue *rb = RKB(i);
783 TValue *rc = RKC(i); 800 TValue *rc = RKC(i);
784 lua_Integer ib; lua_Integer ic; 801 lua_Integer ib; lua_Integer ic;
@@ -786,8 +803,9 @@ void luaV_execute (lua_State *L) {
786 setivalue(ra, intop(&, ib, ic)); 803 setivalue(ra, intop(&, ib, ic));
787 } 804 }
788 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); } 805 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); }
789 ) 806 vmbreak;
790 vmcase(OP_BOR, 807 }
808 vmcase(OP_BOR) {
791 TValue *rb = RKB(i); 809 TValue *rb = RKB(i);
792 TValue *rc = RKC(i); 810 TValue *rc = RKC(i);
793 lua_Integer ib; lua_Integer ic; 811 lua_Integer ib; lua_Integer ic;
@@ -795,8 +813,9 @@ void luaV_execute (lua_State *L) {
795 setivalue(ra, intop(|, ib, ic)); 813 setivalue(ra, intop(|, ib, ic));
796 } 814 }
797 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); } 815 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); }
798 ) 816 vmbreak;
799 vmcase(OP_BXOR, 817 }
818 vmcase(OP_BXOR) {
800 TValue *rb = RKB(i); 819 TValue *rb = RKB(i);
801 TValue *rc = RKC(i); 820 TValue *rc = RKC(i);
802 lua_Integer ib; lua_Integer ic; 821 lua_Integer ib; lua_Integer ic;
@@ -804,8 +823,9 @@ void luaV_execute (lua_State *L) {
804 setivalue(ra, intop(^, ib, ic)); 823 setivalue(ra, intop(^, ib, ic));
805 } 824 }
806 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); } 825 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); }
807 ) 826 vmbreak;
808 vmcase(OP_SHL, 827 }
828 vmcase(OP_SHL) {
809 TValue *rb = RKB(i); 829 TValue *rb = RKB(i);
810 TValue *rc = RKC(i); 830 TValue *rc = RKC(i);
811 lua_Integer ib; lua_Integer ic; 831 lua_Integer ib; lua_Integer ic;
@@ -813,8 +833,9 @@ void luaV_execute (lua_State *L) {
813 setivalue(ra, luaV_shiftl(ib, ic)); 833 setivalue(ra, luaV_shiftl(ib, ic));
814 } 834 }
815 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); } 835 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); }
816 ) 836 vmbreak;
817 vmcase(OP_SHR, 837 }
838 vmcase(OP_SHR) {
818 TValue *rb = RKB(i); 839 TValue *rb = RKB(i);
819 TValue *rc = RKC(i); 840 TValue *rc = RKC(i);
820 lua_Integer ib; lua_Integer ic; 841 lua_Integer ib; lua_Integer ic;
@@ -822,8 +843,9 @@ void luaV_execute (lua_State *L) {
822 setivalue(ra, luaV_shiftl(ib, -ic)); 843 setivalue(ra, luaV_shiftl(ib, -ic));
823 } 844 }
824 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); } 845 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); }
825 ) 846 vmbreak;
826 vmcase(OP_MOD, 847 }
848 vmcase(OP_MOD) {
827 TValue *rb = RKB(i); 849 TValue *rb = RKB(i);
828 TValue *rc = RKC(i); 850 TValue *rc = RKC(i);
829 lua_Number nb; lua_Number nc; 851 lua_Number nb; lua_Number nc;
@@ -837,8 +859,9 @@ void luaV_execute (lua_State *L) {
837 setfltvalue(ra, m); 859 setfltvalue(ra, m);
838 } 860 }
839 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); } 861 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); }
840 ) 862 vmbreak;
841 vmcase(OP_IDIV, /* floor division */ 863 }
864 vmcase(OP_IDIV) { /* floor division */
842 TValue *rb = RKB(i); 865 TValue *rb = RKB(i);
843 TValue *rc = RKC(i); 866 TValue *rc = RKC(i);
844 lua_Number nb; lua_Number nc; 867 lua_Number nb; lua_Number nc;
@@ -850,8 +873,9 @@ void luaV_execute (lua_State *L) {
850 setfltvalue(ra, luai_numidiv(L, nb, nc)); 873 setfltvalue(ra, luai_numidiv(L, nb, nc));
851 } 874 }
852 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); } 875 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); }
853 ) 876 vmbreak;
854 vmcase(OP_POW, 877 }
878 vmcase(OP_POW) {
855 TValue *rb = RKB(i); 879 TValue *rb = RKB(i);
856 TValue *rc = RKC(i); 880 TValue *rc = RKC(i);
857 lua_Number nb; lua_Number nc; 881 lua_Number nb; lua_Number nc;
@@ -859,8 +883,9 @@ void luaV_execute (lua_State *L) {
859 setfltvalue(ra, luai_numpow(L, nb, nc)); 883 setfltvalue(ra, luai_numpow(L, nb, nc));
860 } 884 }
861 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); } 885 else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); }
862 ) 886 vmbreak;
863 vmcase(OP_UNM, 887 }
888 vmcase(OP_UNM) {
864 TValue *rb = RB(i); 889 TValue *rb = RB(i);
865 lua_Number nb; 890 lua_Number nb;
866 if (ttisinteger(rb)) { 891 if (ttisinteger(rb)) {
@@ -873,8 +898,9 @@ void luaV_execute (lua_State *L) {
873 else { 898 else {
874 Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); 899 Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
875 } 900 }
876 ) 901 vmbreak;
877 vmcase(OP_BNOT, 902 }
903 vmcase(OP_BNOT) {
878 TValue *rb = RB(i); 904 TValue *rb = RB(i);
879 lua_Integer ib; 905 lua_Integer ib;
880 if (tointeger(rb, &ib)) { 906 if (tointeger(rb, &ib)) {
@@ -883,16 +909,19 @@ void luaV_execute (lua_State *L) {
883 else { 909 else {
884 Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); 910 Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
885 } 911 }
886 ) 912 vmbreak;
887 vmcase(OP_NOT, 913 }
914 vmcase(OP_NOT) {
888 TValue *rb = RB(i); 915 TValue *rb = RB(i);
889 int res = l_isfalse(rb); /* next assignment may change this value */ 916 int res = l_isfalse(rb); /* next assignment may change this value */
890 setbvalue(ra, res); 917 setbvalue(ra, res);
891 ) 918 vmbreak;
892 vmcase(OP_LEN, 919 }
920 vmcase(OP_LEN) {
893 Protect(luaV_objlen(L, ra, RB(i))); 921 Protect(luaV_objlen(L, ra, RB(i)));
894 ) 922 vmbreak;
895 vmcase(OP_CONCAT, 923 }
924 vmcase(OP_CONCAT) {
896 int b = GETARG_B(i); 925 int b = GETARG_B(i);
897 int c = GETARG_C(i); 926 int c = GETARG_C(i);
898 StkId rb; 927 StkId rb;
@@ -903,11 +932,13 @@ void luaV_execute (lua_State *L) {
903 setobjs2s(L, ra, rb); 932 setobjs2s(L, ra, rb);
904 checkGC(L, (ra >= rb ? ra + 1 : rb)); 933 checkGC(L, (ra >= rb ? ra + 1 : rb));
905 L->top = ci->top; /* restore top */ 934 L->top = ci->top; /* restore top */
906 ) 935 vmbreak;
907 vmcase(OP_JMP, 936 }
937 vmcase(OP_JMP) {
908 dojump(ci, i, 0); 938 dojump(ci, i, 0);
909 ) 939 vmbreak;
910 vmcase(OP_EQ, 940 }
941 vmcase(OP_EQ) {
911 TValue *rb = RKB(i); 942 TValue *rb = RKB(i);
912 TValue *rc = RKC(i); 943 TValue *rc = RKC(i);
913 Protect( 944 Protect(
@@ -916,30 +947,34 @@ void luaV_execute (lua_State *L) {
916 else 947 else
917 donextjump(ci); 948 donextjump(ci);
918 ) 949 )
919 ) 950 vmbreak;
920 vmcase(OP_LT, 951 }
952 vmcase(OP_LT) {
921 Protect( 953 Protect(
922 if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) 954 if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i))
923 ci->u.l.savedpc++; 955 ci->u.l.savedpc++;
924 else 956 else
925 donextjump(ci); 957 donextjump(ci);
926 ) 958 )
927 ) 959 vmbreak;
928 vmcase(OP_LE, 960 }
961 vmcase(OP_LE) {
929 Protect( 962 Protect(
930 if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) 963 if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i))
931 ci->u.l.savedpc++; 964 ci->u.l.savedpc++;
932 else 965 else
933 donextjump(ci); 966 donextjump(ci);
934 ) 967 )
935 ) 968 vmbreak;
936 vmcase(OP_TEST, 969 }
970 vmcase(OP_TEST) {
937 if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) 971 if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra))
938 ci->u.l.savedpc++; 972 ci->u.l.savedpc++;
939 else 973 else
940 donextjump(ci); 974 donextjump(ci);
941 ) 975 vmbreak;
942 vmcase(OP_TESTSET, 976 }
977 vmcase(OP_TESTSET) {
943 TValue *rb = RB(i); 978 TValue *rb = RB(i);
944 if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) 979 if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb))
945 ci->u.l.savedpc++; 980 ci->u.l.savedpc++;
@@ -947,8 +982,9 @@ void luaV_execute (lua_State *L) {
947 setobjs2s(L, ra, rb); 982 setobjs2s(L, ra, rb);
948 donextjump(ci); 983 donextjump(ci);
949 } 984 }
950 ) 985 vmbreak;
951 vmcase(OP_CALL, 986 }
987 vmcase(OP_CALL) {
952 int b = GETARG_B(i); 988 int b = GETARG_B(i);
953 int nresults = GETARG_C(i) - 1; 989 int nresults = GETARG_C(i) - 1;
954 if (b != 0) L->top = ra+b; /* else previous instruction set top */ 990 if (b != 0) L->top = ra+b; /* else previous instruction set top */
@@ -961,8 +997,9 @@ void luaV_execute (lua_State *L) {
961 ci->callstatus |= CIST_REENTRY; 997 ci->callstatus |= CIST_REENTRY;
962 goto newframe; /* restart luaV_execute over new Lua function */ 998 goto newframe; /* restart luaV_execute over new Lua function */
963 } 999 }
964 ) 1000 vmbreak;
965 vmcase(OP_TAILCALL, 1001 }
1002 vmcase(OP_TAILCALL) {
966 int b = GETARG_B(i); 1003 int b = GETARG_B(i);
967 if (b != 0) L->top = ra+b; /* else previous instruction set top */ 1004 if (b != 0) L->top = ra+b; /* else previous instruction set top */
968 lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); 1005 lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
@@ -990,8 +1027,9 @@ void luaV_execute (lua_State *L) {
990 lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); 1027 lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize);
991 goto newframe; /* restart luaV_execute over new Lua function */ 1028 goto newframe; /* restart luaV_execute over new Lua function */
992 } 1029 }
993 ) 1030 vmbreak;
994 vmcasenb(OP_RETURN, 1031 }
1032 vmcase(OP_RETURN) {
995 int b = GETARG_B(i); 1033 int b = GETARG_B(i);
996 if (b != 0) L->top = ra+b-1; 1034 if (b != 0) L->top = ra+b-1;
997 if (cl->p->sizep > 0) luaF_close(L, base); 1035 if (cl->p->sizep > 0) luaF_close(L, base);
@@ -1005,8 +1043,8 @@ void luaV_execute (lua_State *L) {
1005 lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); 1043 lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL);
1006 goto newframe; /* restart luaV_execute over new Lua function */ 1044 goto newframe; /* restart luaV_execute over new Lua function */
1007 } 1045 }
1008 ) 1046 }
1009 vmcase(OP_FORLOOP, 1047 vmcase(OP_FORLOOP) {
1010 if (ttisinteger(ra)) { /* integer loop? */ 1048 if (ttisinteger(ra)) { /* integer loop? */
1011 lua_Integer step = ivalue(ra + 2); 1049 lua_Integer step = ivalue(ra + 2);
1012 lua_Integer idx = ivalue(ra) + step; /* increment index */ 1050 lua_Integer idx = ivalue(ra) + step; /* increment index */
@@ -1028,8 +1066,9 @@ void luaV_execute (lua_State *L) {
1028 setfltvalue(ra + 3, idx); /* ...and external index */ 1066 setfltvalue(ra + 3, idx); /* ...and external index */
1029 } 1067 }
1030 } 1068 }
1031 ) 1069 vmbreak;
1032 vmcase(OP_FORPREP, 1070 }
1071 vmcase(OP_FORPREP) {
1033 TValue *init = ra; 1072 TValue *init = ra;
1034 TValue *plimit = ra + 1; 1073 TValue *plimit = ra + 1;
1035 TValue *pstep = ra + 2; 1074 TValue *pstep = ra + 2;
@@ -1055,8 +1094,9 @@ void luaV_execute (lua_State *L) {
1055 setfltvalue(init, luai_numsub(L, ninit, nstep)); 1094 setfltvalue(init, luai_numsub(L, ninit, nstep));
1056 } 1095 }
1057 ci->u.l.savedpc += GETARG_sBx(i); 1096 ci->u.l.savedpc += GETARG_sBx(i);
1058 ) 1097 vmbreak;
1059 vmcasenb(OP_TFORCALL, 1098 }
1099 vmcase(OP_TFORCALL) {
1060 StkId cb = ra + 3; /* call base */ 1100 StkId cb = ra + 3; /* call base */
1061 setobjs2s(L, cb+2, ra+2); 1101 setobjs2s(L, cb+2, ra+2);
1062 setobjs2s(L, cb+1, ra+1); 1102 setobjs2s(L, cb+1, ra+1);
@@ -1068,15 +1108,16 @@ void luaV_execute (lua_State *L) {
1068 ra = RA(i); 1108 ra = RA(i);
1069 lua_assert(GET_OPCODE(i) == OP_TFORLOOP); 1109 lua_assert(GET_OPCODE(i) == OP_TFORLOOP);
1070 goto l_tforloop; 1110 goto l_tforloop;
1071 ) 1111 }
1072 vmcase(OP_TFORLOOP, 1112 vmcase(OP_TFORLOOP) {
1073 l_tforloop: 1113 l_tforloop:
1074 if (!ttisnil(ra + 1)) { /* continue loop? */ 1114 if (!ttisnil(ra + 1)) { /* continue loop? */
1075 setobjs2s(L, ra, ra + 1); /* save control variable */ 1115 setobjs2s(L, ra, ra + 1); /* save control variable */
1076 ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ 1116 ci->u.l.savedpc += GETARG_sBx(i); /* jump back */
1077 } 1117 }
1078 ) 1118 vmbreak;
1079 vmcase(OP_SETLIST, 1119 }
1120 vmcase(OP_SETLIST) {
1080 int n = GETARG_B(i); 1121 int n = GETARG_B(i);
1081 int c = GETARG_C(i); 1122 int c = GETARG_C(i);
1082 unsigned int last; 1123 unsigned int last;
@@ -1097,8 +1138,9 @@ void luaV_execute (lua_State *L) {
1097 luaC_barrierback(L, h, val); 1138 luaC_barrierback(L, h, val);
1098 } 1139 }
1099 L->top = ci->top; /* correct top (in case of previous open call) */ 1140 L->top = ci->top; /* correct top (in case of previous open call) */
1100 ) 1141 vmbreak;
1101 vmcase(OP_CLOSURE, 1142 }
1143 vmcase(OP_CLOSURE) {
1102 Proto *p = cl->p->p[GETARG_Bx(i)]; 1144 Proto *p = cl->p->p[GETARG_Bx(i)];
1103 LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */ 1145 LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */
1104 if (ncl == NULL) /* no match? */ 1146 if (ncl == NULL) /* no match? */
@@ -1106,8 +1148,9 @@ void luaV_execute (lua_State *L) {
1106 else 1148 else
1107 setclLvalue(L, ra, ncl); /* push cashed closure */ 1149 setclLvalue(L, ra, ncl); /* push cashed closure */
1108 checkGC(L, ra + 1); 1150 checkGC(L, ra + 1);
1109 ) 1151 vmbreak;
1110 vmcase(OP_VARARG, 1152 }
1153 vmcase(OP_VARARG) {
1111 int b = GETARG_B(i) - 1; 1154 int b = GETARG_B(i) - 1;
1112 int j; 1155 int j;
1113 int n = cast_int(base - ci->func) - cl->p->numparams - 1; 1156 int n = cast_int(base - ci->func) - cl->p->numparams - 1;
@@ -1125,10 +1168,12 @@ void luaV_execute (lua_State *L) {
1125 setnilvalue(ra + j); 1168 setnilvalue(ra + j);
1126 } 1169 }
1127 } 1170 }
1128 ) 1171 vmbreak;
1129 vmcase(OP_EXTRAARG, 1172 }
1173 vmcase(OP_EXTRAARG) {
1130 lua_assert(0); 1174 lua_assert(0);
1131 ) 1175 vmbreak;
1176 }
1132 } 1177 }
1133 } 1178 }
1134} 1179}