aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-07-11 12:53:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-07-11 12:53:29 -0300
commit3ca9af51a4f060cf2178901a67a21f8269af3224 (patch)
tree4f1bb541280aa8b4960b16d0925eca60adb2b1a8 /lvm.c
parentc7b89dd28097296bbc14d9b47b4cea72514b2b76 (diff)
downloadlua-3ca9af51a4f060cf2178901a67a21f8269af3224.tar.gz
lua-3ca9af51a4f060cf2178901a67a21f8269af3224.tar.bz2
lua-3ca9af51a4f060cf2178901a67a21f8269af3224.zip
emergency garbage collector (core forces a GC when allocation fails)
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/lvm.c b/lvm.c
index 6c92567f..50ffdfdc 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.62 2006/01/23 19:51:43 roberto Exp roberto $ 2** $Id: lvm.c,v 2.63 2006/06/05 15:58:59 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*/
@@ -85,8 +85,8 @@ static void callTMres (lua_State *L, StkId res, const TValue *f,
85 setobj2s(L, L->top, f); /* push function */ 85 setobj2s(L, L->top, f); /* push function */
86 setobj2s(L, L->top+1, p1); /* 1st argument */ 86 setobj2s(L, L->top+1, p1); /* 1st argument */
87 setobj2s(L, L->top+2, p2); /* 2nd argument */ 87 setobj2s(L, L->top+2, p2); /* 2nd argument */
88 luaD_checkstack(L, 3);
89 L->top += 3; 88 L->top += 3;
89 luaD_checkstack(L, 0);
90 luaD_call(L, L->top - 3, 1); 90 luaD_call(L, L->top - 3, 1);
91 res = restorestack(L, result); 91 res = restorestack(L, result);
92 L->top--; 92 L->top--;
@@ -101,8 +101,8 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1,
101 setobj2s(L, L->top+1, p1); /* 1st argument */ 101 setobj2s(L, L->top+1, p1); /* 1st argument */
102 setobj2s(L, L->top+2, p2); /* 2nd argument */ 102 setobj2s(L, L->top+2, p2); /* 2nd argument */
103 setobj2s(L, L->top+3, p3); /* 3th argument */ 103 setobj2s(L, L->top+3, p3); /* 3th argument */
104 luaD_checkstack(L, 4);
105 L->top += 4; 104 L->top += 4;
105 luaD_checkstack(L, 0);
106 luaD_call(L, L->top - 4, 0); 106 luaD_call(L, L->top - 4, 0);
107} 107}
108 108
@@ -455,9 +455,12 @@ void luaV_execute (lua_State *L, int nexeccalls) {
455 continue; 455 continue;
456 } 456 }
457 case OP_NEWTABLE: { 457 case OP_NEWTABLE: {
458 int b = GETARG_B(i); 458 int asize = luaO_fb2int(GETARG_B(i));
459 int c = GETARG_C(i); 459 int nsize = luaO_fb2int(GETARG_C(i));
460 sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); 460 Table *t = luaH_new(L);
461 sethvalue(L, ra, t);
462 if (asize > 0 || nsize > 0)
463 luaH_resize(L, t, asize, nsize);
461 Protect(luaC_checkGC(L)); 464 Protect(luaC_checkGC(L));
462 continue; 465 continue;
463 } 466 }
@@ -695,10 +698,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
695 int c = GETARG_C(i); 698 int c = GETARG_C(i);
696 int last; 699 int last;
697 Table *h; 700 Table *h;
698 if (n == 0) { 701 if (n == 0) n = cast_int(L->top - ra) - 1;
699 n = cast_int(L->top - ra) - 1;
700 L->top = L->ci->top;
701 }
702 if (c == 0) c = cast_int(*pc++); 702 if (c == 0) c = cast_int(*pc++);
703 runtime_check(L, ttistable(ra)); 703 runtime_check(L, ttistable(ra));
704 h = hvalue(ra); 704 h = hvalue(ra);
@@ -710,6 +710,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
710 setobj2t(L, luaH_setnum(L, h, last--), val); 710 setobj2t(L, luaH_setnum(L, h, last--), val);
711 luaC_barriert(L, h, val); 711 luaC_barriert(L, h, val);
712 } 712 }
713 L->top = L->ci->top; /* correct top (in case of previous open call) */
713 continue; 714 continue;
714 } 715 }
715 case OP_CLOSE: { 716 case OP_CLOSE: {
@@ -724,6 +725,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
724 nup = p->nups; 725 nup = p->nups;
725 ncl = luaF_newLclosure(L, nup, cl->env); 726 ncl = luaF_newLclosure(L, nup, cl->env);
726 ncl->l.p = p; 727 ncl->l.p = p;
728 setclvalue(L, ra, ncl);
727 for (j=0; j<nup; j++, pc++) { 729 for (j=0; j<nup; j++, pc++) {
728 if (GET_OPCODE(*pc) == OP_GETUPVAL) 730 if (GET_OPCODE(*pc) == OP_GETUPVAL)
729 ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)]; 731 ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
@@ -732,7 +734,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
732 ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); 734 ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
733 } 735 }
734 } 736 }
735 setclvalue(L, ra, ncl);
736 Protect(luaC_checkGC(L)); 737 Protect(luaC_checkGC(L));
737 continue; 738 continue;
738 } 739 }