2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * Dalvik bytecode verification subroutines.
20 #ifndef DALVIK_VERIFYSUBS_H_
21 #define DALVIK_VERIFYSUBS_H_
24 * InsnFlags is a 32-bit integer with the following layout:
25 * 0-15 instruction length (or 0 if this address doesn't hold an opcode)
26 * 16-31 single bit flags:
27 * InTry: in "try" block; exceptions thrown here may be caught locally
28 * BranchTarget: other instructions can branch to this instruction
29 * GcPoint: this instruction is a GC safe point
30 * Visited: verifier has examined this instruction at least once
31 * Changed: set/cleared as bytecode verifier runs
35 #define kInsnFlagWidthMask 0x0000ffff
36 #define kInsnFlagInTry (1 << 16)
37 #define kInsnFlagBranchTarget (1 << 17)
38 #define kInsnFlagGcPoint (1 << 18)
39 #define kInsnFlagVisited (1 << 30)
40 #define kInsnFlagChanged (1 << 31)
42 /* add opcode widths to InsnFlags */
43 bool dvmComputeCodeWidths(const Method
* meth
, InsnFlags
* insnFlags
,
44 int* pNewInstanceCount
);
46 /* set the "in try" flag for sections of code wrapped with a "try" block */
47 bool dvmSetTryFlags(const Method
* meth
, InsnFlags
* insnFlags
);
49 /* verification failure reporting */
50 #define LOG_VFY(...) dvmLogVerifyFailure(NULL, __VA_ARGS__)
51 #define LOG_VFY_METH(_meth, ...) dvmLogVerifyFailure(_meth, __VA_ARGS__)
53 /* log verification failure with optional method info */
54 void dvmLogVerifyFailure(const Method
* meth
, const char* format
, ...)
56 __attribute__ ((format(printf
, 2, 3)))
60 /* log verification failure due to resolution trouble */
61 void dvmLogUnableToResolveClass(const char* missingClassDescr
,
64 /* extract the relative branch offset from a branch instruction */
65 bool dvmGetBranchOffset(const Method
* meth
, const InsnFlags
* insnFlags
,
66 int curOffset
, s4
* pOffset
, bool* pConditional
);
68 /* return a RegType enumeration value that "value" just fits into */
69 char dvmDetermineCat1Const(s4 value
);
72 bool dvmWantVerboseVerification(const Method
* meth
);
74 #endif // DALVIK_VERIFYSUBS_H_