Fix volatile in mgc version. Volatile variable should not be allocated in the shared...
authorjzhou <jzhou>
Wed, 3 Nov 2010 23:31:35 +0000 (23:31 +0000)
committerjzhou <jzhou>
Wed, 3 Nov 2010 23:31:35 +0000 (23:31 +0000)
Robust/src/IR/ClassDescriptor.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Tests/VolatileTest.java

index 98bb261ce656b976da67897e317c08d9a4809bd0..3ca241e0a12725125769da72288bee1a6d9273b0 100644 (file)
@@ -199,7 +199,7 @@ public class ClassDescriptor extends Descriptor {
       throw new Error(fd.getSymbol()+" already defined");
     fields.add(fd);
     fieldvec.add(fd);
-    if((fd.isStatic()) || (fd.isVolatile())) {
+    if(fd.isStatic()) {
       this.incStaticFields();
     }
   }
index ff48bb571564077d13a8fc9e1fd387241be24a03..bb0679cc555e743d0859d2d3c7cbb821b4067852 100644 (file)
@@ -2180,8 +2180,8 @@ public class BuildCode {
 
       for(int i=0; i<fields.size(); i++) {
         FieldDescriptor fd=(FieldDescriptor)fields.get(i);
-        if((fd.isStatic()) || (fd.isVolatile())) {
-          // static/volatile field
+        if(fd.isStatic()) {
+          // static field
           output.println(generateTemp(fm,fm.getParameter(0),lb)+"->"+fd.getSafeSymbol()+"=&(global_defs_p->"+cn.getSafeSymbol()+fd.getSafeSymbol()+");");
         }
       }
@@ -5086,7 +5086,7 @@ public class BuildCode {
 // DEBUG       } 
       if(state.MGC) {
         // TODO add version for normal Java later
-      if((ffn.getField().isStatic()) || (ffn.getField().isVolatile())) {
+      if(ffn.getField().isStatic()) {
         // static field
         if((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic())) {
           // is a static block or is invoked in some static block
@@ -5232,7 +5232,7 @@ public class BuildCode {
 // DEBUG   } 
       if(state.MGC) {
         // TODO add version for normal Java later
-      if((fsfn.getField().isStatic()) || (fsfn.getField().isVolatile())) {
+      if(fsfn.getField().isStatic()) {
         // static field
         if((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic())) {
           // is a static block or is invoked in some static block
index 4eb0c7b43dbc0f5adf9511a83c81aa8dfbbf3413..2ec8a703efcbce4fa051705ffa91a79c0e0b36a7 100644 (file)
@@ -1,31 +1,38 @@
-public class VolatileTest  extends Thread {
-  volatile int num;   
-  String name;
+public class VInt {
+  public int num;
   
-  {
-    num = 0;
+  public VInt() {
+    this.num = 0;
   }
+}
+
+public class VolatileTest  extends Thread {
+  volatile VInt vi;   
+  String name;
   
-  public VolatileTest(String name) {
+  public VolatileTest(String name, VInt vi) {
     this.name = name;
+    this.vi = vi;
   }
 
   public void run(){
     if(name.equals("Thread1")){  
-      num=10;  
+      vi.num=10;  
     }  
     else{  
-      System.out.println("value of num is :"+num);  
+      System.out.println("value of num is :"+vi.num);  
     }     
   }  
 
   public static void main(String args[]){  
-    Thread t1 = new VolatileTest("Thread1");   
+    VInt vi = new VInt();
+    
+    Thread t1 = new VolatileTest("Thread1", vi);   
     t1.start();  
 
     Thread.sleep(1000);  
 
-    Thread t2 = new VolatileTest("Thread2");   
+    Thread t2 = new VolatileTest("Thread2", vi);   
     t2.start();  
   }  
 }  
\ No newline at end of file