• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   kSoftFailure,
36   kHardFailure,
37 };
38 std::ostream& operator<<(std::ostream& os, const FailureKind& rhs);
39 
40 // How to log hard failures during verification.
41 enum class HardFailLogMode {
42   kLogNone,                               // Don't log hard failures at all.
43   kLogVerbose,                            // Log with severity VERBOSE.
44   kLogWarning,                            // Log with severity WARNING.
45   kLogInternalFatal,                      // Log with severity FATAL_WITHOUT_ABORT
46 };
47 
48 /*
49  * "Direct" and "virtual" methods are stored independently. The type of call used to invoke the
50  * method determines which list we search, and whether we travel up into superclasses.
51  *
52  * (<clinit>, <init>, and methods declared "private" or "static" are stored in the "direct" list.
53  * All others are stored in the "virtual" list.)
54  */
55 enum MethodType {
56   METHOD_UNKNOWN  = 0,
57   METHOD_DIRECT,      // <init>, private
58   METHOD_STATIC,      // static
59   METHOD_VIRTUAL,     // virtual
60   METHOD_SUPER,       // super
61   METHOD_INTERFACE,   // interface
62   METHOD_POLYMORPHIC  // polymorphic
63 };
64 std::ostream& operator<<(std::ostream& os, const MethodType& rhs);
65 
66 /*
67  * An enumeration of problems that can turn up during verification.
68  * Both VERIFY_ERROR_BAD_CLASS_SOFT and VERIFY_ERROR_BAD_CLASS_HARD denote failures that cause
69  * the entire class to be rejected. However, VERIFY_ERROR_BAD_CLASS_SOFT denotes a soft failure
70  * that can potentially be corrected, and the verifier will try again at runtime.
71  * VERIFY_ERROR_BAD_CLASS_HARD denotes a hard failure that can't be corrected, and will cause
72  * the class to remain uncompiled. Other errors denote verification errors that cause bytecode
73  * to be rewritten to fail at runtime.
74  */
75 enum VerifyError {
76   VERIFY_ERROR_BAD_CLASS_HARD = 1,        // VerifyError; hard error that skips compilation.
77   VERIFY_ERROR_BAD_CLASS_SOFT = 2,        // VerifyError; soft error that verifies again at runtime.
78 
79   VERIFY_ERROR_NO_CLASS = 4,              // NoClassDefFoundError.
80   VERIFY_ERROR_NO_FIELD = 8,              // NoSuchFieldError.
81   VERIFY_ERROR_NO_METHOD = 16,            // NoSuchMethodError.
82   VERIFY_ERROR_ACCESS_CLASS = 32,         // IllegalAccessError.
83   VERIFY_ERROR_ACCESS_FIELD = 64,         // IllegalAccessError.
84   VERIFY_ERROR_ACCESS_METHOD = 128,       // IllegalAccessError.
85   VERIFY_ERROR_CLASS_CHANGE = 256,        // IncompatibleClassChangeError.
86   VERIFY_ERROR_INSTANTIATION = 512,       // InstantiationError.
87   // For opcodes that don't have complete verifier support,  we need a way to continue
88   // execution at runtime without attempting to re-verify (since we know it will fail no
89   // matter what). Instead, run as the interpreter in a special "do access checks" mode
90   // which will perform verifier-like checking on the fly.
91   VERIFY_ERROR_FORCE_INTERPRETER = 1024,  // Skip the verification phase at runtime;
92                                           // force the interpreter to do access checks.
93                                           // (sets a soft fail at compile time).
94   VERIFY_ERROR_LOCKING = 2048,            // Could not guarantee balanced locking. This should be
95                                           // punted to the interpreter with access checks.
96 };
97 std::ostream& operator<<(std::ostream& os, const VerifyError& rhs);
98 
99 }  // namespace verifier
100 }  // namespace art
101 
102 #endif  // ART_RUNTIME_VERIFIER_VERIFIER_ENUMS_H_
103