aboutsummaryrefslogtreecommitdiff
path: root/lgc.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-09-19 19:02:14 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-09-19 19:02:14 -0300
commitddfa1fbccfe4c1ec69f7396a4f5842abe70927ba (patch)
treedf467dc5dc5c64a21bb976ec661796d17d37f791 /lgc.h
parentb443145ff3415fcaee903a7d95fa7212df5a77db (diff)
downloadlua-ddfa1fbccfe4c1ec69f7396a4f5842abe70927ba.tar.gz
lua-ddfa1fbccfe4c1ec69f7396a4f5842abe70927ba.tar.bz2
lua-ddfa1fbccfe4c1ec69f7396a4f5842abe70927ba.zip
GC back to controling pace counting bytes
Memory is the resource we want to save. Still to be reviewed again.
Diffstat (limited to 'lgc.h')
-rw-r--r--lgc.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/lgc.h b/lgc.h
index a30755d0..0b16ac7f 100644
--- a/lgc.h
+++ b/lgc.h
@@ -23,8 +23,9 @@
23** never point to a white one. Moreover, any gray object must be in a 23** never point to a white one. Moreover, any gray object must be in a
24** "gray list" (gray, grayagain, weak, allweak, ephemeron) so that it 24** "gray list" (gray, grayagain, weak, allweak, ephemeron) so that it
25** can be visited again before finishing the collection cycle. (Open 25** can be visited again before finishing the collection cycle. (Open
26** upvalues are an exception to this rule.) These lists have no meaning 26** upvalues are an exception to this rule, as they are attached to
27** when the invariant is not being enforced (e.g., sweep phase). 27** a corresponding thread.) These lists have no meaning when the
28** invariant is not being enforced (e.g., sweep phase).
28*/ 29*/
29 30
30 31
@@ -48,10 +49,10 @@
48 49
49/* 50/*
50** macro to tell when main invariant (white objects cannot point to black 51** macro to tell when main invariant (white objects cannot point to black
51** ones) must be kept. During a collection, the sweep 52** ones) must be kept. During a collection, the sweep phase may break
52** phase may break the invariant, as objects turned white may point to 53** the invariant, as objects turned white may point to still-black
53** still-black objects. The invariant is restored when sweep ends and 54** objects. The invariant is restored when sweep ends and all objects
54** all objects are white again. 55** are white again.
55*/ 56*/
56 57
57#define keepinvariant(g) ((g)->gcstate <= GCSatomic) 58#define keepinvariant(g) ((g)->gcstate <= GCSatomic)
@@ -163,34 +164,37 @@
163 164
164/* 165/*
165** Minor collections will shift to major ones after LUAI_MINORMAJOR% 166** Minor collections will shift to major ones after LUAI_MINORMAJOR%
166** objects become old. 167** bytes become old.
167*/ 168*/
168#define LUAI_MINORMAJOR 100 169#define LUAI_MINORMAJOR 100
169 170
170/* 171/*
171** Major collections will shift to minor ones after a collection 172** Major collections will shift to minor ones after a collection
172** collects at least LUAI_MAJORMINOR% of the new objects. 173** collects at least LUAI_MAJORMINOR% of the new bytes.
173*/ 174*/
174#define LUAI_MAJORMINOR 50 175#define LUAI_MAJORMINOR 50
175 176
176/* 177/*
177** A young (minor) collection will run after creating LUAI_GENMINORMUL% 178** A young (minor) collection will run after creating LUAI_GENMINORMUL%
178** new objects. 179** new bytes.
179*/ 180*/
180#define LUAI_GENMINORMUL 25 181#define LUAI_GENMINORMUL 25
181 182
182 183
183/* incremental */ 184/* incremental */
184 185
185/* Number of objects must be LUAI_GCPAUSE% before starting new cycle */ 186/* Number of bytes must be LUAI_GCPAUSE% before starting new cycle */
186#define LUAI_GCPAUSE 200 187#define LUAI_GCPAUSE 200
187 188
188/* Step multiplier. (Roughly, the collector handles LUAI_GCMUL% objects 189/*
189 for each new allocated object.) */ 190** Step multiplier: The collector handles LUAI_GCMUL% work units for
190#define LUAI_GCMUL 200 191** each new allocated byte. (Each "work unit" corresponds roughly to
192** sweeping or marking one object.)
193*/
194#define LUAI_GCMUL 20 /* ??? */
191 195
192/* How many objects to allocate before next GC step */ 196/* How many bytes to allocate before next GC step */
193#define LUAI_GCSTEPSIZE 250 197#define LUAI_GCSTEPSIZE (250 * sizeof(void*))
194 198
195 199
196#define setgcparam(g,p,v) (g->gcparams[LUA_GCP##p] = luaO_codeparam(v)) 200#define setgcparam(g,p,v) (g->gcparams[LUA_GCP##p] = luaO_codeparam(v))