1 /* 2 * Copyright (C) 2010 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 /* 18 * Basic block functions, as used by the verifier. (The names were chosen 19 * to avoid conflicts with similar structures used by the compiler.) 20 */ 21 #ifndef DALVIK_VFYBASICBLOCK_H_ 22 #define DALVIK_VFYBASICBLOCK_H_ 23 24 #include "PointerSet.h" 25 26 struct VerifierData; 27 28 29 /* 30 * Structure representing a basic block. 31 * 32 * This is used for liveness analysis, which is a reverse-flow algorithm, 33 * so we need to mantain a list of predecessors for each block. 34 * 35 * "liveRegs" indicates the set of registers that are live at the end of 36 * the basic block (after the last instruction has executed). Successor 37 * blocks will compare their results with this to see if this block needs 38 * to be re-evaluated. Note that this is not the same as the contents of 39 * the RegisterLine for the last instruction in the block (which reflects 40 * the state *before* the instruction has executed). 41 */ 42 struct VfyBasicBlock { 43 u4 firstAddr; /* address of first instruction */ 44 u4 lastAddr; /* address of last instruction */ 45 PointerSet* predecessors; /* set of basic blocks that can flow here */ 46 BitVector* liveRegs; /* liveness for each register */ 47 bool changed; /* input set has changed, must re-eval */ 48 bool visited; /* block has been visited at least once */ 49 }; 50 51 /* 52 * Generate a list of basic blocks. 53 */ 54 bool dvmComputeVfyBasicBlocks(struct VerifierData* vdata); 55 56 /* 57 * Free storage allocated by dvmComputeVfyBasicBlocks. 58 */ 59 void dvmFreeVfyBasicBlocks(struct VerifierData* vdata); 60 61 #endif // DALVIK_VFYBASICBLOCK_H_ 62