Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sts=4 et sw=4 tw=99:
3 : * This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef js_TrackedOptimizationInfo_h
8 : #define js_TrackedOptimizationInfo_h
9 :
10 : #include "mozilla/Maybe.h"
11 :
12 : namespace JS {
13 :
14 : #define TRACKED_STRATEGY_LIST(_) \
15 : _(GetProp_ArgumentsLength) \
16 : _(GetProp_ArgumentsCallee) \
17 : _(GetProp_InferredConstant) \
18 : _(GetProp_Constant) \
19 : _(GetProp_NotDefined) \
20 : _(GetProp_StaticName) \
21 : _(GetProp_SimdGetter) \
22 : _(GetProp_TypedObject) \
23 : _(GetProp_DefiniteSlot) \
24 : _(GetProp_Unboxed) \
25 : _(GetProp_CommonGetter) \
26 : _(GetProp_InlineAccess) \
27 : _(GetProp_Innerize) \
28 : _(GetProp_InlineCache) \
29 : _(GetProp_SharedCache) \
30 : _(GetProp_ModuleNamespace) \
31 : \
32 : _(SetProp_CommonSetter) \
33 : _(SetProp_TypedObject) \
34 : _(SetProp_DefiniteSlot) \
35 : _(SetProp_Unboxed) \
36 : _(SetProp_InlineAccess) \
37 : _(SetProp_InlineCache) \
38 : \
39 : _(GetElem_TypedObject) \
40 : _(GetElem_Dense) \
41 : _(GetElem_TypedStatic) \
42 : _(GetElem_TypedArray) \
43 : _(GetElem_String) \
44 : _(GetElem_Arguments) \
45 : _(GetElem_ArgumentsInlined) \
46 : _(GetElem_InlineCache) \
47 : \
48 : _(SetElem_TypedObject) \
49 : _(SetElem_TypedStatic) \
50 : _(SetElem_TypedArray) \
51 : _(SetElem_Dense) \
52 : _(SetElem_Arguments) \
53 : _(SetElem_InlineCache) \
54 : \
55 : _(BinaryArith_Concat) \
56 : _(BinaryArith_SpecializedTypes) \
57 : _(BinaryArith_SpecializedOnBaselineTypes) \
58 : _(BinaryArith_SharedCache) \
59 : _(BinaryArith_Call) \
60 : \
61 : _(InlineCache_OptimizedStub) \
62 : \
63 : _(NewArray_TemplateObject) \
64 : _(NewArray_SharedCache) \
65 : _(NewArray_Call) \
66 : \
67 : _(NewObject_TemplateObject) \
68 : _(NewObject_SharedCache) \
69 : _(NewObject_Call) \
70 : \
71 : _(Compare_SpecializedTypes) \
72 : _(Compare_Bitwise) \
73 : _(Compare_SpecializedOnBaselineTypes) \
74 : _(Compare_SharedCache) \
75 : _(Compare_Call) \
76 : \
77 : _(Call_Inline)
78 :
79 :
80 : // Ordering is important below. All outcomes before GenericSuccess will be
81 : // considered failures, and all outcomes after GenericSuccess will be
82 : // considered successes.
83 : #define TRACKED_OUTCOME_LIST(_) \
84 : _(GenericFailure) \
85 : _(Disabled) \
86 : _(NoTypeInfo) \
87 : _(NoAnalysisInfo) \
88 : _(NoShapeInfo) \
89 : _(UnknownObject) \
90 : _(UnknownProperties) \
91 : _(Singleton) \
92 : _(NotSingleton) \
93 : _(NotFixedSlot) \
94 : _(InconsistentFixedSlot) \
95 : _(NotObject) \
96 : _(NotStruct) \
97 : _(NotUnboxed) \
98 : _(NotUndefined) \
99 : _(UnboxedConvertedToNative) \
100 : _(StructNoField) \
101 : _(InconsistentFieldType) \
102 : _(InconsistentFieldOffset) \
103 : _(NeedsTypeBarrier) \
104 : _(InDictionaryMode) \
105 : _(NoProtoFound) \
106 : _(MultiProtoPaths) \
107 : _(NonWritableProperty) \
108 : _(ProtoIndexedProps) \
109 : _(ArrayBadFlags) \
110 : _(ArrayDoubleConversion) \
111 : _(ArrayRange) \
112 : _(ArraySeenNegativeIndex) \
113 : _(TypedObjectHasDetachedBuffer) \
114 : _(TypedObjectArrayRange) \
115 : _(AccessNotDense) \
116 : _(AccessNotSimdObject) \
117 : _(AccessNotTypedObject) \
118 : _(AccessNotTypedArray) \
119 : _(AccessNotString) \
120 : _(OperandNotString) \
121 : _(OperandNotNumber) \
122 : _(OperandNotStringOrNumber) \
123 : _(OperandNotSimpleArith) \
124 : _(OperandNotEasilyCoercibleToString) \
125 : _(StaticTypedArrayUint32) \
126 : _(StaticTypedArrayCantComputeMask) \
127 : _(OutOfBounds) \
128 : _(GetElemStringNotCached) \
129 : _(NonNativeReceiver) \
130 : _(IndexType) \
131 : _(SetElemNonDenseNonTANotCached) \
132 : _(NoSimdJitSupport) \
133 : _(SimdTypeNotOptimized) \
134 : _(UnknownSimdProperty) \
135 : _(NotModuleNamespace) \
136 : _(UnknownProperty) \
137 : _(NoTemplateObject) \
138 : _(TemplateObjectIsUnboxedWithoutInlineElements) \
139 : _(TemplateObjectIsPlainObjectWithDynamicSlots) \
140 : _(LengthTooBig) \
141 : _(SpeculationOnInputTypesFailed) \
142 : _(RelationalCompare) \
143 : _(OperandTypeNotBitwiseComparable) \
144 : _(OperandMaybeEmulatesUndefined) \
145 : _(LoosyUndefinedNullCompare) \
146 : _(LoosyInt32BooleanCompare) \
147 : _(CallsValueOf) \
148 : _(StrictCompare) \
149 : _(InitHole) \
150 : \
151 : _(ICOptStub_GenericSuccess) \
152 : \
153 : _(ICGetPropStub_ReadSlot) \
154 : _(ICGetPropStub_CallGetter) \
155 : _(ICGetPropStub_ArrayLength) \
156 : _(ICGetPropStub_UnboxedRead) \
157 : _(ICGetPropStub_UnboxedReadExpando) \
158 : _(ICGetPropStub_UnboxedArrayLength) \
159 : _(ICGetPropStub_TypedArrayLength) \
160 : _(ICGetPropStub_DOMProxyShadowed) \
161 : _(ICGetPropStub_DOMProxyUnshadowed) \
162 : _(ICGetPropStub_GenericProxy) \
163 : _(ICGetPropStub_ArgumentsLength) \
164 : \
165 : _(ICSetPropStub_Slot) \
166 : _(ICSetPropStub_GenericProxy) \
167 : _(ICSetPropStub_DOMProxyShadowed) \
168 : _(ICSetPropStub_DOMProxyUnshadowed) \
169 : _(ICSetPropStub_CallSetter) \
170 : _(ICSetPropStub_AddSlot) \
171 : _(ICSetPropStub_SetUnboxed) \
172 : \
173 : _(ICGetElemStub_ReadSlot) \
174 : _(ICGetElemStub_CallGetter) \
175 : _(ICGetElemStub_ReadUnboxed) \
176 : _(ICGetElemStub_Dense) \
177 : _(ICGetElemStub_DenseHole) \
178 : _(ICGetElemStub_TypedArray) \
179 : _(ICGetElemStub_ArgsElementMapped) \
180 : _(ICGetElemStub_ArgsElementUnmapped) \
181 : \
182 : _(ICSetElemStub_Dense) \
183 : _(ICSetElemStub_TypedArray) \
184 : \
185 : _(ICNameStub_ReadSlot) \
186 : _(ICNameStub_CallGetter) \
187 : _(ICNameStub_TypeOfNoProperty) \
188 : \
189 : _(CantInlineGeneric) \
190 : _(CantInlineNoTarget) \
191 : _(CantInlineNotInterpreted) \
192 : _(CantInlineNoBaseline) \
193 : _(CantInlineLazy) \
194 : _(CantInlineNotConstructor) \
195 : _(CantInlineClassConstructor) \
196 : _(CantInlineDisabledIon) \
197 : _(CantInlineTooManyArgs) \
198 : _(CantInlineNeedsArgsObj) \
199 : _(CantInlineDebuggee) \
200 : _(CantInlineExceededDepth) \
201 : _(CantInlineExceededTotalBytecodeLength) \
202 : _(CantInlineBigCaller) \
203 : _(CantInlineBigCallee) \
204 : _(CantInlineBigCalleeInlinedBytecodeLength) \
205 : _(CantInlineNotHot) \
206 : _(CantInlineNotInDispatch) \
207 : _(CantInlineUnreachable) \
208 : _(CantInlineNativeBadForm) \
209 : _(CantInlineNativeBadType) \
210 : _(CantInlineNativeNoTemplateObj) \
211 : _(CantInlineBound) \
212 : _(CantInlineNativeNoSpecialization) \
213 : _(HasCommonInliningPath) \
214 : \
215 : _(GenericSuccess) \
216 : _(Inlined) \
217 : _(DOM) \
218 : _(Monomorphic) \
219 : _(Polymorphic)
220 :
221 : #define TRACKED_TYPESITE_LIST(_) \
222 : _(Receiver) \
223 : _(Operand) \
224 : _(Index) \
225 : _(Value) \
226 : _(Call_Target) \
227 : _(Call_This) \
228 : _(Call_Arg) \
229 : _(Call_Return)
230 :
231 : enum class TrackedStrategy : uint32_t {
232 : #define STRATEGY_OP(name) name,
233 : TRACKED_STRATEGY_LIST(STRATEGY_OP)
234 : #undef STRATEGY_OPT
235 :
236 : Count
237 : };
238 :
239 : enum class TrackedOutcome : uint32_t {
240 : #define OUTCOME_OP(name) name,
241 : TRACKED_OUTCOME_LIST(OUTCOME_OP)
242 : #undef OUTCOME_OP
243 :
244 : Count
245 : };
246 :
247 : enum class TrackedTypeSite : uint32_t {
248 : #define TYPESITE_OP(name) name,
249 : TRACKED_TYPESITE_LIST(TYPESITE_OP)
250 : #undef TYPESITE_OP
251 :
252 : Count
253 : };
254 :
255 : JS_PUBLIC_API(const char*)
256 : TrackedStrategyString(TrackedStrategy strategy);
257 :
258 : JS_PUBLIC_API(const char*)
259 : TrackedOutcomeString(TrackedOutcome outcome);
260 :
261 : JS_PUBLIC_API(const char*)
262 : TrackedTypeSiteString(TrackedTypeSite site);
263 :
264 0 : struct ForEachTrackedOptimizationAttemptOp
265 : {
266 : virtual void operator()(TrackedStrategy strategy, TrackedOutcome outcome) = 0;
267 : };
268 :
269 0 : struct ForEachTrackedOptimizationTypeInfoOp
270 : {
271 : // Called 0+ times per entry, once for each type in the type set that Ion
272 : // saw during MIR construction. readType is always called _before_
273 : // operator() on the same entry.
274 : //
275 : // The keyedBy parameter describes how the type is keyed:
276 : // - "primitive" for primitive types
277 : // - "constructor" for object types tied to a scripted constructor
278 : // function.
279 : // - "alloc site" for object types tied to an allocation site.
280 : // - "prototype" for object types tied neither to a constructor nor
281 : // to an allocation site, but to a prototype.
282 : // - "singleton" for object types which only has a single value.
283 : // - "function" for object types referring to scripted functions.
284 : // - "native" for object types referring to native functions.
285 : //
286 : // The name parameter is the string representation of the type. If the
287 : // type is keyed by "constructor", or if the type itself refers to a
288 : // scripted function, the name is the function's displayAtom. If the type
289 : // is keyed by "native", this is nullptr.
290 : //
291 : // The location parameter is the filename if the type is keyed by
292 : // "constructor", "alloc site", or if the type itself refers to a scripted
293 : // function. If the type is keyed by "native", it is the offset of the
294 : // native function, suitable for use with addr2line on Linux or atos on OS
295 : // X. Otherwise it is nullptr.
296 : //
297 : // The lineno parameter is the line number if the type is keyed by
298 : // "constructor", "alloc site", or if the type itself refers to a scripted
299 : // function. Otherwise it is Nothing().
300 : //
301 : // The location parameter is the only one that may need escaping if being
302 : // quoted.
303 : virtual void readType(const char* keyedBy, const char* name,
304 : const char* location, const mozilla::Maybe<unsigned>& lineno) = 0;
305 :
306 : // Called once per entry.
307 : virtual void operator()(TrackedTypeSite site, const char* mirType) = 0;
308 : };
309 :
310 : } // namespace JS
311 :
312 : #endif // js_TrackedOptimizationInfo_h
|