blob: 017cba68ea74a3ac0da0ec3cf58c5e480b47c890 [file] [log] [blame]
Andreas Gampe98430592014-07-27 19:44:50 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
18#define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
19
20#include "quick_entrypoints.h"
21#include "thread.h"
22
23namespace art {
24
25// Define an enum for the entrypoints. Names are prepended a 'kQuick'.
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070026enum QuickEntrypointEnum { // NOLINT(whitespace/braces)
Andreas Gampe98430592014-07-27 19:44:50 -070027#define ENTRYPOINT_ENUM(name, rettype, ...) kQuick ## name,
28#include "quick_entrypoints_list.h"
29 QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
30#undef QUICK_ENTRYPOINT_LIST
31#undef ENTRYPOINT_ENUM
32};
33
34std::ostream& operator<<(std::ostream& os, const QuickEntrypointEnum& kind);
35
36// Translate a QuickEntrypointEnum value to the corresponding ThreadOffset.
Andreas Gampe542451c2016-07-26 09:02:02 -070037template <PointerSize pointer_size>
Nicolas Geoffraya00b54b2019-12-03 14:36:42 +000038static constexpr ThreadOffset<pointer_size> GetThreadOffset(QuickEntrypointEnum trampoline) {
Andreas Gampe98430592014-07-27 19:44:50 -070039 switch (trampoline)
40 { // NOLINT(whitespace/braces)
41 #define ENTRYPOINT_ENUM(name, rettype, ...) case kQuick ## name : \
42 return QUICK_ENTRYPOINT_OFFSET(pointer_size, p ## name);
43 #include "quick_entrypoints_list.h"
44 QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
45 #undef QUICK_ENTRYPOINT_LIST
46 #undef ENTRYPOINT_ENUM
47 };
48 LOG(FATAL) << "Unexpected trampoline " << static_cast<int>(trampoline);
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080049 UNREACHABLE();
Andreas Gampe98430592014-07-27 19:44:50 -070050}
51
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080052// Do a check functions to be able to test whether the right signature is used.
53template <QuickEntrypointEnum entrypoint, typename... Types>
54void CheckEntrypointTypes();
Andreas Gampe98430592014-07-27 19:44:50 -070055
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080056#define ENTRYPOINT_ENUM(name, ...) \
57template <> inline void CheckEntrypointTypes<kQuick ## name, __VA_ARGS__>() {}; // NOLINT [readability/braces] [4]
58#include "quick_entrypoints_list.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070059QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080060#undef QUICK_ENTRYPOINT_LIST
61#undef ENTRYPOINT_ENUM
62
Serban Constantinescuda8ffec2016-03-09 12:02:11 +000063bool EntrypointRequiresStackMap(QuickEntrypointEnum trampoline);
Alexandre Rames91a65162016-09-19 13:54:30 +010064bool EntrypointCanTriggerGC(QuickEntrypointEnum entrypoint);
Serban Constantinescuda8ffec2016-03-09 12:02:11 +000065
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080066} // namespace art
Andreas Gampe98430592014-07-27 19:44:50 -070067
68#endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_