diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-10 13:39:35 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-10 13:39:35 -0200 |
commit | d915cf4f9dbe525f8faeb4cb04df13d5f08692da (patch) | |
tree | b166ca7e66e02999fee1500363c4d301b7e53951 /lstring.c | |
parent | 53fb65d39451f9245d8ed555f941829520ee6f24 (diff) | |
download | lua-d915cf4f9dbe525f8faeb4cb04df13d5f08692da.tar.gz lua-d915cf4f9dbe525f8faeb4cb04df13d5f08692da.tar.bz2 lua-d915cf4f9dbe525f8faeb4cb04df13d5f08692da.zip |
ways to measure number of `blocks' for GC + details
Diffstat (limited to 'lstring.c')
-rw-r--r-- | lstring.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 1.25 1999/10/19 13:33:22 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 1.26 1999/11/04 17:22:26 roberto Exp roberto $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -15,7 +15,8 @@ | |||
15 | 15 | ||
16 | 16 | ||
17 | 17 | ||
18 | #define gcsizestring(l) (1+(l/64)) /* "weight" for a string with length 'l' */ | 18 | #define gcsizestring(l) numblocks(0, sizeof(TaggedString)+l) |
19 | #define gcsizeudata gcsizestring(0) | ||
19 | 20 | ||
20 | 21 | ||
21 | 22 | ||
@@ -109,7 +110,7 @@ static TaggedString *newone_u (void *buff, int tag, unsigned long h) { | |||
109 | ts->u.d.value = buff; | 110 | ts->u.d.value = buff; |
110 | ts->u.d.tag = (tag == LUA_ANYTAG) ? 0 : tag; | 111 | ts->u.d.tag = (tag == LUA_ANYTAG) ? 0 : tag; |
111 | ts->constindex = -1; /* tag -> this is a userdata */ | 112 | ts->constindex = -1; /* tag -> this is a userdata */ |
112 | L->nblocks++; | 113 | L->nblocks += gcsizeudata; |
113 | return ts; | 114 | return ts; |
114 | } | 115 | } |
115 | 116 | ||
@@ -147,7 +148,7 @@ TaggedString *luaS_newlstr (const char *str, long l) { | |||
147 | 148 | ||
148 | 149 | ||
149 | TaggedString *luaS_createudata (void *udata, int tag) { | 150 | TaggedString *luaS_createudata (void *udata, int tag) { |
150 | unsigned long h = (IntPoint)udata; | 151 | unsigned long h = IntPoint(udata); |
151 | stringtable *tb = &L->string_root[(h%NUM_HASHUDATA)+NUM_HASHSTR]; | 152 | stringtable *tb = &L->string_root[(h%NUM_HASHUDATA)+NUM_HASHSTR]; |
152 | int h1 = h%tb->size; | 153 | int h1 = h%tb->size; |
153 | TaggedString *ts; | 154 | TaggedString *ts; |
@@ -175,7 +176,7 @@ TaggedString *luaS_newfixedstring (const char *str) { | |||
175 | 176 | ||
176 | void luaS_free (TaggedString *t) { | 177 | void luaS_free (TaggedString *t) { |
177 | if (t->constindex == -1) /* is userdata? */ | 178 | if (t->constindex == -1) /* is userdata? */ |
178 | L->nblocks--; | 179 | L->nblocks -= gcsizeudata; |
179 | else { /* is string */ | 180 | else { /* is string */ |
180 | L->nblocks -= gcsizestring(t->u.s.len); | 181 | L->nblocks -= gcsizestring(t->u.s.len); |
181 | luaM_free(t->u.s.gv); | 182 | luaM_free(t->u.s.gv); |