more changes toward compiler DSM support
[IRC.git] / Robust / src / IR / Flat / BuildFlat.java
index be735ffa9bed702a094d7838daab5596e928fdcb..a651fb1b58dc65ca53229f9e21aadaffa149c809 100644 (file)
@@ -102,11 +102,18 @@ public class BuildFlat {
        }
     }
 
+    FlatAtomicEnterNode curran=null;
+
     private void flattenClass(ClassDescriptor cn) {
        Iterator methodit=cn.getMethods();
        while(methodit.hasNext()) {
            currmd=(MethodDescriptor)methodit.next();
            BlockNode bn=state.getMethodBody(currmd);
+
+           if (state.DSM&&currmd.getModifiers().isAtomic()) {
+               curran=new FlatAtomicEnterNode();
+           } else
+               curran=null;
            NodePair np=flattenBlockNode(bn);
            FlatNode fn=np.getBegin();
            if (state.THREAD&&currmd.getModifiers().isSynchronized()) {
@@ -123,11 +130,10 @@ public class BuildFlat {
                    fcunlock.addNext(rnflat);
                }
            } else if (state.DSM&&currmd.getModifiers().isAtomic()) {
-               FlatAtomicEnterNode an=new FlatAtomicEnterNode();
-               an.addNext(fn);
-               fn=an;
+               curran.addNext(fn);
+               fn=curran;
                if (np.getEnd().kind()!=FKind.FlatReturnNode) {
-                   FlatAtomicExitNode aen=new FlatAtomicExitNode();
+                   FlatAtomicExitNode aen=new FlatAtomicExitNode(curran);
                    np.getEnd().addNext(aen);
                    FlatReturnNode rnflat=new FlatReturnNode(null);
                    aen.addNext(rnflat);
@@ -858,9 +864,14 @@ public class BuildFlat {
            MethodDescriptor memd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
            TempDescriptor thistd=getTempforVar(currmd.getThis());
            FlatCall fc=new FlatCall(memd, null, thistd, new TempDescriptor[0]);
-           fc.addNext(rnflat);
+           fc.addNext(ln);
            ln=fc;
        }
+       if (state.DSM&&currmd.getModifiers().isAtomic()) {
+           FlatAtomicExitNode faen=new FlatAtomicExitNode(curran);
+           faen.addNext(ln);
+           ln=faen;
+       }
 
        if (cond!=null) {
            cond.getEnd().addNext(ln);
@@ -913,7 +924,7 @@ public class BuildFlat {
     private NodePair flattenAtomicNode(AtomicNode sbn) {
        NodePair np=flattenBlockNode(sbn.getBlockNode());
        FlatAtomicEnterNode faen=new FlatAtomicEnterNode();
-       FlatAtomicExitNode faexn=new FlatAtomicExitNode();
+       FlatAtomicExitNode faexn=new FlatAtomicExitNode(faen);
        faen.addNext(np.getBegin());
        np.getEnd().addNext(faexn);
        return new NodePair(faen, faexn);