TrackedOptimizationInfo.h 16 KB

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