diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-23 17:33:05 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-23 17:33:05 -0300 |
| commit | fcc46467fa92c8e9951e63baf2c3e1b22bf20a1f (patch) | |
| tree | 54e6ab8b2b6d720911251e6863ddca1e54a75cd0 /lvm.c | |
| parent | f8e354e2404cbd0a91b4299598d4de9757e73fd7 (diff) | |
| download | lua-fcc46467fa92c8e9951e63baf2c3e1b22bf20a1f.tar.gz lua-fcc46467fa92c8e9951e63baf2c3e1b22bf20a1f.tar.bz2 lua-fcc46467fa92c8e9951e63baf2c3e1b22bf20a1f.zip | |
limit of constants per function changed to 2^26 using extra arguments
to opcodes LOADK, GETGLOBAL, and SETGLOBAL
Diffstat (limited to 'lvm.c')
| -rw-r--r-- | lvm.c | 22 |
1 files changed, 15 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.95 2009/07/15 18:38:16 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.96 2009/08/07 16:17:41 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 | */ |
| @@ -353,7 +353,12 @@ void luaV_finishOp (lua_State *L) { | |||
| 353 | CallInfo *ci = L->ci; | 353 | CallInfo *ci = L->ci; |
| 354 | StkId base = ci->u.l.base; | 354 | StkId base = ci->u.l.base; |
| 355 | Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ | 355 | Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ |
| 356 | switch (GET_OPCODE(inst)) { /* finish its execution */ | 356 | OpCode op = GET_OPCODE(inst); |
| 357 | if (op == OP_EXTRAARG) { /* extra argument? */ | ||
| 358 | inst = *(ci->u.l.savedpc - 2); /* get its 'main' instruction */ | ||
| 359 | op = GET_OPCODE(inst); | ||
| 360 | } | ||
| 361 | switch (op) { /* finish its execution */ | ||
| 357 | case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: | 362 | case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: |
| 358 | case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN: | 363 | case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN: |
| 359 | case OP_GETGLOBAL: case OP_GETTABLE: case OP_SELF: { | 364 | case OP_GETGLOBAL: case OP_GETTABLE: case OP_SELF: { |
| @@ -365,7 +370,7 @@ void luaV_finishOp (lua_State *L) { | |||
| 365 | L->top--; | 370 | L->top--; |
| 366 | /* metamethod should not be called when operand is K */ | 371 | /* metamethod should not be called when operand is K */ |
| 367 | lua_assert(!ISK(GETARG_B(inst))); | 372 | lua_assert(!ISK(GETARG_B(inst))); |
| 368 | if (GET_OPCODE(inst) == OP_LE && /* "<=" using "<" instead? */ | 373 | if (op == OP_LE && /* "<=" using "<" instead? */ |
| 369 | ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE))) | 374 | ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE))) |
| 370 | res = !res; /* invert result */ | 375 | res = !res; /* invert result */ |
| 371 | lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); | 376 | lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); |
| @@ -417,7 +422,8 @@ void luaV_finishOp (lua_State *L) { | |||
| 417 | ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) | 422 | ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) |
| 418 | #define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ | 423 | #define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ |
| 419 | ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) | 424 | ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) |
| 420 | #define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) | 425 | #define KBx(i) \ |
| 426 | (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci->u.l.savedpc++))) | ||
| 421 | 427 | ||
| 422 | 428 | ||
| 423 | #define dojump(i) { ci->u.l.savedpc += (i); luai_threadyield(L);} | 429 | #define dojump(i) { ci->u.l.savedpc += (i); luai_threadyield(L);} |
| @@ -468,7 +474,8 @@ void luaV_execute (lua_State *L) { | |||
| 468 | continue; | 474 | continue; |
| 469 | } | 475 | } |
| 470 | case OP_LOADK: { | 476 | case OP_LOADK: { |
| 471 | setobj2s(L, ra, KBx(i)); | 477 | TValue *rb = KBx(i); |
| 478 | setobj2s(L, ra, rb); | ||
| 472 | continue; | 479 | continue; |
| 473 | } | 480 | } |
| 474 | case OP_LOADBOOL: { | 481 | case OP_LOADBOOL: { |
| @@ -502,9 +509,10 @@ void luaV_execute (lua_State *L) { | |||
| 502 | } | 509 | } |
| 503 | case OP_SETGLOBAL: { | 510 | case OP_SETGLOBAL: { |
| 504 | TValue g; | 511 | TValue g; |
| 512 | TValue *rb = KBx(i); | ||
| 505 | sethvalue(L, &g, cl->env); | 513 | sethvalue(L, &g, cl->env); |
| 506 | lua_assert(ttisstring(KBx(i))); | 514 | lua_assert(ttisstring(rb)); |
| 507 | Protect(luaV_settable(L, &g, KBx(i), ra)); | 515 | Protect(luaV_settable(L, &g, rb, ra)); |
| 508 | continue; | 516 | continue; |
| 509 | } | 517 | } |
| 510 | case OP_SETUPVAL: { | 518 | case OP_SETUPVAL: { |
