summaryrefslogtreecommitdiff
path: root/libguile/whippet/benchmarks/simple-allocator.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/benchmarks/simple-allocator.h
parentaf96820e072d18c49ac03e80c6f3466d568dc77d (diff)
parentf909438596f63ecd44c5b9a28385260714857361 (diff)
downloadguile-db181e67ff482ab08cbdb0c1a88997b3a886f900.tar.gz
Merged Whippet into libguile/whippet
Diffstat (limited to 'libguile/whippet/benchmarks/simple-allocator.h')
-rw-r--r--libguile/whippet/benchmarks/simple-allocator.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/libguile/whippet/benchmarks/simple-allocator.h b/libguile/whippet/benchmarks/simple-allocator.h
new file mode 100644
index 000000000..09ed8f3be
--- /dev/null
+++ b/libguile/whippet/benchmarks/simple-allocator.h
@@ -0,0 +1,21 @@
+#ifndef SIMPLE_ALLOCATOR_H
+#define SIMPLE_ALLOCATOR_H
+
+#include "simple-tagging-scheme.h"
+#include "gc-api.h"
+
+static inline void*
+gc_allocate_with_kind(struct gc_mutator *mut, enum alloc_kind kind, size_t bytes) {
+ void *obj = gc_allocate(mut, bytes, GC_ALLOCATION_TAGGED);
+ *tag_word(gc_ref_from_heap_object(obj)) = tag_live(kind);
+ return obj;
+}
+
+static inline void*
+gc_allocate_pointerless_with_kind(struct gc_mutator *mut, enum alloc_kind kind, size_t bytes) {
+ void *obj = gc_allocate(mut, bytes, GC_ALLOCATION_TAGGED_POINTERLESS);
+ *tag_word(gc_ref_from_heap_object(obj)) = tag_live(kind);
+ return obj;
+}
+
+#endif // SIMPLE_ALLOCATOR_H