ServerScriptContext.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 ServerScriptContext : public ScriptContextInfo
  7. {
  8. #if ENABLE_OOP_NATIVE_CODEGEN
  9. private:
  10. struct ThreadContextHolder
  11. {
  12. ServerThreadContext* threadContextInfo;
  13. ThreadContextHolder(ServerThreadContext* threadContextInfo);
  14. ~ThreadContextHolder();
  15. };
  16. ThreadContextHolder threadContextHolder;
  17. public:
  18. ServerScriptContext(ScriptContextDataIDL * contextData, ServerThreadContext* threadContextInfo);
  19. ~ServerScriptContext();
  20. virtual intptr_t GetNullAddr() const override;
  21. virtual intptr_t GetUndefinedAddr() const override;
  22. virtual intptr_t GetTrueAddr() const override;
  23. virtual intptr_t GetFalseAddr() const override;
  24. virtual intptr_t GetUndeclBlockVarAddr() const override;
  25. virtual intptr_t GetEmptyStringAddr() const override;
  26. virtual intptr_t GetNegativeZeroAddr() const override;
  27. virtual intptr_t GetNumberTypeStaticAddr() const override;
  28. virtual intptr_t GetStringTypeStaticAddr() const override;
  29. virtual intptr_t GetSymbolTypeStaticAddr() const override;
  30. virtual intptr_t GetObjectTypeAddr() const override;
  31. virtual intptr_t GetObjectHeaderInlinedTypeAddr() const override;
  32. virtual intptr_t GetRegexTypeAddr() const override;
  33. virtual intptr_t GetArrayTypeAddr() const override;
  34. virtual intptr_t GetNativeIntArrayTypeAddr() const override;
  35. virtual intptr_t GetNativeFloatArrayTypeAddr() const override;
  36. virtual intptr_t GetArrayConstructorAddr() const override;
  37. virtual intptr_t GetCharStringCacheAddr() const override;
  38. virtual intptr_t GetSideEffectsAddr() const override;
  39. virtual intptr_t GetArraySetElementFastPathVtableAddr() const override;
  40. virtual intptr_t GetIntArraySetElementFastPathVtableAddr() const override;
  41. virtual intptr_t GetFloatArraySetElementFastPathVtableAddr() const override;
  42. virtual intptr_t GetLibraryAddr() const override;
  43. virtual intptr_t GetGlobalObjectAddr() const override;
  44. virtual intptr_t GetGlobalObjectThisAddr() const override;
  45. virtual intptr_t GetNumberAllocatorAddr() const override;
  46. virtual intptr_t GetRecyclerAddr() const override;
  47. virtual bool GetRecyclerAllowNativeCodeBumpAllocation() const override;
  48. virtual bool IsPRNGSeeded() const override;
  49. virtual bool IsClosed() const override;
  50. virtual intptr_t GetBuiltinFunctionsBaseAddr() const override;
  51. #ifdef ENABLE_SCRIPT_DEBUGGING
  52. virtual intptr_t GetDebuggingFlagsAddr() const override;
  53. virtual intptr_t GetDebugStepTypeAddr() const override;
  54. virtual intptr_t GetDebugFrameAddressAddr() const override;
  55. virtual intptr_t GetDebugScriptIdWhenSetAddr() const override;
  56. #endif
  57. virtual intptr_t GetChakraLibAddr() const override;
  58. virtual intptr_t GetAddr() const override;
  59. virtual intptr_t GetVTableAddress(VTableValue vtableType) const override;
  60. virtual bool IsRecyclerVerifyEnabled() const override;
  61. virtual uint GetRecyclerVerifyPad() const override;
  62. virtual void AddToDOMFastPathHelperMap(intptr_t funcInfoAddr, IR::JnHelperMethod helper) override;
  63. virtual IR::JnHelperMethod GetDOMFastPathHelper(intptr_t funcInfoAddr) override;
  64. typedef JsUtil::BaseDictionary<uint, Js::ServerSourceTextModuleRecord*, Memory::HeapAllocator> ServerModuleRecords;
  65. ServerModuleRecords m_moduleRecords;
  66. virtual Field(Js::Var)* GetModuleExportSlotArrayAddress(uint moduleIndex, uint slotIndex) override;
  67. void SetIsPRNGSeeded(bool value);
  68. void AddModuleRecordInfo(unsigned int moduleId, __int64 localExportSlotsAddr);
  69. void UpdateGlobalObjectThisAddr(intptr_t globalThis);
  70. OOPEmitBufferManager * GetEmitBufferManager(bool asmJsManager);
  71. void DecommitEmitBufferManager(bool asmJsManager);
  72. #ifdef PROFILE_EXEC
  73. Js::ScriptContextProfiler* GetCodeGenProfiler(_In_ PageAllocator* pageAllocator);
  74. Js::ScriptContextProfiler* GetFirstCodeGenProfiler() const;
  75. #endif
  76. ServerThreadContext* GetThreadContext() { return threadContextHolder.threadContextInfo; }
  77. OOPCodeGenAllocators * GetCodeGenAllocators();
  78. ArenaAllocator * GetSourceCodeArena();
  79. void Close();
  80. void AddRef();
  81. void Release();
  82. private:
  83. JITDOMFastPathHelperMap * m_domFastPathHelperMap;
  84. #ifdef PROFILE_EXEC
  85. Js::ScriptContextProfiler * codeGenProfiler;
  86. CriticalSection profilerCS;
  87. #endif
  88. ArenaAllocator m_sourceCodeArena;
  89. OOPEmitBufferManager m_interpreterThunkBufferManager;
  90. OOPEmitBufferManager m_asmJsInterpreterThunkBufferManager;
  91. ScriptContextDataIDL m_contextData;
  92. intptr_t m_globalThisAddr;
  93. uint m_refCount;
  94. OOPCodeGenAllocators m_codeGenAlloc;
  95. bool m_isPRNGSeeded;
  96. bool m_isClosed;
  97. #endif
  98. };