• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_HPROF_HEAP_PROFILER_INTERFACE_H
17 #define ECMASCRIPT_HPROF_HEAP_PROFILER_INTERFACE_H
18 
19 #include "libpandabase/macros.h"
20 
21 namespace panda::ecmascript {
22 class EcmaVM;
23 class Progress;
24 class Stream;
25 
26 enum class DumpFormat { JSON, BINARY, OTHER };
27 
28 class HeapProfilerInterface {
29 public:
30     static HeapProfilerInterface *GetInstance(EcmaVM *vm);
31     static void Destroy(EcmaVM *vm);
32 
33     HeapProfilerInterface() = default;
34     virtual ~HeapProfilerInterface() = default;
35 
36     virtual bool DumpHeapSnapshot(DumpFormat dumpFormat, Stream *stream, Progress *progress = nullptr,
37                                   bool isVmMode = true, bool isPrivate = false) = 0;
38 
39     virtual bool StartHeapTracking(double timeInterval, bool isVmMode = true, Stream *stream = nullptr,
40                                    bool traceAllocation = false, bool newThread = true) = 0;
41     virtual bool UpdateHeapTracking(Stream *stream) = 0;
42     virtual bool StopHeapTracking(Stream *stream, Progress *progress = nullptr, bool newThread = true) = 0;
43 
44     NO_MOVE_SEMANTIC(HeapProfilerInterface);
45     NO_COPY_SEMANTIC(HeapProfilerInterface);
46 };
47 }  // namespace panda::ecmascript
48 #endif  // ECMASCRIPT_HPROF_HEAP_PROFILER_INTERFACE_H
49