Coverage Report

Created: 2018-07-03 15:31

/home/travis/build/MoarVM/MoarVM/src/gc/wb.h
Line
Count
Source (jump to first uncovered line)
1
/* Functions for if the write barriers are hit. */
2
MVM_PUBLIC void MVM_gc_write_barrier_hit(MVMThreadContext *tc, MVMCollectable *update_root);
3
4
/* Ensures that if a generation 2 object comes to hold a reference to a
5
 * nursery object, then the generation 2 object becomes an inter-generational
6
 * root. */
7
0
MVM_STATIC_INLINE void MVM_gc_write_barrier(MVMThreadContext *tc, MVMCollectable *update_root, const MVMCollectable *referenced) {
8
0
    if (((update_root->flags & MVM_CF_SECOND_GEN) && referenced && !(referenced->flags & MVM_CF_SECOND_GEN)))
9
0
        MVM_gc_write_barrier_hit(tc, update_root);
10
0
}
11
12
/* Does an assignment, but makes sure the write barrier MVM_WB is applied
13
 * first. Takes the root object, the address within it we're writing to, and
14
 * the thing we're writing. Note that update_addr is not involved in the
15
 * write barrier. */
16
#if MVM_GC_DEBUG
17
#define MVM_ASSIGN_REF(tc, update_root, update_addr, referenced) \
18
    { \
19
        void *_r = referenced; \
20
        if (_r && ((MVMCollectable *)_r)->owner == 0) \
21
            MVM_panic(1, "Invalid assignment (maybe of heap frame to stack frame?)"); \
22
        MVM_ASSERT_NOT_FROMSPACE(tc, _r); \
23
        MVM_gc_write_barrier(tc, update_root, (MVMCollectable *)_r); \
24
        update_addr = _r; \
25
    }
26
#else
27
#define MVM_ASSIGN_REF(tc, update_root, update_addr, referenced) \
28
    { \
29
        void *_r = referenced; \
30
        MVM_gc_write_barrier(tc, update_root, (MVMCollectable *)_r); \
31
        update_addr = _r; \
32
    }
33
#endif