/
MVMSpeshLog.h
107 lines (91 loc) · 3 KB
/
MVMSpeshLog.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Representation used for holding data logged by the interpreter for the
* purpose of producing specializations. */
/* The kind of log entry we have. */
typedef enum {
/* Entry to a callframe. */
MVM_SPESH_LOG_ENTRY,
/* Parameter type information. */
MVM_SPESH_LOG_PARAMETER,
/* Parameter type if we were to decontainerize the parameter. Recorded
* when the parameter is a container type. */
MVM_SPESH_LOG_PARAMETER_DECONT,
/* Decont, attribute lookup, or lexical lookup type information. */
MVM_SPESH_LOG_TYPE,
/* Static lexical lookup (bytecode says we can cache the result). */
MVM_SPESH_LOG_STATIC,
/* Invoked static frame, and whether we are its outer. */
MVM_SPESH_LOG_INVOKE,
/* OSR point. */
MVM_SPESH_LOG_OSR,
/* Return from a callframe, possibly with a logged type. */
MVM_SPESH_LOG_RETURN
} MVMSpeshLogEntryKind;
/* Flags on types. */
#define MVM_SPESH_LOG_TYPE_FLAG_CONCRETE 1
#define MVM_SPESH_LOG_TYPE_FLAG_RW_CONT 2
/* An entry in the spesh log. */
struct MVMSpeshLogEntry {
/* The kind of log entry it is; discriminator for the union. */
MVMint32 kind;
/* Call frame correlation ID. */
MVMint32 id;
union {
/* Entry to a call frame (ENTRY). */
struct {
MVMStaticFrame *sf;
MVMCallsite *cs;
} entry;
/* Observed parameter type (PARAMETER, PARAMETER_DECONT). */
struct {
MVMObject *type;
MVMint32 flags;
MVMuint16 arg_idx;
} param;
/* Observed type (TYPE, RETURN). */
struct {
MVMObject *type;
MVMint32 flags;
MVMint32 bytecode_offset;
} type;
/* Observed value (STATIC). */
struct {
MVMObject *value;
MVMint32 bytecode_offset;
} value;
/* Observed invocation (INVOKE). */
struct {
MVMStaticFrame *sf;
MVMint32 caller_is_outer;
MVMint32 bytecode_offset;
} invoke;
/* Observed OSR point (OSR). */
struct {
MVMint32 bytecode_offset;
} osr;
};
};
/* The spesh log representation itself. */
struct MVMSpeshLogBody {
/* The sending thread. */
MVMThread *thread;
/* Array of log entries. */
MVMSpeshLogEntry *entries;
/* Number of log entries so far and limit. */
MVMuint32 used;
MVMuint32 limit;
/* If this was created due to a new compilation unit (heuristic to do
* better at outer-loop OSR); we go over-quota for those, and this is
* to help us restore it again. */
MVMuint8 was_compunit_bumped;
/* When in debug mode, mutex and condition variable used to block the
* thread sending a log until the spesh worker has processed it. */
uv_mutex_t *block_mutex;
uv_cond_t *block_condvar;
AO_t completed;
};
struct MVMSpeshLog {
MVMObject common;
MVMSpeshLogBody body;
};
/* Function for REPR setup. */
const MVMREPROps * MVMSpeshLog_initialize(MVMThreadContext *tc);