aboutsummaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-24 17:26:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-24 17:26:39 -0300
commitcb3d5dce30089512085f78a0bef79e30ef732e30 (patch)
tree0459a127a7a7641a0a8f5eec7558db1432730e6d /lvm.c
parent2caecf1b3efdbee4e08888a04143421589d6143b (diff)
downloadlua-cb3d5dce30089512085f78a0bef79e30ef732e30.tar.gz
lua-cb3d5dce30089512085f78a0bef79e30ef732e30.tar.bz2
lua-cb3d5dce30089512085f78a0bef79e30ef732e30.zip
opcodes 'OP_GETTABUP'/'OP_SETTABUP' operate only with string keys,
so they can use fast-track table access
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/lvm.c b/lvm.c
index a15ebe56..e1268567 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.270 2017/04/11 18:41:09 roberto Exp roberto $ 2** $Id: lvm.c,v 2.271 2017/04/20 19:53:55 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*/
@@ -838,9 +838,14 @@ void luaV_execute (lua_State *L) {
838 vmbreak; 838 vmbreak;
839 } 839 }
840 vmcase(OP_GETTABUP) { 840 vmcase(OP_GETTABUP) {
841 const TValue *slot;
841 TValue *upval = cl->upvals[GETARG_B(i)]->v; 842 TValue *upval = cl->upvals[GETARG_B(i)]->v;
842 TValue *rc = RKC(i); 843 TValue *rc = RKC(i);
843 gettableProtected(L, upval, rc, ra); 844 TString *key = tsvalue(rc); /* key must be a string */
845 if (luaV_fastget(L, upval, key, slot, luaH_getstr)) {
846 setobj2s(L, ra, slot);
847 }
848 else Protect(luaV_finishget(L, upval, rc, ra, slot));
844 vmbreak; 849 vmbreak;
845 } 850 }
846 vmcase(OP_GETTABLE) { 851 vmcase(OP_GETTABLE) {
@@ -850,10 +855,13 @@ void luaV_execute (lua_State *L) {
850 vmbreak; 855 vmbreak;
851 } 856 }
852 vmcase(OP_SETTABUP) { 857 vmcase(OP_SETTABUP) {
858 const TValue *slot;
853 TValue *upval = cl->upvals[GETARG_A(i)]->v; 859 TValue *upval = cl->upvals[GETARG_A(i)]->v;
854 TValue *rb = RKB(i); 860 TValue *rb = RKB(i);
855 TValue *rc = RKC(i); 861 TValue *rc = RKC(i);
856 settableProtected(L, upval, rb, rc); 862 TString *key = tsvalue(rb); /* key must be a string */
863 if (!luaV_fastset(L, upval, key, slot, luaH_getstr, rc))
864 Protect(luaV_finishset(L, upval, rb, rc, slot));
857 vmbreak; 865 vmbreak;
858 } 866 }
859 vmcase(OP_SETUPVAL) { 867 vmcase(OP_SETUPVAL) {
@@ -879,15 +887,15 @@ void luaV_execute (lua_State *L) {
879 vmbreak; 887 vmbreak;
880 } 888 }
881 vmcase(OP_SELF) { 889 vmcase(OP_SELF) {
882 const TValue *aux; 890 const TValue *slot;
883 StkId rb = RB(i); 891 StkId rb = RB(i);
884 TValue *rc = RKC(i); 892 TValue *rc = RKC(i);
885 TString *key = tsvalue(rc); /* key must be a string */ 893 TString *key = tsvalue(rc); /* key must be a string */
886 setobjs2s(L, ra + 1, rb); 894 setobjs2s(L, ra + 1, rb);
887 if (luaV_fastget(L, rb, key, aux, luaH_getstr)) { 895 if (luaV_fastget(L, rb, key, slot, luaH_getstr)) {
888 setobj2s(L, ra, aux); 896 setobj2s(L, ra, slot);
889 } 897 }
890 else Protect(luaV_finishget(L, rb, rc, ra, aux)); 898 else Protect(luaV_finishget(L, rb, rc, ra, slot));
891 vmbreak; 899 vmbreak;
892 } 900 }
893 vmcase(OP_ADD) { 901 vmcase(OP_ADD) {