ScriptContextProfiler.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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;
  7. namespace Js
  8. {
  9. class ScriptContextProfiler
  10. {
  11. #ifdef PROFILE_EXEC
  12. friend class NativeCodeGenerator;
  13. friend class ServerScriptContext;
  14. public:
  15. ScriptContextProfiler();
  16. ~ScriptContextProfiler();
  17. bool IsInitialized() const { return profilerArena != nullptr; }
  18. void Initialize(PageAllocator * pageAllocator, Recycler * recycler);
  19. ULONG AddRef();
  20. ULONG Release();
  21. Profiler * GetProfiler() { return profiler; }
  22. Profiler * GetBackgroundRecyclerProfiler() { return backgroundRecyclerProfiler; }
  23. void ProfileBegin(Js::Phase phase);
  24. void ProfileEnd(Js::Phase phase);
  25. void ProfileSuspend(Js::Phase, Js::Profiler::SuspendRecord * suspendRecord);
  26. void ProfileResume(Js::Profiler::SuspendRecord * suspendRecord);
  27. void ProfilePrint(Js::Phase phase);
  28. void ProfileMerge(ScriptContextProfiler * profiler);
  29. void ProfilePrint();
  30. private:
  31. ArenaAllocator * profilerArena;
  32. ArenaAllocator * backgroundRecyclerProfilerArena;
  33. Profiler * profiler;
  34. Profiler * backgroundRecyclerProfiler;
  35. uint refcount;
  36. Recycler * recycler;
  37. PageAllocator *pageAllocator;
  38. ScriptContextProfiler *next;
  39. #endif
  40. };
  41. };