diff options
| -rw-r--r-- | ldo.c | 19 |
1 files changed, 5 insertions, 14 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 1.213 2003/02/13 16:08:47 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.214 2003/02/27 11:52:30 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -428,22 +428,13 @@ struct SParser { /* data to `f_parser' */ | |||
| 428 | }; | 428 | }; |
| 429 | 429 | ||
| 430 | static void f_parser (lua_State *L, void *ud) { | 430 | static void f_parser (lua_State *L, void *ud) { |
| 431 | lu_mem old_blocks; | ||
| 432 | Proto *tf; | ||
| 433 | Closure *cl; | ||
| 434 | struct SParser *p = cast(struct SParser *, ud); | 431 | struct SParser *p = cast(struct SParser *, ud); |
| 435 | /* before parsing, give a (good) chance to GC */ | 432 | Proto *tf = p->bin ? luaU_undump(L, p->z, &p->buff) : |
| 436 | if (G(L)->nblocks + G(L)->nblocks/4 >= G(L)->GCthreshold) | 433 | luaY_parser(L, p->z, &p->buff); |
| 437 | luaC_collectgarbage(L); | 434 | Closure *cl = luaF_newLclosure(L, 0, gt(L)); |
| 438 | old_blocks = G(L)->nblocks; | ||
| 439 | tf = p->bin ? luaU_undump(L, p->z, &p->buff) : luaY_parser(L, p->z, &p->buff); | ||
| 440 | cl = luaF_newLclosure(L, 0, gt(L)); | ||
| 441 | cl->l.p = tf; | 435 | cl->l.p = tf; |
| 442 | setclvalue(L->top, cl); | 436 | setclvalue(L->top, cl); |
| 443 | incr_top(L); | 437 | incr_top(L); |
| 444 | /* add new memory to threshold (as it probably will stay) */ | ||
| 445 | lua_assert(G(L)->nblocks >= old_blocks); | ||
| 446 | G(L)->GCthreshold += (G(L)->nblocks - old_blocks); | ||
| 447 | } | 438 | } |
| 448 | 439 | ||
| 449 | 440 | ||
| @@ -455,7 +446,7 @@ int luaD_protectedparser (lua_State *L, ZIO *z, int bin) { | |||
| 455 | luaZ_initbuffer(L, &p.buff); | 446 | luaZ_initbuffer(L, &p.buff); |
| 456 | status = luaD_rawrunprotected(L, f_parser, &p); | 447 | status = luaD_rawrunprotected(L, f_parser, &p); |
| 457 | luaZ_freebuffer(L, &p.buff); | 448 | luaZ_freebuffer(L, &p.buff); |
| 458 | if (status != 0) { /* error */ | 449 | if (status != 0) { /* error? */ |
| 459 | StkId oldtop = restorestack(L, oldtopr); | 450 | StkId oldtop = restorestack(L, oldtopr); |
| 460 | seterrorobj(L, status, oldtop); | 451 | seterrorobj(L, status, oldtop); |
| 461 | } | 452 | } |
