diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-04 10:31:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-04 10:31:21 -0300 |
commit | a80cada9142f9e967c710e37934067a708224161 (patch) | |
tree | b6ecc44201408c9e9cf520f47f15413531c51161 /lgc.c | |
parent | a00013c8d0d268616e004715da499e88e03b534c (diff) | |
download | lua-a80cada9142f9e967c710e37934067a708224161.tar.gz lua-a80cada9142f9e967c710e37934067a708224161.tar.bz2 lua-a80cada9142f9e967c710e37934067a708224161.zip |
new cache for interning strings
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.201 2014/12/20 13:58:15 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.202 2015/01/16 16:54:37 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -967,6 +967,19 @@ void luaC_freeallobjects (lua_State *L) { | |||
967 | } | 967 | } |
968 | 968 | ||
969 | 969 | ||
970 | /* | ||
971 | ** Clear API string cache. (Entries cannot be empty, so fill them with | ||
972 | ** a non-collectable string.) | ||
973 | */ | ||
974 | static void clearapihash (global_State *g) { | ||
975 | int i; | ||
976 | for (i = 0; i < STRCACHE_SIZE; i++) { | ||
977 | if (iswhite(g->strcache[i])) /* will entry be collected? */ | ||
978 | g->strcache[i] = g->memerrmsg; /* replace it with something fixed */ | ||
979 | } | ||
980 | } | ||
981 | |||
982 | |||
970 | static l_mem atomic (lua_State *L) { | 983 | static l_mem atomic (lua_State *L) { |
971 | global_State *g = G(L); | 984 | global_State *g = G(L); |
972 | l_mem work; | 985 | l_mem work; |
@@ -1007,6 +1020,7 @@ static l_mem atomic (lua_State *L) { | |||
1007 | /* clear values from resurrected weak tables */ | 1020 | /* clear values from resurrected weak tables */ |
1008 | clearvalues(g, g->weak, origweak); | 1021 | clearvalues(g, g->weak, origweak); |
1009 | clearvalues(g, g->allweak, origall); | 1022 | clearvalues(g, g->allweak, origall); |
1023 | clearapihash(g); | ||
1010 | g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ | 1024 | g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ |
1011 | work += g->GCmemtrav; /* complete counting */ | 1025 | work += g->GCmemtrav; /* complete counting */ |
1012 | return work; /* estimate of memory marked by 'atomic' */ | 1026 | return work; /* estimate of memory marked by 'atomic' */ |