1 /**
2 * Copyright (c) 2022-2024 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_PROFILING_INL_H
17 #define PANDA_PROFILING_INL_H
18
19 #include "profiling.h"
20 #include "runtime/profiling/generated/profiling_includes_disasm.h"
21 #include "runtime/include/profiling_gen.h"
22
23 namespace ark::profiling {
24
ReadProfile(std::istream & stm,ark::panda_file::SourceLang lang)25 inline Expected<ProfileContainer, const char *> ReadProfile([[maybe_unused]] std::istream &stm,
26 [[maybe_unused]] ark::panda_file::SourceLang lang)
27 {
28 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
29 switch (lang) {
30 #include "runtime/profiling/generated/read_profile.h"
31 default:
32 break;
33 }
34 return Unexpected("ReadProfile: No plugin found for the given language");
35 }
36
DestroyProfile(ProfileContainer profile,ark::panda_file::SourceLang lang)37 inline void DestroyProfile([[maybe_unused]] ProfileContainer profile, [[maybe_unused]] ark::panda_file::SourceLang lang)
38 {
39 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
40 switch (lang) {
41 #include "runtime/profiling/generated/destroy_profile.h"
42 default:
43 break;
44 }
45 }
46
FindMethodInProfile(ProfileContainer profile,ark::panda_file::SourceLang lang,const std::string & methodName)47 inline ProfileType FindMethodInProfile([[maybe_unused]] ProfileContainer profile,
48 [[maybe_unused]] ark::panda_file::SourceLang lang,
49 [[maybe_unused]] const std::string &methodName)
50 {
51 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
52 switch (lang) {
53 #include "runtime/profiling/generated/find_method_in_profile.h"
54 default:
55 LOG(FATAL, COMMON) << "FindMethodInProfile: No plugin found for the given language";
56 }
57 return INVALID_PROFILE;
58 }
59
DumpProfile(ProfileType profile,ark::panda_file::SourceLang lang,BytecodeInstruction * inst,std::ostream & stm)60 inline void DumpProfile([[maybe_unused]] ProfileType profile, [[maybe_unused]] ark::panda_file::SourceLang lang,
61 [[maybe_unused]] BytecodeInstruction *inst, [[maybe_unused]] std::ostream &stm)
62 {
63 // NOLINTNEXTLINE(hicpp-multiway-paths-covered)
64 switch (lang) {
65 #include "runtime/profiling/generated/dump_profile.h"
66 default:
67 break;
68 }
69 }
70 } // namespace ark::profiling
71
72 #endif // PANDA_PROFILING_INL_H