aboutsummaryrefslogtreecommitdiff
path: root/lstate.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-29 17:05:47 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-29 17:05:47 -0300
commit0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b (patch)
treeb7af445c2b08aa760b3315c6083c4bb30387f2ee /lstate.h
parentb4c353434f28f3e9d4c45e61d42b4fd07d76cad2 (diff)
downloadlua-0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b.tar.gz
lua-0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b.tar.bz2
lua-0dc5deca1c0182a4a3db2fcfd7bc721f27fb352b.zip
Optimization in 'markold'
OLD1 objects can be potentially anywhere in the 'allgc' list (up to 'reallyold'), but frequently they are all after 'old1' (natural evolution of survivals) or do not exist at all (when all objects die young). So, instead of 'markold' starts looking for them always from the start of 'allgc', the collector keeps an extra pointer, 'firstold1', that points to the first OLD1 object in the 'allgc' list, or is NULL if there are no OLD1 objects in that list.
Diffstat (limited to '')
-rw-r--r--lstate.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/lstate.h b/lstate.h
index c02b4c8b..697d73b2 100644
--- a/lstate.h
+++ b/lstate.h
@@ -46,6 +46,15 @@
46** lists. Moreover, barriers can age young objects in young lists as 46** lists. Moreover, barriers can age young objects in young lists as
47** OLD0, which then become OLD1. However, a list never contains 47** OLD0, which then become OLD1. However, a list never contains
48** elements younger than their main ages. 48** elements younger than their main ages.
49**
50** The generational collector also uses a pointer 'firstold1', which
51** points to the first OLD1 object in the list. It is used to optimize
52** 'markold'. (Potentially OLD1 objects can be anywhere between 'allgc'
53** and 'reallyold', but often the list has no OLD1 objects or they are
54** after 'old1'.) Note the difference between it and 'old1':
55** 'firstold1': no OLD1 objects before this point; there can be all
56** ages after it.
57** 'old1': no objects younger than OLD1 after this point.
49*/ 58*/
50 59
51/* 60/*
@@ -54,7 +63,7 @@
54** can become gray have such a field. The field is not the same 63** can become gray have such a field. The field is not the same
55** in all objects, but it always has this name.) Any gray object 64** in all objects, but it always has this name.) Any gray object
56** must belong to one of these lists, and all objects in these lists 65** must belong to one of these lists, and all objects in these lists
57** must be gray: 66** must be gray (with one exception explained below):
58** 67**
59** 'gray': regular gray objects, still waiting to be visited. 68** 'gray': regular gray objects, still waiting to be visited.
60** 'grayagain': objects that must be revisited at the atomic phase. 69** 'grayagain': objects that must be revisited at the atomic phase.
@@ -65,6 +74,12 @@
65** 'weak': tables with weak values to be cleared; 74** 'weak': tables with weak values to be cleared;
66** 'ephemeron': ephemeron tables with white->white entries; 75** 'ephemeron': ephemeron tables with white->white entries;
67** 'allweak': tables with weak keys and/or weak values to be cleared. 76** 'allweak': tables with weak keys and/or weak values to be cleared.
77**
78** The exception to that "gray rule" is the TOUCHED2 objects in
79** generational mode. Those objects stay in a gray list (because they
80** must be visited again at the end of the cycle), but they are marked
81** black (because assignments to them must activate barriers, to move
82** them back to TOUCHED1).
68*/ 83*/
69 84
70 85
@@ -266,6 +281,7 @@ typedef struct global_State {
266 GCObject *survival; /* start of objects that survived one GC cycle */ 281 GCObject *survival; /* start of objects that survived one GC cycle */
267 GCObject *old1; /* start of old1 objects */ 282 GCObject *old1; /* start of old1 objects */
268 GCObject *reallyold; /* objects more than one cycle old ("really old") */ 283 GCObject *reallyold; /* objects more than one cycle old ("really old") */
284 GCObject *firstold1; /* first OLD1 object in the list (if any) */
269 GCObject *finobjsur; /* list of survival objects with finalizers */ 285 GCObject *finobjsur; /* list of survival objects with finalizers */
270 GCObject *finobjold1; /* list of old1 objects with finalizers */ 286 GCObject *finobjold1; /* list of old1 objects with finalizers */
271 GCObject *finobjrold; /* list of really old objects with finalizers */ 287 GCObject *finobjrold; /* list of really old objects with finalizers */