• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
21 #include "quick_entrypoints_enum.h"
22 #include "thread.h"
23 
24 namespace art {
25 
26 // Define an enum for the entrypoints. Names are prepended a 'kQuick'.
27 enum QuickEntrypointEnum
28 {  // NOLINT(whitespace/braces)
29 #define ENTRYPOINT_ENUM(name, rettype, ...) kQuick ## name,
30 #include "quick_entrypoints_list.h"
31   QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
32 #undef QUICK_ENTRYPOINT_LIST
33 #undef ENTRYPOINT_ENUM
34 };
35 
36 std::ostream& operator<<(std::ostream& os, const QuickEntrypointEnum& kind);
37 
38 // Translate a QuickEntrypointEnum value to the corresponding ThreadOffset.
39 template <PointerSize pointer_size>
GetThreadOffset(QuickEntrypointEnum trampoline)40 static ThreadOffset<pointer_size> GetThreadOffset(QuickEntrypointEnum trampoline) {
41   switch (trampoline)
42   {  // NOLINT(whitespace/braces)
43   #define ENTRYPOINT_ENUM(name, rettype, ...) case kQuick ## name : \
44       return QUICK_ENTRYPOINT_OFFSET(pointer_size, p ## name);
45   #include "quick_entrypoints_list.h"
46     QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
47   #undef QUICK_ENTRYPOINT_LIST
48   #undef ENTRYPOINT_ENUM
49   };
50   LOG(FATAL) << "Unexpected trampoline " << static_cast<int>(trampoline);
51   UNREACHABLE();
52 }
53 
54 // Do a check functions to be able to test whether the right signature is used.
55 template <QuickEntrypointEnum entrypoint, typename... Types>
56 void CheckEntrypointTypes();
57 
58 #define ENTRYPOINT_ENUM(name, ...) \
59 template <> inline void CheckEntrypointTypes<kQuick ## name, __VA_ARGS__>() {};  // NOLINT [readability/braces] [4]
60 #include "quick_entrypoints_list.h"
61   QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
62 #undef QUICK_ENTRYPOINT_LIST
63 #undef ENTRYPOINT_ENUM
64 
65 bool EntrypointRequiresStackMap(QuickEntrypointEnum trampoline);
66 bool EntrypointCanTriggerGC(QuickEntrypointEnum entrypoint);
67 
68 }  // namespace art
69 
70 #endif  // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
71