1
0
mirror of https://github.com/lua/lua.git synced 2025-01-28 06:03:00 +08:00

documentation for write barriers

This commit is contained in:
Roberto Ierusalimschy 2002-11-14 14:15:53 -02:00
parent a845a46cc8
commit 41fd639cab
8 changed files with 25 additions and 25 deletions

14
lapi.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 1.218 2002/11/07 15:39:23 roberto Exp roberto $
** $Id: lapi.c,v 1.219 2002/11/14 11:51:50 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -191,7 +191,7 @@ LUA_API void lua_insert (lua_State *L, int index) {
LUA_API void lua_replace (lua_State *L, int index) {
lua_lock(L);
api_checknelems(L, 1);
setobj(luaA_index(L, index), L->top - 1); /* unknown destination */
setobj(luaA_index(L, index), L->top - 1); /* write barrier */
L->top--;
lua_unlock(L);
}
@ -438,7 +438,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
cl->c.f = fn;
L->top -= n;
while (n--)
setobj(&cl->c.upvalue[n], L->top+n);
setobj2n(&cl->c.upvalue[n], L->top+n);
setclvalue(L->top, cl);
api_incr_top(L);
lua_unlock(L);
@ -565,7 +565,7 @@ LUA_API void lua_rawset (lua_State *L, int index) {
api_checknelems(L, 2);
t = luaA_index(L, index);
api_check(L, ttistable(t));
setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1);
setobj2t(luaH_set(L, hvalue(t), L->top-2), L->top-1); /* write barrier */
L->top -= 2;
lua_unlock(L);
}
@ -577,7 +577,7 @@ LUA_API void lua_rawseti (lua_State *L, int index, int n) {
api_checknelems(L, 1);
o = luaA_index(L, index);
api_check(L, ttistable(o));
setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1);
setobj2t(luaH_setnum(L, hvalue(o), n), L->top-1); /* write barrier */
L->top--;
lua_unlock(L);
}
@ -593,11 +593,11 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
api_check(L, ttistable(mt));
switch (ttype(obj)) {
case LUA_TTABLE: {
hvalue(obj)->metatable = hvalue(mt);
hvalue(obj)->metatable = hvalue(mt); /* write barrier */
break;
}
case LUA_TUSERDATA: {
uvalue(obj)->uv.metatable = hvalue(mt);
uvalue(obj)->uv.metatable = hvalue(mt); /* write barrier */
break;
}
default: {

View File

@ -1,5 +1,5 @@
/*
** $Id: lcode.c,v 1.111 2002/08/21 18:56:33 roberto Exp roberto $
** $Id: lcode.c,v 1.112 2002/10/16 20:40:58 roberto Exp roberto $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@ -214,7 +214,7 @@ static int addk (FuncState *fs, TObject *k, TObject *v) {
Proto *f = fs->f;
luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
MAXARG_Bx, "constant table overflow");
setobj(&f->k[fs->nk], v);
setobj2n(&f->k[fs->nk], v);
setnvalue(luaH_set(fs->L, fs->h, k), fs->nk);
return fs->nk++;
}

4
ldo.c
View File

@ -1,5 +1,5 @@
/*
** $Id: ldo.c,v 1.199 2002/11/07 15:37:10 roberto Exp roberto $
** $Id: ldo.c,v 1.200 2002/11/13 11:31:39 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@ -188,7 +188,7 @@ static void adjust_varargs (lua_State *L, int nfixargs, StkId base) {
actual -= nfixargs; /* number of extra arguments */
htab = luaH_new(L, 0, 0); /* create `arg' table */
for (i=0; i<actual; i++) /* put extra arguments into `arg' table */
setobj2t(luaH_setnum(L, htab, i+1), L->top - actual + i);
setobj2n(luaH_setnum(L, htab, i+1), L->top - actual + i);
/* store counter in field `n' */
setsvalue(&nname, luaS_newliteral(L, "n"));
setnvalue(luaH_set(L, htab, &nname), actual);

View File

@ -1,5 +1,5 @@
/*
** $Id: lfunc.c,v 1.61 2002/10/21 20:41:46 roberto Exp roberto $
** $Id: lfunc.c,v 1.62 2002/11/13 11:31:39 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@ -64,7 +64,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
void luaF_close (lua_State *L, StkId level) {
UpVal *p;
while ((p = ngcotouv(L->openupval)) != NULL && p->v >= level) {
setobj(&p->value, p->v); /* save current value */
setobj(&p->value, p->v); /* save current value (write barrier) */
p->v = &p->value; /* now current value lives here */
L->openupval = p->next; /* remove from `open' list */
luaC_link(L, valtogco(p), LUA_TUPVAL);

View File

@ -1,5 +1,5 @@
/*
** $Id: lstate.c,v 1.109 2002/10/25 21:30:00 roberto Exp roberto $
** $Id: lstate.c,v 1.110 2002/11/13 11:31:39 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@ -129,7 +129,7 @@ lua_State *luaE_newthread (lua_State *L) {
preinit_state(L1);
L1->l_G = L->l_G;
stack_init(L1, L); /* init stack */
setobj(gt(L1), gt(L)); /* share table of globals */
setobj2n(gt(L1), gt(L)); /* share table of globals */
return L1;
}

View File

@ -1,5 +1,5 @@
/*
** $Id: ltable.c,v 1.121 2002/11/13 11:31:39 roberto Exp roberto $
** $Id: ltable.c,v 1.122 2002/11/14 11:51:50 roberto Exp roberto $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@ -372,7 +372,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
mp = n;
}
}
setobj2t(key(mp), key);
setobj2t(key(mp), key); /* write barrier */
lua_assert(ttisnil(val(mp)));
for (;;) { /* correct `firstfree' */
if (ttisnil(key(t->firstfree)))

View File

@ -1,5 +1,5 @@
/*
** $Id: lundump.c,v 1.43 2002/08/07 00:36:03 lhf Exp lhf $
** $Id: lundump.c,v 1.56 2002/10/25 21:30:41 roberto Exp roberto $
** load pre-compiled Lua chunks
** See Copyright Notice in lua.h
*/
@ -154,7 +154,7 @@ static void LoadConstants (LoadState* S, Proto* f)
setnvalue(o,LoadNumber(S));
break;
case LUA_TSTRING:
setsvalue(o,LoadString(S));
setsvalue2n(o,LoadString(S));
break;
case LUA_TNIL:
setnilvalue(o);

12
lvm.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 1.259 2002/11/06 19:08:00 roberto Exp roberto $
** $Id: lvm.c,v 1.260 2002/11/07 15:37:10 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@ -57,13 +57,13 @@ const TObject *luaV_tonumber (const TObject *obj, TObject *n) {
}
int luaV_tostring (lua_State *L, TObject *obj) {
int luaV_tostring (lua_State *L, StkId obj) {
if (!ttisnumber(obj))
return 0;
else {
char s[32]; /* 16 digits, sign, point and \0 (+ some extra...) */
lua_number2str(s, nvalue(obj));
setsvalue(obj, luaS_new(L, s));
setsvalue2s(obj, luaS_new(L, s));
return 1;
}
}
@ -176,7 +176,7 @@ void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {
TObject *oldval = luaH_set(L, h, key); /* do a primitive set */
if (!ttisnil(oldval) || /* result is no nil? */
(tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
setobj2t(oldval, val);
setobj2t(oldval, val); /* write barrier */
return;
}
/* else will try the tag method */
@ -453,7 +453,7 @@ StkId luaV_execute (lua_State *L) {
}
case OP_SETUPVAL: {
int b = GETARG_B(i);
setobj(cl->upvals[b]->v, ra);
setobj(cl->upvals[b]->v, ra); /* write barrier */
break;
}
case OP_SETTABLE: {
@ -696,7 +696,7 @@ StkId luaV_execute (lua_State *L) {
}
bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */
for (; n > 0; n--)
setobj2t(luaH_setnum(L, h, bc+n), ra+n);
setobj2t(luaH_setnum(L, h, bc+n), ra+n); /* write barrier */
break;
}
case OP_CLOSE: {