浏览代码

documentation for write barriers

Roberto Ierusalimschy 23 年之前
父节点
当前提交
41fd639cab
共有 8 个文件被更改,包括 25 次插入25 次删除
  1. 7 7
      lapi.c
  2. 2 2
      lcode.c
  3. 2 2
      ldo.c
  4. 2 2
      lfunc.c
  5. 2 2
      lstate.c
  6. 2 2
      ltable.c
  7. 2 2
      lundump.c
  8. 6 6
      lvm.c

+ 7 - 7
lapi.c

@@ -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
 ** Lua API
 ** See Copyright Notice in lua.h
 ** 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_API void lua_replace (lua_State *L, int index) {
   lua_lock(L);
   lua_lock(L);
   api_checknelems(L, 1);
   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--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -438,7 +438,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
   cl->c.f = fn;
   cl->c.f = fn;
   L->top -= n;
   L->top -= n;
   while (n--)
   while (n--)
-    setobj(&cl->c.upvalue[n], L->top+n);
+    setobj2n(&cl->c.upvalue[n], L->top+n);
   setclvalue(L->top, cl);
   setclvalue(L->top, cl);
   api_incr_top(L);
   api_incr_top(L);
   lua_unlock(L);
   lua_unlock(L);
@@ -565,7 +565,7 @@ LUA_API void lua_rawset (lua_State *L, int index) {
   api_checknelems(L, 2);
   api_checknelems(L, 2);
   t = luaA_index(L, index);
   t = luaA_index(L, index);
   api_check(L, ttistable(t));
   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;
   L->top -= 2;
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -577,7 +577,7 @@ LUA_API void lua_rawseti (lua_State *L, int index, int n) {
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   o = luaA_index(L, index);
   o = luaA_index(L, index);
   api_check(L, ttistable(o));
   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--;
   L->top--;
   lua_unlock(L);
   lua_unlock(L);
 }
 }
@@ -593,11 +593,11 @@ LUA_API int lua_setmetatable (lua_State *L, int objindex) {
   api_check(L, ttistable(mt));
   api_check(L, ttistable(mt));
   switch (ttype(obj)) {
   switch (ttype(obj)) {
     case LUA_TTABLE: {
     case LUA_TTABLE: {
-      hvalue(obj)->metatable = hvalue(mt);
+      hvalue(obj)->metatable = hvalue(mt);  /* write barrier */
       break;
       break;
     }
     }
     case LUA_TUSERDATA: {
     case LUA_TUSERDATA: {
-      uvalue(obj)->uv.metatable = hvalue(mt);
+      uvalue(obj)->uv.metatable = hvalue(mt);  /* write barrier */
       break;
       break;
     }
     }
     default: {
     default: {

+ 2 - 2
lcode.c

@@ -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
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -214,7 +214,7 @@ static int addk (FuncState *fs, TObject *k, TObject *v) {
     Proto *f = fs->f;
     Proto *f = fs->f;
     luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
     luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject,
                     MAXARG_Bx, "constant table overflow");
                     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);
     setnvalue(luaH_set(fs->L, fs->h, k), fs->nk);
     return fs->nk++;
     return fs->nk++;
   }
   }

+ 2 - 2
ldo.c

@@ -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
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 ** 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 */
   actual -= nfixargs;  /* number of extra arguments */
   htab = luaH_new(L, 0, 0);  /* create `arg' table */
   htab = luaH_new(L, 0, 0);  /* create `arg' table */
   for (i=0; i<actual; i++)  /* put extra arguments into `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' */
   /* store counter in field `n' */
   setsvalue(&nname, luaS_newliteral(L, "n"));
   setsvalue(&nname, luaS_newliteral(L, "n"));
   setnvalue(luaH_set(L, htab, &nname), actual);
   setnvalue(luaH_set(L, htab, &nname), actual);

+ 2 - 2
lfunc.c

@@ -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
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 ** 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) {
 void luaF_close (lua_State *L, StkId level) {
   UpVal *p;
   UpVal *p;
   while ((p = ngcotouv(L->openupval)) != NULL && p->v >= level) {
   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 */
     p->v = &p->value;  /* now current value lives here */
     L->openupval = p->next;  /* remove from `open' list */
     L->openupval = p->next;  /* remove from `open' list */
     luaC_link(L, valtogco(p), LUA_TUPVAL);
     luaC_link(L, valtogco(p), LUA_TUPVAL);

+ 2 - 2
lstate.c

@@ -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
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -129,7 +129,7 @@ lua_State *luaE_newthread (lua_State *L) {
   preinit_state(L1);
   preinit_state(L1);
   L1->l_G = L->l_G;
   L1->l_G = L->l_G;
   stack_init(L1, L);  /* init stack */
   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;
   return L1;
 }
 }
 
 

+ 2 - 2
ltable.c

@@ -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)
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -372,7 +372,7 @@ static TObject *newkey (lua_State *L, Table *t, const TObject *key) {
       mp = n;
       mp = n;
     }
     }
   }
   }
