Home | History | Annotate | Download | only in 086-ssa-edge-split
      1 /*
      2  * Copyright (C) 2007 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 public class Blort
     18 {
     19     /**
     20      * This method requires the edge-splitter to add a node
     21      * to get to the finally block, since there are
     22      * two exception sources.
     23      *
     24      */
     25     public int edgeSplitPredTest(int x) {
     26         int y = 1;
     27 
     28         try {
     29             Integer.toString(x);
     30             Integer.toString(x);
     31             y++;
     32         } finally {
     33             return y;
     34         }
     35     }
     36 
     37     /**
     38      * just because this should do nothing
     39      */
     40     void voidFunction() {
     41     }
     42 
     43     /**
     44      * Current SSA form requires each move-exception block to have
     45      * a unique predecessor
     46      */
     47     void edgeSplitMoveException() {
     48         try {
     49             hashCode();
     50             hashCode();
     51         } catch (Throwable tr) {
     52         }
     53     }
     54 
     55     /**
     56      * Presently, any basic block ending in an instruction with
     57      * a result needs to have a unique successor. This appies
     58      * only to the block between the switch instruction and the return
     59      * in this case.
     60      */
     61     int edgeSplitSuccessor(int x) {
     62         int y = 0;
     63 
     64         switch(x) {
     65             case 1: y++;
     66             break;
     67             case 2: y++;
     68             break;
     69             case 3: y++;
     70             break;
     71         }
     72         return y;
     73     }
     74 }
     75