Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 1 | /* |
| 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" |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 21 | #include "quick_entrypoints_enum.h" |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 22 | #include "thread.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | // Define an enum for the entrypoints. Names are prepended a 'kQuick'. |
Andreas Gampe | 8cf9cb38 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 27 | enum QuickEntrypointEnum { // NOLINT(whitespace/braces) |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 28 | #define ENTRYPOINT_ENUM(name, rettype, ...) kQuick ## name, |
| 29 | #include "quick_entrypoints_list.h" |
| 30 | QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM) |
| 31 | #undef QUICK_ENTRYPOINT_LIST |
| 32 | #undef ENTRYPOINT_ENUM |
| 33 | }; |
| 34 | |
| 35 | std::ostream& operator<<(std::ostream& os, const QuickEntrypointEnum& kind); |
| 36 | |
| 37 | // Translate a QuickEntrypointEnum value to the corresponding ThreadOffset. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 38 | template <PointerSize pointer_size> |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 39 | static ThreadOffset<pointer_size> GetThreadOffset(QuickEntrypointEnum trampoline) { |
| 40 | switch (trampoline) |
| 41 | { // NOLINT(whitespace/braces) |
| 42 | #define ENTRYPOINT_ENUM(name, rettype, ...) case kQuick ## name : \ |
| 43 | return QUICK_ENTRYPOINT_OFFSET(pointer_size, p ## name); |
| 44 | #include "quick_entrypoints_list.h" |
| 45 | QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM) |
| 46 | #undef QUICK_ENTRYPOINT_LIST |
| 47 | #undef ENTRYPOINT_ENUM |
| 48 | }; |
| 49 | LOG(FATAL) << "Unexpected trampoline " << static_cast<int>(trampoline); |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 50 | UNREACHABLE(); |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 53 | // Do a check functions to be able to test whether the right signature is used. |
| 54 | template <QuickEntrypointEnum entrypoint, typename... Types> |
| 55 | void CheckEntrypointTypes(); |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 56 | |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 57 | #define ENTRYPOINT_ENUM(name, ...) \ |
| 58 | template <> inline void CheckEntrypointTypes<kQuick ## name, __VA_ARGS__>() {}; // NOLINT [readability/braces] [4] |
| 59 | #include "quick_entrypoints_list.h" |
Andreas Gampe | 8cf9cb38 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 60 | QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM) |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 61 | #undef QUICK_ENTRYPOINT_LIST |
| 62 | #undef ENTRYPOINT_ENUM |
| 63 | |
Serban Constantinescu | da8ffec | 2016-03-09 12:02:11 +0000 | [diff] [blame] | 64 | bool EntrypointRequiresStackMap(QuickEntrypointEnum trampoline); |
Alexandre Rames | 91a6516 | 2016-09-19 13:54:30 +0100 | [diff] [blame] | 65 | bool EntrypointCanTriggerGC(QuickEntrypointEnum entrypoint); |
Serban Constantinescu | da8ffec | 2016-03-09 12:02:11 +0000 | [diff] [blame] | 66 | |
Andreas Gampe | 1cc7dba | 2014-12-17 18:43:01 -0800 | [diff] [blame] | 67 | } // namespace art |
Andreas Gampe | 9843059 | 2014-07-27 19:44:50 -0700 | [diff] [blame] | 68 | |
| 69 | #endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_ |