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_H
17 #define PANDA_PROFILING_H
18
19 #include "libpandafile/bytecode_instruction.h"
20 #include "source_lang_enum.h"
21 #include "libpandabase/utils/expected.h"
22 #include "runtime/include/profiling_gen.h"
23 #include <string_view>
24 #include <iostream>
25
26 namespace ark::profiling {
27 enum class CallKind { UNKNOWN = 0, MONOMORPHIC, POLYMORPHIC, MEGAMORPHIC, COUNT };
28
CallKindToString(CallKind callKind)29 inline const char *CallKindToString(CallKind callKind)
30 {
31 static constexpr auto COUNT = static_cast<uint8_t>(CallKind::COUNT);
32 static constexpr std::array<const char *, COUNT> CALL_KIND_NAMES = {"UNKNOWN", "MONOMORPHIC", "POLYMORPHIC",
33 "MEGAMORPHIC"};
34 auto idx = static_cast<uint8_t>(callKind);
35 ASSERT(idx < COUNT);
36 return CALL_KIND_NAMES[idx];
37 }
38
39 enum AnyInputType : uint8_t {
40 DEFAULT = 0,
41 INTEGER = 1,
42 SPECIAL = 2,
43 SPECIAL_INT = INTEGER | SPECIAL,
44 LAST = SPECIAL_INT
45 };
46
47 using ProfileContainer = void *;
48 using ProfileType = void *;
49
50 // NOLINTNEXTLINE(misc-misplaced-const)
51 static constexpr ProfileType INVALID_PROFILE = nullptr;
52 static constexpr uint8_t MAX_FUNC_NUMBER = 4U;
53
54 } // namespace ark::profiling
55
56 #endif // PANDA_PROFILING_H
57