JITTimeFunctionBody.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. // forward decls
  7. class AsmJsJITInfo;
  8. class JITTimeProfileInfo;
  9. class FunctionJITRuntimeInfo;
  10. class JITRecyclableObject;
  11. class JITTimeFunctionBody
  12. {
  13. public:
  14. JITTimeFunctionBody(FunctionBodyDataIDL * bodyData);
  15. static void InitializeJITFunctionData(
  16. __in ArenaAllocator * arena,
  17. __in Js::FunctionBody * functionBody,
  18. __out FunctionBodyDataIDL * jitBody);
  19. intptr_t GetAddr() const;
  20. uint GetFunctionNumber() const;
  21. uint GetSourceContextId() const;
  22. uint GetNestedCount() const;
  23. uint GetScopeSlotArraySize() const;
  24. uint GetParamScopeSlotArraySize() const;
  25. uint GetByteCodeCount() const;
  26. uint GetByteCodeInLoopCount() const;
  27. uint GetNonLoadByteCodeCount() const;
  28. uint GetLoopCount() const;
  29. uint GetByteCodeLength() const;
  30. uint GetInnerScopeCount() const;
  31. uint GetInlineCacheCount() const;
  32. uint GetRecursiveCallSiteCount() const;
  33. uint GetForInLoopDepth() const;
  34. Js::RegSlot GetLocalFrameDisplayReg() const;
  35. Js::RegSlot GetLocalClosureReg() const;
  36. Js::RegSlot GetEnvReg() const;
  37. Js::RegSlot GetFirstTmpReg() const;
  38. Js::RegSlot GetFirstInnerScopeReg() const;
  39. Js::RegSlot GetVarCount() const;
  40. Js::RegSlot GetConstCount() const;
  41. Js::RegSlot GetLocalsCount() const;
  42. Js::RegSlot GetTempCount() const;
  43. Js::RegSlot GetFuncExprScopeReg() const;
  44. Js::RegSlot GetThisRegForEventHandler() const;
  45. Js::RegSlot GetFirstNonTempLocalIndex() const;
  46. Js::RegSlot GetEndNonTempLocalIndex() const;
  47. Js::RegSlot GetNonTempLocalVarCount() const;
  48. Js::RegSlot GetRestParamRegSlot() const;
  49. Js::RegSlot GetParamClosureReg() const;
  50. Js::PropertyId GetPropertyIdFromCacheId(uint cacheId) const;
  51. Js::PropertyId GetReferencedPropertyId(uint index) const;
  52. uint16 GetEnvDepth() const;
  53. uint16 GetArgUsedForBranch() const;
  54. Js::ProfileId GetProfiledCallSiteCount() const;
  55. Js::ArgSlot GetInParamsCount() const;
  56. bool DoStackNestedFunc() const;
  57. bool DoStackClosure() const;
  58. bool DoBackendArgumentsOptimization() const;
  59. bool IsLibraryCode() const;
  60. bool HasTry() const;
  61. bool HasThis() const;
  62. bool HasFinally() const;
  63. bool HasOrParentHasArguments() const;
  64. bool IsGenerator() const;
  65. bool IsCoroutine() const;
  66. bool IsLambda() const;
  67. bool IsAsmJsMode() const;
  68. bool IsWasmFunction() const;
  69. bool IsStrictMode() const;
  70. bool IsEval() const;
  71. bool HasImplicitArgIns() const;
  72. bool HasRestParameter() const;
  73. bool HasScopeObject() const;
  74. bool HasCachedScopePropIds() const;
  75. bool HasInlineCachesOnFunctionObject() const;
  76. bool DoInterruptProbe() const;
  77. bool IsGlobalFunc() const;
  78. void DisableInlineApply();
  79. bool IsInlineApplyDisabled() const;
  80. bool IsNonTempLocalVar(uint32 varIndex) const;
  81. bool DoJITLoopBody() const;
  82. bool IsInlineSpreadDisabled() const;
  83. void DisableInlineSpread();
  84. bool HasLoops() const;
  85. bool HasNonBuiltInCallee() const;
  86. bool HasNestedLoop() const;
  87. bool UsesArgumentsObject() const;
  88. bool IsParamAndBodyScopeMerged() const;
  89. bool CanInlineRecursively(uint depth, bool tryAggressive = true) const;
  90. bool NeedScopeObjectForArguments(bool hasNonSimpleParams) const;
  91. bool GetDoScopeObjectCreation() const;
  92. const byte * GetByteCodeBuffer() const;
  93. StatementMapIDL * GetFullStatementMap() const;
  94. uint GetFullStatementMapCount() const;
  95. void * ReadFromAuxData(uint offset) const;
  96. void * ReadFromAuxContextData(uint offset) const;
  97. Js::FunctionInfoPtrPtr GetNestedFuncRef(uint index) const;
  98. intptr_t GetConstantVar(Js::RegSlot location) const;
  99. JITRecyclableObject * GetConstantContent(Js::RegSlot location) const;
  100. template<class T>
  101. T* GetConstAsT(Js::RegSlot location) const
  102. {
  103. Assert(m_bodyData.constTableContent != nullptr);
  104. Assert(m_bodyData.constTableContent->content != nullptr);
  105. Assert(location < GetConstCount());
  106. Assert(location != 0);
  107. auto obj = m_bodyData.constTableContent->content[location - Js::FunctionBody::FirstRegSlot];
  108. Assert(obj);
  109. obj->vtbl = VirtualTableInfo<T>::Address;
  110. //Assert(T::Is(obj));
  111. return (T*)obj;
  112. }
  113. template<>
  114. Js::JavascriptNumber* GetConstAsT<Js::JavascriptNumber>(Js::RegSlot location) const
  115. {
  116. Assert(m_bodyData.constTableContent != nullptr);
  117. Assert(m_bodyData.constTableContent->content != nullptr);
  118. Assert(location < GetConstCount());
  119. Assert(location != 0);
  120. #if !FLOATVAR
  121. auto obj = m_bodyData.constTableContent->content[location - Js::FunctionBody::FirstRegSlot];
  122. if (!obj)
  123. {
  124. #endif
  125. Js::JavascriptNumber* num = (Js::JavascriptNumber*)GetConstantVar(location);
  126. Assert(Js::TaggedNumber::Is(num));
  127. return num;
  128. #if !FLOATVAR
  129. }
  130. Assert(obj);
  131. obj->vtbl = VirtualTableInfo<Js::JavascriptNumber>::Address;
  132. Assert(Js::JavascriptNumber::Is(obj));
  133. return (Js::JavascriptNumber*)obj;
  134. #endif
  135. }
  136. intptr_t GetInlineCache(uint index) const;
  137. intptr_t GetIsInstInlineCache(uint index) const;
  138. Js::TypeId GetConstantType(Js::RegSlot location) const;
  139. void * GetConstTable() const;
  140. bool IsConstRegPropertyString(Js::RegSlot reg, ScriptContextInfo * context) const;
  141. intptr_t GetRootObject() const;
  142. intptr_t GetLoopHeaderAddr(uint loopNum) const;
  143. const JITLoopHeaderIDL * GetLoopHeaderData(uint loopNum) const;
  144. intptr_t GetScriptIdAddr() const;
  145. intptr_t GetProbeCountAddr() const;
  146. intptr_t GetFlagsAddr() const;
  147. intptr_t GetRegAllocLoadCountAddr() const;
  148. intptr_t GetRegAllocStoreCountAddr() const;
  149. intptr_t GetCallCountStatsAddr() const;
  150. intptr_t GetFormalsPropIdArrayAddr() const;
  151. intptr_t GetObjectLiteralTypeRef(uint index) const;
  152. intptr_t GetLiteralRegexAddr(uint index) const;
  153. const AsmJsJITInfo * GetAsmJsInfo() const;
  154. const JITTimeProfileInfo * GetReadOnlyProfileInfo() const;
  155. JITTimeProfileInfo * GetProfileInfo() const;
  156. bool HasProfileInfo() const;
  157. bool IsRegSlotFormal(Js::RegSlot reg) const;
  158. bool HasPropIdToFormalsMap() const;
  159. static bool LoopContains(const JITLoopHeaderIDL * loop1, const JITLoopHeaderIDL * loop2);
  160. char16* GetDisplayName() const;
  161. intptr_t GetAuxDataAddr(uint offset) const;
  162. const Js::PropertyIdArray * ReadPropertyIdArrayFromAuxData(uint offset) const;
  163. Js::PropertyIdArray * GetFormalsPropIdArray() const;
  164. Js::ForInCache * GetForInCache(uint profileId) const;
  165. bool InitializeStatementMap(Js::SmallSpanSequence * statementMap, ArenaAllocator* alloc) const;
  166. private:
  167. Js::FunctionInfo::Attributes GetAttributes() const;
  168. Js::FunctionBody::FunctionBodyFlags GetFlags() const;
  169. FunctionBodyDataIDL m_bodyData;
  170. };