Coverage Report

Created: 2017-04-15 07:07

/home/travis/build/MoarVM/MoarVM/src/spesh/candidate.h
Line
Count
Source (jump to first uncovered line)
1
/* A specialization candidate. */
2
struct MVMSpeshCandidate {
3
    /* The callsite we should have for a match. */
4
    MVMCallsite *cs;
5
6
    /* Guards on incoming args. */
7
    MVMSpeshGuard *guards;
8
9
    /* Number of guards we have. */
10
    MVMuint32 num_guards;
11
12
    /* Length of the specialized bytecode in bytes. */
13
    MVMuint32 bytecode_size;
14
15
    /* The specialized bytecode. */
16
    MVMuint8 *bytecode;
17
18
    /* Frame handlers for this specialization. */
19
    MVMFrameHandler *handlers;
20
21
    /* Spesh slots, used to hold information for fast access. */
22
    MVMCollectable **spesh_slots;
23
24
    /* Number of spesh slots. */
25
    MVMuint32 num_spesh_slots;
26
27
    /* The number of deoptimization mappings we have. */
28
    MVMuint32 num_deopts;
29
30
    /* Deoptimization mappings. */
31
    MVMint32 *deopts;
32
33
    /* Atomic integer for the number of times we've entered the code so far
34
     * for the purpose of logging, in the trace phase. We used this as an
35
     * index into the log slots when running logging code. Once it hits the
36
     * limit on number of log attempts it increments no further. */
37
    AO_t log_enter_idx;
38
39
    /* Atomic integer for the number of times we need to exit the logging
40
     * version of the code. When this hits zero, we know we were the last
41
     * run, that there are no remaining runs, and so we should finalize
42
     * the specialization. */
43
    AO_t log_exits_remaining;
44
45
    /* The spesh graph, if we're still in the process of producing a
46
     * specialization for this candidate. NULL afterwards. */
47
    MVMSpeshGraph *sg;
48
49
    /* Logging slots, used when we're in the log phase of producing
50
     * a specialization. */
51
    MVMCollectable **log_slots;
52
53
    /* Number of logging slots. */
54
    MVMuint32 num_log_slots;
55
56
    /* Number of inlines and inlines table; see graph.h for description of
57
     * the table format. */
58
    MVMint32 num_inlines;
59
    MVMSpeshInline *inlines;
60
61
    /* The list of local types (only set up if we do inlines). */
62
    MVMuint16 *local_types;
63
64
    /* The list of lexical types (only set up if we do inlines). */
65
    MVMuint16 *lexical_types;
66
67
    /* Number of locals the specialized code has (may be different from the
68
     * original frame thanks to inlining). */
69
    MVMuint16 num_locals;
70
71
    /* Number of lexicals the specialized code has. */
72
    MVMuint16 num_lexicals;
73
74
    /* Memory sizes to allocate for work/env, taking into account inlining. */
75
    MVMuint32 work_size;
76
    MVMuint32 env_size;
77
78
    /* Number of handlers. */
79
    MVMuint32 num_handlers;
80
81
    /* Whether this is a candidate we're in the process of doing OSR logging
82
     * on. */
83
    MVMuint32 osr_logging;
84
85
    /* JIT-code structure */
86
    MVMJitCode *jitcode;
87
};
88
89
/* The number of specializations we'll allow per static frame. */
90
723k
#define MVM_SPESH_LIMIT 4
91
92
/* A specialization guard. */
93
struct MVMSpeshGuard {
94
    /* The kind of guard this is. */
95
    MVMint32 kind;
96
97
    /* The incoming argument slot it applies to. */
98
    MVMint32 slot;
99
100
    /* Object we might be wanting to match against. */
101
    MVMCollectable *match;
102
};
103
104
/* Kinds of guard we have. */
105
13.6M
#define MVM_SPESH_GUARD_CONC       1   /* Value is concrete with match type. */
106
2.05M
#define MVM_SPESH_GUARD_TYPE       2   /* Value is type object with match type. */
107
0
#define MVM_SPESH_GUARD_DC_CONC    3   /* Decont'd value is concrete with match type. */
108
0
#define MVM_SPESH_GUARD_DC_TYPE    4   /* Decont'd value is type object with match type. */
109
0
#define MVM_SPESH_GUARD_DC_CONC_RW 5   /* Decont'd value is concrete with match type; rw cont. */
110
0
#define MVM_SPESH_GUARD_DC_TYPE_RW 6   /* Decont'd value is type object with match type; rw cont. */
111
112
/* Functions for generating a specialization. */
113
MVMSpeshCandidate * MVM_spesh_candidate_setup(MVMThreadContext *tc,
114
    MVMStaticFrame *static_frame, MVMCallsite *callsite, MVMRegister *args,
115
    MVMint32 osr);
116
void MVM_spesh_candidate_specialize(MVMThreadContext *tc, MVMStaticFrame *static_frame,
117
        MVMSpeshCandidate *candidate);
118
void MVM_spesh_candidate_destroy(MVMThreadContext *tc, MVMSpeshCandidate *candidate);