Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

LockAnalysis.java

00001 package edu.ksu.cis.bandera.pdgslicer;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998, 1999   Hongjun Zheng (zheng@cis.ksu.edu)      *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project in the SAnToS Laboratory,         *
00009  * Department of Computing and Information Sciences, Kansas State    *
00010  * University, USA (http://www.cis.ksu.edu/santos).                  *
00011  * It is understood that any modification not identified as such is  *
00012  * not covered by the preceding statement.                           *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this toolkit; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * Java is a trademark of Sun Microsystems, Inc.                     *
00030  *                                                                   *
00031  * To submit a bug report, send a comment, or get the latest news on *
00032  * this project and other SAnToS projects, please visit the web-site *
00033  *                http://www.cis.ksu.edu/santos                      *
00034  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00035 
00036 import ca.mcgill.sable.util.*;
00037 import ca.mcgill.sable.soot.*;
00038 import ca.mcgill.sable.soot.jimple.*;
00039 import edu.ksu.cis.bandera.pdgslicer.exceptions.*;
00040 import edu.ksu.cis.bandera.annotation.*;
00041 
00042 //import java.util.Hashtable;
00043 import java.util.Enumeration;
00044 import java.util.Vector;
00045 import java.util.BitSet;
00046 import java.util.Hashtable;
00047 /**
00048  * This class is for lock analysis: collecting and processing information
00049  * of locks in one method.
00050  */
00051 public class LockAnalysis {
00052     private StmtGraph stmtGraph;
00053     private StmtList stmtList;
00054     private BuildPDG pdgDom;
00055     private MethodInfo mdInfo;
00056   /**
00057    * A list of {@link MonitorPair MonitorPair}.
00058    */
00059     private List lockPairList;
00060 
00061     //SynchroStmt List
00062   /**
00063    * A list of {@link SynchroStmt SynchroStmt}.
00064    */
00065     private List waitStmtList;
00066   /**
00067    * A list of {@link SynchroStmt SynchroStmt}.
00068    */
00069     private List notifyStmtList;
00070   /**
00071    * @param methodInfo method need be analysed.
00072    * @param cfanns annotation manager.
00073    */
00074 public LockAnalysis(MethodInfo methodInfo, AnnotationManager cfanns) {
00075     mdInfo = methodInfo;
00076     stmtList = methodInfo.originalStmtList;
00077     stmtGraph = methodInfo.indexMaps.getStmtGraph();
00078     pdgDom = methodInfo.methodPDG;
00079     buildLockPairList(cfanns);
00080     collectWaitNotifyStmt();
00081     if (lockPairList.isEmpty() && waitStmtList.isEmpty() && notifyStmtList.isEmpty())
00082         pdgDom.setLockAnalysis(null);
00083     else
00084         pdgDom.setLockAnalysis(this);
00085 }
00086 //In current stage, we just consider the most simple condition of enter and
00087 //exit monitor : no embedding and no overlapping
00088   /**
00089    * Build lock pair list of current method into {@link #lockPairList lockPairList}.
00090    */
00091 private void buildLockPairList(AnnotationManager cfanns) {
00092     lockPairList = new ArrayList();
00093     SootMethod sm = mdInfo.sootMethod;
00094     SootClass sootClass = mdInfo.sootClass;
00095     Annotation annForSm = cfanns.getAnnotation(sootClass, sm);
00096     Vector synchAnnotations = getSynchAnnotation(stmtList, annForSm);
00097     for (Enumeration e = synchAnnotations.elements(); e.hasMoreElements();) {
00098         SynchronizedStmtAnnotation cfann = (SynchronizedStmtAnnotation) e.nextElement();
00099         SynchronizedStmtAnnotation synchCFANN = (SynchronizedStmtAnnotation) cfann;
00100         Stmt enterMonitorStmt = synchCFANN.getEnterMonitor();
00101         MonitorPair mp = new MonitorPair();
00102         mp.setSynchroBodyAnn(synchCFANN.getBlockAnnotation());
00103         mp.setCatchAnn(synchCFANN.getCatchAnnotation());
00104         Stmt synchroStmts[] = synchCFANN.getStatements();
00105         mp.setBeginSynchroStmt(synchroStmts[0]);
00106         mp.setEndSynchroStmt(synchroStmts[synchroStmts.length - 1]);
00107         mp.setEnterMonitor((EnterMonitorStmt) enterMonitorStmt);
00108         mp.setExitMonitors(synchCFANN.getExitMonitors().elements());
00109         mp.setLock(getActualLock(enterMonitorStmt));
00110         Annotation catchAnn = synchCFANN.getCatchAnnotation();
00111         Stmt catchStmts[] = catchAnn.getStatements();
00112         mp.setExitMonitorInException(catchStmts[1]);
00113         lockPairList.add(mp);
00114     }
00115 }
00116 //SynchroStmt list
00117   /**
00118    * Collect wait/notify statement in current method into
00119    * {@link #waitStmtList waitStmtList} and {@link #notifyStmtList notifyStmtList}.
00120    */
00121 private void collectWaitNotifyStmt() {
00122     waitStmtList = new ArrayList();
00123     notifyStmtList = new ArrayList();
00124     Iterator stmtIt = stmtList.iterator();
00125     while (stmtIt.hasNext()) {
00126         Stmt stmt = (Stmt) stmtIt.next();
00127         if (stmt instanceof InvokeStmt) {
00128             Value expr = ((InvokeStmt) stmt).getInvokeExpr();
00129             if (expr instanceof VirtualInvokeExpr) {
00130                 VirtualInvokeExpr vie = (VirtualInvokeExpr) expr;
00131                 if (vie.getMethod().getName().equals("wait") && (vie.getType() instanceof VoidType) && vie.getArgCount() == 0) {
00132                     SynchroStmt synStmt = new SynchroStmt(stmt, "wait");
00133                     //synStmt.setLock(getValueOfLocal(vie.getBase(), stmt, new StmtCls(), stmtGraph));
00134                     synStmt.setLock(vie.getBase());
00135                     waitStmtList.add(synStmt);
00136                 } else
00137                     if ((vie.getMethod().getName().equals("notify") || vie.getMethod().getName().equals("notifyAll")) && vie.getType() instanceof VoidType && vie.getArgCount() == 0) {
00138                         SynchroStmt synStmt = new SynchroStmt(stmt, vie.getMethod().getName());
00139                         //synStmt.setLock(getValueOfLocal(vie.getBase(), stmt, new StmtCls(), stmtGraph));
00140                         synStmt.setLock(vie.getBase());
00141                         notifyStmtList.add(synStmt);
00142                     }
00143             }
00144         }
00145     }
00146 }
00147   /**
00148    * Get all monitor pairs on which given statement is
00149    * synchronization dependent.
00150    * <br> (1) Get a list of monitor pairs by {@link #dependOnMonitors(Stmt) 
00151    * dependOnMonitors()};
00152    * <br> (2) Build a table from {@link EnterMonitorStmt EnterMonitorStmt}
00153    * to corresponding {@link MonitorPair MonitorPair}.
00154    * <p>
00155    * @param stmt query statement.
00156    * @return a table from {@link EnterMonitorStmt EnterMonitorStmt}
00157    * to corresponding {@link MonitorPair MonitorPair}, on which given 
00158    * <code>stmt</code> is
00159    * synchronization dependent.
00160    */
00161 public Hashtable dependOnMonitorPairs(Stmt stmt)
00162 {
00163     List monitorPairList = dependOnMonitors(stmt);
00164     Hashtable monitorPairs = new Hashtable();
00165     for (Iterator listIt = monitorPairList.iterator(); listIt.hasNext();) {
00166         MonitorPair monitorPair = (MonitorPair) listIt.next();
00167         Stmt monitorStmt = (Stmt) monitorPair.getEnterMonitor();
00168         /*
00169         Set exitMonitorSet = exitMonitorsIn(monitorPair);
00170         monitorPairs.put(monitorStmt, exitMonitorSet);
00171         */
00172         monitorPairs.put(monitorStmt, monitorPair);
00173     }
00174     return monitorPairs;
00175 }
00176   /** 
00177    * See if one statement is synchronization dependent on any monitor pair.
00178    * <br> One statement is synchronization dependent on a monitor pair if the 
00179    * statement is in the monitor section. For example,
00180    * <br> (1) entermonitor lock 
00181    * <br> ... ...
00182    * <br> (i) astatement;
00183    * <br> ... ...
00184    * <br> (n) exitmonitor lock
00185    * <br> Then <code>astatement</code> is synchronization dependent on the 
00186    * monitor pair (1) and (n).
00187    * <p>
00188    * @param stmt query statement.
00189    * @return a list of {@link MonitorPair MonitorPair}.
00190    */
00191 public List dependOnMonitors(Stmt stmt) {
00192     List monitorPairList = new ArrayList();
00193     Iterator lockPairIt = lockPairList.iterator();
00194     while (lockPairIt.hasNext()) {
00195         MonitorPair lockPair = (MonitorPair) lockPairIt.next();
00196         BitSet codeBetweenMonitor = stmtsBetween(lockPair);
00197         if (codeBetweenMonitor.get(stmtList.indexOf(stmt)))
00198             monitorPairList.add(lockPair);
00199     }
00200     return monitorPairList;
00201 }
00202   /**
00203    * Get all enter/exit monitor statements on which the given statement
00204    * is synchronization dependent.
00205    * <p>
00206    * @param stmt query statement.
00207    * @return a list of enter/exit monitor statements indexed in a BitSet.
00208    */
00209 public BitSet dependOnMonitorSet(Stmt stmt)
00210 //Index set
00211 {
00212     List monitorPairList = dependOnMonitors(stmt);
00213     Set monitorSet = new ArraySet();
00214     for (Iterator listIt = monitorPairList.iterator(); listIt.hasNext();) {
00215         MonitorPair monitorPair = (MonitorPair) listIt.next();
00216         Stmt monitorStmt = (Stmt) monitorPair.getEnterMonitor();
00217         monitorSet.add(monitorStmt);
00218         Set exitMonitorSet = exitMonitorsIn(monitorPair);
00219         monitorSet.addAll(exitMonitorSet);
00220     }
00221     return SetUtil.stmtSetToBitSet(monitorSet,stmtList);
00222 }
00223 /**
00224  * Get all exit monitor statements in a {@link MonitorPair MonitorPair}.
00225  * <p>
00226  * @param mp query monitor pair.
00227  * @return a set of {@link Stmt Stmt}.
00228  */
00229 public Set exitMonitorsIn(MonitorPair mp) {
00230     Set exitMonitorIndexSet = new ArraySet();
00231     for (Iterator exitIt = mp.getExitMonitors().iterator(); exitIt.hasNext();) {
00232         Stmt exitMonitor = (Stmt) exitIt.next();
00233         if (exitMonitor != null)
00234             //this conditional should be removed
00235             //after correction of jjjc annotations
00236 
00237             exitMonitorIndexSet.add(exitMonitor);
00238     }
00239     Stmt exitMonitorInException = mp.getExitMonitorInException();
00240     Stmt endSynchroStmt = mp.getEndSynchroStmt();
00241     int exitMonitorInExceptionIndex = stmtList.indexOf(exitMonitorInException);
00242     int endSynchroStmtIndex = stmtList.indexOf(endSynchroStmt);
00243     for (int i = exitMonitorInExceptionIndex; i < endSynchroStmtIndex; i++)
00244         exitMonitorIndexSet.add((Stmt) stmtList.get(i));
00245     return exitMonitorIndexSet;
00246 }
00247 /**
00248  * Get the lock to which a given monitor statement is associated.
00249  * <p>
00250  * @param monitorStmt enter/exit monitor statement.
00251  * @return the value of the lock to which <code>monitorStmt</code> is 
00252  * associated.
00253  * @throws MonitorStmtInstanceException if <code>monitorStmt</code> is not 
00254  * enter/exit monitor statement.
00255  */
00256 
00257 public Value getActualLock(Stmt monitorStmt) {
00258     if (!(monitorStmt instanceof EnterMonitorStmt) && !(monitorStmt instanceof ExitMonitorStmt))
00259         throw new MonitorStmtInstanceException("The statement monitorStmt should be an EnterMonitor or ExitMonitor Stmt in getActualLock of LockAnalysis");
00260     Value lock;
00261     if (monitorStmt instanceof EnterMonitorStmt)
00262         lock = ((EnterMonitorStmt) monitorStmt).getOp();
00263     else
00264         // monitorStmt instanceof ExitMonitorStmt
00265         lock = ((ExitMonitorStmt) monitorStmt).getOp();
00266     //return getValueOfLocal(lock, monitorStmt, new StmtCls(), stmtGraph);
00267     return lock;
00268 }
00269 /**
00270  * Get the lock pair list.
00271  * <p>
00272  * @return {@link #lockPairList lockPairList}.
00273  */
00274   public List getLockPairList()
00275     {
00276       return lockPairList;
00277     }
00278 /**
00279  * Get monitor pair from an enter/exit monitor statement.
00280  * <p>
00281  * @param monitor an enter/exit monitor statement.
00282  * @return a monitor pair such that one of the pair is the given
00283  * <code>monitor</code>.
00284  * @throws StatementTypeException if the given <code>monitor</code> 
00285  * is not an enter/exit monitor statement.
00286  */
00287 public MonitorPair getMonitorPair(Stmt monitor) {
00288     if (monitor instanceof EnterMonitorStmt)
00289         return getMonitorPairFromEnter(monitor);
00290     else
00291         if (monitor instanceof ExitMonitorStmt)
00292             return getMonitorPairFromExit(monitor);
00293         else
00294             throw new StatementTypeException("The statement should be entermonitor or exitmonitor statement : " + monitor + " in LockAnalysis");
00295 }
00296 /**
00297  * Get monitor pair from an enter monitor statement.
00298  * <p>
00299  * @param enterMonitor query enter monitor statement.
00300  * @return a monitor pair such that one of the pair is the given
00301  * <code>enterMonitor</code>.
00302  * @throws CorrespondingMonitorNotFoundException if such monitor pair can
00303  * not be found.
00304  */
00305 private MonitorPair getMonitorPairFromEnter(Stmt enterMonitor) {
00306     for (Iterator lockPairIt = lockPairList.iterator(); lockPairIt.hasNext();) {
00307         MonitorPair lockPair = (MonitorPair) lockPairIt.next();
00308         Stmt lockStmt = (Stmt) lockPair.getEnterMonitor();
00309         if (enterMonitor.equals(lockStmt))
00310             return lockPair;
00311     }
00312     throw new CorrespondingMonitorNotFoundException("Can't find the corresponding monitor pair according to the statement (index) : " + enterMonitor + " in LockAnalysis");
00313 }
00314 /**
00315  * Get monitor pair from an exit monitor statement.
00316  * <p>
00317  * @param exitMonitor query exit monitor statement.
00318  * @return a monitor pair such that one of the pair is the given
00319  * <code>exitrMonitor</code>.
00320  * @throws CorrespondingMonitorNotFoundException if such monitor pair can
00321  * not be found.
00322  */
00323 private MonitorPair getMonitorPairFromExit(Stmt exitMonitor) {
00324     for (Iterator lockPairIt = lockPairList.iterator(); lockPairIt.hasNext();) {
00325         MonitorPair lockPair = (MonitorPair) lockPairIt.next();
00326         Set exitMonitorsInLockPair = exitMonitorsIn(lockPair);
00327         if (exitMonitorsInLockPair.contains(exitMonitor))
00328             return lockPair;
00329     }
00330     throw new CorrespondingMonitorNotFoundException("Can't find the corresponding monitor pair according to the statement (index) : " + exitMonitor + " in LockAnalysis");
00331 }
00332 /**
00333  * Get notity statement list.
00334  * <p>
00335  * @return {@link #notifyStmtList notifyStmtList}.
00336  */
00337   public List getNotifyStmtList()
00338     {
00339       return notifyStmtList;
00340     }
00341 /**
00342  * Get all annotations of synchronization (enter/exit monitor) statement
00343  * in the given statement list.
00344  * <p>
00345  * @param stmtList statement list from which synchronization statements are to be selected.
00346  * @param annotation annotation of current method.
00347  * @return a vector of {@link Annotation Annotation} of all synchroniztion statements
00348  * in the given <code>stmtList</code>.
00349  */
00350 private Vector getSynchAnnotation(StmtList stmtList, Annotation annotation) {
00351     Vector v = new Vector();
00352     for (Iterator i = stmtList.iterator(); i.hasNext();) {
00353         Stmt stmt = (Stmt) i.next();
00354         if (stmt instanceof JEnterMonitorStmt) {
00355             Annotation a = null;
00356             try {
00357                 a = annotation.getContainingAnnotation(stmt);
00358             } catch (Exception e) {
00359             }
00360             if (a == null) {
00361                 System.out.println("HEYYYY! The annotation for method " + mdInfo.sootClass.getName() + "." + mdInfo.sootMethod.getName() + " is null because current version of jjjc make the <init> method without annotation. This will be modified later.");
00362             } else {
00363                 v.addElement(a);
00364             }
00365         }
00366     }
00367     return v;
00368 }
00369 /**
00370  * Get wait statement list.
00371  * <p>
00372  * @return {@link #waitStmtList waitStmtList}.
00373  */
00374   public List getWaitStmtList()
00375     {
00376       return waitStmtList;
00377     }
00378 /**
00379  * Get lock value for every element in {@link #lockPairList lockPairList}.
00380  * <p>
00381  * @return a set of lock {@link Value Value}.
00382  */
00383 private Set lockValueSet() {
00384     Set lockSet = new ArraySet();
00385     for (int i = 0; i < this.lockPairList.size(); i++) {
00386         MonitorPair mp = (MonitorPair) this.lockPairList.get(i);
00387         Value lockValue = mp.getLock();
00388         lockSet.add(lockValue);
00389     }
00390     return lockSet;
00391 }
00392 //this method is to compute the reachable statements from entermonitor
00393 //statement or wait statement
00394 //statement Index list
00395 /**
00396  * Get all (control flow) reachable statements from a given statement.
00397  * <p>
00398  * @param stmt query statement.
00399  * @return a list of statement indexed in a BitSet.
00400  */
00401 public BitSet reachableStmtFrom(Stmt stmt) {
00402     BitSet reachableStmt = new BitSet(stmtList.size());
00403     //reachableStmt.set(stmtList.indexOf(stmt));
00404     LinkedList stack = new LinkedList();
00405     stack.addFirst(stmt);
00406     while (!stack.isEmpty()) {
00407         Stmt currentStmt = (Stmt) stack.removeFirst();
00408         List succsList = stmtGraph.getSuccsOf(currentStmt);
00409         for (Iterator succsIt = succsList.iterator(); succsIt.hasNext();) {
00410             Stmt succ = (Stmt) succsIt.next();
00411             int succIndex = stmtList.indexOf(succ);
00412             if (!reachableStmt.get(succIndex)) {
00413                 reachableStmt.set(succIndex);
00414                 stack.addLast(succ);
00415             }
00416         }
00417     }
00418     return reachableStmt;
00419 }
00420 /**
00421  * Get all enter monitor statements on which a given statement
00422  * is ready dependent. If the given statement is reachable from
00423  * an entermonitor statement, then we say the given statement
00424  * is ready dependent on the entermonitor statement.
00425  * <p>
00426  * @param stmt query statement.
00427  * @return a set of enter monitor statements.
00428  */
00429 public Set readyDependOnEnters(Stmt stmt) {
00430     Set enterSet = new ArraySet();
00431     for (Iterator lockPairIt = lockPairList.iterator(); lockPairIt.hasNext();) {
00432         MonitorPair monitorPair = (MonitorPair) lockPairIt.next();
00433         Stmt monitorStmt = (Stmt) monitorPair.getEnterMonitor();
00434         BitSet reachableStmt = reachableStmtFrom(monitorStmt);
00435         if (reachableStmt.get(stmtList.indexOf(stmt))) {
00436             if (!safeLock(monitorPair))
00437                 //important
00438                 enterSet.add(monitorStmt);
00439         }
00440     }
00441     return enterSet;
00442 }
00443 /**
00444  * Get all <code>wait</code> statements on which a given statement
00445  * is ready dependent. If the given statement is reachable from
00446  * a <code>wait</code> statement, then we say the given statement
00447  * is ready dependent on the <code>wait</code> statement.
00448  * <p>
00449  * @param stmt query statement.
00450  * @return a set of <code>wait</code> statements indexed in a BitSet.
00451  */
00452 public BitSet readyDependOnWaits(Stmt stmt) {
00453     Set waitSet = new ArraySet();
00454     for (Iterator waitStmtIt = waitStmtList.iterator(); waitStmtIt.hasNext();) {
00455         SynchroStmt synStmt = (SynchroStmt) waitStmtIt.next();
00456         Stmt waitStmt = synStmt.getWaitNotify();
00457         if (stmt.equals(waitStmt)) continue;
00458         BitSet reachableStmt = reachableStmtFrom(waitStmt);
00459         if (reachableStmt.get(stmtList.indexOf(stmt)))
00460             waitSet.add(waitStmt);
00461     }
00462     return SetUtil.stmtSetToBitSet(waitSet,stmtList);
00463 }
00464 /**
00465  * See if an enter/exit monitor statement is with a safe lock.
00466  * <br> This method is currently empty, need to be filled with programs.
00467  * <p>
00468  * @param monitor enter/exit monitor statement
00469  * @return boolean.
00470  */
00471   public boolean safeLock(Stmt monitor)
00472     {
00473       MonitorPair monitorPair = getMonitorPair(monitor);
00474 
00475       return safeLock(monitorPair);
00476     }
00477   //the first method (safeLock) should be recoded further
00478 /**
00479  * See if a monitor pair is with a safe lock.
00480  * <br> This method is currently empty, need to be filled with programs.
00481  * <p>
00482  * @param monitorPair monitor pair
00483  * @return boolean.
00484  */
00485   public boolean safeLock(MonitorPair monitorPair)
00486     {
00487       // no wait-free indefinite loop
00488       /*check each back edge and natural loop in the monitor pair to determine
00489     if the loop is indefinite loop:
00490        if backEdge.from is IF statement, then the loop is not indefinite
00491        if backEdge.from is goto, the loop is possibly indefinite
00492           if all successors of statements in the loop are in natural loop
00493           then the loop will be indefinite, otherwise not
00494     check if there is a wait in the indefinte loop
00495       */
00496        
00497       // no wait commands for other locks
00498       /* check all wait statement between the monitor pair, to see if it is waiting on the same lock with current monitor pair
00499        */
00500 
00501       // no entermonitor or exitmonitor on unsafe locks
00502 
00503       return true;
00504     }
00505 //determine the code between each monitor statement pair which are
00506 //synchronization dependent on both enter and exit monitor statement
00507 //it's the same as natural loop algorithm
00508 //Index list
00509 /**
00510  * Get all statements between a monitor pair.
00511  * <p>
00512  * @param monitorPair monitor pair.
00513  * @return a set of statements between the monitor pair indexed in a BitSet.
00514  */
00515 private BitSet stmtsBetween(MonitorPair monitorPair) {
00516     BitSet stmtsBetweenMonitor = new BitSet(stmtList.size());
00517     Stmt monitorStmt = (Stmt) monitorPair.getEnterMonitor();
00518     int enterIndex = stmtList.indexOf(monitorStmt);
00519     monitorStmt = monitorPair.getEndSynchroStmt();
00520     int endIndex = stmtList.indexOf(monitorStmt);
00521     List exitMonitors = monitorPair.getExitMonitors();
00522     for (int i = enterIndex + 1; i <= endIndex; i++)
00523         if (!exitMonitors.contains(stmtList.get(i)))
00524             stmtsBetweenMonitor.set(i);
00525     return stmtsBetweenMonitor;
00526 }
00527 /**
00528  * See if a given statement is synchronization dependent on an enter/exit monitor
00529  * statement.
00530  * <br> Algorithm: check if the given statement is in between the monitor pair.
00531  * <p>
00532  * @param stmt query statement.
00533  * @param monitor enter/exit monitor statement.
00534  * @return boolean.
00535  */ 
00536 public boolean stmtSynchroDependOn(Stmt stmt, Stmt monitor)
00537 //exit or enter;
00538 {
00539     if (monitor instanceof EnterMonitorStmt || monitor instanceof ExitMonitorStmt) {
00540         //check out the corresponding monitor pair from the pair list
00541         MonitorPair monitorPair = getMonitorPair(monitor);
00542         return stmtSynchroDependOn(stmt, monitorPair);
00543     } else
00544         throw new StatementTypeException("The statement should be entermonitor or exitmonitor statement : " + monitor + " in LockAnalysis");
00545 }
00546 /**
00547  * See if a given statement is synchronization dependent on a monitor pair.
00548  * <br> Algorithm: check if the given statement is in between the monitor pair.
00549  * <p>
00550  * @param stmt query statement.
00551  * @param monitorPair monitor pair.
00552  * @return boolean.
00553  */ 
00554 public boolean stmtSynchroDependOn(Stmt stmt, MonitorPair monitorPair)
00555 //check if stmt is belonged to the codes between monitorPair
00556 {
00557     int stmtIndex = stmtList.indexOf(stmt);
00558     BitSet codeBetweenMonitor = stmtsBetween(monitorPair);
00559     if (codeBetweenMonitor.get(stmtIndex))
00560         return true;
00561     return false;
00562 }
00563 }

Generated at Thu Feb 7 06:49:56 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001