1 /* 2 * Copyright (C) 2015 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_VERIFIER_VERIFIER_ENUMS_H_ 18 #define ART_RUNTIME_VERIFIER_VERIFIER_ENUMS_H_ 19 20 #include <stdint.h> 21 22 namespace art { 23 namespace verifier { 24 25 // The mode that the verifier should run as. 26 enum class VerifyMode : int8_t { 27 kNone, // Everything is assumed verified. 28 kEnable, // Standard verification, try pre-verifying at compile-time. 29 kSoftFail, // Force a soft fail, punting to the interpreter with access checks. 30 }; 31 32 // The outcome of verification. 33 enum class FailureKind { 34 kNoFailure, 35 kAccessChecksFailure, 36 kTypeChecksFailure, 37 kSoftFailure, 38 kHardFailure, 39 }; 40 std::ostream& operator<<(std::ostream& os, FailureKind rhs); 41 42 // How to log hard failures during verification. 43 enum class HardFailLogMode { 44 kLogNone, // Don't log hard failures at all. 45 kLogVerbose, // Log with severity VERBOSE. 46 kLogWarning, // Log with severity WARNING. 47 kLogInternalFatal, // Log with severity FATAL_WITHOUT_ABORT 48 }; 49 50 /* 51 * "Direct" and "virtual" methods are stored independently. The type of call used to invoke the 52 * method determines which list we search, and whether we travel up into superclasses. 53 * 54 * (<clinit>, <init>, and methods declared "private" or "static" are stored in the "direct" list. 55 * All others are stored in the "virtual" list.) 56 */ 57 enum MethodType { 58 METHOD_UNKNOWN = 0, 59 METHOD_DIRECT, // <init>, private 60 METHOD_STATIC, // static 61 METHOD_VIRTUAL, // virtual 62 METHOD_SUPER, // super 63 METHOD_INTERFACE, // interface 64 METHOD_POLYMORPHIC // polymorphic 65 }; 66 std::ostream& operator<<(std::ostream& os, MethodType rhs); 67 68 /* 69 * An enumeration of problems that can turn up during verification. 70 */ 71 enum VerifyError : uint32_t { 72 VERIFY_ERROR_BAD_CLASS_HARD = 1 << 0, // VerifyError; hard error that skips compilation. 73 VERIFY_ERROR_NO_CLASS = 1 << 1, // NoClassDefFoundError. 74 VERIFY_ERROR_UNRESOLVED_TYPE_CHECK = 1 << 2, // Missing class for doing a type check 75 VERIFY_ERROR_NO_METHOD = 1 << 3, // NoSuchMethodError. 76 VERIFY_ERROR_ACCESS_CLASS = 1 << 4, // IllegalAccessError. 77 VERIFY_ERROR_ACCESS_FIELD = 1 << 5, // IllegalAccessError. 78 VERIFY_ERROR_ACCESS_METHOD = 1 << 6, // IllegalAccessError. 79 VERIFY_ERROR_CLASS_CHANGE = 1 << 7, // IncompatibleClassChangeError. 80 VERIFY_ERROR_INSTANTIATION = 1 << 8, // InstantiationError. 81 VERIFY_ERROR_LOCKING = 1 << 9, // Could not guarantee balanced locking. This should be 82 // punted to the interpreter with access checks. 83 VERIFY_ERROR_RUNTIME_THROW = 1 << 10, // The interpreter found an instruction that will 84 // throw. Used for app compatibility for apps < T. 85 }; 86 std::ostream& operator<<(std::ostream& os, VerifyError rhs); 87 88 } // namespace verifier 89 } // namespace art 90 91 #endif // ART_RUNTIME_VERIFIER_VERIFIER_ENUMS_H_ 92