aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-10-30 13:39:30 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-10-30 13:39:30 -0200
commit84b3daebbd09b334db0fa125700ffdb1d326c4f6 (patch)
treedc99189c46297759609894ac71f75d4a57c854fa /ldo.c
parentf6978173e03fdbe5536887b08beb53884f7c1a18 (diff)
downloadlua-84b3daebbd09b334db0fa125700ffdb1d326c4f6.tar.gz
lua-84b3daebbd09b334db0fa125700ffdb1d326c4f6.tar.bz2
lua-84b3daebbd09b334db0fa125700ffdb1d326c4f6.zip
generic for coded as two dedicated instructions to simplify resumption
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/ldo.c b/ldo.c
index 2bbbde92..52c08ce7 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.48 2008/08/26 13:27:42 roberto Exp roberto $ 2** $Id: ldo.c,v 2.49 2008/10/28 16:53:16 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*/
@@ -391,8 +391,10 @@ static void unroll (lua_State *L) {
391 for (;;) { 391 for (;;) {
392 Instruction inst; 392 Instruction inst;
393 luaV_execute(L); /* execute up to higher C 'boundary' */ 393 luaV_execute(L); /* execute up to higher C 'boundary' */
394 if (L->ci == L->base_ci) /* stack is empty? */ 394 if (L->ci == L->base_ci) { /* stack is empty? */
395 lua_assert(L->baseCcalls == G(L)->nCcalls);
395 return; /* coroutine finished normally */ 396 return; /* coroutine finished normally */
397 }
396 L->baseCcalls--; /* undo increment that allows yields */ 398 L->baseCcalls--; /* undo increment that allows yields */
397 inst = *(L->savedpc - 1); /* interrupted instruction */ 399 inst = *(L->savedpc - 1); /* interrupted instruction */
398 switch (GET_OPCODE(inst)) { /* finish its execution */ 400 switch (GET_OPCODE(inst)) { /* finish its execution */
@@ -419,15 +421,9 @@ static void unroll (lua_State *L) {
419 } 421 }
420 case OP_SETGLOBAL: case OP_SETTABLE: 422 case OP_SETGLOBAL: case OP_SETTABLE:
421 break; /* nothing to be done */ 423 break; /* nothing to be done */
422 case OP_TFORLOOP: { 424 case OP_TFORCALL: {
423 StkId cb = L->base + GETARG_A(inst) + 3; 425 lua_assert(GET_OPCODE(*L->savedpc) == OP_TFORLOOP);
424 L->top = L->ci->top; 426 L->top = L->ci->top; /* correct top */
425 lua_assert(GET_OPCODE(*L->savedpc) == OP_JMP);
426 if (!ttisnil(cb)) { /* continue loop? */
427 setobjs2s(L, cb - 1, cb); /* save control variable */
428 L->savedpc += GETARG_sBx(*L->savedpc); /* jump back */
429 }
430 L->savedpc++;
431 break; 427 break;
432 } 428 }
433 default: lua_assert(0); 429 default: lua_assert(0);