summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-03-23 14:07:34 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-03-23 14:07:34 -0300
commit21bc05c920e6289d6d6e1de5c3c8f0eb64e60fb2 (patch)
tree90eb568edbb8a2339f0a2ffa5da8e0c0b43ea49d /lapi.c
parent29a13b4128caccca1c7796a1252cb04d4e8a0569 (diff)
downloadlua-21bc05c920e6289d6d6e1de5c3c8f0eb64e60fb2.tar.gz
lua-21bc05c920e6289d6d6e1de5c3c8f0eb64e60fb2.tar.bz2
lua-21bc05c920e6289d6d6e1de5c3c8f0eb64e60fb2.zip
write barrier for C upvalues
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lapi.c b/lapi.c
index 48993abf..ba25b89e 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.3 2004/02/20 16:01:05 roberto Exp roberto $ 2** $Id: lapi.c,v 2.4 2004/03/09 17:34:35 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -68,11 +68,10 @@ static TValue *luaA_index (lua_State *L, int idx) {
68 case LUA_REGISTRYINDEX: return registry(L); 68 case LUA_REGISTRYINDEX: return registry(L);
69 case LUA_GLOBALSINDEX: return gt(L); 69 case LUA_GLOBALSINDEX: return gt(L);
70 default: { 70 default: {
71 TValue *func = (L->base - 1); 71 Closure *func = curr_func(L);
72 idx = LUA_GLOBALSINDEX - idx; 72 idx = LUA_GLOBALSINDEX - idx;
73 lua_assert(iscfunction(func)); 73 return (idx <= func->c.nupvalues)
74 return (idx <= clvalue(func)->c.nupvalues) 74 ? &func->c.upvalue[idx-1]
75 ? &clvalue(func)->c.upvalue[idx-1]
76 : cast(TValue *, &luaO_nilobject); 75 : cast(TValue *, &luaO_nilobject);
77 } 76 }
78 } 77 }
@@ -194,7 +193,9 @@ LUA_API void lua_replace (lua_State *L, int idx) {
194 api_checknelems(L, 1); 193 api_checknelems(L, 1);
195 o = luaA_index(L, idx); 194 o = luaA_index(L, idx);
196 api_checkvalidindex(L, o); 195 api_checkvalidindex(L, o);
197 setobj(L, o, L->top - 1); /* write barrier???? */ 196 setobj(L, o, L->top - 1);
197 if (idx < LUA_GLOBALSINDEX) /* function upvalue? */
198 luaC_barrier(L, curr_func(L), L->top - 1);
198 L->top--; 199 L->top--;
199 lua_unlock(L); 200 lua_unlock(L);
200} 201}