-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathServerThreadContext.h
100 lines (77 loc) · 3.33 KB
/
ServerThreadContext.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
//-------------------------------------------------------------------------------------------------------
// 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
#if ENABLE_OOP_NATIVE_CODEGEN
class ProcessContext
{
private:
uint refCount;
public:
HANDLE processHandle;
intptr_t chakraBaseAddress;
intptr_t crtBaseAddress;
ProcessContext(HANDLE processHandle, intptr_t chakraBaseAddress, intptr_t crtBaseAddress);
~ProcessContext();
void AddRef();
void Release();
bool HasRef();
};
class ServerThreadContext : public ThreadContextInfo
{
public:
typedef BVSparseNode<JitArenaAllocator> BVSparseNode;
ServerThreadContext(ThreadContextDataIDL * data, ProcessContext* processContext);
~ServerThreadContext();
virtual HANDLE GetProcessHandle() const override;
virtual bool IsThreadBound() const override;
virtual size_t GetScriptStackLimit() const override;
virtual intptr_t GetThreadStackLimitAddr() const override;
#ifdef ENABLE_WASM_SIMD
virtual intptr_t GetSimdTempAreaAddr(uint8 tempIndex) const override;
#endif
virtual intptr_t GetDisableImplicitFlagsAddr() const override;
virtual intptr_t GetImplicitCallFlagsAddr() const override;
virtual intptr_t GetBailOutRegisterSaveSpaceAddr() const override;
PreReservedSectionAllocWrapper * GetPreReservedSectionAllocator();
virtual bool IsNumericProperty(Js::PropertyId propId) override;
virtual ptrdiff_t GetChakraBaseAddressDifference() const override;
virtual ptrdiff_t GetCRTBaseAddressDifference() const override;
#if defined(_CONTROL_FLOW_GUARD) && !defined(_M_ARM)
OOPJITThunkEmitter * GetJITThunkEmitter();
#endif
CustomHeap::OOPCodePageAllocators * GetThunkPageAllocators();
CustomHeap::OOPCodePageAllocators * GetCodePageAllocators();
SectionAllocWrapper * GetSectionAllocator();
void UpdateNumericPropertyBV(BVSparseNode * newProps);
void SetWellKnownHostTypeId(Js::TypeId typeId) { this->wellKnownHostTypeIds[WellKnownHostType_HTMLAllCollection] = typeId; }
void AddRef();
void Release();
void Close();
PageAllocator * GetForegroundPageAllocator();
DWORD GetRuntimePid() { return m_pid; }
intptr_t GetRuntimeChakraBaseAddress() const;
intptr_t GetRuntimeCRTBaseAddress() const;
bool CanCreatePreReservedSegment() const;
void SetCanCreatePreReservedSegment(bool value);
static intptr_t GetJITCRTBaseAddress();
private:
ProcessContext* processContext;
BVSparse<HeapAllocator> * m_numericPropertyBV;
PreReservedSectionAllocWrapper m_preReservedSectionAllocator;
SectionAllocWrapper m_sectionAllocator;
CustomHeap::OOPCodePageAllocators m_thunkPageAllocators;
CustomHeap::OOPCodePageAllocators m_codePageAllocators;
#if defined(_CONTROL_FLOW_GUARD) && !defined(_M_ARM)
OOPJITThunkEmitter m_jitThunkEmitter;
#endif
// only allocate with this from foreground calls (never from CodeGen calls)
PageAllocator m_pageAlloc;
ThreadContextDataIDL m_threadContextData;
DWORD m_pid; //save client process id for easier diagnose
CriticalSection m_cs;
uint m_refCount;
bool m_canCreatePreReservedSegment;
};
#endif