Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sts=4 et sw=4 tw=99:
3 : * This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "jscntxt.h"
8 : #include "jsfriendapi.h"
9 :
10 : #include "vm/Runtime.h"
11 :
12 : using js::gc::Cell;
13 :
14 : mozilla::Atomic<uint32_t, mozilla::Relaxed> MemProfiler::sActiveProfilerCount;
15 : NativeProfiler* MemProfiler::sNativeProfiler;
16 :
17 : GCHeapProfiler*
18 0 : MemProfiler::GetGCHeapProfiler(void* addr)
19 : {
20 0 : JSRuntime* runtime = reinterpret_cast<Cell*>(addr)->runtimeFromAnyThread();
21 0 : return runtime->gc.mMemProfiler.mGCHeapProfiler;
22 : }
23 :
24 : GCHeapProfiler*
25 0 : MemProfiler::GetGCHeapProfiler(JSRuntime* runtime)
26 : {
27 0 : return runtime->gc.mMemProfiler.mGCHeapProfiler;
28 : }
29 :
30 : JS_FRIEND_API(MemProfiler*)
31 0 : MemProfiler::GetMemProfiler(JSContext* context)
32 : {
33 0 : return &context->runtime()->gc.mMemProfiler;
34 : }
35 :
36 : JS_FRIEND_API(void)
37 0 : MemProfiler::start(GCHeapProfiler* aGCHeapProfiler)
38 : {
39 0 : ReleaseAllJITCode(mRuntime->defaultFreeOp());
40 0 : mGCHeapProfiler = aGCHeapProfiler;
41 0 : sActiveProfilerCount++;
42 0 : }
43 :
44 : JS_FRIEND_API(void)
45 0 : MemProfiler::stop()
46 : {
47 0 : sActiveProfilerCount--;
48 0 : mGCHeapProfiler = nullptr;
49 0 : }
|