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