TrackedOptimizationInfo.h 16 KB

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