Exemplo n.º 1
0
  //	STEP 4: Is the merge operator union or intersection?
  //	UNION
  protected void merge(Object in1, Object in2, Object out) {
    MonitorSet inSet1 = (MonitorSet) in1;
    MonitorSet inSet2 = (MonitorSet) in2;
    MonitorSet outSet = (MonitorSet) out;

    inSet1.intersection(inSet2, outSet);
  }
Exemplo n.º 2
0
  protected Object newInitialFlow() {
    MonitorSet fullSet = new MonitorSet();
    fullSet.add("&");
    return fullSet;

    // return fullSet.clone();

  }
Exemplo n.º 3
0
 private void updateMonitor(MonitorSet ms, Object unit) {
   // System.out.println("===inside updateMonitor===");
   // ml.test();
   Iterator it = ms.iterator();
   while (it.hasNext()) {
     Object obj = it.next();
     if (obj instanceof MonitorDepth) {
       MonitorDepth md = (MonitorDepth) obj;
       String objName = md.getObjName();
       if (monitor.containsKey(objName)) {
         if (md.getDepth() > 0) {
           monitor.get(objName).add(unit);
           // System.out.println("add to monitorset "+unit);
         }
       } else {
         FlowSet monitorObjs = new ArraySparseSet();
         monitorObjs.add(unit);
         monitor.put(objName, monitorObjs);
         // System.out.println("put into monitor: "+objName);
       }
     }
   }
 }
Exemplo n.º 4
0
  /*
  private void testForDebug(){
  System.out.println("--------test for debug-------");
  int i = 0;
  for (i=0;i<nodes.size();i++){
  JPegStmt stmt = (JPegStmt)nodes.elementAt(i);
  //System.out.println("Tag: "+ ((Tag)stmt.getTags().get(0)).toString());
   if (((Tag)stmt.getTags().get(0)).toString().equals("8")){
   int pos = nodes.indexOf(stmt);
   if (((MonitorSet)valueAfter.elementAt(pos)).size() >0 &&
   !((MonitorSet)valueAfter.elementAt(pos)).contains("&")){
   System.out.println("sp"+stmt.getTags().get(0)+" "+nodes.elementAt(pos));

   ((MonitorSet)valueAfter.elementAt(pos)).test();
   }
   }
   }
   System.out.println("--------test for debug end------");
   }
   */
  protected void copy(Object source, Object dest) {
    MonitorSet sourceSet = (MonitorSet) source;
    MonitorSet destSet = (MonitorSet) dest;

    sourceSet.copy(destSet);
  }
Exemplo n.º 5
0
  //	STEP 5: Define flow equations.
  //	in(s) = ( out(s) minus defs(s) ) union uses(s)
  //
  protected void flowThrough(Object inValue, Object unit, Object outValue) {
    MonitorSet in = (MonitorSet) inValue;
    MonitorSet out = (MonitorSet) outValue;
    JPegStmt s = (JPegStmt) unit;
    Tag tag = (Tag) s.getTags().get(0);
    // System.out.println("s: "+tag+" "+s);
    // Copy in to out
    // if (in.contains("&")) in.remove("&");

    in.copy(out);
    //	System.out.println("-----in: ");
    // in.test();

    if (in.size() > 0) {

      if (!s.getName().equals("waiting") && !s.getName().equals("notified-entry"))
        updateMonitor(in, unit);
    }
    String objName = s.getObject();
    // if (objName == null) throw new RuntimeException("null object: "+s.getUnit());
    if (s.getName().equals("entry") || s.getName().equals("exit")) {
      if (out.contains("&")) out.remove("&");

      Object obj = out.getMonitorDepth(objName);

      if (obj == null) {

        if (s.getName().equals("entry")) {
          MonitorDepth md = new MonitorDepth(objName, 1);
          out.add(md);
          // System.out.println("add to out: "+md.getObjName()+" "+md.getDepth());
        }
        /*
        else{
        throw new RuntimeException("The monitor depth can not be decreased at  "+
        (Tag)((JPegStmt)s).getTags().get(0)+" "+unit);
        }
        */

      } else {
        // System.out.println("obj: "+obj);
        if (obj instanceof MonitorDepth) {
          MonitorDepth md = (MonitorDepth) obj;

          if (s.getName().equals("entry")) {
            md.increaseDepth();
            // System.out.println("===increase depth===");
          } else {

            if (md.getDepth() > 1) {
              // System.out.println("===decrease depth==");
              md.decreaseDepth();
            } else if (md.getDepth() == 1) {
              //  System.out.println("===remove monitordepth: "+md);

              out.remove(md);
            } else throw new RuntimeException("The monitor depth can not be decreased at  " + unit);
          }
        } else throw new RuntimeException("MonitorSet contains non MonitorDepth element!");
      }
    }

    // System.out.println("-----out: "+out);
    // out.test();
    // testForDebug();
  }