diff options
| -rw-r--r-- | lvm.c | 25 |
1 files changed, 9 insertions, 16 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.149 2012/01/25 21:05:40 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.150 2012/05/08 13:53:33 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 | */ |
| @@ -502,7 +502,11 @@ void luaV_finishOp (lua_State *L) { | |||
| 502 | 502 | ||
| 503 | #define Protect(x) { {x;}; base = ci->u.l.base; } | 503 | #define Protect(x) { {x;}; base = ci->u.l.base; } |
| 504 | 504 | ||
| 505 | #define checkGC(L,c) Protect(luaC_condGC(L, c); luai_threadyield(L);) | 505 | #define checkGC(L,c) \ |
| 506 | Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \ | ||
| 507 | luaC_step(L); \ | ||
| 508 | L->top = ci->top;}) /* restore top */ \ | ||
| 509 | luai_threadyield(L); ) | ||
| 506 | 510 | ||
| 507 | 511 | ||
| 508 | #define arith_op(op,tm) { \ | 512 | #define arith_op(op,tm) { \ |
| @@ -595,11 +599,7 @@ void luaV_execute (lua_State *L) { | |||
| 595 | sethvalue(L, ra, t); | 599 | sethvalue(L, ra, t); |
| 596 | if (b != 0 || c != 0) | 600 | if (b != 0 || c != 0) |
| 597 | luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); | 601 | luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); |
| 598 | checkGC(L, | 602 | checkGC(L, ra + 1); |
| 599 | L->top = ra + 1; /* limit of live values */ | ||
| 600 | luaC_step(L); | ||
| 601 | L->top = ci->top; /* restore top */ | ||
| 602 | ) | ||
| 603 | ) | 603 | ) |
| 604 | vmcase(OP_SELF, | 604 | vmcase(OP_SELF, |
| 605 | StkId rb = RB(i); | 605 | StkId rb = RB(i); |
| @@ -651,10 +651,7 @@ void luaV_execute (lua_State *L) { | |||
| 651 | ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */ | 651 | ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */ |
| 652 | rb = b + base; | 652 | rb = b + base; |
| 653 | setobjs2s(L, ra, rb); | 653 | setobjs2s(L, ra, rb); |
| 654 | checkGC(L, | 654 | checkGC(L, (ra >= rb ? ra + 1 : rb)); |
| 655 | L->top = (ra >= rb ? ra + 1 : rb); /* limit of live values */ | ||
| 656 | luaC_step(L); | ||
| 657 | ) | ||
| 658 | L->top = ci->top; /* restore top */ | 655 | L->top = ci->top; /* restore top */ |
| 659 | ) | 656 | ) |
| 660 | vmcase(OP_JMP, | 657 | vmcase(OP_JMP, |
| @@ -832,11 +829,7 @@ void luaV_execute (lua_State *L) { | |||
| 832 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ | 829 | pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ |
| 833 | else | 830 | else |
| 834 | setclLvalue(L, ra, ncl); /* push cashed closure */ | 831 | setclLvalue(L, ra, ncl); /* push cashed closure */ |
| 835 | checkGC(L, | 832 | checkGC(L, ra + 1); |
| 836 | L->top = ra + 1; /* limit of live values */ | ||
| 837 | luaC_step(L); | ||
| 838 | L->top = ci->top; /* restore top */ | ||
| 839 | ) | ||
| 840 | ) | 833 | ) |
| 841 | vmcase(OP_VARARG, | 834 | vmcase(OP_VARARG, |
| 842 | int b = GETARG_B(i) - 1; | 835 | int b = GETARG_B(i) - 1; |
