summaryrefslogtreecommitdiff
path: root/libguile/whippet/api/mmc-attrs.h
blob: 9371f8abe082e8937e2609d0ad192d41aedba3d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef MMC_ATTRS_H
#define MMC_ATTRS_H

#include "gc-config.h"
#include "gc-assert.h"
#include "gc-attrs.h"

static inline enum gc_allocator_kind gc_allocator_kind(void) {
  return GC_ALLOCATOR_INLINE_BUMP_POINTER;
}
static inline size_t gc_allocator_small_granule_size(void) {
  return 16;
}
static inline size_t gc_allocator_large_threshold(void) {
  return 8192;
}

static inline size_t gc_allocator_allocation_pointer_offset(void) {
  return sizeof(uintptr_t) * 0;
}
static inline size_t gc_allocator_allocation_limit_offset(void) {
  return sizeof(uintptr_t) * 1;
}

static inline size_t gc_allocator_freelist_offset(size_t size,
                                                  enum gc_allocation_kind kind) {
  GC_CRASH();
}

static inline size_t gc_allocator_alloc_table_alignment(void) {
  return 4 * 1024 * 1024;
}
static inline uint8_t gc_allocator_alloc_table_begin_pattern(enum gc_allocation_kind kind) {
  uint8_t young = 1;
  uint8_t trace_precisely = 0;
  uint8_t trace_none = 8;
  uint8_t trace_conservatively = 16;
  uint8_t pinned = 16;
  if (GC_CONSERVATIVE_TRACE) {
    switch (kind) {
      case GC_ALLOCATION_TAGGED:
      case GC_ALLOCATION_UNTAGGED_CONSERVATIVE:
        return young | trace_conservatively;
      case GC_ALLOCATION_TAGGED_POINTERLESS:
        return young | trace_none;
      case GC_ALLOCATION_UNTAGGED_POINTERLESS:
        return young | trace_none;
      default:
        GC_CRASH();
      };
  } else {
    switch (kind) {
      case GC_ALLOCATION_TAGGED:
        return young | trace_precisely;
      case GC_ALLOCATION_TAGGED_POINTERLESS:
        return young | trace_none;
      case GC_ALLOCATION_UNTAGGED_POINTERLESS:
        return young | trace_none | pinned;
      case GC_ALLOCATION_UNTAGGED_CONSERVATIVE:
      default:
        GC_CRASH();
    };
  }
}
static inline uint8_t gc_allocator_alloc_table_end_pattern(void) {
  return 32;
}

static inline enum gc_old_generation_check_kind gc_old_generation_check_kind(size_t obj_size) {
  if (GC_GENERATIONAL) {
    if (obj_size <= gc_allocator_large_threshold())
      return GC_OLD_GENERATION_CHECK_ALLOC_TABLE;
    return GC_OLD_GENERATION_CHECK_SLOW;
  }
  return GC_OLD_GENERATION_CHECK_NONE;
}
static inline uint8_t gc_old_generation_check_alloc_table_tag_mask(void) {
  return 7;
}
static inline uint8_t gc_old_generation_check_alloc_table_young_tag(void) {
  return 1;
}

static inline enum gc_write_barrier_kind gc_write_barrier_kind(size_t obj_size) {
  if (GC_GENERATIONAL) {
    if (obj_size <= gc_allocator_large_threshold())
      return GC_WRITE_BARRIER_FIELD;
    return GC_WRITE_BARRIER_SLOW;
  }
  return GC_WRITE_BARRIER_NONE;
}
static inline size_t gc_write_barrier_field_table_alignment(void) {
  GC_ASSERT(GC_GENERATIONAL);
  return gc_allocator_alloc_table_alignment();
}
static inline ptrdiff_t gc_write_barrier_field_table_offset(void) {
  GC_ASSERT(GC_GENERATIONAL);
  return 0;
}
static inline size_t gc_write_barrier_field_fields_per_byte(void) {
  GC_ASSERT(GC_GENERATIONAL);
  return 2;
}
static inline uint8_t gc_write_barrier_field_first_bit_pattern(void) {
  GC_ASSERT(GC_GENERATIONAL);
  return 64; // NOFL_METADATA_BYTE_LOGGED_0
}

static inline enum gc_safepoint_mechanism gc_safepoint_mechanism(void) {
  return GC_SAFEPOINT_MECHANISM_COOPERATIVE;
}

static inline enum gc_cooperative_safepoint_kind gc_cooperative_safepoint_kind(void) {
  return GC_COOPERATIVE_SAFEPOINT_HEAP_FLAG;
}

static inline int gc_can_pin_objects(void) {
  return 1;
}

#endif // MMC_ATTRS_H