diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-01-31 12:28:41 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-01-31 12:28:41 -0200 |
commit | 026a7e92bec8f313d8286a64f8bfc3d2b199e18e (patch) | |
tree | 7edb84919d145ff2e87279b1c8a41cf4f25f3be7 | |
parent | c4ea0c3b29252bcafeadf2f69532bdb67ab20bb9 (diff) | |
download | lua-026a7e92bec8f313d8286a64f8bfc3d2b199e18e.tar.gz lua-026a7e92bec8f313d8286a64f8bfc3d2b199e18e.tar.bz2 lua-026a7e92bec8f313d8286a64f8bfc3d2b199e18e.zip |
bug in some short-circuit optimizations
-rw-r--r-- | lcode.c | 28 |
1 files changed, 7 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.48 2010/07/02 20:42:40 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.49 2010/07/07 16:27:29 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 | */ |
@@ -603,21 +603,14 @@ void luaK_goiftrue (FuncState *fs, expdesc *e) { | |||
603 | int pc; /* pc of last jump */ | 603 | int pc; /* pc of last jump */ |
604 | luaK_dischargevars(fs, e); | 604 | luaK_dischargevars(fs, e); |
605 | switch (e->k) { | 605 | switch (e->k) { |
606 | case VK: case VKNUM: case VTRUE: { | ||
607 | pc = NO_JUMP; /* always true; do nothing */ | ||
608 | break; | ||
609 | } | ||
610 | case VJMP: { | 606 | case VJMP: { |
611 | invertjump(fs, e); | 607 | invertjump(fs, e); |
612 | pc = e->u.info; | 608 | pc = e->u.info; |
613 | break; | 609 | break; |
614 | } | 610 | } |
615 | case VFALSE: { | 611 | case VK: case VKNUM: case VTRUE: { |
616 | if (!hasjumps(e)) { | 612 | pc = NO_JUMP; /* always true; do nothing */ |
617 | pc = luaK_jump(fs); /* always jump */ | 613 | break; |
618 | break; | ||
619 | } | ||
620 | /* else go through */ | ||
621 | } | 614 | } |
622 | default: { | 615 | default: { |
623 | pc = jumponcond(fs, e, 0); | 616 | pc = jumponcond(fs, e, 0); |
@@ -634,20 +627,13 @@ static void luaK_goiffalse (FuncState *fs, expdesc *e) { | |||
634 | int pc; /* pc of last jump */ | 627 | int pc; /* pc of last jump */ |
635 | luaK_dischargevars(fs, e); | 628 | luaK_dischargevars(fs, e); |
636 | switch (e->k) { | 629 | switch (e->k) { |
637 | case VNIL: case VFALSE: { | ||
638 | pc = NO_JUMP; /* always false; do nothing */ | ||
639 | break; | ||
640 | } | ||
641 | case VJMP: { | 630 | case VJMP: { |
642 | pc = e->u.info; | 631 | pc = e->u.info; |
643 | break; | 632 | break; |
644 | } | 633 | } |
645 | case VTRUE: { | 634 | case VNIL: case VFALSE: { |
646 | if (!hasjumps(e)) { | 635 | pc = NO_JUMP; /* always false; do nothing */ |
647 | pc = luaK_jump(fs); /* always jump */ | 636 | break; |
648 | break; | ||
649 | } | ||
650 | /* else go through */ | ||
651 | } | 637 | } |
652 | default: { | 638 | default: { |
653 | pc = jumponcond(fs, e, 1); | 639 | pc = jumponcond(fs, e, 1); |