diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-02-26 17:40:29 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-02-26 17:40:29 -0300 |
commit | 0fe2576a39633ab7873f9d4fd989f1e5203a5725 (patch) | |
tree | c759f10fb3565f924dad29874d85d9d1b139c3bf /lcode.c | |
parent | d08d237a49ff3cb961012b1de374914af6da3000 (diff) | |
download | lua-0fe2576a39633ab7873f9d4fd989f1e5203a5725.tar.gz lua-0fe2576a39633ab7873f9d4fd989f1e5203a5725.tar.bz2 lua-0fe2576a39633ab7873f9d4fd989f1e5203a5725.zip |
new instructions to optimize indexing on upvalues
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.42 2009/09/23 20:33:05 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.43 2010/01/11 17:38:30 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 | */ |
@@ -384,6 +384,12 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { | |||
384 | e->k = VRELOCABLE; | 384 | e->k = VRELOCABLE; |
385 | break; | 385 | break; |
386 | } | 386 | } |
387 | case VINDEXEDUP: { | ||
388 | freereg(fs, e->u.s.aux); | ||
389 | e->u.s.info = luaK_codeABC(fs, OP_GETTABUP, 0, e->u.s.info, e->u.s.aux); | ||
390 | e->k = VRELOCABLE; | ||
391 | break; | ||
392 | } | ||
387 | case VVARARG: | 393 | case VVARARG: |
388 | case VCALL: { | 394 | case VCALL: { |
389 | luaK_setoneret(fs, e); | 395 | luaK_setoneret(fs, e); |
@@ -493,6 +499,12 @@ int luaK_exp2anyreg (FuncState *fs, expdesc *e) { | |||
493 | } | 499 | } |
494 | 500 | ||
495 | 501 | ||
502 | void luaK_exp2anyregup (FuncState *fs, expdesc *e) { | ||
503 | if (e->k != VUPVAL || hasjumps(e)) | ||
504 | luaK_exp2anyreg(fs, e); | ||
505 | } | ||
506 | |||
507 | |||
496 | void luaK_exp2val (FuncState *fs, expdesc *e) { | 508 | void luaK_exp2val (FuncState *fs, expdesc *e) { |
497 | if (hasjumps(e)) | 509 | if (hasjumps(e)) |
498 | luaK_exp2anyreg(fs, e); | 510 | luaK_exp2anyreg(fs, e); |
@@ -553,6 +565,11 @@ void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { | |||
553 | luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); | 565 | luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); |
554 | break; | 566 | break; |
555 | } | 567 | } |
568 | case VINDEXEDUP: { | ||
569 | int e = luaK_exp2RK(fs, ex); | ||
570 | luaK_codeABC(fs, OP_SETTABUP, var->u.s.info, var->u.s.aux, e); | ||
571 | break; | ||
572 | } | ||
556 | default: { | 573 | default: { |
557 | lua_assert(0); /* invalid var kind to store */ | 574 | lua_assert(0); /* invalid var kind to store */ |
558 | break; | 575 | break; |
@@ -695,8 +712,9 @@ static void codenot (FuncState *fs, expdesc *e) { | |||
695 | 712 | ||
696 | 713 | ||
697 | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | 714 | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { |
715 | lua_assert(!hasjumps(t)); | ||
698 | t->u.s.aux = luaK_exp2RK(fs, k); | 716 | t->u.s.aux = luaK_exp2RK(fs, k); |
699 | t->k = VINDEXED; | 717 | t->k = (t->k == VUPVAL) ? VINDEXEDUP : VINDEXED; |
700 | } | 718 | } |
701 | 719 | ||
702 | 720 | ||