|
From: <ans...@us...> - 2007-01-08 08:40:58
|
Revision: 3056
http://jnode.svn.sourceforge.net/jnode/?rev=3056&view=rev
Author: ansari82
Date: 2007-01-08 00:40:57 -0800 (Mon, 08 Jan 2007)
Log Message:
-----------
Added capability of compilertest to generate text and binary output for compiled methods, and modified jikestest for testing float/double ops more thoroughly
Modified Paths:
--------------
branches/jikesRVM/core/src/test/org/jnode/test/JikesTest.java
branches/jikesRVM/core/src/test/org/jnode/test/core/CompilerTest.java
Modified: branches/jikesRVM/core/src/test/org/jnode/test/JikesTest.java
===================================================================
--- branches/jikesRVM/core/src/test/org/jnode/test/JikesTest.java 2007-01-08 08:39:10 UTC (rev 3055)
+++ branches/jikesRVM/core/src/test/org/jnode/test/JikesTest.java 2007-01-08 08:40:57 UTC (rev 3056)
@@ -2,38 +2,68 @@
public class JikesTest {
+public static float stFValue = 15.0F;
+public static double stDValue = 30.0;
+
+public float FValue = 5.0F;
+public double DValue = 10.0;
+
public static void main (String [] argv) {
- int [] array = {1,2,3,4,5,6}; int i = 1;long j = 5; long t0, t1;
- System.out.println("jikesReturns expect true, return "+!jikesReturns());
- System.out.println("jikesTakesParam expect true, return "+(jikesTakesParam(5)==5?true:false));
- System.out.println("jikesAccessLocalSTATICVar expect true, return "+(jikesAccessLocalSTATICVar()==true?true:false));
- System.out.println("jikesCallLocalSTATICMethod expect true, return "+(jikesCallLocalSTATICMethod(5)==true?true:false));
- System.out.println("jikesAccessLocalSTATICArray expect true, return "+(jikesAccessLocalSTATICArray(j)==0?true:false));
- System.out.println("jikesAccessArray expect true, return "+(jikesAccessArray(array)==array[0]?true:false));
- System.out.println("jikesAccessJTOC expect time, return "+jikesAccessJTOC());
- System.out.print( "jikesPrintInt expect 5, return ");jikesPrintInt(5);
- System.out.print( "jikesPrintStr expect yaay, return ");jikesPrintStr(new String("yaay"));
- System.out.println("jikesmulTest expect 15, return "+jikesmulTest(3,5));
- System.out.println("jikesshlTest expect 4, return "+jikesshlTest(2,1));
- System.out.println("jikesshrTest expect 4, return "+jikesshrTest(8,1));
- System.out.println("jikessarTest expect 4, return "+jikessarTest(8,1));
- System.out.println("jikesFloatTest expect true, return "+!jikesFloatTest((float)5.0, (float)1.0));
- System.out.println("jikesFloatTest expect true, return "+ jikesFloatTest((float)1.0, (float)5.0));
- System.out.println("jikesFloatTest expect true, return "+ jikesFloatTest((float)1.0, (float)1.0));
- System.out.println("jikesAllocPrimitiveArray expect true, return "+(jikesAllocPrimitiveArray()[1]==localSTATIC?true:false));
- System.out.println("jikesAllocObjectArray expect true, return "+(testInstanceOf(jikesAllocObjectArray()[1])?true:false));
- System.out.println("jikesAllocMultiArray expect true, return "+(jikesAllocMultiArray()[1][1]==localSTATIC?true:false));
- System.out.println("jikesMonitor expect true, return "+jikesMonitor());
- System.out.print( "jikesTryCatchException expect true, return ");jikesTryCatch();
- t0 = time();System.out.print("jikestestSmallLoop:"+jikestestsmallloop()+" time:");t1 = time();System.out.println(t1 - t0);
- t0 = time();System.out.print("jikestestBigLoop: "+jikestestbigloop() +" time:");t1 = time();System.out.println(t1 - t0);
- sayHi2();
- JikesTest myHello = new JikesTest();myHello.sayHi();
+ int [] array = {1,2,3,4,5,6}; int i = 1;long j = 5; long t0, t1;
+ System.out.println("jikesReturns expect true, return "+!jikesReturns());
+ System.out.println("jikesTakesParam expect true, return "+(jikesTakesParam(5)==5?true:false));
+ System.out.println("jikesAccessLocalSTATICVar expect true, return "+(jikesAccessLocalSTATICVar()==true?true:false));
+ System.out.println("jikesCallLocalSTATICMethod expect true, return "+(jikesCallLocalSTATICMethod(5)==true?true:false));
+ System.out.println("jikesAccessLocalSTATICArray expect true, return "+(jikesAccessLocalSTATICArray(j)==0?true:false));
+ System.out.println("jikesAccessArray expect true, return "+(jikesAccessArray(array)==array[0]?true:false));
+ System.out.println("jikesAccessJTOC expect time, return "+jikesAccessJTOC());
+ System.out.print( "jikesPrintInt expect 5, return ");jikesPrintInt(5);
+ System.out.print( "jikesPrintStr expect yaay, return ");jikesPrintStr(new String("yaay"));
+ System.out.println("jikesmulTest expect 15, return "+jikesmulTest(3,5));
+ System.out.println("jikesshlTest expect 4, return "+jikesshlTest(2,1));
+ System.out.println("jikesshrTest expect 4, return "+jikesshrTest(8,1));
+ System.out.println("jikessarTest expect 4, return "+jikessarTest(8,1));
+ System.out.println("jikesFloatTest expect true, return "+!jikesFloatTest((float)5.0, (float)1.0));
+ System.out.println("jikesFloatTest expect true, return "+ jikesFloatTest((float)1.0, (float)5.0));
+ System.out.println("jikesFloatTest expect true, return "+ jikesFloatTest((float)1.0, (float)1.0));
+ System.out.println("jikesAllocPrimitiveArray expect true, return "+(jikesAllocPrimitiveArray()[1]==localSTATIC?true:false));
+ System.out.println("jikesAllocObjectArray expect true, return "+(testInstanceOf(jikesAllocObjectArray()[1])?true:false));
+ System.out.println("jikesAllocMultiArray expect true, return "+(jikesAllocMultiArray()[1][1]==localSTATIC?true:false));
+ System.out.println("jikesMonitor expect true, return "+jikesMonitor());
+ System.out.print( "jikesTryCatchException expect true, return ");jikesTryCatch();
+ t0 = time();System.out.print("jikestestSmallLoop:"+jikestestsmallloop()+" time:");t1 = time();System.out.println(t1 - t0);
+ t0 = time();System.out.print("jikestestBigLoop: "+jikestestbigloop() +" time:");t1 = time();System.out.println(t1 - t0);
+ sayHi2();
+ JikesTest myHello = new JikesTest();myHello.sayHi();
+
+ System.out.println("value before "+stFValue+" "+stDValue);
+ stFValue+=5.0F;
+ stDValue+=10.0;
+ System.out.println("value after "+stFValue+" "+stDValue);
+ System.out.println("obj value before "+myHello.FValue+" "+myHello.DValue);
+ float f = myHello.setF(myHello.FValue+=5.0F);
+ double d = myHello.setD(myHello.DValue+=10.0);
+ System.out.println("obj value after "+f+" "+d);
System.out.println("throw array out of bounds");
array[10] = 0;
-
}
+public float setF(float f) {
+ return realSetF(f);
+}
+public double setD(double d) {
+ return realSetD(d);
+}
+
+public float realSetF(float f) {
+ FValue = f;
+ return FValue;
+}
+public double realSetD(double d) {
+ DValue = d;
+ return DValue;
+}
+
private static void jikesTryException () {
throw new NullPointerException("true");
}
Modified: branches/jikesRVM/core/src/test/org/jnode/test/core/CompilerTest.java
===================================================================
--- branches/jikesRVM/core/src/test/org/jnode/test/core/CompilerTest.java 2007-01-08 08:39:10 UTC (rev 3055)
+++ branches/jikesRVM/core/src/test/org/jnode/test/core/CompilerTest.java 2007-01-08 08:40:57 UTC (rev 3056)
@@ -28,7 +28,10 @@
import java.io.PrintStream;
import org.jnode.assembler.ObjectResolver;
+import org.jnode.assembler.x86.X86Assembler;
+import org.jnode.assembler.x86.X86BinaryAssembler;
import org.jnode.assembler.x86.X86TextAssembler;
+import org.jnode.assembler.x86.X86Constants.Mode;
import org.jnode.vm.Vm;
import org.jnode.vm.VmArchitecture;
import org.jnode.vm.VmSystemClassLoader;
@@ -104,7 +107,17 @@
// "org.jnode.vm.bytecode.BytecodeParser",
// "com.ibm.JikesRVM.VM_Runtime",
// "org.jnode.test.JikesTest",
- "org.jnode.vm.classmgr.VmConstFloat"
+// "org.jnode.vm.classmgr.VmConstFloat",
+// "org.jnode.vm.x86.compiler.l1a.ItemFactory",
+// "org.jnode.vm.scheduler.IdleThread",
+// "org.jnode.vm.classmgr.VmAnnotation",
+// "com.ibm.JikesRVM.opt.OPT_LICM",
+// "org.jnode.vm.scheduler.VmProcessor",
+// "org.jnode.vm.scheduler.VmThread",
+// "org.jnode.test.DoubleTest2",
+ "java.lang.String",
+
+
};
public static void main(String[] args) throws Exception {
@@ -126,7 +139,7 @@
vm.toString();
System.out.println("Architecture: " + arch.getFullName());
- //final ObjectResolver resolver = new DummyResolver();
+ final ObjectResolver resolver = new DummyResolver();
final X86CpuID cpuId = X86CpuID.createID(processorId);
//NativeCodeCompiler c = cs[0];
final NativeCodeCompiler[] cs = {
@@ -148,8 +161,8 @@
for (int i = 0; i < cnt; i++) {
final VmMethod method = type.getDeclaredMethod(i);
counts[ci]++;
-// if(method.getName().contains("is"))
- compile(method, arch, cs[ci], cpuId, ci + 1);
+ if(method.getName().contains("init"))
+ compile(method, arch, cs[ci], cpuId, ci + 1, resolver);
}
}
final long end = System.currentTimeMillis();
@@ -162,35 +175,45 @@
}
static void compile(VmMethod method, VmArchitecture arch, NativeCodeCompiler c, X86CpuID cpuId,
- int level) throws IOException {
+ int level, ObjectResolver resolver) throws IOException {
+ final String cname = method.getDeclaringClass().getName();
final String mname = method.getFullName();
- final String fname = mname.replace('<', '_').replace('>', '_').replace('/','.') + "." + c.getName()
+ final String fname = cname + "#" +mname.replace('<', '_').replace('>', '_').replace('/','.') + "." + c.getName()
+ ".method";
- final FileOutputStream out = new FileOutputStream(fname);
+ FileOutputStream out = new FileOutputStream(fname);
+ X86Assembler os [] = {
+ new X86TextAssembler(new OutputStreamWriter(out),cpuId, ((VmX86Architecture)arch).getMode(), method.getMangledName()),
+ new X86BinaryAssembler(cpuId, ((VmX86Architecture)arch).getMode(), 0),
+ };
+
- try {
- if (!method.isAbstract()) {
- final PrintStream ps = new PrintStream(out);
- BytecodeViewer viewer = new BytecodeViewer(
- new ControlFlowGraph(method.getBytecode()), ps);
- BytecodeParser.parse(method.getBytecode(), viewer);
- ps.flush();
- }
-
- X86TextAssembler os = new X86TextAssembler(new OutputStreamWriter(out),
- cpuId, ((VmX86Architecture)arch).getMode(), method.getMangledName());
+ for(int i = 0; i < os.length; i++) {
try {
- c.compileBootstrap(method, os, level);
- //c.compileRuntime(method, resolver, level, os);
+ if (!method.isAbstract()) {
+ if(!(os[i] instanceof X86BinaryAssembler)) {
+ final PrintStream ps = new PrintStream(out);
+ BytecodeViewer viewer = new BytecodeViewer(
+ new ControlFlowGraph(method.getBytecode()), ps);
+ BytecodeParser.parse(method.getBytecode(), viewer);
+ ps.flush();
+ }
+ }
+
+ if(!Vm.isRunningVm()) c.compileBootstrap(method, os[i], level);
+ else c.compileRuntime(method, resolver, level, os[i]);
+ if(os[i] instanceof X86TextAssembler) ((X86TextAssembler)os[i]).flush();
+ if(os[i] instanceof X86BinaryAssembler) {
+ out = new FileOutputStream(fname+".bin");
+ X86BinaryAssembler bos = (X86BinaryAssembler)os[i];
+ out.write(bos.getBytes(), 0, bos.getLength());
+ }
+ } catch (Throwable ex) {
+ System.out.println("Error in ### Method " + mname + " -> " + fname);
+ ex.printStackTrace();
+ System.exit(1);
} finally {
- os.flush();
+ out.close();
}
- } catch (Throwable ex) {
- System.out.println("Error in ### Method " + mname + " -> " + fname);
- ex.printStackTrace();
- System.exit(1);
- } finally {
- out.close();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|