-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathJitTransferData.h
114 lines (96 loc) · 4.98 KB
/
JitTransferData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
namespace Js
{
class EntryPointInfo;
class JitEquivalentTypeGuard;
struct CtorCacheGuardTransferEntry;
struct TypeGuardTransferEntry;
};
struct TypeGuardTransferData
{
Field(unsigned int) propertyGuardCount;
FieldNoBarrier(TypeGuardTransferEntryIDL*) entries;
};
struct CtorCacheTransferData
{
Field(unsigned int) ctorCachesCount;
FieldNoBarrier(CtorCacheTransferEntryIDL **) entries;
};
class JitTransferData
{
friend Js::EntryPointInfo;
private:
typedef JsUtil::BaseHashSet<void*, Recycler, PowerOf2SizePolicy> TypeRefSet;
Field(TypeRefSet*) jitTimeTypeRefs;
Field(PinnedTypeRefsIDL*) runtimeTypeRefs;
Field(int) propertyGuardCount;
// This is a dynamically sized array of dynamically sized TypeGuardTransferEntries. It's heap allocated by the JIT
// thread and lives until entry point is installed, at which point it is explicitly freed.
FieldNoBarrier(Js::TypeGuardTransferEntry*) propertyGuardsByPropertyId;
Field(size_t) propertyGuardsByPropertyIdPlusSize;
// This is a dynamically sized array of dynamically sized CtorCacheGuardTransferEntry. It's heap allocated by the JIT
// thread and lives until entry point is installed, at which point it is explicitly freed.
FieldNoBarrier(Js::CtorCacheGuardTransferEntry*) ctorCacheGuardsByPropertyId;
Field(size_t) ctorCacheGuardsByPropertyIdPlusSize;
Field(int) equivalentTypeGuardCount;
Field(int) lazyBailoutPropertyCount;
// This is a dynamically sized array of JitEquivalentTypeGuards. It's heap allocated by the JIT thread and lives
// until entry point is installed, at which point it is explicitly freed. We need it during installation so as to
// swap the cache associated with each guard from the heap to the recycler (so the types in the cache are kept alive).
FieldNoBarrier(Js::JitEquivalentTypeGuard**) equivalentTypeGuards;
FieldNoBarrier(Js::PropertyId*) lazyBailoutProperties;
FieldNoBarrier(NativeCodeData*) jitTransferRawData;
FieldNoBarrier(EquivalentTypeGuardOffsets*) equivalentTypeGuardOffsets;
Field(TypeGuardTransferData) typeGuardTransferData;
Field(CtorCacheTransferData) ctorCacheTransferData;
Field(bool) falseReferencePreventionBit;
Field(bool) isReady;
public:
JitTransferData() :
jitTimeTypeRefs(nullptr), runtimeTypeRefs(nullptr),
propertyGuardCount(0), propertyGuardsByPropertyId(nullptr), propertyGuardsByPropertyIdPlusSize(0),
ctorCacheGuardsByPropertyId(nullptr), ctorCacheGuardsByPropertyIdPlusSize(0),
equivalentTypeGuardCount(0), equivalentTypeGuards(nullptr), jitTransferRawData(nullptr),
falseReferencePreventionBit(true), isReady(false), lazyBailoutProperties(nullptr), lazyBailoutPropertyCount(0) {}
void SetRawData(NativeCodeData* rawData) { jitTransferRawData = rawData; }
void AddJitTimeTypeRef(void* typeRef, Recycler* recycler);
int GetRuntimeTypeRefCount() { return this->runtimeTypeRefs ? this->runtimeTypeRefs->count : 0; }
void** GetRuntimeTypeRefs() { return this->runtimeTypeRefs ? (void**)this->runtimeTypeRefs->typeRefs : nullptr; }
void SetRuntimeTypeRefs(PinnedTypeRefsIDL* pinnedTypeRefs) { this->runtimeTypeRefs = pinnedTypeRefs; }
Js::JitEquivalentTypeGuard** GetEquivalentTypeGuards() const { return this->equivalentTypeGuards; }
void SetEquivalentTypeGuards(Js::JitEquivalentTypeGuard** guards, int count)
{
this->equivalentTypeGuardCount = count;
this->equivalentTypeGuards = guards;
}
void SetLazyBailoutProperties(Js::PropertyId* properties, int count)
{
this->lazyBailoutProperties = properties;
this->lazyBailoutPropertyCount = count;
}
void SetEquivalentTypeGuardOffsets(EquivalentTypeGuardOffsets* offsets)
{
equivalentTypeGuardOffsets = offsets;
}
void SetTypeGuardTransferData(JITOutputIDL* data)
{
typeGuardTransferData.entries = data->typeGuardEntries;
typeGuardTransferData.propertyGuardCount = data->propertyGuardCount;
}
void SetCtorCacheTransferData(JITOutputIDL * data)
{
ctorCacheTransferData.entries = data->ctorCacheEntries;
ctorCacheTransferData.ctorCachesCount = data->ctorCachesCount;
}
bool GetIsReady() { return this->isReady; }
void SetIsReady() { this->isReady = true; }
void RecordTypeGuards(int propertyGuardCount, Js::TypeGuardTransferEntry* typeGuardTransferRecord, size_t typeGuardTransferPlusSize);
void RecordCtorCacheGuards(Js::CtorCacheGuardTransferEntry* ctorCacheTransferRecord, size_t ctorCacheTransferPlusSize);
void Cleanup();
private:
void EnsureJitTimeTypeRefs(Recycler* recycler);
};