1 salcianu 1.1.2.1 // ParIntGraphPair.java, created Mon Mar 27 20:11:14 2000 by salcianu 2 cananian 1.1.2.4 // Copyright (C) 2000 Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu> 3 salcianu 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 salcianu 1.1.2.1 package harpoon.Analysis.PointerAnalysis; 5 salcianu 1.1.2.1 6 salcianu 1.1.2.1 /** 7 salcianu 1.1.2.1 * <code>ParIntGraphPair</code> is a simple pair of two 8 salcianu 1.1.2.1 <code>ParIntGraph</code>s. 9 salcianu 1.1.2.1 10 salcianu 1.1.2.1 The existence of this structure is motivated by some details 11 salcianu 1.1.2.1 of the FLEX intermediate representation. 12 salcianu 1.1.2.1 13 salcianu 1.1.2.1 In the original algorithm, a single parallel interaction graph 14 salcianu 1.1.2.1 at the end of each BB was enough. However, as in FLEX CALL is 15 salcianu 1.1.2.1 an implicit if, with a branch for normal execution and another 16 salcianu 1.1.2.1 one for exceptions, there could be two ways of finishing a BB, 17 salcianu 1.1.2.1 and hence, we need to maintain two graphs. 18 salcianu 1.1.2.1 19 salcianu 1.1.2.1 * 20 cananian 1.1.2.4 * @author Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu> 21 salcianu 1.3 * @version $Id: ParIntGraphPair.java,v 1.3 2003/06/04 18:44:32 salcianu Exp $ 22 salcianu 1.1.2.1 */ 23 salcianu 1.1.2.3 class ParIntGraphPair implements java.io.Serializable { 24 salcianu 1.1.2.1 25 salcianu 1.1.2.1 // Normally, pig0 is enough; if the BB is terminated with a CALL 26 salcianu 1.1.2.1 // pig0 is the graph for normal return from the call, and 27 salcianu 1.1.2.1 // pig1 is the graph in case an exception is returned 28 salcianu 1.1.2.1 ParIntGraph pig[] = new ParIntGraph[2]; 29 salcianu 1.1.2.1 30 salcianu 1.1.2.1 /** Creates a <code>ParIntGraphPair</code>. */ 31 salcianu 1.1.2.1 ParIntGraphPair(ParIntGraph _pig0, ParIntGraph _pig1) { 32 salcianu 1.1.2.1 this.pig[0] = _pig0; 33 salcianu 1.1.2.1 this.pig[1] = _pig1; 34 salcianu 1.1.2.1 } 35 salcianu 1.1.2.1 36 salcianu 1.1.2.1 /** Checks whether two pairs are equal or not. */ 37 salcianu 1.3 static boolean identical(ParIntGraphPair pp1, ParIntGraphPair pp2) { 38 salcianu 1.1.2.1 if((pp1 == null) || (pp2 == null)) 39 salcianu 1.1.2.1 return pp1 == pp2; 40 salcianu 1.1.2.1 return 41 salcianu 1.1.2.1 ParIntGraph.identical(pp1.pig[0], pp2.pig[0]) && 42 salcianu 1.1.2.1 ParIntGraph.identical(pp1.pig[1], pp2.pig[1]); 43 salcianu 1.1.2.1 } 44 salcianu 1.1.2.1 45 salcianu 1.1.2.1 /** Join another pair of <code>ParIntGraph</code>s to this one. 46 salcianu 1.1.2.1 The operation is done pairwise. This method is called only by 47 salcianu 1.1.2.1 the <code>InterProcPA</code> module. */ 48 salcianu 1.1.2.1 void join(ParIntGraphPair pp2){ 49 salcianu 1.1.2.2 if(pp2 == null) return; 50 salcianu 1.1.2.2 partial_join(0, pp2.pig[0]); 51 salcianu 1.1.2.2 partial_join(1, pp2.pig[1]); 52 salcianu 1.1.2.2 } 53 salcianu 1.1.2.2 54 salcianu 1.1.2.2 private void partial_join(int k, ParIntGraph pig2) { 55 salcianu 1.1.2.2 if(pig2 == null) 56 salcianu 1.1.2.2 return; 57 salcianu 1.1.2.2 58 salcianu 1.1.2.2 if(pig[k] == null) 59 salcianu 1.1.2.2 pig[k] = (ParIntGraph) pig2.clone(); 60 salcianu 1.1.2.2 61 salcianu 1.1.2.2 pig[k].join(pig2); 62 salcianu 1.1.2.1 } 63 salcianu 1.1.2.1 64 salcianu 1.1.2.1 } 65 cananian 1.2