aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-04-13 13:51:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-04-13 13:51:01 -0300
commite7c8393682f2977742cdac359cce9e558318aeac (patch)
tree4e3213fdea8c30dcf6f1d2b633eb1a54c755814e /lcode.c
parentceaa97ff5b78db364b1608ede26e3dba9050be0e (diff)
downloadlua-e7c8393682f2977742cdac359cce9e558318aeac.tar.gz
lua-e7c8393682f2977742cdac359cce9e558318aeac.tar.bz2
lua-e7c8393682f2977742cdac359cce9e558318aeac.zip
optimization INCLOCAL is not necessary, with `for'
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/lcode.c b/lcode.c
index f75ac359..abf4f537 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.23 2000/04/07 19:35:20 roberto Exp roberto $ 2** $Id: lcode.c,v 1.24 2000/04/12 18:57:19 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -460,6 +460,9 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
460 case OP_MULT: case OP_DIV: case OP_POW: 460 case OP_MULT: case OP_DIV: case OP_POW:
461 delta = -1; mode = iO; break; 461 delta = -1; mode = iO; break;
462 462
463 case OP_SETLOCAL: /* `setlocal' default pops one value */
464 delta = -1; arg2 = 1; mode = iAB; break;
465
463 case OP_RETURN: 466 case OP_RETURN:
464 if (GET_OPCODE(i) == OP_CALL && GETARG_B(i) == MULT_RET) { 467 if (GET_OPCODE(i) == OP_CALL && GETARG_B(i) == MULT_RET) {
465 SET_OPCODE(i, OP_TAILCALL); 468 SET_OPCODE(i, OP_TAILCALL);
@@ -501,26 +504,6 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
501 } 504 }
502 break; 505 break;
503 506
504 case OP_SETLOCAL: {
505 int pc = fs->pc;
506 Instruction *code = fs->f->code;
507 delta = -1;
508 if (pc-1 > fs->lasttarget && /* no jumps in-between instructions? */
509 code[pc-2] == CREATE_U(OP_GETLOCAL, arg1) &&
510 GET_OPCODE(i) == OP_ADDI && abs(GETARG_S(i)) <= MAXARG_sA) {
511 /* `local=local+k' */
512 fs->pc = pc-1;
513 code[pc-2] = CREATE_sAB(OP_INCLOCAL, GETARG_S(i), arg1);
514 luaK_deltastack(fs, delta);
515 return pc-1;
516 }
517 else {
518 arg2 = 1; /* `setlocal' default pops one value */
519 mode = iAB;
520 }
521 break;
522 }
523
524 case OP_ADD: 507 case OP_ADD:
525 delta = -1; 508 delta = -1;
526 switch(GET_OPCODE(i)) { 509 switch(GET_OPCODE(i)) {
@@ -585,8 +568,7 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) {
585 break; 568 break;
586 569
587 case OP_GETDOTTED: case OP_GETINDEXED: 570 case OP_GETDOTTED: case OP_GETINDEXED:
588 case OP_TAILCALL: case OP_INCLOCAL: 571 case OP_TAILCALL: case OP_ADDI:
589 case OP_ADDI:
590 LUA_INTERNALERROR(L, "instruction used only for optimizations"); 572 LUA_INTERNALERROR(L, "instruction used only for optimizations");
591 return 0; /* to avoid warnings */ 573 return 0; /* to avoid warnings */
592 574