JITTimeFunctionBody.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 JITTimeFunctionBody
  11. {
  12. public:
  13. JITTimeFunctionBody(FunctionBodyDataIDL * bodyData);
  14. static void InitializeJITFunctionData(
  15. __in Recycler * recycler,
  16. __in Js::FunctionBody * functionBody,
  17. __out FunctionBodyDataIDL * jitBody);
  18. intptr_t GetAddr() const;
  19. uint GetFunctionNumber() const;
  20. uint GetSourceContextId() const;
  21. uint GetNestedCount() const;
  22. uint GetScopeSlotArraySize() const;
  23. uint GetParamScopeSlotArraySize() const;
  24. uint GetByteCodeCount() const;
  25. uint GetByteCodeInLoopCount() const;
  26. uint GetNonLoadByteCodeCount() const;
  27. uint GetLoopCount() const;
  28. uint GetByteCodeLength() const;
  29. uint GetInnerScopeCount() const;
  30. uint GetInlineCacheCount() const;
  31. uint GetRecursiveCallSiteCount() const;
  32. Js::RegSlot GetLocalFrameDisplayReg() const;
  33. Js::RegSlot GetLocalClosureReg() const;
  34. Js::RegSlot GetEnvReg() const;
  35. Js::RegSlot GetFirstTmpReg() const;
  36. Js::RegSlot GetFirstInnerScopeReg() const;
  37. Js::RegSlot GetVarCount() const;
  38. Js::RegSlot GetConstCount() const;
  39. Js::RegSlot GetLocalsCount() const;
  40. Js::RegSlot GetTempCount() const;
  41. Js::RegSlot GetFuncExprScopeReg() const;
  42. Js::RegSlot GetThisRegForEventHandler() const;
  43. Js::RegSlot GetFirstNonTempLocalIndex() const;
  44. Js::RegSlot GetEndNonTempLocalIndex() const;
  45. Js::RegSlot GetNonTempLocalVarCount() const;
  46. Js::RegSlot GetRestParamRegSlot() const;
  47. Js::RegSlot GetParamClosureReg() const;
  48. Js::PropertyId GetPropertyIdFromCacheId(uint cacheId) const;
  49. Js::PropertyId GetReferencedPropertyId(uint index) const;
  50. uint16 GetEnvDepth() const;
  51. uint16 GetProfiledIterations() const;
  52. uint16 GetArgUsedForBranch() const;
  53. Js::ProfileId GetProfiledCallSiteCount() const;
  54. Js::ArgSlot GetInParamsCount() const;
  55. bool DoStackNestedFunc() const;
  56. bool DoStackClosure() const;
  57. bool DoBackendArgumentsOptimization() const;
  58. bool IsLibraryCode() const;
  59. bool HasTry() const;
  60. bool HasFinally() const;
  61. bool HasOrParentHasArguments() const;
  62. bool IsGenerator() const;
  63. bool IsAsmJsMode() const;
  64. bool IsStrictMode() const;
  65. bool IsEval() const;
  66. bool HasImplicitArgIns() const;
  67. bool HasRestParameter() const;
  68. bool HasScopeObject() const;
  69. bool HasCachedScopePropIds() const;
  70. bool HasInlineCachesOnFunctionObject() const;
  71. bool DoInterruptProbe() const;
  72. bool IsGlobalFunc() const;
  73. void DisableInlineApply();
  74. bool IsInlineApplyDisabled() const;
  75. bool IsNonTempLocalVar(uint32 varIndex) const;
  76. bool DoJITLoopBody() const;
  77. bool IsInlineSpreadDisabled() const;
  78. void DisableInlineSpread();
  79. bool HasLoops() const;
  80. bool HasNonBuiltInCallee() const;
  81. bool HasNestedLoop() const;
  82. bool UsesArgumentsObject() const;
  83. bool IsParamAndBodyScopeMerged() const;
  84. bool CanInlineRecursively(uint depth, bool tryAggressive = true) const;
  85. bool NeedScopeObjectForArguments(bool hasNonSimpleParams) const;
  86. const byte * GetByteCodeBuffer() const;
  87. void * ReadFromAuxData(uint offset) const;
  88. void * ReadFromAuxContextData(uint offset) const;
  89. intptr_t GetNestedFuncRef(uint index) const;
  90. intptr_t GetConstantVar(Js::RegSlot location) const;
  91. template<class T>
  92. T* GetConstAsT(Js::RegSlot location) const
  93. {
  94. Assert(m_bodyData.constTableContent != nullptr);
  95. Assert(location < GetConstCount());
  96. Assert(location != 0);
  97. auto obj = m_bodyData.constTableContent[location - Js::FunctionBody::FirstRegSlot];
  98. Assert(obj);
  99. Assert(T::Is(obj));
  100. return (T*)obj;
  101. }
  102. intptr_t GetInlineCache(uint index) const;
  103. intptr_t GetIsInstInlineCache(uint index) const;
  104. Js::TypeId GetConstantType(Js::RegSlot location) const;
  105. void * GetConstTable() const;
  106. intptr_t GetRootObject() const;
  107. intptr_t GetLoopHeaderAddr(uint loopNum) const;
  108. const JITLoopHeaderIDL * GetLoopHeaderData(uint loopNum) const;
  109. intptr_t GetScriptIdAddr() const;
  110. intptr_t GetProbeCountAddr() const;
  111. intptr_t GetFlagsAddr() const;
  112. intptr_t GetRegAllocLoadCountAddr() const;
  113. intptr_t GetRegAllocStoreCountAddr() const;
  114. intptr_t GetCallCountStatsAddr() const;
  115. intptr_t GetFormalsPropIdArrayAddr() const;
  116. intptr_t GetObjectLiteralTypeRef(uint index) const;
  117. intptr_t GetLiteralRegexAddr(uint index) const;
  118. const AsmJsJITInfo * GetAsmJsInfo() const;
  119. const JITTimeProfileInfo * GetReadOnlyProfileInfo() const;
  120. JITTimeProfileInfo * GetProfileInfo() const;
  121. bool HasProfileInfo() const;
  122. static bool LoopContains(const JITLoopHeaderIDL * loop1, const JITLoopHeaderIDL * loop2);
  123. wchar_t* GetDisplayName() const;
  124. intptr_t GetAuxDataAddr(uint offset) const;
  125. const Js::PropertyIdArray * ReadPropertyIdArrayFromAuxData(uint offset) const;
  126. Js::PropertyIdArray * GetFormalsPropIdArray() const;
  127. void InitializeStatementMap(__out Js::SmallSpanSequence * statementMap) const;
  128. private:
  129. Js::FunctionInfo::Attributes GetAttributes() const;
  130. Js::FunctionBody::FunctionBodyFlags GetFlags() const;
  131. FunctionBodyDataIDL m_bodyData;
  132. };