ServerThreadContext.h 3.0 KB

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