• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include <algorithm>
17 #include <array>
18 #include <string_view>
19 
20 #include "irtoc_function_utils.h"
21 
22 using namespace std::literals::string_view_literals;  // Enables 'sv' suffix
23 
24 constexpr std::array NOALIAS_IRTOC_FUNC = {
25     "CreateObjectByIdEntrypoint"sv,      "CreateObjectByClassInterpreter"sv, "CreateArrayByIdEntrypoint"sv,
26     "CreateMultiDimensionalArrayById"sv,
27 #ifdef PANDA_WITH_ETS
28     "LaunchFromInterpreterShort"sv,      "LaunchFromInterpreterLong"sv,      "LaunchFromInterpreterRange"sv,
29 #endif
30 };
31 
32 constexpr std::array PTR_IGN_IRTOC_FUNC = {"ResolveStringByIdEntrypoint"sv,
33                                            "ResolveLiteralArrayByIdEntrypoint"sv,
34                                            "ResolveTypeByIdEntrypoint"sv,
35                                            "GetCalleeMethodFromBytecodeId"sv,
36                                            "GetInstructionsByMethod"sv,
37                                            "GetFieldByIdEntrypoint"sv,
38                                            "GetStaticFieldByIdEntrypoint"sv,
39                                            "FindCatchBlockInIFrames"sv,
40                                            "ResolveVirtualMethod"sv,
41                                            "GetMethodClassById"sv,
42                                            "VmCreateString"sv,
43                                            "AllocFrameInterp"sv,
44                                            "InitializeFrame"sv};
45 
46 namespace panda::llvmbackend::irtoc_function_utils {
IsNoAliasIrtocFunction(const std::string & externalName)47 bool IsNoAliasIrtocFunction(const std::string &externalName)
48 {
49     return std::find(NOALIAS_IRTOC_FUNC.begin(), NOALIAS_IRTOC_FUNC.end(), externalName) != NOALIAS_IRTOC_FUNC.end();
50 }
IsPtrIgnIrtocFunction(const std::string & externalName)51 bool IsPtrIgnIrtocFunction(const std::string &externalName)
52 {
53     return std::find(PTR_IGN_IRTOC_FUNC.begin(), PTR_IGN_IRTOC_FUNC.end(), externalName) != PTR_IGN_IRTOC_FUNC.end();
54 }
55 }  // namespace panda::llvmbackend::irtoc_function_utils