summaryrefslogtreecommitdiff
path: root/libguile/whippet/benchmarks/simple-allocator.h
blob: 09ed8f3be4221be87593e79b0a5a7211a0446d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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