• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 PANDA_RUNTIME_MEM_GC_GC_SCOPED_FUNC_H
17 #define PANDA_RUNTIME_MEM_GC_GC_SCOPED_FUNC_H
18 
19 #include "libpandabase/trace/trace.h"
20 #include "runtime/mem/gc/gc_scoped_phase.h"
21 #include "runtime/timing.h"
22 
23 namespace panda::mem {
24 // Forward declaration
25 class GC;
26 
27 enum GCScopeType { TRACE_TIMING, TRACE_TIMING_PHASE, TIMING_PHASE, TRACE_PHASE };
28 
29 template <GCScopeType gc_scope_type>
30 class GCScope {
31 public:
32     GCScope() = delete;
33     NO_COPY_SEMANTIC(GCScope);
34     NO_MOVE_SEMANTIC(GCScope);
35     ~GCScope() = default;
36 };
37 
38 template <>
39 class GCScope<TRACE_TIMING> : public trace::ScopedTrace, public ScopedTiming {  // NOLINT(fuchsia-multiple-inheritance)
40 public:
41     GCScope(std::string_view name, GC *gc);
42     NO_COPY_SEMANTIC(GCScope);
43     NO_MOVE_SEMANTIC(GCScope);
44     ~GCScope() = default;
45 };
46 
47 template <>
48 // NOLINTNEXTLINE(fuchsia-multiple-inheritance)
49 class GCScope<TRACE_TIMING_PHASE> : public trace::ScopedTrace, public ScopedTiming, public GCScopedPhase {
50 public:
51     GCScope(std::string_view name, GC *gc, GCPhase phase);
52     NO_COPY_SEMANTIC(GCScope);
53     NO_MOVE_SEMANTIC(GCScope);
54     ~GCScope() = default;
55 };
56 
57 template <>
58 class GCScope<TIMING_PHASE> : public ScopedTiming, public GCScopedPhase {  // NOLINT(fuchsia-multiple-inheritance)
59 public:
60     GCScope(std::string_view name, GC *gc, GCPhase phase);
61     NO_COPY_SEMANTIC(GCScope);
62     NO_MOVE_SEMANTIC(GCScope);
63     ~GCScope() = default;
64 };
65 
66 template <>
67 class GCScope<TRACE_PHASE> : public trace::ScopedTrace, public GCScopedPhase {  // NOLINT(fuchsia-multiple-inheritance)
68 public:
69     GCScope(std::string_view name, GC *gc, GCPhase phase);
70     NO_COPY_SEMANTIC(GCScope);
71     NO_MOVE_SEMANTIC(GCScope);
72     ~GCScope() = default;
73 };
74 }  // namespace panda::mem
75 
76 #endif  // PANDA_RUNTIME_MEM_GC_GC_SCOPED_FUNC_H
77