JsrtRuntime.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "JsrtDebugManager.h"
  9. class JsrtContext;
  10. class JsrtRuntime
  11. {
  12. friend class JsrtContext;
  13. public:
  14. JsrtRuntime(ThreadContext * threadContext, bool useIdle, bool dispatchExceptions);
  15. ~JsrtRuntime();
  16. ThreadContext * GetThreadContext() { return this->threadContext; }
  17. JsRuntimeHandle ToHandle() { return static_cast<JsRuntimeHandle>(this); }
  18. static JsrtRuntime * FromHandle(JsRuntimeHandle runtimeHandle)
  19. {
  20. JsrtRuntime * runtime = static_cast<JsrtRuntime *>(runtimeHandle);
  21. runtime->threadContext->ValidateThreadContext();
  22. return runtime;
  23. }
  24. static void Uninitialize();
  25. bool UseIdle() const { return useIdle; }
  26. unsigned int Idle();
  27. bool DispatchExceptions() const { return dispatchExceptions; }
  28. void CloseContexts();
  29. void SetBeforeCollectCallback(JsBeforeCollectCallback beforeCollectCallback, void * callbackContext);
  30. #ifdef ENABLE_DEBUG_CONFIG_OPTIONS
  31. void SetSerializeByteCodeForLibrary(bool set) { serializeByteCodeForLibrary = set; }
  32. bool IsSerializeByteCodeForLibrary() const { return serializeByteCodeForLibrary; }
  33. #endif
  34. void EnsureJsrtDebugManager();
  35. void DeleteJsrtDebugManager();
  36. JsrtDebugManager * GetJsrtDebugManager();
  37. private:
  38. static void __cdecl RecyclerCollectCallbackStatic(void * context, RecyclerCollectCallBackFlags flags);
  39. private:
  40. ThreadContext * threadContext;
  41. AllocationPolicyManager* allocationPolicyManager;
  42. JsrtContext * contextList;
  43. ThreadContext::CollectCallBack * collectCallback;
  44. JsBeforeCollectCallback beforeCollectCallback;
  45. JsrtThreadService threadService;
  46. void * callbackContext;
  47. bool useIdle;
  48. bool dispatchExceptions;
  49. #ifdef ENABLE_DEBUG_CONFIG_OPTIONS
  50. bool serializeByteCodeForLibrary;
  51. #endif
  52. JsrtDebugManager * jsrtDebugManager;
  53. };