-  setobj2t(key(mp), key);
+  setobj2t(key(mp), key);  /* write barrier */
   lua_assert(ttisnil(val(mp)));
   lua_assert(ttisnil(val(mp)));
   for (;;) {  /* correct `firstfree' */
   for (;;) {  /* correct `firstfree' */
     if (ttisnil(key(t->firstfree)))
     if (ttisnil(key(t->firstfree)))

+ 2 - 2
lundump.c

@@ -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
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -154,7 +154,7 @@ static void LoadConstants (LoadState* S, Proto* f)
 	setnvalue(o,LoadNumber(S));
 	setnvalue(o,LoadNumber(S));
 	break;
 	break;
    case LUA_TSTRING:
    case LUA_TSTRING:
-	setsvalue(o,LoadString(S));
+	setsvalue2n(o,LoadString(S));
 	break;
 	break;
    case LUA_TNIL:
    case LUA_TNIL:
    	setnilvalue(o);
    	setnilvalue(o);

+ 6 - 6
lvm.c

@@ -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
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** 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))
   if (!ttisnumber(obj))
     return 0;
     return 0;
   else {
   else {
     char s[32];  /* 16 digits, sign, point and \0  (+ some extra...) */
     char s[32];  /* 16 digits, sign, point and \0  (+ some extra...) */
     lua_number2str(s, nvalue(obj));
     lua_number2str(s, nvalue(obj));
-    setsvalue(obj, luaS_new(L, s));
+    setsvalue2s(obj, luaS_new(L, s));
     return 1;
     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 */
       TObject *oldval = luaH_set(L, h, key); /* do a primitive set */
       if (!ttisnil(oldval) ||  /* result is no nil? */
       if (!ttisnil(oldval) ||  /* result is no nil? */
           (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
           (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
-        setobj2t(oldval, val);
+        setobj2t(oldval, val);  /* write barrier */
         return;
         return;
       }
       }
       /* else will try the tag method */
       /* else will try the tag method */
@@ -453,7 +453,7 @@ StkId luaV_execute (lua_State *L) {
       }
       }
       case OP_SETUPVAL: {
       case OP_SETUPVAL: {
         int b = GETARG_B(i);
         int b = GETARG_B(i);
-        setobj(cl->upvals[b]->v, ra);
+        setobj(cl->upvals[b]->v, ra);  /* write barrier */
         break;
         break;
       }
       }
       case OP_SETTABLE: {
       case OP_SETTABLE: {
@@ -696,7 +696,7 @@ StkId luaV_execute (lua_State *L) {
         }
         }
         bc &= ~(LFIELDS_PER_FLUSH-1);  /* bc = bc - bc%FPF */
         bc &= ~(LFIELDS_PER_FLUSH-1);  /* bc = bc - bc%FPF */
         for (; n > 0; n--)
         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;
         break;
       }
       }
       case OP_CLOSE: {
       case OP_CLOSE: {