diff options
-rw-r--r-- | lvm.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.125 2010/10/29 17:52:46 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.126 2010/12/06 21:08:36 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 | */ |
@@ -471,7 +471,7 @@ void luaV_finishOp (lua_State *L) { | |||
471 | 471 | ||
472 | #define Protect(x) { {x;}; base = ci->u.l.base; } | 472 | #define Protect(x) { {x;}; base = ci->u.l.base; } |
473 | 473 | ||
474 | #define checkGC(L) Protect(luaC_checkGC(L); luai_threadyield(L);) | 474 | #define checkGC(L,c) Protect(luaC_condGC(L, c); luai_threadyield(L);) |
475 | 475 | ||
476 | 476 | ||
477 | #define arith_op(op,tm) { \ | 477 | #define arith_op(op,tm) { \ |
@@ -558,7 +558,11 @@ void luaV_execute (lua_State *L) { | |||
558 | sethvalue(L, ra, t); | 558 | sethvalue(L, ra, t); |
559 | if (b != 0 || c != 0) | 559 | if (b != 0 || c != 0) |
560 | luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); | 560 | luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); |
561 | checkGC(L); | 561 | checkGC(L, |
562 | L->top = ra + 1; /* limit of live values */ | ||
563 | luaC_step(L); | ||
564 | L->top = ci->top; /* restore top */ | ||
565 | ) | ||
562 | ) | 566 | ) |
563 | vmcase(OP_SELF, | 567 | vmcase(OP_SELF, |
564 | StkId rb = RB(i); | 568 | StkId rb = RB(i); |
@@ -603,10 +607,17 @@ void luaV_execute (lua_State *L) { | |||
603 | vmcase(OP_CONCAT, | 607 | vmcase(OP_CONCAT, |
604 | int b = GETARG_B(i); | 608 | int b = GETARG_B(i); |
605 | int c = GETARG_C(i); | 609 | int c = GETARG_C(i); |
610 | StkId rb; | ||
606 | L->top = base + c + 1; /* mark the end of concat operands */ | 611 | L->top = base + c + 1; /* mark the end of concat operands */ |
607 | Protect(luaV_concat(L, c-b+1); checkGC(L);) | 612 | Protect(luaV_concat(L, c - b + 1)); |
613 | ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */ | ||
614 | rb = b + base; | ||
615 | setobjs2s(L, ra, rb); | ||
616 | checkGC(L, | ||
617 | L->top = (ra >= rb ? ra + 1 : rb); /* limit of live values */ | ||
618 | luaC_step(L); | ||
619 | ) | ||
608 | L->top = ci->top; /* restore top */ | 620 | L->top = ci->top; /* restore top */ |
609 | setobjs2s(L, RA(i), base+b); | ||
610 | ) | 621 | ) |
611 | vmcase(OP_JMP, | 622 | vmcase(OP_JMP, |
612 | dojump(GETARG_sBx(i)); | 623 | dojump(GETARG_sBx(i)); |
@@ -780,7 +791,11 @@ void luaV_execute (lua_State *L) { | |||
780 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ | 791 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ |
781 | else | 792 | else |
782 | setclvalue(L, ra, ncl); /* push cashed closure */ | 793 | setclvalue(L, ra, ncl); /* push cashed closure */ |
783 | checkGC(L); | 794 | checkGC(L, |
795 | L->top = ra + 1; /* limit of live values */ | ||
796 | luaC_step(L); | ||
797 | L->top = ci->top; /* restore top */ | ||
798 | ) | ||
784 | ) | 799 | ) |
785 | vmcase(OP_VARARG, | 800 | vmcase(OP_VARARG, |
786 | int b = GETARG_B(i) - 1; | 801 | int b = GETARG_B(i) - 1; |