Add new sharetable

This commit is contained in:
Cloud Wu
2019-04-17 21:30:47 +08:00
committed by 云风
parent 2ceb642b5d
commit 76b166f04a
8 changed files with 392 additions and 3 deletions

View File

@@ -1018,6 +1018,7 @@ static l_mem atomic (lua_State *L) {
clearvalues(g, g->allweak, origall);
luaS_clearcache(g);
g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
luaS_collect(g, 0); /* send short strings set to gc thread */
work += g->GCmemtrav; /* complete counting */
return work; /* estimate of memory marked by 'atomic' */
}
@@ -1084,7 +1085,6 @@ static lu_mem singlestep (lua_State *L) {
return (n * GCFINALIZECOST);
}
else { /* emergency mode or no more finalizers */
luaS_collect(g, 0); /* send short strings set to gc thread */
g->gcstate = GCSpause; /* finish collection */
return 0;
}

View File

@@ -509,7 +509,7 @@ exist(struct ssm_ref *r, TString *s) {
TString *t = r->array[mid];
if (t == s)
return 1;
if (s > t)
if (memcmp(&s,&t,sizeof(TString *)) > 0)
begin = mid + 1;
else
end = mid - 1;

View File

@@ -207,6 +207,8 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
const TValue *tm; /* '__newindex' metamethod */
if (slot != NULL) { /* is 't' a table? */
Table *h = hvalue(t); /* save 't' table */
if (isshared(h))
luaG_typeerror(L, t, "change");
lua_assert(ttisnil(slot)); /* old value must be nil */
tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */
if (tm == NULL) { /* no metamethod? */

View File

@@ -81,7 +81,7 @@
(!ttistable(t) \
? (slot = NULL, 0) \
: (slot = f(hvalue(t), k), \
ttisnil(slot) ? 0 \
(ttisnil(slot) || isshared(hvalue(t))) ? 0 \
: (luaC_barrierback(L, hvalue(t), v), \
setobj2t(L, cast(TValue *,slot), v), \
1)))