aboutsummaryrefslogtreecommitdiff
path: root/lvm.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-07 17:26:15 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-11-07 17:26:15 -0300
commit37c215b43f27a1c41e8a920987e1c3bd7b34330d (patch)
treef14f4417384cffb9d2e5ef3c09621555a5d1e9a2 /lvm.h
parent9e99f3071d07767f9e882c4abf3537f75ce2d161 (diff)
parentfa075b79530af1cbc977349f2e467d69ce01202c (diff)
downloadlua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.tar.gz
lua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.tar.bz2
lua-37c215b43f27a1c41e8a920987e1c3bd7b34330d.zip
Merge branch 'newarray' into nextversion
Diffstat (limited to '')
-rw-r--r--lvm.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/lvm.h b/lvm.h
index dba1ad27..c74c81f8 100644
--- a/lvm.h
+++ b/lvm.h
@@ -76,38 +76,43 @@ typedef enum {
76 76
77 77
78/* 78/*
79** fast track for 'gettable': if 't' is a table and 't[k]' is present, 79** fast track for 'gettable'
80** return 1 with 'slot' pointing to 't[k]' (position of final result).
81** Otherwise, return 0 (meaning it will have to check metamethod)
82** with 'slot' pointing to an empty 't[k]' (if 't' is a table) or NULL
83** (otherwise). 'f' is the raw get function to use.
84*/ 80*/
85#define luaV_fastget(L,t,k,slot,f) \ 81#define luaV_fastget(t,k,res,f, aux) \
86 (!ttistable(t) \ 82 (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, res)))
87 ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \
88 : (slot = f(hvalue(t), k), /* else, do raw access */ \
89 !isempty(slot))) /* result not empty? */
90 83
91 84
92/* 85/*
93** Special case of 'luaV_fastget' for integers, inlining the fast case 86** Special case of 'luaV_fastget' for integers, inlining the fast case
94** of 'luaH_getint'. 87** of 'luaH_getint'.
95*/ 88*/
96#define luaV_fastgeti(L,t,k,slot) \ 89#define luaV_fastgeti(t,k,res,aux) \
97 (!ttistable(t) \ 90 if (!ttistable(t)) aux = HNOTATABLE; \
98 ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ 91 else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \
99 : (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \ 92 if ((u - 1u < h->alimit)) { \
100 ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ 93 int tag = *getArrTag(h,(u)-1u); \
101 !isempty(slot))) /* result not empty? */ 94 if (tagisempty(tag)) aux = HNOTFOUND; \
95 else { farr2val(h, u, tag, res); aux = HOK; }} \
96 else { aux = luaH_getint(h, u, res); }}
97
98
99#define luaV_fastset(t,k,val,aux,f) \
100 (aux = (!ttistable(t) ? HNOTATABLE : f(hvalue(t), k, val)))
101
102#define luaV_fastseti(t,k,val,aux) \
103 if (!ttistable(t)) aux = HNOTATABLE; \
104 else { Table *h = hvalue(t); lua_Unsigned u = l_castS2U(k); \
105 if ((u - 1u < h->alimit)) { \
106 lu_byte *tag = getArrTag(h,(u)-1u); \
107 if (tagisempty(*tag)) aux = ~cast_int(u); \
108 else { fval2arr(h, u, tag, val); aux = HOK; }} \
109 else { aux = luaH_psetint(h, u, val); }}
102 110
103 111
104/* 112/*
105** Finish a fast set operation (when fast get succeeds). In that case, 113** Finish a fast set operation (when fast set succeeds).
106** 'slot' points to the place to put the value.
107*/ 114*/
108#define luaV_finishfastset(L,t,slot,v) \ 115#define luaV_finishfastset(L,t,v) luaC_barrierback(L, gcvalue(t), v)
109 { setobj2t(L, cast(TValue *,slot), v); \
110 luaC_barrierback(L, gcvalue(t), v); }
111 116
112 117
113/* 118/*
@@ -126,9 +131,9 @@ LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p,
126 F2Imod mode); 131 F2Imod mode);
127LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode); 132LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode);
128LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key, 133LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
129 StkId val, const TValue *slot); 134 StkId val, int aux);
130LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, 135LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
131 TValue *val, const TValue *slot); 136 TValue *val, int aux);
132LUAI_FUNC void luaV_finishOp (lua_State *L); 137LUAI_FUNC void luaV_finishOp (lua_State *L);
133LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci); 138LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci);
134LUAI_FUNC void luaV_concat (lua_State *L, int total); 139LUAI_FUNC void luaV_concat (lua_State *L, int total);