SerializableFunctionFields.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #ifdef DEFINE_ALL_FIELDS
  6. #define DEFINE_PARSEABLE_FUNCTION_INFO_FIELDS 1
  7. #define DEFINE_FUNCTION_BODY_FIELDS 1
  8. #endif
  9. // Default declaration for FunctionBody.h
  10. #ifndef DECLARE_SERIALIZABLE_FIELD
  11. #define DECLARE_SERIALIZABLE_FIELD(type, name, serializableType) Field(type) name
  12. #endif
  13. #ifndef DECLARE_SERIALIZABLE_ACCESSOR_FIELD
  14. #define DECLARE_SERIALIZABLE_ACCESSOR_FIELD(type, name, serializableType, defaultValue)
  15. #endif
  16. #ifndef DECLARE_SERIALIZABLE_ACCESSOR_FIELD_NO_CHECK
  17. #define DECLARE_SERIALIZABLE_ACCESSOR_FIELD_NO_CHECK(type, name, serializableType)
  18. #endif
  19. #ifndef DECLARE_TAG_FIELD
  20. #define DECLARE_TAG_FIELD(type, name, serializableType)
  21. #endif
  22. #ifdef CURRENT_ACCESS_MODIFIER
  23. #define PROTECTED_FIELDS protected:
  24. #define PRIVATE_FIELDS private:
  25. #define PUBLIC_FIELDS public:
  26. #else
  27. #define CURRENT_ACCESS_MODIFIER
  28. #define PROTECTED_FIELDS
  29. #define PRIVATE_FIELDS
  30. #define PUBLIC_FIELDS
  31. #endif
  32. #if DEFINE_PARSEABLE_FUNCTION_INFO_FIELDS
  33. PROTECTED_FIELDS
  34. DECLARE_SERIALIZABLE_FIELD(FunctionBodyFlags, flags, FunctionBodyFlags);
  35. DECLARE_SERIALIZABLE_FIELD(uint32, m_grfscr, ULong); // For values, see fscr* values in scrutil.h.
  36. DECLARE_SERIALIZABLE_FIELD(ArgSlot, m_inParamCount, ArgSlot); // Count of 'in' parameters to method
  37. DECLARE_SERIALIZABLE_FIELD(ArgSlot, m_reportedInParamCount, ArgSlot); // Count of 'in' parameters to method excluding default and rest
  38. DECLARE_SERIALIZABLE_FIELD(charcount_t, m_cchStartOffset, CharCount); // offset in characters from the start of the document.
  39. DECLARE_SERIALIZABLE_FIELD(charcount_t, m_cchLength, CharCount); // length of the function in code points (not bytes)
  40. DECLARE_SERIALIZABLE_FIELD(uint, m_cbLength, UInt32); // length of the function in bytes
  41. DECLARE_SERIALIZABLE_FIELD(uint, m_displayShortNameOffset, UInt32); // Offset into the display name where the short name is found
  42. PUBLIC_FIELDS
  43. DECLARE_SERIALIZABLE_FIELD(UINT, scopeSlotArraySize, UInt32);
  44. DECLARE_SERIALIZABLE_FIELD(UINT, paramScopeSlotArraySize, UInt32);
  45. CURRENT_ACCESS_MODIFIER
  46. #endif
  47. #if DEFINE_FUNCTION_BODY_FIELDS
  48. PUBLIC_FIELDS
  49. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, VarCount, RegSlot, 0); // Count of non-constant locals
  50. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, ConstantCount, RegSlot, 0); // Count of enregistered constants
  51. DECLARE_SERIALIZABLE_ACCESSOR_FIELD_NO_CHECK(RegSlot, FirstTmpRegister, RegSlot);
  52. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, OutParamMaxDepth, RegSlot, 0); // Count of call depth in a nested expression
  53. DECLARE_SERIALIZABLE_ACCESSOR_FIELD_NO_CHECK(uint, ByteCodeCount, RegSlot);
  54. DECLARE_SERIALIZABLE_ACCESSOR_FIELD_NO_CHECK(uint, ByteCodeWithoutLDACount, RegSlot);
  55. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, ByteCodeInLoopCount, UInt32, 0);
  56. DECLARE_SERIALIZABLE_FIELD(uint16, m_envDepth, UInt16);
  57. DECLARE_SERIALIZABLE_FIELD(uint16, m_argUsedForBranch, UInt16);
  58. PRIVATE_FIELDS
  59. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledLdLenCount, UInt16);
  60. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledLdElemCount, UInt16);
  61. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledStElemCount, UInt16);
  62. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledCallSiteCount, UInt16);
  63. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledArrayCallSiteCount, UInt16);
  64. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledDivOrRemCount, UInt16);
  65. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledSwitchCount, UInt16);
  66. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledReturnTypeCount, UInt16);
  67. DECLARE_SERIALIZABLE_FIELD(ProfileId, profiledSlotCount, UInt16);
  68. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, LoopCount, RegSlot, 0);
  69. DECLARE_TAG_FIELD(bool, m_tag31, Bool); // Used to tag the low bit to prevent possible GC false references
  70. DECLARE_SERIALIZABLE_FIELD(bool, m_hasFinally, Bool);
  71. DECLARE_SERIALIZABLE_FIELD(bool, hasScopeObject, Bool);
  72. DECLARE_SERIALIZABLE_FIELD(bool, hasCachedScopePropIds, Bool);
  73. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, ForInLoopDepth, UInt32, 0);
  74. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, InlineCacheCount, UInt32, 0);
  75. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, RootObjectLoadInlineCacheStart, UInt32, 0);
  76. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, RootObjectLoadMethodInlineCacheStart, UInt32, 0);
  77. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, RootObjectStoreInlineCacheStart, UInt32, 0);
  78. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, IsInstInlineCacheCount, UInt32, 0);
  79. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, ReferencedPropertyIdCount, UInt32, 0);
  80. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, ObjLiteralCount, UInt32, 0);
  81. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, LiteralRegexCount, UInt32, 0);
  82. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(uint, InnerScopeCount, UInt32, 0);
  83. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(ProfileId, ProfiledForInLoopCount, UInt16, 0);
  84. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, LocalClosureRegister, RegSlot, Constants::NoRegister);
  85. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, ParamClosureRegister, RegSlot, Constants::NoRegister);
  86. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, LocalFrameDisplayRegister, RegSlot, Constants::NoRegister);
  87. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, EnvRegister, RegSlot, Constants::NoRegister);
  88. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, ThisRegisterForEventHandler, RegSlot, Constants::NoRegister);
  89. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, FirstInnerScopeRegister, RegSlot, Constants::NoRegister);
  90. DECLARE_SERIALIZABLE_ACCESSOR_FIELD(RegSlot, FuncExprScopeRegister, RegSlot, Constants::NoRegister);
  91. CURRENT_ACCESS_MODIFIER
  92. #endif
  93. #undef DEFINE_ALL_FIELDS
  94. #undef DEFINE_PARSEABLE_FUNCTION_INFO_FIELDS
  95. #undef DEFINE_FUNCTION_BODY_FIELDS
  96. #undef CURRENT_ACCESS_MODIFIER
  97. #undef DECLARE_SERIALIZABLE_FIELD
  98. #undef DECLARE_SERIALIZABLE_ACCESSOR_FIELD
  99. #undef DECLARE_SERIALIZABLE_ACCESSOR_FIELD_NO_CHECK
  100. #undef PROTECTED_FIELDS
  101. #undef PRIVATE_FIELDS
  102. #undef PUBLIC_FIELDS
  103. #undef DECLARE_TAG_FIELD