2
0

JITTimeFunctionBody.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. void EnsureConsistentConstCount() const;
  93. const byte * GetByteCodeBuffer() const;
  94. StatementMapIDL * GetFullStatementMap() const;
  95. uint GetFullStatementMapCount() const;
  96. void * ReadFromAuxData(uint offset) const;
  97. void * ReadFromAuxContextData(uint offset) const;
  98. Js::FunctionInfoPtrPtr GetNestedFuncRef(uint index) const;
  99. intptr_t GetConstantVar(Js::RegSlot location) const;
  100. JITRecyclableObject * GetConstantContent(Js::RegSlot location) const;
  101. template<class T>
  102. T* GetConstAsT(Js::RegSlot location) const
  103. {
  104. Assert(m_bodyData.constTableContent != nullptr);
  105. Assert(m_bodyData.constTableContent->content != nullptr);
  106. Assert(location < GetConstCount());
  107. Assert(location != 0);
  108. auto obj = m_bodyData.constTableContent->content[location - Js::FunctionBody::FirstRegSlot];
  109. Assert(obj);
  110. obj->vtbl = VirtualTableInfo<T>::Address;
  111. //Assert(T::Is(obj));
  112. return (T*)obj;
  113. }
  114. template<>
  115. Js::JavascriptNumber* GetConstAsT<Js::JavascriptNumber>(Js::RegSlot location) const
  116. {
  117. Assert(m_bodyData.constTableContent != nullptr);
  118. Assert(m_bodyData.constTableContent->content != nullptr);
  119. Assert(location < GetConstCount());
  120. Assert(location != 0);
  121. #if !FLOATVAR
  122. auto obj = m_bodyData.constTableContent->content[location - Js::FunctionBody::FirstRegSlot];
  123. if (!obj)
  124. {
  125. #endif
  126. Js::JavascriptNumber* num = (Js::JavascriptNumber*)GetConstantVar(location);
  127. Assert(Js::TaggedNumber::Is(num));
  128. return num;
  129. #if !FLOATVAR
  130. }
  131. Assert(obj);
  132. obj->vtbl = VirtualTableInfo<Js::JavascriptNumber>::Address;
  133. Assert(Js::JavascriptNumber::Is(obj));
  134. return (Js::JavascriptNumber*)obj;
  135. #endif
  136. }
  137. intptr_t GetInlineCache(uint index) const;
  138. intptr_t GetIsInstInlineCache(uint index) const;
  139. Js::TypeId GetConstantType(Js::RegSlot location) const;
  140. void * GetConstTable() const;
  141. bool IsConstRegPropertyString(Js::RegSlot reg, ScriptContextInfo * context) const;
  142. intptr_t GetRootObject() const;
  143. intptr_t GetLoopHeaderAddr(uint loopNum) const;
  144. const JITLoopHeaderIDL * GetLoopHeaderData(uint loopNum) const;
  145. intptr_t GetScriptIdAddr() const;
  146. intptr_t GetProbeCountAddr() const;
  147. intptr_t GetFlagsAddr() const;
  148. intptr_t GetRegAllocLoadCountAddr() const;
  149. intptr_t GetRegAllocStoreCountAddr() const;
  150. intptr_t GetCallCountStatsAddr() const;
  151. intptr_t GetFormalsPropIdArrayAddr() const;
  152. intptr_t GetObjectLiteralTypeRef(uint index) const;
  153. intptr_t GetLiteralRegexAddr(uint index) const;
  154. uint GetNestedFuncIndexForSlotIdInCachedScope(uint index) const;
  155. const AsmJsJITInfo * GetAsmJsInfo() const;
  156. const JITTimeProfileInfo * GetReadOnlyProfileInfo() const;
  157. JITTimeProfileInfo * GetProfileInfo() const;
  158. bool HasProfileInfo() const;
  159. bool IsRegSlotFormal(Js::RegSlot reg) const;
  160. bool HasPropIdToFormalsMap() const;
  161. static bool LoopContains(const JITLoopHeaderIDL * loop1, const JITLoopHeaderIDL * loop2);
  162. char16* GetDisplayName() const;
  163. intptr_t GetAuxDataAddr(uint offset) const;
  164. const Js::PropertyIdArray * ReadPropertyIdArrayFromAuxData(uint offset) const;
  165. Js::PropertyIdArray * GetFormalsPropIdArray() const;
  166. Js::ForInCache * GetForInCache(uint profileId) const;
  167. bool InitializeStatementMap(Js::SmallSpanSequence * statementMap, ArenaAllocator* alloc) const;
  168. private:
  169. Js::FunctionInfo::Attributes GetAttributes() const;
  170. Js::FunctionBody::FunctionBodyFlags GetFlags() const;
  171. FunctionBodyDataIDL m_bodyData;
  172. };