• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #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     "LookupGetterByNameShortEntrypoint"sv, "LookupGetterByNameLongEntrypoint"sv, "LookupGetterByNameObjEntrypoint"sv,
30     "LookupSetterByNameShortEntrypoint"sv, "LookupSetterByNameLongEntrypoint"sv, "LookupSetterByNameObjEntrypoint"sv,
31     "LookupFieldByNameEntrypoint"sv,
32 #endif
33 };
34 
35 constexpr std::array PTR_IGN_IRTOC_FUNC = {
36     "ResolveStringByIdEntrypoint"sv,
37     "ResolveLiteralArrayByIdEntrypoint"sv,
38     "ResolveTypeByIdEntrypoint"sv,
39     "GetCalleeMethodFromBytecodeId"sv,
40     "GetInstructionsByMethod"sv,
41     "GetFieldByIdEntrypoint"sv,
42     "GetStaticFieldByIdEntrypoint"sv,
43     "FindCatchBlockInIFrames"sv,
44     "ResolveVirtualMethod"sv,
45     "GetMethodClassById"sv,
46     "VmCreateString"sv,
47     "AllocFrameInterp"sv,
48     "InitializeFrame"sv,
49     "memmove"sv,
50 };
51 
52 namespace ark::llvmbackend::irtoc_function_utils {
IsNoAliasIrtocFunction(const std::string & externalName)53 bool IsNoAliasIrtocFunction(const std::string &externalName)
54 {
55     return std::find(NOALIAS_IRTOC_FUNC.begin(), NOALIAS_IRTOC_FUNC.end(), externalName) != NOALIAS_IRTOC_FUNC.end();
56 }
IsPtrIgnIrtocFunction(const std::string & externalName)57 bool IsPtrIgnIrtocFunction(const std::string &externalName)
58 {
59     return std::find(PTR_IGN_IRTOC_FUNC.begin(), PTR_IGN_IRTOC_FUNC.end(), externalName) != PTR_IGN_IRTOC_FUNC.end();
60 }
61 }  // namespace ark::llvmbackend::irtoc_function_utils
62