Coverage Report

Created: 2018-07-03 15:31

/home/travis/build/MoarVM/MoarVM/src/spesh/plan.h
Line
Count
Source
1
/* The minimum number OSR hits a static frame as a whole has to receive
2
 * (across all callsites and type tuples) before it is hot enough to further
3
 * consider. */
4
274k
#define MVM_SPESH_PLAN_SF_MIN_OSR   100
5
6
/* The minimum number of hits or OSR hits a given static frame and interned
7
 * callsite combination have to have before it is hot enough to further
8
 * consider. */
9
50.7k
#define MVM_SPESH_PLAN_CS_MIN_OSR   100
10
11
/* The percentage of hits or OSR hits that a type tuple should receive, out of
12
 * the total callsite hits, to receive an "observed types" specialization. */
13
99.6k
#define MVM_SPESH_PLAN_TT_OBS_PERCENT       25
14
70.7k
#define MVM_SPESH_PLAN_TT_OBS_PERCENT_OSR   25
15
16
/* The plan of what specializations to produce. */
17
struct MVMSpeshPlan {
18
    /* List of planned specializations. */
19
    MVMSpeshPlanned *planned;
20
21
    /* Number of planned specializations. */
22
    MVMuint32 num_planned;
23
24
    /* The number of specialization plans space is allocated for. */
25
    MVMuint32 alloc_planned;
26
};
27
28
/* Kinds of specializations we might decide to produce. */
29
typedef enum {
30
    /* A certain specialization based only on callsite. */
31
    MVM_SPESH_PLANNED_CERTAIN,
32
33
    /* A specialization based on an exact observed argument type tuple. */
34
    MVM_SPESH_PLANNED_OBSERVED_TYPES,
35
36
    /* A specialization based on analysis of various argument types that
37
     * showed up. This may happen when one argument type is predcitable, but
38
     * others are not. */
39
    MVM_SPESH_PLANNED_DERIVED_TYPES
40
} MVMSpeshPlannedKind;
41
42
/* An planned specialization that should be produced. */
43
struct MVMSpeshPlanned {
44
    /* What kind of specialization we're planning. */
45
    MVMSpeshPlannedKind kind;
46
47
    /* The maximum stack depth this was seen at; used to sort the plan so we
48
     * can specialize deepest first, in hope of having callees specialized
49
     * ahead of callers. */
50
    MVMuint32 max_depth;
51
52
    /* The static frame with the code to specialize. */
53
    MVMStaticFrame *sf;
54
55
    /* The callsite statistics entry that this specialization was planned as
56
     * a result of (by extension, we find the callsite, if any). */
57
    MVMSpeshStatsByCallsite *cs_stats;
58
59
    /* The type tuple to produce the specialization for, if this is a type
60
     * based specialization. NULL for certain specializations. The memory
61
     * associated with this tuple will always have been allocated by the
62
     * planner, not shared with the statistics structure, even if this is a
63
     * specialization for an exactly observed type. */
64
    MVMSpeshStatsType *type_tuple;
65
66
    /* Type statistics, if any, that the plan was formed based upon. */
67
    MVMSpeshStatsByType **type_stats;
68
69
    /* Number of entries in the type_stats array. (For an observed type
70
     * specialization, this would be 1.) */
71
    MVMuint32 num_type_stats;
72
};
73
74
MVMSpeshPlan * MVM_spesh_plan(MVMThreadContext *tc, MVMObject *updated_static_frames);
75
void MVM_spesh_plan_gc_mark(MVMThreadContext *tc, MVMSpeshPlan *plan, MVMGCWorklist *worklist);
76
void MVM_spesh_plan_gc_describe(MVMThreadContext *tc, MVMHeapSnapshotState *ss, MVMSpeshPlan *plan);
77
void MVM_spesh_plan_destroy(MVMThreadContext *tc, MVMSpeshPlan *plan);