|
Message
From: cvs at opencores.org<cvs@o...>
Date: Thu Aug 16 17:26:43 CEST 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/08 16:17:26 Added: jop/java/target/src/test/gcinc myObject.java SimpGC1.java SimpGC2.java SimpGC4.java SimpGC5.java SimpGC6.java SimpleTree.java Log: no message Revision Changes Path 1.1 jop/java/target/src/test/gcinc/myObject.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/myObject.java?rev=1.1&content-type=text/x-cvsweb-markup Index: myObject.java =================================================================== package gcinc; public class myObject { public int my_int1,my_int2; public myObject() { my_int1=0; my_int2=0; } } 1.1 jop/java/target/src/test/gcinc/SimpGC1.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpGC1.java?rev=1.1&content-type=text/x-cvsweb-markup Index: SimpGC1.java =================================================================== package gcinc; public class SimpGC1 { public void createObjects() { int i=1; while(true) { new myObject(); System.out.print(i); System.out.print(" "); i++; for(int j=0;j<20000;j++) { } } } public static void main(String[] args) { SimpGC1 sgc= new SimpGC1(); sgc.createObjects(); } } 1.1 jop/java/target/src/test/gcinc/SimpGC2.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpGC2.java?rev=1.1&content-type=text/x-cvsweb-markup Index: SimpGC2.java =================================================================== package gcinc; public class SimpGC2 { public void createObjects() { int i; for(i=1;i<3*9730;i++) //make GC trigger 3 times (3*9730) { allocateObject(); } System.out.println(i); } public void allocateObject() { myObject mo; mo=new myObject(); } public static void main(String[] args) { SimpGC2 sgc= new SimpGC2(); sgc.createObjects(); for(;;){} } } 1.1 jop/java/target/src/test/gcinc/SimpGC4.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpGC4.java?rev=1.1&content-type=text/x-cvsweb-markup Index: SimpGC4.java
===================================================================
package gcinc;
import com.jopdesign.sys.GC;
public class SimpGC4 implements Runnable {
public myList list;
public boolean test;
private typeA myReference;
int length,nr;
public SimpGC4(int i) {
length = i;
}
public void run() {
if(test)
{
if (!myReference.testYourself(length)){
throw new Error("Object is in wrong state");}
synchronized(monitor)
{shared=myReference;}
myReference=null;
test=false;
}
//System.out.println("running");
if (SimpGC4.shared!=null){
synchronized(monitor){
myReference=SimpGC4.shared;
SimpGC4.shared=null;
}
test=true;
}
}
static typeA shared;
static SimpGC4 a,b,c;
static Object monitor;
/**
* @param args
*/
public static void main(String[] args) {
a = new SimpGC4(22);
b = new SimpGC4(22);
c = new SimpGC4(22);
monitor=new Object();
SimpGC4.shared=new typeA(22);
for (;;) {
a.run();
GC.gc();
b.run();
GC.gc();
c.run();
GC.gc();
}
}
}
1.1 jop/java/target/src/test/gcinc/SimpGC5.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpGC5.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: SimpGC5.java
===================================================================
package gcinc;
import com.jopdesign.sys.GC;
public class SimpGC5 {
public static void main(String[] args) {
//Warning: required space grows with sum(2expn), n=0,1,2 ...
SimpleTree st= new SimpleTree(8);
GC.gc();
if(!st.verify()){
throw new Error("Something wrong");
}
//Make this a couple of times
st=st.getLeftSubtree();
st=st.getRightSubtree();
st=st.getLeftSubtree();
GC.gc();
if(!st.verify()){
throw new Error("Something wrong");
}
st=st.getRightSubtree();
GC.gc();
if(!st.verify()){
throw new Error("Something wrong");
}
st=st.getLeftSubtree();
GC.gc();
if(!st.verify()){
throw new Error("Something wrong");
}
for(;;){
System.out.println("Everything is fine");
}
}
}
1.1 jop/java/target/src/test/gcinc/SimpGC6.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpGC6.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: SimpGC6.java
===================================================================
package gcinc;
import com.jopdesign.sys.GC;
public class SimpGC6 {
private SimpGC6 reference;
public void setReference(SimpGC6 simp){
reference=simp;
}
public void createChainedObjects(){
SimpGC6 ref1,ref2;
ref1=new SimpGC6();
ref2=new SimpGC6();
ref1.setReference(ref2);
ref2.setReference(ref1);
}
public static void main(String[] args) {
SimpGC6 sgc=new SimpGC6();
//Start our experiment with a clean heap
System.out.println("call GC1");
GC.gc();
//Measure how many objects fit into memory-make GC trigger
for(int i=0; i<9730; i++){
new myObject();
System.out.print("nc:");
System.out.print(i);
System.out.print(" ");
}
//Clean objects remaining from last for
System.out.println("call GC2");
GC.gc();
//Create chained objects
for(int i=0; i<5000; i++){
sgc.createChainedObjects();
}
//Clean them
System.out.println("call GC3");
GC.gc();
//If the objects were cleaned GC should trigger at the same point as
//in the first loop
for(int i=0; i<9730; i++){
new myObject();
System.out.print("sc:");
System.out.print(i);
}
for (;;) {
//System.out.println("I'm running");
}
}
}
1.1 jop/java/target/src/test/gcinc/SimpleTree.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/test/gcinc/SimpleTree.java?rev=1.1&content-type=text/x-cvsweb-markup
Index: SimpleTree.java
===================================================================
package gcinc;
public class SimpleTree {
class node{
node left,right;
boolean initialized;
int myLevel;
public void grow(int i){
if (i>0 && initialized==false){
left=new node();
right=new node();
left.grow(i-1);
right.grow(i-1);
initialized=true;
myLevel=i;
}
return;
}
public boolean verify(int depth){
boolean Ok;
Ok= myLevel==depth;
if (depth>0){
Ok=Ok && left.verify(depth-1);
Ok=Ok && right.verify(depth-1);
}
return Ok;
}
}
private node root;
private int depth;
public void setRootNode(node n){
root=n;
}
public SimpleTree(int depth){
root= new node();
root.grow(depth);
this.depth=depth;
}
public SimpleTree(){
}
public boolean verify(){
return root.verify(depth);
}
public SimpleTree getLeftSubtree(){
SimpleTree st;
st=new SimpleTree();
st.setRootNode(root.left);
st.depth=depth -1;
return st;
}
public SimpleTree getRightSubtree(){
SimpleTree st;
st=new SimpleTree();
st.setRootNode(root.right);
st.depth=depth -1;
return st;
}
}
|
 |