-
Notifications
You must be signed in to change notification settings - Fork 7
/
tracer.h
65 lines (50 loc) · 2.5 KB
/
tracer.h
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
#ifndef TRACER_H
#define TRACER_H
#include "gc-ref.h"
#include "gc-edge.h"
#include "root.h"
struct gc_heap;
// Data types to be implemented by tracer.
struct gc_tracer;
struct gc_trace_worker;
// Data types to be implemented by collector.
struct gc_trace_worker_data;
////////////////////////////////////////////////////////////////////////
/// To be implemented by collector.
////////////////////////////////////////////////////////////////////////
// Visit all fields in an object.
static inline void trace_one(struct gc_ref ref, struct gc_heap *heap,
struct gc_trace_worker *worker) GC_ALWAYS_INLINE;
static inline void trace_root(struct gc_root root, struct gc_heap *heap,
struct gc_trace_worker *worker) GC_ALWAYS_INLINE;
static void
gc_trace_worker_call_with_data(void (*f)(struct gc_tracer *tracer,
struct gc_heap *heap,
struct gc_trace_worker *worker,
struct gc_trace_worker_data *data),
struct gc_tracer *tracer,
struct gc_heap *heap,
struct gc_trace_worker *worker);
////////////////////////////////////////////////////////////////////////
/// To be implemented by tracer.
////////////////////////////////////////////////////////////////////////
// Initialize the tracer when the heap is created.
static int gc_tracer_init(struct gc_tracer *tracer, struct gc_heap *heap,
size_t parallelism);
// Initialize the tracer for a new GC cycle.
static void gc_tracer_prepare(struct gc_tracer *tracer);
// Release any resources allocated during the trace.
static void gc_tracer_release(struct gc_tracer *tracer);
// Add root objects to the trace. Call before tracer_trace.
static inline void gc_tracer_add_root(struct gc_tracer *tracer,
struct gc_root root);
// Given that an object has been shaded grey, enqueue for tracing.
static inline void gc_trace_worker_enqueue(struct gc_trace_worker *worker,
struct gc_ref ref) GC_ALWAYS_INLINE;
static inline struct gc_trace_worker_data*
gc_trace_worker_data(struct gc_trace_worker *worker) GC_ALWAYS_INLINE;
// Just trace roots.
static inline void gc_tracer_trace_roots(struct gc_tracer *tracer);
// Run the full trace, including roots.
static inline void gc_tracer_trace(struct gc_tracer *tracer);
#endif // TRACER_H