an example of an evil task
authorjjenista <jjenista>
Fri, 8 Apr 2011 22:37:08 +0000 (22:37 +0000)
committerjjenista <jjenista>
Fri, 8 Apr 2011 22:37:08 +0000 (22:37 +0000)
Robust/src/Tests/dfj/evil-task/makefile [new file with mode: 0644]
Robust/src/Tests/dfj/evil-task/test.java [new file with mode: 0644]

diff --git a/Robust/src/Tests/dfj/evil-task/makefile b/Robust/src/Tests/dfj/evil-task/makefile
new file mode 100644 (file)
index 0000000..6c36b3b
--- /dev/null
@@ -0,0 +1,59 @@
+PROGRAM=Test
+
+SOURCE_FILES=test.java
+
+BUILDSCRIPT=../../../buildscript
+
+COREPROFOVERFLOW= #-coreprof-checkoverflow
+USECOREPROF= #-coreprof $(COREPROFOVERFLOW) \
+       -coreprof-eventwords 1024*1024*128 \
+       -coreprof-enable cpe_main \
+       -coreprof-enable cpe_runmalloc \
+       -coreprof-enable cpe_runfree \
+       -coreprof-enable cpe_count_poolalloc \
+       -coreprof-enable cpe_count_poolreuse \
+       -coreprof-enable cpe_workschedgrab \
+       -coreprof-enable cpe_taskdispatch \
+       -coreprof-enable cpe_taskexecute \
+       -coreprof-enable cpe_taskretire
+#      -coreprof-enable cpe_taskstallvar \
+#      -coreprof-enable cpe_taskstallmem
+
+
+DISJOINT= -disjoint -disjoint-k 1 -enable-assertions #-disjoint-desire-determinism
+
+USEOOO= -ooojava  8 2               -ooodebug -squeue
+USERCR= -ooojava  7 2 -rcr -pointer -ooodebug -squeue 
+
+BSFLAGS= -64bit -mainclass $(PROGRAM) -heapsize-mb 1024 -garbagestats -noloop -joptimize -debug #-ooodebug-disable-task-mem-pool -justanalyze
+
+
+all: ooo
+
+
+single:
+       $(BUILDSCRIPT) $(BSFLAGS) -thread -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) 
+
+
+ooo: $(PROGRAM)p.bin
+
+$(PROGRAM)p.bin: $(SOURCE_FILES) makefile
+       $(BUILDSCRIPT) $(BSFLAGS) $(USECOREPROF) $(USEOOO) $(DISJOINT) -o $(PROGRAM)p -builddir par  $(SOURCE_FILES) 
+
+rcr: $(PROGRAM)r.bin
+
+$(PROGRAM)r.bin: $(SOURCE_FILES) makefile
+       $(BUILDSCRIPT) $(BSFLAGS) $(USECOREPROF) $(USERCR) $(DISJOINT) -o $(PROGRAM)r -builddir rcr  $(SOURCE_FILES) 
+
+
+clean:
+       rm -f  $(PROGRAM)p.bin $(PROGRAM)r.bin $(PROGRAM)s.bin
+       rm -fr par rcr sing
+       rm -f  *~
+       rm -f  *.dot
+       rm -f  *.png
+       rm -f  *.txt
+       rm -f  aliases.txt
+       rm -f  mlpReport*txt
+       rm -f  results*txt
+       rm -f  coreprof.dat
diff --git a/Robust/src/Tests/dfj/evil-task/test.java b/Robust/src/Tests/dfj/evil-task/test.java
new file mode 100644 (file)
index 0000000..5d073a4
--- /dev/null
@@ -0,0 +1,80 @@
+
+public class Foo {
+  public int z;
+  public Foo x;
+
+  public Foo() {
+    z = 0;
+    x = null;
+  }
+}
+
+public class Test {
+
+  static public void main( String args[] ) {
+    innerMain( Integer.parseInt( args[0] ) );
+  }
+
+  static public void innerMain( int n ) {
+
+    int total = 0;
+
+    // attach a big chain of things that we'll
+    // never use in the actual computation, but
+    // write code in such a way that traverser
+    // must conservatively walk the whole chain,
+    // because we want the traversers to get
+    // behind and do something EVIL!!
+    Foo bigChain = createAFoo();
+    Foo newLink  = bigChain;
+    for( int i = 0; i < 900900; ++i ) {
+      newLink.x = createAFoo();
+      newLink = newLink.x;
+    }
+    
+    for( int i = 0; i < n; ++i ) { 
+
+      Foo tmp = createAFoo();
+      Foo val = createAFoo();
+      val.z = i*3;
+      val.x = bigChain;
+      tmp.x = val;
+
+      sese evil {
+        Foo foo = tmp;
+
+        // actual computation just gets to val,
+        // traverser will go down the big chain
+        for( int j = 0; j < 1; ++j ) {
+          foo = foo.x;
+        }
+        
+        // now mutate heap so traverser, if it
+        // ran, would be broken
+        tmp.x = null;
+
+        // then do some tiny bit of work
+        total += compute( foo );
+      }
+    }
+
+    System.out.println( total );
+  }
+
+  static public int compute( Foo foo ) {
+
+    // create a write effect that
+    // does not actually mutate heap
+    Foo bar = foo;
+    for( int j = 0; j < 2; ++j ) {
+      bar = bar.x;
+    }
+    foo.x.x = bar;
+
+    return foo.z;
+  }
+
+  static Foo createAFoo() {
+    return new Foo();
+  }
+}