summaryrefslogtreecommitdiff
path: root/libguile/whippet/src/root.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2025-04-11 14:10:41 +0200
committerAndy Wingo <wingo@pobox.com>2025-04-11 14:10:41 +0200
commitdb181e67ff482ab08cbdb0c1a88997b3a886f900 (patch)
tree6d16fbca515ae3cf506a9d16dbc89c472446e5d9 /libguile/whippet/src/root.h
parentaf96820e072d18c49ac03e80c6f3466d568dc77d (diff)
parentf909438596f63ecd44c5b9a28385260714857361 (diff)
downloadguile-db181e67ff482ab08cbdb0c1a88997b3a886f900.tar.gz
Merged Whippet into libguile/whippet
Diffstat (limited to 'libguile/whippet/src/root.h')
-rw-r--r--libguile/whippet/src/root.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/libguile/whippet/src/root.h b/libguile/whippet/src/root.h
new file mode 100644
index 000000000..4fc705e61
--- /dev/null
+++ b/libguile/whippet/src/root.h
@@ -0,0 +1,81 @@
+#ifndef ROOT_H
+#define ROOT_H
+
+#include "gc-edge.h"
+#include "extents.h"
+
+struct gc_ephemeron;
+struct gc_heap;
+struct gc_mutator;
+struct gc_edge_buffer;
+
+enum gc_root_kind {
+ GC_ROOT_KIND_NONE,
+ GC_ROOT_KIND_HEAP,
+ GC_ROOT_KIND_MUTATOR,
+ GC_ROOT_KIND_CONSERVATIVE_EDGES,
+ GC_ROOT_KIND_CONSERVATIVE_POSSIBLY_INTERIOR_EDGES,
+ GC_ROOT_KIND_RESOLVED_EPHEMERONS,
+ GC_ROOT_KIND_EDGE,
+ GC_ROOT_KIND_EDGE_BUFFER,
+};
+
+struct gc_root {
+ enum gc_root_kind kind;
+ union {
+ struct gc_heap *heap;
+ struct gc_mutator *mutator;
+ struct gc_ephemeron *resolved_ephemerons;
+ struct extent_range range;
+ struct gc_edge edge;
+ struct gc_edge_buffer *edge_buffer;
+ };
+};
+
+static inline struct gc_root
+gc_root_heap(struct gc_heap* heap) {
+ struct gc_root ret = { GC_ROOT_KIND_HEAP };
+ ret.heap = heap;
+ return ret;
+}
+
+static inline struct gc_root
+gc_root_mutator(struct gc_mutator* mutator) {
+ struct gc_root ret = { GC_ROOT_KIND_MUTATOR };
+ ret.mutator = mutator;
+ return ret;
+}
+
+static inline struct gc_root
+gc_root_conservative_edges(uintptr_t lo_addr, uintptr_t hi_addr,
+ int possibly_interior) {
+ enum gc_root_kind kind = possibly_interior
+ ? GC_ROOT_KIND_CONSERVATIVE_POSSIBLY_INTERIOR_EDGES
+ : GC_ROOT_KIND_CONSERVATIVE_EDGES;
+ struct gc_root ret = { kind };
+ ret.range = (struct extent_range) {lo_addr, hi_addr};
+ return ret;
+}
+
+static inline struct gc_root
+gc_root_resolved_ephemerons(struct gc_ephemeron* resolved) {
+ struct gc_root ret = { GC_ROOT_KIND_RESOLVED_EPHEMERONS };
+ ret.resolved_ephemerons = resolved;
+ return ret;
+}
+
+static inline struct gc_root
+gc_root_edge(struct gc_edge edge) {
+ struct gc_root ret = { GC_ROOT_KIND_EDGE };
+ ret.edge = edge;
+ return ret;
+}
+
+static inline struct gc_root
+gc_root_edge_buffer(struct gc_edge_buffer *buf) {
+ struct gc_root ret = { GC_ROOT_KIND_EDGE_BUFFER };
+ ret.edge_buffer = buf;
+ return ret;
+}
+
+#endif // ROOT_H