ServerThreadContext.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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);
  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. CustomHeap::OOPCodePageAllocators * GetThunkPageAllocators();
  29. CustomHeap::OOPCodePageAllocators * GetCodePageAllocators();
  30. SectionAllocWrapper * GetSectionAllocator();
  31. void UpdateNumericPropertyBV(BVSparseNode * newProps);
  32. void SetWellKnownHostTypeId(Js::TypeId typeId) { this->wellKnownHostTypeHTMLAllCollectionTypeId = typeId; }
  33. void AddRef();
  34. void Release();
  35. void Close();
  36. PageAllocator * GetForegroundPageAllocator();
  37. #ifdef STACK_BACK_TRACE
  38. DWORD GetRuntimePid() { return m_pid; }
  39. #endif
  40. intptr_t GetRuntimeChakraBaseAddress() const;
  41. intptr_t GetRuntimeCRTBaseAddress() const;
  42. intptr_t GetJITCRTBaseAddress() const;
  43. private:
  44. class AutoCloseHandle
  45. {
  46. public:
  47. AutoCloseHandle(HANDLE handle) : handle(handle) { Assert(handle != GetCurrentProcess()); }
  48. ~AutoCloseHandle() { CloseHandle(this->handle); }
  49. private:
  50. HANDLE handle;
  51. };
  52. AutoCloseHandle m_autoProcessHandle;
  53. BVSparse<HeapAllocator> * m_numericPropertyBV;
  54. PreReservedSectionAllocWrapper m_preReservedSectionAllocator;
  55. SectionAllocWrapper m_sectionAllocator;
  56. CustomHeap::OOPCodePageAllocators m_thunkPageAllocators;
  57. CustomHeap::OOPCodePageAllocators m_codePageAllocators;
  58. OOPCodeGenAllocators m_codeGenAlloc;
  59. // only allocate with this from foreground calls (never from CodeGen calls)
  60. PageAllocator m_pageAlloc;
  61. ThreadContextDataIDL m_threadContextData;
  62. DWORD m_pid; //save client process id for easier diagnose
  63. CriticalSection m_cs;
  64. uint m_refCount;
  65. #endif
  66. };