/home/travis/build/MoarVM/MoarVM/src/6model/reprs/MVMSpeshLog.h
Line | Count | Source |
1 | | /* Representation used for holding data logged by the interpreter for the |
2 | | * purpose of producing specializations. */ |
3 | | |
4 | | /* The kind of log entry we have. */ |
5 | | typedef enum { |
6 | | /* Entry to a callframe. */ |
7 | | MVM_SPESH_LOG_ENTRY, |
8 | | /* Parameter type information. */ |
9 | | MVM_SPESH_LOG_PARAMETER, |
10 | | /* Parameter type if we were to decontainerize the parameter. Recorded |
11 | | * when the parameter is a container type. */ |
12 | | MVM_SPESH_LOG_PARAMETER_DECONT, |
13 | | /* Decont, attribute lookup, or lexical lookup type information. */ |
14 | | MVM_SPESH_LOG_TYPE, |
15 | | /* Static lexical lookup (bytecode says we can cache the result). */ |
16 | | MVM_SPESH_LOG_STATIC, |
17 | | /* Invoked static frame, and whether we are its outer. */ |
18 | | MVM_SPESH_LOG_INVOKE, |
19 | | /* OSR point. */ |
20 | | MVM_SPESH_LOG_OSR, |
21 | | /* Return from a callframe, possibly with a logged type. */ |
22 | | MVM_SPESH_LOG_RETURN, |
23 | | /* Spesh plugin resolution result. */ |
24 | | MVM_SPESH_LOG_PLUGIN_RESOLUTION, |
25 | | } MVMSpeshLogEntryKind; |
26 | | |
27 | | /* Flags on types. */ |
28 | 26.8M | #define MVM_SPESH_LOG_TYPE_FLAG_CONCRETE 1 |
29 | 4.84M | #define MVM_SPESH_LOG_TYPE_FLAG_RW_CONT 2 |
30 | | |
31 | | /* An entry in the spesh log. */ |
32 | | struct MVMSpeshLogEntry { |
33 | | /* The kind of log entry it is; discriminator for the union. */ |
34 | | MVMint32 kind; |
35 | | |
36 | | /* Call frame correlation ID. */ |
37 | | MVMint32 id; |
38 | | |
39 | | union { |
40 | | /* Entry to a call frame (ENTRY). */ |
41 | | struct { |
42 | | MVMStaticFrame *sf; |
43 | | MVMCallsite *cs; |
44 | | } entry; |
45 | | |
46 | | /* Observed parameter type (PARAMETER, PARAMETER_DECONT). */ |
47 | | struct { |
48 | | MVMObject *type; |
49 | | MVMint32 flags; |
50 | | MVMuint16 arg_idx; |
51 | | } param; |
52 | | |
53 | | /* Observed type (TYPE, RETURN). */ |
54 | | struct { |
55 | | MVMObject *type; |
56 | | MVMint32 flags; |
57 | | MVMint32 bytecode_offset; |
58 | | } type; |
59 | | |
60 | | /* Observed value (STATIC). */ |
61 | | struct { |
62 | | MVMObject *value; |
63 | | MVMint32 bytecode_offset; |
64 | | } value; |
65 | | |
66 | | /* Observed invocation (INVOKE). */ |
67 | | struct { |
68 | | MVMStaticFrame *sf; |
69 | | MVMint16 caller_is_outer; |
70 | | MVMuint16 was_multi; |
71 | | MVMint32 bytecode_offset; |
72 | | } invoke; |
73 | | |
74 | | /* Observed OSR point (OSR). */ |
75 | | struct { |
76 | | MVMint32 bytecode_offset; |
77 | | } osr; |
78 | | |
79 | | /* Spesh log resolution result (PLUGIN_RESOLUTION). */ |
80 | | struct { |
81 | | MVMuint32 bytecode_offset; |
82 | | MVMuint16 guard_index; |
83 | | } plugin; |
84 | | }; |
85 | | }; |
86 | | |
87 | | /* The spesh log representation itself. */ |
88 | | struct MVMSpeshLogBody { |
89 | | /* The sending thread. */ |
90 | | MVMThread *thread; |
91 | | |
92 | | /* Array of log entries. */ |
93 | | MVMSpeshLogEntry *entries; |
94 | | |
95 | | /* Number of log entries so far and limit. */ |
96 | | MVMuint32 used; |
97 | | MVMuint32 limit; |
98 | | |
99 | | /* If this was created due to a new compilation unit (heuristic to do |
100 | | * better at outer-loop OSR); we go over-quota for those, and this is |
101 | | * to help us restore it again. */ |
102 | | MVMuint8 was_compunit_bumped; |
103 | | |
104 | | /* When in debug mode, mutex and condition variable used to block the |
105 | | * thread sending a log until the spesh worker has processed it. */ |
106 | | uv_mutex_t *block_mutex; |
107 | | uv_cond_t *block_condvar; |
108 | | AO_t completed; |
109 | | }; |
110 | | struct MVMSpeshLog { |
111 | | MVMObject common; |
112 | | MVMSpeshLogBody body; |
113 | | }; |
114 | | |
115 | | /* Function for REPR setup. */ |
116 | | const MVMREPROps * MVMSpeshLog_initialize(MVMThreadContext *tc); |