Coverage Report

Created: 2017-04-15 07:07

/home/travis/build/MoarVM/MoarVM/src/core/interp.h
Line
Count
Source (jump to first uncovered line)
1
/* A GC sync point is a point where we can check if we're being signalled
2
 * to stop to do a GC run. This is placed at points where it is safe to
3
 * do such a thing, and hopefully so that it happens often enough; note
4
 * that every call down to the allocator is also a sync point, so this
5
 * really only means we need to do this enough to make sure tight native
6
 * loops trigger it. */
7
/* Don't use a MVM_load(&tc->gc_status) here for performance, it's okay
8
 * if the interrupt is delayed a bit. */
9
#define GC_SYNC_POINT(tc) \
10
    if (tc->gc_status) { \
11
        MVM_gc_enter_from_interrupt(tc); \
12
    }
13
14
/* Different views of a register. */
15
union MVMRegister {
16
    MVMObject         *o;
17
    MVMString *s;
18
    MVMint8            i8;
19
    MVMuint8           u8;
20
    MVMint16           i16;
21
    MVMuint16          u16;
22
    MVMint32           i32;
23
    MVMuint32          u32;
24
    MVMint64           i64;
25
    MVMuint64          u64;
26
    MVMnum32           n32;
27
    MVMnum64           n64;
28
};
29
30
/* Most operands an operation will have. */
31
#define MVM_MAX_OPERANDS 8
32
33
/* Kind of de-opt mark. */
34
#define MVM_DEOPT_MARK_ONE 1
35
#define MVM_DEOPT_MARK_ALL 2
36
#define MVM_DEOPT_MARK_OSR 4
37
38
/* Information about an opcode. */
39
struct MVMOpInfo {
40
    MVMuint16   opcode;
41
    const char *name;
42
    char        mark[2];
43
    MVMuint16   num_operands;
44
    MVMuint8    pure;
45
    MVMuint8    deopt_point;
46
    MVMuint8    no_inline;
47
    MVMuint8    jittivity;
48
    MVMuint8    operands[MVM_MAX_OPERANDS];
49
};
50
51
/* Operand read/write/literal flags. */
52
#define MVM_operand_literal     0
53
#define MVM_operand_read_reg    1
54
#define MVM_operand_write_reg   2
55
#define MVM_operand_read_lex    3
56
#define MVM_operand_write_lex   4
57
#define MVM_operand_rw_mask     7
58
59
/* Register data types. */
60
#define MVM_reg_int8            1
61
#define MVM_reg_int16           2
62
#define MVM_reg_int32           3
63
#define MVM_reg_int64           4
64
#define MVM_reg_num32           5
65
#define MVM_reg_num64           6
66
#define MVM_reg_str             7
67
#define MVM_reg_obj             8
68
#define MVM_reg_uint8           17
69
#define MVM_reg_uint16          18
70
#define MVM_reg_uint32          19
71
#define MVM_reg_uint64          20
72
73
/* Operand data types. */
74
#define MVM_operand_int8        (MVM_reg_int8 << 3)
75
#define MVM_operand_int16       (MVM_reg_int16 << 3)
76
#define MVM_operand_int32       (MVM_reg_int32 << 3)
77
#define MVM_operand_int64       (MVM_reg_int64 << 3)
78
#define MVM_operand_num32       (MVM_reg_num32 << 3)
79
#define MVM_operand_num64       (MVM_reg_num64 << 3)
80
#define MVM_operand_str         (MVM_reg_str << 3)
81
#define MVM_operand_obj         (MVM_reg_obj << 3)
82
#define MVM_operand_ins         (9 << 3)
83
#define MVM_operand_type_var    (10 << 3)
84
#define MVM_operand_coderef     (12 << 3)
85
#define MVM_operand_callsite    (13 << 3)
86
#define MVM_operand_spesh_slot  (16 << 3)
87
#define MVM_operand_uint8       (MVM_reg_uint8 << 3)
88
#define MVM_operand_uint16      (MVM_reg_uint16 << 3)
89
#define MVM_operand_uint32      (MVM_reg_uint32 << 3)
90
#define MVM_operand_uint64      (MVM_reg_uint64 << 3)
91
#define MVM_operand_type_mask   (31 << 3)
92
93
/* Functions. */
94
void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContext *, void *), void *invoke_data);
95
MVM_PUBLIC void MVM_interp_enable_tracing();
96
97
0
MVM_STATIC_INLINE MVMint64 MVM_BC_get_I64(const MVMuint8 *cur_op, int offset) {
98
0
    const MVMuint8 *const where = cur_op + offset;
99
0
#ifdef MVM_CAN_UNALIGNED_INT64
100
0
    return *(MVMint64 *)where;
101
0
#else
102
0
    MVMint64 temp;
103
0
    memmove(&temp, where, sizeof(MVMint64));
104
0
    return temp;
105
0
#endif
106
0
}
107
108
0
MVM_STATIC_INLINE MVMnum64 MVM_BC_get_N64(const MVMuint8 *cur_op, int offset) {
109
0
    const MVMuint8 *const where = cur_op + offset;
110
0
#ifdef MVM_CAN_UNALIGNED_NUM64
111
0
    return *(MVMnum64 *)where;
112
0
#else
113
0
    MVMnum64 temp;
114
0
    memmove(&temp, cur_op + offset, sizeof(MVMnum64));
115
0
    return temp;
116
0
#endif
117
0
}