Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_MODIFIERS_H_ |
| 18 | #define ART_RUNTIME_MODIFIERS_H_ |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 22 | namespace art { |
| 23 | |
Andreas Gampe | 5182932 | 2014-08-25 15:05:04 -0700 | [diff] [blame] | 24 | static constexpr uint32_t kAccPublic = 0x0001; // class, field, method, ic |
| 25 | static constexpr uint32_t kAccPrivate = 0x0002; // field, method, ic |
| 26 | static constexpr uint32_t kAccProtected = 0x0004; // field, method, ic |
| 27 | static constexpr uint32_t kAccStatic = 0x0008; // field, method, ic |
| 28 | static constexpr uint32_t kAccFinal = 0x0010; // class, field, method, ic |
| 29 | static constexpr uint32_t kAccSynchronized = 0x0020; // method (only allowed on natives) |
| 30 | static constexpr uint32_t kAccSuper = 0x0020; // class (not used in dex) |
| 31 | static constexpr uint32_t kAccVolatile = 0x0040; // field |
| 32 | static constexpr uint32_t kAccBridge = 0x0040; // method (1.5) |
| 33 | static constexpr uint32_t kAccTransient = 0x0080; // field |
| 34 | static constexpr uint32_t kAccVarargs = 0x0080; // method (1.5) |
| 35 | static constexpr uint32_t kAccNative = 0x0100; // method |
| 36 | static constexpr uint32_t kAccInterface = 0x0200; // class, ic |
| 37 | static constexpr uint32_t kAccAbstract = 0x0400; // class, method, ic |
| 38 | static constexpr uint32_t kAccStrict = 0x0800; // method |
| 39 | static constexpr uint32_t kAccSynthetic = 0x1000; // class, field, method, ic |
| 40 | static constexpr uint32_t kAccAnnotation = 0x2000; // class, ic (1.5) |
| 41 | static constexpr uint32_t kAccEnum = 0x4000; // class, field, ic (1.5) |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 42 | |
Andreas Gampe | 5182932 | 2014-08-25 15:05:04 -0700 | [diff] [blame] | 43 | static constexpr uint32_t kAccJavaFlagsMask = 0xffff; // bits set from Java sources (low 16) |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 44 | |
Igor Murashkin | df707e4 | 2016-02-02 16:56:50 -0800 | [diff] [blame] | 45 | static constexpr uint32_t kAccConstructor = 0x00010000; // method (dex only) <(cl)init> |
| 46 | static constexpr uint32_t kAccDeclaredSynchronized = 0x00020000; // method (dex only) |
| 47 | static constexpr uint32_t kAccClassIsProxy = 0x00040000; // class (dex only) |
Alex Light | 7532d58 | 2017-02-13 16:36:06 -0800 | [diff] [blame] | 48 | // Set to indicate that the ArtMethod is obsolete and has a different DexCache + DexFile from its |
| 49 | // declaring class. This flag may only be applied to methods. |
| 50 | static constexpr uint32_t kAccObsoleteMethod = 0x00040000; // method (runtime) |
Igor Murashkin | df707e4 | 2016-02-02 16:56:50 -0800 | [diff] [blame] | 51 | // Used by a method to denote that its execution does not need to go through slow path interpreter. |
| 52 | static constexpr uint32_t kAccSkipAccessChecks = 0x00080000; // method (dex only) |
| 53 | // Used by a class to denote that the verifier has attempted to check it at least once. |
| 54 | static constexpr uint32_t kAccVerificationAttempted = 0x00080000; // class (runtime) |
| 55 | static constexpr uint32_t kAccFastNative = 0x00080000; // method (dex only) |
Alex Light | 7ead0c0 | 2016-02-22 13:43:29 -0800 | [diff] [blame] | 56 | // This is set by the class linker during LinkInterfaceMethods. It is used by a method to represent |
| 57 | // that it was copied from its declaring class into another class. All methods marked kAccMiranda |
| 58 | // and kAccDefaultConflict will have this bit set. Any kAccDefault method contained in the methods_ |
| 59 | // array of a concrete class will also have this bit set. |
| 60 | static constexpr uint32_t kAccCopied = 0x00100000; // method (runtime) |
Igor Murashkin | df707e4 | 2016-02-02 16:56:50 -0800 | [diff] [blame] | 61 | static constexpr uint32_t kAccMiranda = 0x00200000; // method (dex only) |
| 62 | static constexpr uint32_t kAccDefault = 0x00400000; // method (runtime) |
Alex Light | 9139e00 | 2015-10-09 15:59:48 -0700 | [diff] [blame] | 63 | // This is set by the class linker during LinkInterfaceMethods. Prior to that point we do not know |
| 64 | // if any particular method needs to be a default conflict. Used to figure out at runtime if |
| 65 | // invoking this method will throw an exception. |
Andreas Gampe | f517e28 | 2016-04-28 14:56:54 -0700 | [diff] [blame] | 66 | static constexpr uint32_t kAccDefaultConflict = 0x00800000; // method (runtime) |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 67 | |
Nicolas Geoffray | 62e631a | 2016-04-20 16:27:53 +0100 | [diff] [blame] | 68 | // Set by the verifier for a method we do not want the compiler to compile. |
Andreas Gampe | f517e28 | 2016-04-28 14:56:54 -0700 | [diff] [blame] | 69 | static constexpr uint32_t kAccCompileDontBother = 0x01000000; // method (runtime) |
| 70 | |
| 71 | // Set by the verifier for a method that could not be verified to follow structured locking. |
| 72 | static constexpr uint32_t kAccMustCountLocks = 0x02000000; // method (runtime) |
Mingyao Yang | 063fc77 | 2016-08-02 11:02:54 -0700 | [diff] [blame] | 73 | |
| 74 | // Set by the class linker for a method that has only one implementation for a |
| 75 | // virtual call. |
| 76 | static constexpr uint32_t kAccSingleImplementation = 0x08000000; // method (runtime) |
| 77 | |
Nicolas Geoffray | 762869d | 2016-07-15 15:28:35 +0100 | [diff] [blame] | 78 | static constexpr uint32_t kAccIntrinsic = 0x80000000; // method (runtime) |
Nicolas Geoffray | 62e631a | 2016-04-20 16:27:53 +0100 | [diff] [blame] | 79 | |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 80 | // Special runtime-only flags. |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 81 | // Interface and all its super-interfaces with default methods have been recursively initialized. |
| 82 | static constexpr uint32_t kAccRecursivelyInitialized = 0x20000000; |
| 83 | // Interface declares some default method. |
| 84 | static constexpr uint32_t kAccHasDefaultMethod = 0x40000000; |
Andreas Gampe | 5182932 | 2014-08-25 15:05:04 -0700 | [diff] [blame] | 85 | // class/ancestor overrides finalize() |
| 86 | static constexpr uint32_t kAccClassIsFinalizable = 0x80000000; |
Andreas Gampe | 5182932 | 2014-08-25 15:05:04 -0700 | [diff] [blame] | 87 | |
Nicolas Geoffray | 762869d | 2016-07-15 15:28:35 +0100 | [diff] [blame] | 88 | static constexpr uint32_t kAccFlagsNotUsedByIntrinsic = 0x007FFFFF; |
| 89 | static constexpr uint32_t kAccMaxIntrinsic = 0xFF; |
| 90 | |
Andreas Gampe | 5182932 | 2014-08-25 15:05:04 -0700 | [diff] [blame] | 91 | // Valid (meaningful) bits for a field. |
| 92 | static constexpr uint32_t kAccValidFieldFlags = kAccPublic | kAccPrivate | kAccProtected | |
| 93 | kAccStatic | kAccFinal | kAccVolatile | kAccTransient | kAccSynthetic | kAccEnum; |
| 94 | |
| 95 | // Valid (meaningful) bits for a method. |
| 96 | static constexpr uint32_t kAccValidMethodFlags = kAccPublic | kAccPrivate | kAccProtected | |
| 97 | kAccStatic | kAccFinal | kAccSynchronized | kAccBridge | kAccVarargs | kAccNative | |
| 98 | kAccAbstract | kAccStrict | kAccSynthetic | kAccMiranda | kAccConstructor | |
| 99 | kAccDeclaredSynchronized; |
| 100 | |
| 101 | // Valid (meaningful) bits for a class (not interface). |
| 102 | // Note 1. These are positive bits. Other bits may have to be zero. |
| 103 | // Note 2. Inner classes can expose more access flags to Java programs. That is handled by libcore. |
| 104 | static constexpr uint32_t kAccValidClassFlags = kAccPublic | kAccFinal | kAccSuper | |
| 105 | kAccAbstract | kAccSynthetic | kAccEnum; |
| 106 | |
| 107 | // Valid (meaningful) bits for an interface. |
| 108 | // Note 1. Annotations are interfaces. |
| 109 | // Note 2. These are positive bits. Other bits may have to be zero. |
| 110 | // Note 3. Inner classes can expose more access flags to Java programs. That is handled by libcore. |
| 111 | static constexpr uint32_t kAccValidInterfaceFlags = kAccPublic | kAccInterface | |
| 112 | kAccAbstract | kAccSynthetic | kAccAnnotation; |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 113 | |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 114 | } // namespace art |
| 115 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 116 | #endif // ART_RUNTIME_MODIFIERS_H_ |
Ian Rogers | 08f753d | 2012-08-24 14:35:25 -0700 | [diff] [blame] | 117 | |