2
0

JsrtRuntime.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #include "ChakraCore.h"
  7. #include "JsrtThreadService.h"
  8. #ifdef ENABLE_SCRIPT_DEBUGGING
  9. #include "JsrtDebugManager.h"
  10. #endif
  11. class JsrtContext;
  12. class JsrtRuntime
  13. {
  14. friend class JsrtContext;
  15. public:
  16. JsrtRuntime(ThreadContext * threadContext, bool useIdle, bool dispatchExceptions);
  17. ~JsrtRuntime();
  18. ThreadContext * GetThreadContext() { return this->threadContext; }
  19. JsRuntimeHandle ToHandle() { return static_cast<JsRuntimeHandle>(this); }
  20. static JsrtRuntime * FromHandle(JsRuntimeHandle runtimeHandle)
  21. {
  22. JsrtRuntime * runtime = static_cast<JsrtRuntime *>(runtimeHandle);
  23. runtime->threadContext->ValidateThreadContext();
  24. return runtime;
  25. }
  26. static void Uninitialize();
  27. bool UseIdle() const { return useIdle; }
  28. unsigned int Idle();
  29. bool DispatchExceptions() const { return dispatchExceptions; }
  30. void CloseContexts();
  31. void SetBeforeCollectCallback(JsBeforeCollectCallback beforeCollectCallback, void * callbackContext);
  32. #ifdef ENABLE_DEBUG_CONFIG_OPTIONS
  33. void SetSerializeByteCodeForLibrary(bool set) { serializeByteCodeForLibrary = set; }
  34. bool IsSerializeByteCodeForLibrary() const { return serializeByteCodeForLibrary; }
  35. #endif
  36. #ifdef ENABLE_SCRIPT_DEBUGGING
  37. void EnsureJsrtDebugManager();
  38. void DeleteJsrtDebugManager();
  39. JsrtDebugManager * GetJsrtDebugManager();
  40. #endif
  41. #if ENABLE_TTD
  42. uint32 BPRegister_TTD(int64 bpID, Js::ScriptContext* scriptContext, Js::Utf8SourceInfo* utf8SourceInfo, uint32 line, uint32 column, BOOL* isNewBP);
  43. void BPDelete_TTD(uint32 bpID);
  44. void BPClearDocument_TTD();
  45. #endif
  46. private:
  47. static void __cdecl RecyclerCollectCallbackStatic(void * context, RecyclerCollectCallBackFlags flags);
  48. private:
  49. ThreadContext * threadContext;
  50. AllocationPolicyManager* allocationPolicyManager;
  51. JsrtContext * contextList;
  52. ThreadContext::CollectCallBack * collectCallback;
  53. JsBeforeCollectCallback beforeCollectCallback;
  54. JsrtThreadService threadService;
  55. void * callbackContext;
  56. bool useIdle;
  57. bool dispatchExceptions;
  58. #ifdef ENABLE_DEBUG_CONFIG_OPTIONS
  59. bool serializeByteCodeForLibrary;
  60. #endif
  61. #ifdef ENABLE_SCRIPT_DEBUGGING
  62. JsrtDebugManager * jsrtDebugManager;
  63. #endif
  64. };