ServerThreadContext.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #if ENABLE_OOP_NATIVE_CODEGEN
  7. class ProcessContext
  8. {
  9. private:
  10. uint refCount;
  11. public:
  12. HANDLE processHandle;
  13. intptr_t chakraBaseAddress;
  14. intptr_t crtBaseAddress;
  15. ProcessContext(HANDLE processHandle, intptr_t chakraBaseAddress, intptr_t crtBaseAddress);
  16. ~ProcessContext();
  17. void AddRef();
  18. void Release();
  19. bool HasRef();
  20. };
  21. class ServerThreadContext : public ThreadContextInfo
  22. {
  23. public:
  24. typedef BVSparseNode<JitArenaAllocator> BVSparseNode;
  25. ServerThreadContext(ThreadContextDataIDL * data, ProcessContext* processContext);
  26. ~ServerThreadContext();
  27. virtual HANDLE GetProcessHandle() const override;
  28. virtual bool IsThreadBound() const override;
  29. virtual size_t GetScriptStackLimit() const override;
  30. virtual intptr_t GetThreadStackLimitAddr() const override;
  31. #ifdef ENABLE_WASM_SIMD
  32. virtual intptr_t GetSimdTempAreaAddr(uint8 tempIndex) const override;
  33. #endif
  34. virtual intptr_t GetDisableImplicitFlagsAddr() const override;
  35. virtual intptr_t GetImplicitCallFlagsAddr() const override;
  36. virtual intptr_t GetBailOutRegisterSaveSpaceAddr() const override;
  37. PreReservedSectionAllocWrapper * GetPreReservedSectionAllocator();
  38. virtual bool IsNumericProperty(Js::PropertyId propId) override;
  39. virtual ptrdiff_t GetChakraBaseAddressDifference() const override;
  40. virtual ptrdiff_t GetCRTBaseAddressDifference() const override;
  41. #if defined(_CONTROL_FLOW_GUARD) && !defined(_M_ARM)
  42. OOPJITThunkEmitter * GetJITThunkEmitter();
  43. #endif
  44. CustomHeap::OOPCodePageAllocators * GetThunkPageAllocators();
  45. CustomHeap::OOPCodePageAllocators * GetCodePageAllocators();
  46. SectionAllocWrapper * GetSectionAllocator();
  47. void UpdateNumericPropertyBV(BVSparseNode * newProps);
  48. void SetWellKnownHostTypeId(Js::TypeId typeId) { this->wellKnownHostTypeIds[WellKnownHostType_HTMLAllCollection] = typeId; }
  49. void AddRef();
  50. void Release();
  51. void Close();
  52. PageAllocator * GetForegroundPageAllocator();
  53. DWORD GetRuntimePid() { return m_pid; }
  54. intptr_t GetRuntimeChakraBaseAddress() const;
  55. intptr_t GetRuntimeCRTBaseAddress() const;
  56. bool CanCreatePreReservedSegment() const;
  57. void SetCanCreatePreReservedSegment(bool value);
  58. static intptr_t GetJITCRTBaseAddress();
  59. private:
  60. ProcessContext* processContext;
  61. BVSparse<HeapAllocator> * m_numericPropertyBV;
  62. PreReservedSectionAllocWrapper m_preReservedSectionAllocator;
  63. SectionAllocWrapper m_sectionAllocator;
  64. CustomHeap::OOPCodePageAllocators m_thunkPageAllocators;
  65. CustomHeap::OOPCodePageAllocators m_codePageAllocators;
  66. #if defined(_CONTROL_FLOW_GUARD) && !defined(_M_ARM)
  67. OOPJITThunkEmitter m_jitThunkEmitter;
  68. #endif
  69. // only allocate with this from foreground calls (never from CodeGen calls)
  70. PageAllocator m_pageAlloc;
  71. ThreadContextDataIDL m_threadContextData;
  72. DWORD m_pid; //save client process id for easier diagnose
  73. CriticalSection m_cs;
  74. uint m_refCount;
  75. bool m_canCreatePreReservedSegment;
  76. };
  77. #endif