JitTransferData.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. namespace Js
  7. {
  8. class EntryPointInfo;
  9. class JitEquivalentTypeGuard;
  10. struct CtorCacheGuardTransferEntry;
  11. struct TypeGuardTransferEntry;
  12. };
  13. struct TypeGuardTransferData
  14. {
  15. Field(unsigned int) propertyGuardCount;
  16. FieldNoBarrier(TypeGuardTransferEntryIDL*) entries;
  17. };
  18. struct CtorCacheTransferData
  19. {
  20. Field(unsigned int) ctorCachesCount;
  21. FieldNoBarrier(CtorCacheTransferEntryIDL **) entries;
  22. };
  23. class JitTransferData
  24. {
  25. friend Js::EntryPointInfo;
  26. private:
  27. typedef JsUtil::BaseHashSet<void*, Recycler, PowerOf2SizePolicy> TypeRefSet;
  28. Field(TypeRefSet*) jitTimeTypeRefs;
  29. Field(PinnedTypeRefsIDL*) runtimeTypeRefs;
  30. Field(int) propertyGuardCount;
  31. // This is a dynamically sized array of dynamically sized TypeGuardTransferEntries. It's heap allocated by the JIT
  32. // thread and lives until entry point is installed, at which point it is explicitly freed.
  33. FieldNoBarrier(Js::TypeGuardTransferEntry*) propertyGuardsByPropertyId;
  34. Field(size_t) propertyGuardsByPropertyIdPlusSize;
  35. // This is a dynamically sized array of dynamically sized CtorCacheGuardTransferEntry. It's heap allocated by the JIT
  36. // thread and lives until entry point is installed, at which point it is explicitly freed.
  37. FieldNoBarrier(Js::CtorCacheGuardTransferEntry*) ctorCacheGuardsByPropertyId;
  38. Field(size_t) ctorCacheGuardsByPropertyIdPlusSize;
  39. Field(int) equivalentTypeGuardCount;
  40. Field(int) lazyBailoutPropertyCount;
  41. // This is a dynamically sized array of JitEquivalentTypeGuards. It's heap allocated by the JIT thread and lives
  42. // until entry point is installed, at which point it is explicitly freed. We need it during installation so as to
  43. // swap the cache associated with each guard from the heap to the recycler (so the types in the cache are kept alive).
  44. FieldNoBarrier(Js::JitEquivalentTypeGuard**) equivalentTypeGuards;
  45. FieldNoBarrier(Js::PropertyId*) lazyBailoutProperties;
  46. FieldNoBarrier(NativeCodeData*) jitTransferRawData;
  47. FieldNoBarrier(EquivalentTypeGuardOffsets*) equivalentTypeGuardOffsets;
  48. Field(TypeGuardTransferData) typeGuardTransferData;
  49. Field(CtorCacheTransferData) ctorCacheTransferData;
  50. Field(bool) falseReferencePreventionBit;
  51. Field(bool) isReady;
  52. public:
  53. JitTransferData() :
  54. jitTimeTypeRefs(nullptr), runtimeTypeRefs(nullptr),
  55. propertyGuardCount(0), propertyGuardsByPropertyId(nullptr), propertyGuardsByPropertyIdPlusSize(0),
  56. ctorCacheGuardsByPropertyId(nullptr), ctorCacheGuardsByPropertyIdPlusSize(0),
  57. equivalentTypeGuardCount(0), equivalentTypeGuards(nullptr), jitTransferRawData(nullptr),
  58. falseReferencePreventionBit(true), isReady(false), lazyBailoutProperties(nullptr), lazyBailoutPropertyCount(0) {}
  59. void SetRawData(NativeCodeData* rawData) { jitTransferRawData = rawData; }
  60. void AddJitTimeTypeRef(void* typeRef, Recycler* recycler);
  61. int GetRuntimeTypeRefCount() { return this->runtimeTypeRefs ? this->runtimeTypeRefs->count : 0; }
  62. void** GetRuntimeTypeRefs() { return this->runtimeTypeRefs ? (void**)this->runtimeTypeRefs->typeRefs : nullptr; }
  63. void SetRuntimeTypeRefs(PinnedTypeRefsIDL* pinnedTypeRefs) { this->runtimeTypeRefs = pinnedTypeRefs; }
  64. Js::JitEquivalentTypeGuard** GetEquivalentTypeGuards() const { return this->equivalentTypeGuards; }
  65. void SetEquivalentTypeGuards(Js::JitEquivalentTypeGuard** guards, int count)
  66. {
  67. this->equivalentTypeGuardCount = count;
  68. this->equivalentTypeGuards = guards;
  69. }
  70. void SetLazyBailoutProperties(Js::PropertyId* properties, int count)
  71. {
  72. this->lazyBailoutProperties = properties;
  73. this->lazyBailoutPropertyCount = count;
  74. }
  75. void SetEquivalentTypeGuardOffsets(EquivalentTypeGuardOffsets* offsets)
  76. {
  77. equivalentTypeGuardOffsets = offsets;
  78. }
  79. void SetTypeGuardTransferData(JITOutputIDL* data)
  80. {
  81. typeGuardTransferData.entries = data->typeGuardEntries;
  82. typeGuardTransferData.propertyGuardCount = data->propertyGuardCount;
  83. }
  84. void SetCtorCacheTransferData(JITOutputIDL * data)
  85. {
  86. ctorCacheTransferData.entries = data->ctorCacheEntries;
  87. ctorCacheTransferData.ctorCachesCount = data->ctorCachesCount;
  88. }
  89. bool GetIsReady() { return this->isReady; }
  90. void SetIsReady() { this->isReady = true; }
  91. void RecordTypeGuards(int propertyGuardCount, Js::TypeGuardTransferEntry* typeGuardTransferRecord, size_t typeGuardTransferPlusSize);
  92. void RecordCtorCacheGuards(Js::CtorCacheGuardTransferEntry* ctorCacheTransferRecord, size_t ctorCacheTransferPlusSize);
  93. void Cleanup();
  94. private:
  95. void EnsureJitTimeTypeRefs(Recycler* recycler);
  96. };