|
From: <ans...@us...> - 2007-01-16 23:20:02
|
Revision: 3082
http://jnode.svn.sourceforge.net/jnode/?rev=3082&view=rev
Author: ansari82
Date: 2007-01-16 15:20:01 -0800 (Tue, 16 Jan 2007)
Log Message:
-----------
Large commit of all current fixes to make boot image compile
Modified Paths:
--------------
branches/jikesRVM/all/conf/x86/menu-cdrom.lst
branches/jikesRVM/all/conf/x86/menu.lst
branches/jikesRVM/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java
branches/jikesRVM/builder/src/builder/org/jnode/build/VMwareBuilderTask.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/JikesRVMOptCompiler.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethod.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethods.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_Runtime.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Class.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Field.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_FieldReference.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MemberReference.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MethodReference.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Primitive.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Type.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_TypeReference.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_BURS_Helpers.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_ClassLoaderProxy.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_DynamicTypeCheckExpansion.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_GenericStackManager.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_NormalizeConstants.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/VM_OptCompiledMethod.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/ir/OPT_BC2IR.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/ir/OPT_ClassConstantOperand.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/ir/OPT_LongConstantOperand.java
branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/ir/OPT_RegisterPool.java
branches/jikesRVM/core/src/native/x86/ints32.asm
branches/jikesRVM/core/src/native/x86/vm-ints.asm
branches/jikesRVM/core/src/native/x86/vm.asm
branches/jikesRVM/core/src/test/org/jnode/test/core/CompilerTest.java
Modified: branches/jikesRVM/all/conf/x86/menu-cdrom.lst
===================================================================
(Binary files differ)
Modified: branches/jikesRVM/all/conf/x86/menu.lst
===================================================================
--- branches/jikesRVM/all/conf/x86/menu.lst 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/all/conf/x86/menu.lst 2007-01-16 23:20:01 UTC (rev 3082)
@@ -4,7 +4,7 @@
# ---------------------------
title JNode (default)
-kernel (hd0,0)/jnode32.gz mp=no
+kernel (hd0,0)/jnode32.gz mp=no kdb
module (hd0,0)/default.jgz
# ---------------------------
Modified: branches/jikesRVM/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java
===================================================================
--- branches/jikesRVM/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/builder/src/builder/org/jnode/build/AbstractBootImageBuilder.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -213,8 +213,6 @@
do {
again = false;
oldCount = clsMgr.getLoadedClassCount();
- for (VmType< ? > vmClass : clsMgr.getLoadedClasses())
- vmClass.setInBootImage(true);
for (VmType< ? > vmClass : clsMgr.getLoadedClasses()) {
vmClass.link();
final boolean compHigh = isCompileHighOptLevel(vmClass);
@@ -550,7 +548,8 @@
// Load the jarfile as byte-array
// copyJarFile(blockedObjects, piRegistry);
-
+ for (VmType< ? > vmClass : clsMgr.getLoadedClasses())
+ vmClass.setInBootImage(true);
// Now emit all object images to the actual image
emitObjects(os, arch, blockedObjects, false);
Modified: branches/jikesRVM/builder/src/builder/org/jnode/build/VMwareBuilderTask.java
===================================================================
--- branches/jikesRVM/builder/src/builder/org/jnode/build/VMwareBuilderTask.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/builder/src/builder/org/jnode/build/VMwareBuilderTask.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -111,7 +111,7 @@
if((logFile != null) && (logFile.trim().length() != 0))
{
- put(w, "serial0.present", "FALSE");
+ put(w, "serial0.present", "TRUE");
put(w, "serial0.fileType", "file");
put(w, "serial0.fileName", logFile);
}
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/JikesRVMOptCompiler.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/JikesRVMOptCompiler.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/JikesRVMOptCompiler.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -92,9 +92,9 @@
OPT_CompilationPlan compPlan =
new OPT_CompilationPlan(jikesMethod, optimizationPlan, null, options);
//Compile with Jikes
- VM_CompiledMethod jikescm = optCompileWithFallBackInternal(jikesMethod, compPlan);
+ /*VM_CompiledMethod jikes*/cm = optCompileWithFallBackInternal(jikesMethod, compPlan);
//Build necessary result for JNode VM from Jikes compiled output
- cm = ((VM_OptCompiledMethod)jikescm).buildJnodeCM((X86Assembler)nos, getEntryPoints());
+ /*cm = */((VM_OptCompiledMethod)cm).buildJnodeCM((X86Assembler)nos, getEntryPoints());
//Uninitialise Jikes' VM_Magic
// VM_Magic.uninit();
compilationInProgress = false;
@@ -200,15 +200,17 @@
}
@Override
public String[] getCompilerPackages() {
- return new String[] { "org.jnode.vm.x86.compiler",
- "com.ibm.JikesRVM",
- "com.ibm.JikesRVM.adaptive",
- "com.ibm.JikesRVM.classloader",
- "com.ibm.JikesRVM.memoryManagers.mmInterface",
-// "com.ibm.JikesRVM.opt",
-// "com.ibm.JikesRVM.opt.ir",
- "com.ibm.JikesRVM.OSR",
- "com.ibm.JikesRVM.util"};
+ return new String[] {
+// "org.jnode.vm.x86.compiler",
+// "com.ibm.JikesRVM",
+// "com.ibm.JikesRVM.adaptive",
+// "com.ibm.JikesRVM.classloader",
+// "com.ibm.JikesRVM.memoryManagers.mmInterface",
+// "com.ibm.JikesRVM.opt",
+// "com.ibm.JikesRVM.opt.ir",
+// "com.ibm.JikesRVM.OSR",
+// "com.ibm.JikesRVM.util"
+ };
}
//-------------------------------------------------------------------------------------------//
@@ -219,62 +221,76 @@
public static boolean compilableMethod(VmMethod vmMethod) {
if (
-// && !( vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.x86.compiler.l1a.X86Byte")
-// && vmMethod.getName().contains("other"))
- vmMethod.getDeclaringClass().getName().startsWith("java.io")
- || vmMethod.getDeclaringClass().getName().startsWith("java.lang")
-// && !(vmMethod.getDeclaringClass().getName().startsWith("java.lang.ClassLoader")
-// && vmMethod.getName().contains("loadClass"))
-// && !(vmMethod.getDeclaringClass().getName().startsWith("java.lang.String")
-// && vmMethod.getName().contains("init"))
- || vmMethod.getDeclaringClass().getName().startsWith("java.net")
- || vmMethod.getDeclaringClass().getName().startsWith("java.nio")
- || vmMethod.getDeclaringClass().getName().startsWith("java.security")
- && !vmMethod.getDeclaringClass().getName().startsWith("java.security.Permissions")
- || vmMethod.getDeclaringClass().getName().startsWith("java.util")
- || vmMethod.getDeclaringClass().getName().startsWith("javax")
- || vmMethod.getDeclaringClass().getName().startsWith("gnu.classpath")
- || vmMethod.getDeclaringClass().getName().startsWith("gnu.java")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.assembler")
- && !vmMethod.getDeclaringClass().getName().startsWith("org.jnode.assembler.x86.X86B")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.boot.")
- && !vmMethod.getDeclaringClass().getName().startsWith("org.jnode.boot.Main")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.naming")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.plugin")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.protocol")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.security")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.system")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.util")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.bytecode")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.classmgr")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.compiler")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.isolate")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler")
- || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.x86.compiler")
- && !vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.x86.compiler.l1a.X86Byte")
-// || (vmMethod.getDeclaringClass().getName().lastIndexOf('.') > 0 ?
-// vmMethod.getDeclaringClass().getName().substring(0,
-// vmMethod.getDeclaringClass().getName().lastIndexOf('.'))
-// : "").contentEquals("org.jnode.vm")
+// vmMethod.getDeclaringClass().getName().startsWith("java.io")
+// || vmMethod.getDeclaringClass().getName().startsWith("java.lang")
+// || vmMethod.getDeclaringClass().getName().startsWith("java.net")
+// || vmMethod.getDeclaringClass().getName().startsWith("java.nio")
+// || vmMethod.getDeclaringClass().getName().startsWith("java.security")
+// || vmMethod.getDeclaringClass().getName().startsWith("java.util")
+// || vmMethod.getDeclaringClass().getName().startsWith("javax")
+// || vmMethod.getDeclaringClass().getName().startsWith("gnu.classpath")
+// || vmMethod.getDeclaringClass().getName().startsWith("gnu.java")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.assembler")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.boot")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.naming")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.plugin")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.protocol")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.security")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.system")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.util")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.bytecode")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.classmgr")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.compiler")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.isolate")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.x86.compiler")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm")
+// && !(
+// vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmSystemClassLoader")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmReflection")
+// && vmMethod.getName().contentEquals("invoke") //manipulates ESP, which Jikes needs to control
+// )
+
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.A")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.B")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.C")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.H")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.I")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.J")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.L")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.M")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.O")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.R")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.S")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.U")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.Vi")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmA")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmE")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmJ")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmM")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmP")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmR")
+// && !vmMethod.getName().contentEquals("invoke") //manipulates ESP, which Jikes needs to control
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmSt")
+// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmSystem")
+ vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmSystemClassLoader$")
+ || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.VmSystemClassLoader")
+//
+ && (
+ vmMethod.getName().contains("init")
+ || vmMethod.getName().startsWith("a")
+ || vmMethod.getName().startsWith("c")
+ || vmMethod.getName().startsWith("d")
+ || vmMethod.getName().startsWith("f")
+ || vmMethod.getName().startsWith("g")
+ || vmMethod.getName().startsWith("i")
+ || vmMethod.getName().startsWith("l")
+ || vmMethod.getName().startsWith("p")
+ || vmMethod.getName().startsWith("r")
+ || vmMethod.getName().startsWith("s")
+
+ )
-
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.I")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.M")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.P")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.S")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.VmP")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.VmS")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.VmThreadQ")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.VmThreadV")
-// || vmMethod.getDeclaringClass().getName().startsWith("org.jnode.vm.scheduler.VmThread")
-// && (
-// vmMethod.isStatic()
-// || vmMethod.getName().startsWith("a")
-// || vmMethod.getName().startsWith("c")
-// || vmMethod.getName().startsWith("d")
-// || vmMethod.getName().startsWith("g")
-//
-// )
)
{
return true;
@@ -330,7 +346,7 @@
//Try and get from constant pool, should be there.
if(this instanceof JikesRVMOptCompiler) {
- int catchid = cm.getJikesCM().getETable()[i*4+3];
+ int catchid = ((VM_CompiledMethod)cm)/*.getJikesCM()*/.getETable()[i*4+3];
String jnodeType = VM_Type.getVM_Type(catchid).getJnodeType().getName();
for(int j = 0; j < bc.getCP().getLength(); j++) {
if (bc.getCP().getAny(j) instanceof VmConstClass &&
@@ -450,7 +466,7 @@
//Try and get from constant pool, should be there.
if(this instanceof JikesRVMOptCompiler) {
- int catchid = cm.getJikesCM().getETable()[i*4+3];
+ int catchid = ((VM_CompiledMethod)cm)/*.getJikesCM()*/.getETable()[i*4+3];
String jnodeType = VM_Type.getVM_Type(catchid).getJnodeType().getName();
for(int j = 0; j < bc.getCP().getLength(); j++) {
if (bc.getCP().getAny(j) instanceof VmConstClass &&
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethod.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethod.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethod.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -1,5 +1,7 @@
package com.ibm.JikesRVM;
+import java.util.Enumeration;
+
import org.jnode.assembler.Label;
import org.jnode.assembler.NativeStream;
import org.jnode.assembler.x86.X86Assembler;
@@ -25,16 +27,23 @@
import com.ibm.JikesRVM.classloader.VM_Method;
import com.ibm.JikesRVM.classloader.VM_NormalMethod;
import com.ibm.JikesRVM.classloader.VM_Type;
+import com.ibm.JikesRVM.classloader.VM_TypeReference;
import com.ibm.JikesRVM.opt.VM_OptCompiledMethod;
+import com.ibm.JikesRVM.opt.ir.MIR_Move;
import com.ibm.JikesRVM.opt.ir.OPT_BasicBlock;
import com.ibm.JikesRVM.opt.ir.OPT_IR;
import com.ibm.JikesRVM.opt.ir.OPT_Instruction;
import com.ibm.JikesRVM.opt.ir.OPT_InstructionEnumeration;
+import com.ibm.JikesRVM.opt.ir.OPT_Operand;
import com.ibm.JikesRVM.opt.ir.OPT_Operators;
+import com.ibm.JikesRVM.opt.ir.OPT_PhysicalRegisterSet;
+import com.ibm.JikesRVM.opt.ir.OPT_Register;
+import com.ibm.JikesRVM.opt.ir.OPT_RegisterOperand;
+import com.ibm.JikesRVM.opt.ir.OPT_StackLocationOperand;
-public abstract class VM_CompiledMethod implements X86CompilerConstants {
+public abstract class VM_CompiledMethod extends CompiledMethod implements X86CompilerConstants {
- protected CompiledMethod jnodecm;
+ //protected CompiledMethod jnodecm;
public static final int optlevel = 3;
@@ -52,7 +61,7 @@
public final static int NUM_COMPILER_TYPES = 4;
- protected final int cmid;
+// protected final int cmid;
/*
* constants for bitField1
@@ -83,8 +92,9 @@
*/
protected int bitField1;
- public VM_CompiledMethod(int id, VM_Method m) {
- cmid = id;
+ public VM_CompiledMethod(VM_Method m) {
+ super(optlevel);
+// cmid = id;
method = m;
}
@@ -94,7 +104,7 @@
* Return the compiled method id for this compiled method
*/
public int getId() {
- return cmid;
+ return getCompiledCodeId();//return cmid;
}
/**
@@ -362,13 +372,7 @@
return null;
}
- public CompiledMethod getJnodeCompiledMethod() {
- return jnodecm;
- }
- public void setJnodeCompiledMethod(CompiledMethod jnodeCompiledMethod) {
- this.jnodecm = jnodeCompiledMethod;
- }
/* This is a hacked method for porting the opt compiler into Jnode.
* It only does what is needed in terms of the port, be very careful when using it.
@@ -378,7 +382,7 @@
//Create jikes method based on jnode method
VM_NormalMethod jikesmethod = (VM_NormalMethod)VM_Method.buildFromJnodeMethod(jnodecm.getMethod());
//Create jikes compiled-method based on jnode compiled-method and jikes method above
- VM_CompiledMethod jikescm = new VM_OptCompiledMethod(jnodecm.getId(), jikesmethod);
+ VM_CompiledMethod jikescm = new VM_OptCompiledMethod(jikesmethod);
//Copy machine code if it exists
if (jnodecm.getCompiledCode() != null) {
@@ -418,10 +422,10 @@
return eTable;
}
- public CompiledMethod buildJnodeCM(X86Assembler os, EntryPoints ep) {
+ public void/*CompiledMethod*/ buildJnodeCM(X86Assembler os, EntryPoints ep) {
final VmMethod jnodeMethod = (VmMethod)method.getJnodeMember();
- jnodecm.setJikesCM(this);
+// jnodecm.setJikesCM(this);
final VmMethodCode code = new VmMethodCode();
final Label startLabel = new Label(jnodeMethod.getMangledName()+"_"+"$$start");
final Label startCodeLabel = new Label(jnodeMethod.getMangledName()+"_"+"$$code");
@@ -430,12 +434,13 @@
final int count;
if (eTable != null) count = eTable.length >> 2; else count = 0;
- CompiledExceptionHandler[] ceh = new CompiledExceptionHandler[count];
+ CompiledExceptionHandler[] ceh = null;
+ if(count != 0) ceh = new CompiledExceptionHandler[count];
for(int i = 0; i < count; i++) ceh[i] = new CompiledExceptionHandler();
codeObject = os.startObject(ep.getVmMethodCodeClass());
os.setObjectRef(code);
- jnodecm.setCodeStart(os.setObjectRef(startLabel));
+ /*jnodecm.*/setCodeStart(os.setObjectRef(startLabel));
final int startOffset = os.getLength();
// Set startCode label
@@ -467,7 +472,7 @@
}
}
}
- jnodecm.setExceptionHandlers(ceh);
+ /*jnodecm.*/setExceptionHandlers(ceh);
}
//Build bc-address mapping
@@ -484,7 +489,7 @@
bci = i.position.bcIndex;
}
if(bci >= 0 && mci >= ((VM_OptCompiledMethod)this).getEndPrologueOffset() && depth >= 0)
- jnodecm.add(jnodeMethod, bci, mci+offset, 0);
+ /*jnodecm.*/add(jnodeMethod, bci, mci+offset, 0);
//Print final IR if outputting to text instead of binary/machine code
if(os.isTextStream()) {
@@ -500,12 +505,31 @@
// Now create the default exception handler
Label handlerLabel = new Label(jnodeMethod.getMangledName()+"_$$def-ex-handler");
- jnodecm.setDefExceptionHandler(os.setObjectRef(handlerLabel));
+ /*jnodecm.*/setDefExceptionHandler(os.setObjectRef(handlerLabel));
if(temp_ir.stackManager.frameIsRequired()) {
- int frameSize = temp_ir.stackManager.getFrameFixedSize()-INTSIZE;
- os.writeLEA(X86Register.ESP, X86Register.EBP, -frameSize);
- os.writePOP(X86Register.EBX);
- os.writePOP(X86Register.ESI);
+ int frameSize = temp_ir.stackManager.getFrameFixedSize();
+ os.writeLEA(X86Register.ESP, X86Register.EBP, +INTSIZE);
+
+ OPT_PhysicalRegisterSet phys = temp_ir.regpool.getPhysicalRegisterSet();
+ int nNonvolatileGPRS = temp_ir.compiledMethod.getNumberOfNonvolatileGPRs();
+
+ int n = nNonvolatileGPRS - 1;
+ for (Enumeration e = phys.enumerateNonvolatileGPRsBackwards();
+ e.hasMoreElements() && n >= 0 ; n--) {
+ OPT_Register nv = (OPT_Register)e.nextElement();
+ int nvoffset = temp_ir.stackManager.getNonvolatileGPROffset(n);
+// OPT_Operand M = new OPT_StackLocationOperand(true, -offset, 4);
+ os.writeMOV(VM_SizeConstants.BYTES_IN_ADDRESS,
+ getJnodeRegister(nv, phys), getJnodeRegister(phys.getESP(),
+ phys), -nvoffset);
+// os.writeMOV(getJnodeRegister(nv, phys), X86Register.ESP, nvoffset);
+// inst.insertBefore(MIR_Move.create(IA32_MOV, new OPT_RegisterOperand(nv, VM_TypeReference.Int), M));
+
+
+
+// os.writePOP(X86Register.EBX);
+// os.writePOP(X86Register.ESI);
+ }
}
//Restore monitor lock if necessary (needed because of def-exhandling)
if(method.isSynchronized()) {
@@ -527,7 +551,7 @@
os.writePOP(adx);
os.writePOP(aax);
}
- os.writeLEA(X86Register.ESP, X86Register.EBP, 4);
+// os.writeLEA(X86Register.ESP, X86Register.EBP, 4);
os.writePOP(X86Register.EBP);
final int soffset = (VmArray.DATA_OFFSET * 4) + (X86JumpTable.VM_ATHROW_NOTRACE_IDX << 2);
os.writeJMP(X86Register.EDI, soffset);
@@ -535,12 +559,36 @@
//Finish off
codeObject.markEnd();
- jnodecm.setCodeEnd(os.setObjectRef(endLabel));
+ /*jnodecm.*/setCodeEnd(os.setObjectRef(endLabel));
temp_ir = null;
- return jnodecm;
+ //return jnodecm;
}
+ private X86Register.GPR getJnodeRegister(OPT_Register r, OPT_PhysicalRegisterSet phys) {
+ if(r==phys.getEAX())
+ return X86Register.EAX;
+ else if(r==phys.getEBX())
+ return X86Register.EBX;
+ else if(r==phys.getECX())
+ return X86Register.ECX;
+ else if(r==phys.getEDX())
+ return X86Register.EDX;
+ else if(r==phys.getEDI())
+ return X86Register.EDI;
+ else if(r==phys.getESI())
+ return X86Register.ESI;
+ else if(r==phys.getESP())
+ return X86Register.ESP;
+ else if(r==phys.getEBP())
+ return X86Register.EBP;
+ else {
+ try {throw new Exception("VM_CompiledMethod: getJnodeRegister: Unknown reg: "+r.toString());}
+ catch(Exception e){System.out.println(e.getMessage()); System.exit(-1);}
+ }
+ return null;
+ }
+
public final int getSharedStaticsOffset(VmSharedStaticsEntry entry, X86Assembler os) {
if (os.isCode32()) {
return (VmArray.DATA_OFFSET * 4)
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethods.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethods.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_CompiledMethods.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -16,10 +16,7 @@
public static VM_CompiledMethod createCompiledMethod(VM_Method m,
int compilerType) {
VM._assert(jnodeCompiledMethods != null);
- CompiledMethod jnodecm = new CompiledMethod(compilerType);
- int id = jnodecm.getCompiledCodeId();
- VM_CompiledMethod jikescm = new VM_OptCompiledMethod(id, m);
- jikescm.setJnodeCompiledMethod(jnodecm);
+ VM_CompiledMethod jikescm = new VM_OptCompiledMethod(m);
return jikescm;
}
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_Runtime.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_Runtime.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/VM_Runtime.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -48,7 +48,7 @@
if (!rhs.isResolved()) {
rhs.resolve();
}
- return lhs.getClass().isAssignableFrom(rhs.getClass());
+ return lhs.getJnodeType().isAssignableFrom(rhs.getJnodeType());
}
public static Object buildMultiDimensionalArray(int methodId, int[] dimensions, VM_Array type) {
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Class.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Class.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Class.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -122,6 +122,33 @@
}
}
+ public final double getDoubleLiteral(int i) {
+ Object cpEntry = jnodeType.getCP().getAny(i);
+ return ((VmConstDouble)cpEntry).doubleValue();
+ }
+
+ public final long getLongLiteral(int i) {
+ Object cpEntry = jnodeType.getCP().getAny(i);
+ return ((VmConstLong)cpEntry).longValue();
+ }
+
+ public final float getFloatLiteral(int i) {
+ Object cpEntry = jnodeType.getCP().getAny(i);
+ return ((VmConstFloat)cpEntry).floatValue();
+ }
+
+ public final int getIntLiteral(int i) {
+ Object cpEntry = jnodeType.getCP().getAny(i);
+ return ((VmConstInt)cpEntry).intValue();
+ }
+
+ public final String getStringLiteral(int i) {
+ Object cpEntry = jnodeType.getCP().getAny(i);
+ VmSharedStatics vmStatics = jnodeType.getLoader().getSharedStatics();
+ int val = ((VmConstString)cpEntry).getSharedStaticsIndex();
+ return (String)vmStatics.getRawObject(val);
+ }
+
/**
* Get offset of a literal constant, in bytes.
* Offset is with respect to virtual machine's "table of contents" (jtoc).
@@ -129,57 +156,14 @@
public final Offset getLiteralOffset(int i) {
Object cpEntry = jnodeType.getCP().getAny(i);
- if(cpEntry instanceof VmConstDouble){
- double val = ((VmConstDouble)cpEntry).doubleValue();
- long raw_val = Double.doubleToLongBits(val);
- int idx = VM_Statics.findOrCreateDoubleLiteral(raw_val);
- return Offset.fromIntZeroExtend(idx);
- }
- else if(cpEntry instanceof VmConstLong) {
- long val = ((VmConstLong)cpEntry).longValue();
- int idx = VM_Statics.findOrCreateLongLiteral(val);
- return Offset.fromIntZeroExtend(idx);
- }
- else if(cpEntry instanceof VmConstFloat) {
- float val = ((VmConstFloat)cpEntry).floatValue();
- int raw_val = Float.floatToIntBits(val);
- int idx = VM_Statics.findOrCreateFloatLiteral(raw_val);
- return Offset.fromIntZeroExtend(idx);
- }
- else if(cpEntry instanceof VmConstInt) {
- int val = ((VmConstInt)cpEntry).intValue();
- int idx = VM_Statics.findOrCreateIntLiteral(val);
- return Offset.fromIntZeroExtend(idx);
- }
- else if(cpEntry instanceof VmConstString) {
+ if(cpEntry instanceof VmConstString) {
VmSharedStatics vmStatics = jnodeType.getLoader().getSharedStatics();
int val = ((VmConstString)cpEntry).getSharedStaticsIndex();
- String str = (String)vmStatics.getRawObject(val);
- VM_Atom atom = VM_Atom.findOrCreateAsciiAtom(str);
- try {
- VM_Statics.findOrCreateStringLiteral(atom, str);
- return Offset.fromIntZeroExtend(val*4 + VmArray.DATA_OFFSET*4);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ return Offset.fromIntZeroExtend(val*4 + VmArray.DATA_OFFSET*4);
}
- else if(cpEntry instanceof VmConstClass) {
- VM_Type jikesType = null;
- if(((VmConstClass)cpEntry).isResolved()){
- jikesType = VM_Type.buildFromJnodeType(((VmConstClass)cpEntry).getResolvedVmClass());
- } else {
- ((VmConstClass)cpEntry).resolve(this.jnodeType.getLoader());
- jikesType = VM_Type.buildFromJnodeType(((VmConstClass)cpEntry).getResolvedVmClass());
- }
- int id = jikesType.getTypeRef().getId();
- int idx = VM_Statics.findOrCreateClassLiteral(id);
- return Offset.fromIntZeroExtend(idx);
- }
else {
throw new Error("TODO: "+cpEntry+" "+cpEntry.getClass());
}
- return null;
}
public VM_Method getClassInitializerMethod() {
@@ -191,9 +175,8 @@
}
public void resolve() {
- jnodeType.link();
-// jnodeType.prepare();
-// jnodeType.prepareForInstantiation();
+// jnodeType.link();
+ jnodeType.prepare();
}
/**
@@ -226,10 +209,6 @@
return VM_Class.buildFromJnodeClass(jnodeType.getSuperClass());
}
- public boolean isInterface() {
- return jnodeType.isInterface();
- }
-
public boolean isFinal() {
return jnodeType.isFinal();
}
@@ -323,7 +302,7 @@
@Override
public void instantiate() {
- jnodeType.link();
+ jnodeType.prepare();
}
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Field.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Field.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Field.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -37,7 +37,7 @@
VM_Atom methodDescriptor = VM_Atom.findOrCreateAsciiAtom(jnodeField.getSignature());
VM_MemberReference memRef = VM_MemberReference.findOrCreate(declaringClass.getTypeRef(), methodName, methodDescriptor);
if(memRef.asFieldReference().isResolved())
- return memRef.asFieldReference().getResolvedMember();
+ return memRef.asFieldReference().peekResolvedField();
VM_Field jikesField = new VM_Field(declaringClass, memRef, jnodeField.getModifiers(), jnodeField);
return jikesField;
}
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_FieldReference.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_FieldReference.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_FieldReference.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -52,8 +52,8 @@
try {
throw new Exception("VM_FieldReference: resolve");
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+
+ e.printStackTrace(); System.exit(-1);
}
return null;
}
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MemberReference.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MemberReference.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MemberReference.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -260,7 +260,8 @@
if(VM.writingBootImage && !thisClass.getJnodeType().isAlwaysInitialized()
&& resolvedThis.isStatic()
- && !thisClass.getJnodeType().isSharedStatics()) {
+// && !thisClass.getJnodeType().isSharedStatics()
+ ) {
// JNODE Isolate-specific
// This class is an isolate type, so the state of the isolated object
// needs to be checked, if a static field from it is being accessed,
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MethodReference.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MethodReference.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_MethodReference.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -188,7 +188,7 @@
throw new Exception("VM_MethodReference.resolve() not implemented!");
} catch (Exception e) {
// TODO Auto-generated catch block
- e.printStackTrace();
+ e.printStackTrace(); System.exit(-1);
}
return null;
// Hasn't been resolved yet. Do it now triggering class loading if necessary.
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Primitive.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Primitive.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Primitive.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -167,7 +167,6 @@
@Override
public void resolve() {
jnodeType.prepare();
- jnodeType.prepareForInstantiation();
}
@Override
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Type.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Type.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_Type.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -198,11 +198,11 @@
* Is this class part of the virtual machine's boot image?
*/
public final boolean isInBootImage() throws UninterruptiblePragma {
- return false;//return jnodeType.isInBootImage();
+ return jnodeType.isInBootImage();
}
public final Class getClassForType() {
- return null;//jnodeType.asClass();
+ return jnodeType.asClass();
}
public boolean isInstantiated() {
@@ -317,5 +317,9 @@
return jnodeType.isSharedStatics();
}
+ public boolean isInterface() {
+ return jnodeType.isInterface();
+ }
+
}
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_TypeReference.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_TypeReference.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/classloader/VM_TypeReference.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -559,7 +559,7 @@
// objects when not running the VM (we get host JDK Class objects
// and that just doesn't work).
try {
- jnodeType = VmType.getObjectClass().getLoader().loadClass(name.classNameFromDescriptor(), false);
+ jnodeType = VmType.getObjectClass().getLoader().loadClass(name.classNameFromDescriptor(), true);
} catch (Exception e) {
e.printStackTrace();
return null;
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_BURS_Helpers.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_BURS_Helpers.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_BURS_Helpers.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -222,7 +222,7 @@
if(VM.BuildForJNode) {
OPT_RegisterOperand eax = new OPT_RegisterOperand(burs.ir.regpool.getPhysicalRegisterSet().getEAX(),
VM_TypeReference.ObjectReference);
- EMIT(MIR_Move.mutate(s, IA32_MOV, obj, eax));
+ EMIT(MIR_Move.mutate(s, IA32_MOV, eax, obj));
}
else {
int offset = - burs.ir.stackManager. allocateSpaceForCaughtException();
@@ -1867,13 +1867,15 @@
VM_Class decl = null;
//Make JTOC register
- jtoc = regpool.makeTempInt();
- EMIT(JnodeMagic.create(JNODE_SHARED_STATICS, jtoc.asRegister()));
+ jtoc = new OPT_RegisterOperand(regpool.getPhysicalRegisterSet().getPR(), VM_TypeReference.Address);
+ //EMIT(JnodeMagic.create(JNODE_SHARED_STATICS, jtoc.asRegister()));
OPT_Operand memberOp = s.getOperand(0);
//Get the declaring class for the field/method requiring resolution
if(memberOp instanceof OPT_MethodOperand)
decl = ((OPT_MethodOperand)memberOp).getTarget().getDeclaringClass();
+ else if (memberOp instanceof OPT_TypeOperand)
+ decl = ((OPT_TypeOperand)memberOp).getVMType().asClass();
else
decl = ((OPT_LocationOperand)memberOp).getFieldRef().peekResolvedMember().getDeclaringClass();
@@ -1886,8 +1888,8 @@
Offset.fromIntSignExtend(jtocOffset), (byte)BYTES_IN_ADDRESS, null, null)));
//Call class resolver
- jtoc = regpool.makeTempInt();
- EMIT(JnodeMagic.create(JNODE_SHARED_STATICS, jtoc.asRegister().copyRO()));
+ jtoc = new OPT_RegisterOperand(regpool.getPhysicalRegisterSet().getPR(), VM_TypeReference.Address);
+ //EMIT(JnodeMagic.create(JNODE_SHARED_STATICS, jtoc.asRegister().copyRO()));
OPT_Operand target = OPT_MemoryOperand.BD(jtoc.asRegister().copyRO(),
VM_Magic.getVmTypeInitialize().getOffset(), (byte)BYTES_IN_ADDRESS, null, null);
EMIT(MIR_Call.mutate1(s, IA32_CALL, null, null, target, classr.copy()));
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_ClassLoaderProxy.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_ClassLoaderProxy.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_ClassLoaderProxy.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -281,8 +281,7 @@
*/
public static OPT_IntConstantOperand getIntFromConstantPool (VM_Class klass,
int index) {
- Offset offset = klass.getLiteralOffset(index) ;
- int val = VM_Statics.getSlotContentsAsInt(offset);
+ int val = klass.getIntLiteral(index);
return new OPT_IntConstantOperand(val);
}
@@ -292,10 +291,8 @@
*/
public static OPT_DoubleConstantOperand getDoubleFromConstantPool (VM_Class klass,
int index) {
- Offset offset = klass.getLiteralOffset(index) ;
- long val_raw = VM_Statics.getSlotContentsAsLong(offset);
- double val = Double.longBitsToDouble(val_raw);
- return new OPT_DoubleConstantOperand(val, offset);
+ double val = klass.getDoubleLiteral(index);
+ return new OPT_DoubleConstantOperand(val);
}
/**
@@ -304,10 +301,8 @@
*/
public static OPT_FloatConstantOperand getFloatFromConstantPool (VM_Class klass,
int index) {
- Offset offset = klass.getLiteralOffset(index) ;
- int val_raw = VM_Statics.getSlotContentsAsInt(offset);
- float val = Float.intBitsToFloat(val_raw);
- return new OPT_FloatConstantOperand(val, offset);
+ float val = klass.getFloatLiteral(index);
+ return new OPT_FloatConstantOperand(val);
}
/**
@@ -316,9 +311,8 @@
*/
public static OPT_LongConstantOperand getLongFromConstantPool (VM_Class klass,
int index) {
- Offset offset = klass.getLiteralOffset(index) ;
- long val = VM_Statics.getSlotContentsAsLong(offset);
- return new OPT_LongConstantOperand(val, offset);
+ long val = klass.getLongLiteral(index);
+ return new OPT_LongConstantOperand(val);
}
/**
@@ -327,23 +321,7 @@
*/
public static OPT_StringConstantOperand getStringFromConstantPool (VM_Class klass, int index) {
Offset offset = klass.getLiteralOffset(index);
- String val;
- if (VM.runningVM) {
- val = (String)VM_Statics.getSlotContentsAsObject(offset);
- } else {
- // Sigh. What we really want to do is acquire the
- // String object from the class constant pool.
- // But, we aren't set up to do that. The following
- // isn't strictly correct, but is closer than the completely bogus
- // thing we were doing before.
- // TODO: Fix this to do the right thing.
- // This will be wrong if someone is comparing string constants
- // using ==, != since we're very unlikely to get the aliasing right.
- // Then again, if you are using ==, != with strings and one of them
- // isn't <null>, perhaps you deserve what you get.
- // This is defect 2838.
- val = ("BootImageStringConstant "+VM_Statics.offsetAsSlot(offset)).intern();
- }
+ String val = klass.getStringLiteral(index);
return new OPT_StringConstantOperand(val, offset);
}
@@ -352,8 +330,7 @@
* pool.
*/
public static OPT_ClassConstantOperand getClassFromConstantPool (VM_Class klass, int index) {
- Offset offset = klass.getLiteralOffset(index);
VM_TypeReference val = klass.getTypeRef(index);
- return new OPT_ClassConstantOperand(val, offset);
+ return new OPT_ClassConstantOperand(val);
}
}
Modified: branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_DynamicTypeCheckExpansion.java
===================================================================
--- branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_DynamicTypeCheckExpansion.java 2007-01-16 23:17:32 UTC (rev 3081)
+++ branches/jikesRVM/core/src/core/com/ibm/JikesRVM/opt/OPT_DynamicTypeCheckExpansion.java 2007-01-16 23:20:01 UTC (rev 3082)
@@ -7,6 +7,7 @@
import com.ibm.JikesRVM.*;
import com.ibm.JikesRVM.classloader.*;
import com.ibm.JikesRVM.opt.ir.*;
+
import org.vmmagic.unboxed.*;
/**
* Expansion of Dynamic Type Checking operations.
@@ -537,9 +538,10 @@
OPT_RegisterOperand RHStib,
OPT_RegisterOperand result) {
// Is LHStype a class?
- if (LHStype.isClassType()) {
+ if (LHStype.isClassType()
+ && !(VM.BuildForJNode && LHStype.peekResolvedType().isInterface())) {
VM_Class LHSclass = (VM_Class)LHStype.peekResolvedType();
- if (LHSclass != null && LHSclass.isResolved()) {
+ if (LHSclass != null) {
// Cases 4, 5, and 6 of VM_DynamicTypeCheck: LHSclass is a
// resolved class or interface
if (LHSclass.isInterface()) {
@@ -594,7 +596,11 @@
int LHSDepth = LHSclass.getTypeDepth();
int LHSId = LHSclass.getId();
OPT_RegisterOperand superclassIds;
+ OPT_Operand classTIB = null;
if(VM.BuildForJNode) {
+ if(s.getOpcode()==INSTANCEOF_UNRESOLVED_opcode) {
+ classTIB = resolveJnodeClass(LHSclass, s, ir);
+ }
superclassIds =
InsertUnary(s, ir, GET_SUPERCLASS_IDS_FROM_TIB,
VM_TypeReference.IntArray, RHStib);
@@ -607,14 +613,16 @@
}
OPT_RegisterOperand refCandidate = null;
if(VM.BuildForJNode) {
- refCandidate =
+ if(s.getOpcode()!=INSTANCEOF_UNRESOLVED_opcode) {
+ classTIB = getTIB(s, ir, LHSclass);
+ }
+ refCandidate =
InsertLoadOffset(s, ir, INT_LOAD, VM_TypeReference.Int,
superclassIds, Offset.fromIntZeroExtend(
(LHSDepth << LOG_BYTES_IN_ADDRESS)
+VM_ObjectModel.ARRAY_DATA_OFFSET.toInt()),
new OPT_LocationOperand(VM_TypeReference.Int),
TG());
- OPT_Operand classTIB = getTIB(s, ir, LHSclass);
s.insertBefore(BooleanCmp.create(BOOLEAN_CMP_ADDR, result,
refCandidate,
classTIB,
@@ -665,11 +673,12 @@
return callHelper(s, ir);
}
}
- if (LHStype.isArrayType()) {
+ if (LHStype.isArrayType()
+ || (VM.BuildForJNode && LHStype.peekResolvedType().isInterface())) {
// Case 2 of VM_DynamicTypeCheck: LHS is an array.
- VM_Array LHSArray = (VM_Array)LHStype.peekResolvedType();
- if (LHSArray != null) {
- VM_Type innermostElementType = LHSArray.getInnermostElementType();
+ VM_Type LHSArray = LHStype.peekResolvedType();
+ if (LHSArray != null && LHStype.isArrayType()) {
+ VM_Type innermostElementType = ((VM_Array)LHSArray).getInnermostElementType();
if (innermostElementType.isPrimitiveType() ||
(innermostElementType.asClass().isResolved() &&
innermostElementType.asClass().isFinal())) {
@@ -763,9 +772,10 @@
s.insertBefore(continueAt);
s.remove();
- if (LHStype.isClassType()) {
+ if (LHStype.isClassType()
+ && !(VM.BuildForJNode && LHStype.peekResolvedType().isInterface())) {
VM_Class LHSclass = (VM_Class)LHStype.peekResolvedType();
- if (LHSclass != null && LHSclass.isResolved()) {
+ if (LHSclass != null) {
// Cases 4, 5, and 6 of VM_DynamicTypeCheck: LHSclass is a resolved
// class or interface
if (LHSclass.isInterface()) {
@@ -823,8 +833,12 @@
int LHSDepth = LHSclass.getTypeDepth();
int LHSId = LHSclass.getId();
OPT_RegisterOperand superclassIds;
+ OPT_RegisterOperand cls = null;
if(VM.BuildForJNode) {
- superclassIds =
+ if(s.getOpcode()==INSTANCEOF_UNRESOLVED_opcode) {
+ cls = resolveJnodeClass(LHSclass, continueAt, ir);
+ }
+ superclassIds =
InsertUnary(continueAt, ir, GET_SUPERCLASS_IDS_FROM_TIB,
VM_TypeReference.IntArray, RHStib);
}
@@ -852,25 +866,26 @@
}
OPT_Operand cmpWith;
OPT_LocationOperand loc;
- OPT_RegisterOperand refCandidate;
Offset supOffset;
+ OPT_RegisterOperand refCandidate = null;
if(VM.BuildForJNode) {
cmpWith = ir.regpool.makeTempInt();
OPT_RegisterOperand jtoc = ir.regpool.makeTempInt();
- Offset clsOffset = LHSclass.getTibOffset();
+ loc = new OPT_LocationOperand(VM_TypeReference.Int);
supOffset = Offset.fromIntZeroExtend(LHSDepth << LOG_BYTES_IN_INT)
- .add(VM_ObjectModel.getArrayDataOffset());
- loc = new OPT_LocationOperand(VM_TypeReference.Int);
- continueAt.insertBefore(JnodeMagic.create(JNODE_SHARED_STATICS, jtoc));
- OPT_RegisterOperand cls = InsertLoadOffset(continueAt, ir, INT_LOAD, VM_TypeReference.Int,
- jtoc, clsOffset, loc, TG());
+ .add(VM_ObjectModel.getArrayDataOffset());
+ if(s.getOpcode()!=INSTANCEOF_UNRESOLVED_opcode) {
+ Offset clsOffset = LHSclass.getTibOffset();
+ continueAt.insertBefore(JnodeMagic.create(JNODE_SHARED_STATICS, jtoc));
+ cls = InsertLoadOffset(continueAt, ir, INT_LOAD, VM_TypeReference.Int,
+ jtoc, clsOffset, loc, TG());
+ }
continueAt.insertBefore(Move.create(INT_MOVE, cmpWith.asRegister(), cls));
-
- refCandidate =
- InsertLoadOffset(continueAt, ir, INT_LOAD, VM_TypeReference.Int,
- superclassIds, supOffset,
- new OPT_LocationOperand(VM_TypeReference.Int),
- TG());
+ refCandidate =
+ InsertLoadOffset(continueAt, ir, INT_LOAD, VM_TypeReference.Int,
+ superclassIds, supOffset,
+ new OPT_LocationOperand(VM_TypeReference.Int),
+ TG());
}
else {
cmpWith = IC(LHSId);
@@ -883,7 +898,7 @@
TG());
}
continueAt.insertBefore(IfCmp.create(INT_IFCMP, oldGuard,
- refCandidate, cmpWith,
+ refCandidate, cmpWith.copy(),
OPT_ConditionOperand.NOT_EQUAL(),
falseBlock.makeJumpTarget(),
falseProb));
@@ -911,71 +926,137 @@
}
}
- if (LHStype.isArrayType()) {
+ if (LHStype.isArrayType()
+ || (VM.BuildForJNode && LHStype.peekResolvedType().isInterface())) {
// Case 2 of VM_DynamicTypeCheck: LHS is an array.
- VM_Array LHSArray = (VM_Array)LHStype.peekResolvedType();
+ VM_Type LHSArray = LHStype.peekResolvedType();
if (LHSArray != null) {
OPT_Operand classTIB = getTIB(continueAt, ir, LHSArray);
- VM_Type innermostElementType = LHSArray.getInnermostElementType();
- if (innermostElementType.isPrimitiveType() ||
- (innermostElementType.asClass().isResolved() &&
- innermostElementType.asClass().isFinal())) {
- // [^k of primitive or [^k of final class. Just like final classes,
- // a PTR compare of rhsTIB and the TIB of the class gives the answer.
- continueAt.insertBefore(IfCmp.create(REF_IFCMP, oldGuard,
- RHStib, classTIB,
- OPT_ConditionOperand.NOT_EQUAL(),
- falseBlock.makeJumpTarget(),
- falseProb));
- return continueAt;
+ if(LHStype.isArrayType()) {
+ VM_Type innermostElementType = ((VM_Array)LHSArray).getInnermostElementType();
+ if (innermostElementType.isPrimitiveType() ||
+ (innermostElementType.asClass().isResolved() &&
+ innermostElementType.asClass().isFinal())) {
+ // [^k of primitive or [^k of final class. Just like final classes,
+ // a PTR compare of rhsTIB and the TIB of the class gives the answer.
+ continueAt.insertBefore(IfCmp.create(REF_IFCMP, oldGuard,
+ RHStib, classTIB,
+ OPT_ConditionOperand.NOT_EQUAL(),
+ falseBlock.makeJumpTarget(),
+ falseProb));
+ return continueAt;
+ }
}
- // TODO: branch probability calculation is somewhat bogus for this case.
- OPT_Instruction shortcircuit =
- IfCmp.create(REF_IFCMP, oldGuard, RHStib, classTIB,
- OPT_ConditionOperand.EQUAL(),
- trueBlock.makeJumpTarget(),
- new OPT_BranchProfileOperand());
- if (oldGuard != null)
- oldGuard = oldGuard.copyD2D();
- continueAt.insertBefore(shortcircuit);
- OPT_BasicBlock myBlock = shortcircuit.getBasicBlock();
- OPT_BasicBlock mainBlock =
- myBlock.splitNodeWithLinksAt(shortcircuit, ir);
- myBlock.insertOut(trueBlock); // must come after the splitNodeAt
- OPT_RegisterOperand rhsType =
- InsertUnary(continueAt, ir, GET_TYPE_FROM_TIB,
- VM_TypeReference.VM_Type, RHStib.copyD2U());
- if (innermostElementType.isJavaLangObjectType()) {
- OPT_IntConstantOperand lhsDimension = IC(LHStype.getDimensionality());
- OPT_RegisterOperand rhsDimension =
- getField(continueAt, ir, rhsType, VM_Entrypoints.dimensionField);
- OPT_Instruction dimTest =
- IfCmp2.create(INT_IFCMP2, oldGuard, rhsDimension, lhsDimension,
- OPT_ConditionOperand.GREATER(),
- trueBlock.makeJumpTarget(),
- ((OPT_BranchProfileOperand)falseProb.copy()).flip(),
- OPT_ConditionOperand.LESS(),
- falseBlock.makeJumpTarget(),
- (OPT_BranchProfileOperand)falseProb.copy());
- if (oldGuard != null)
- oldGuard = oldGuard.copyD2D();
- continueAt.insertBefore(dimTest);
- OPT_BasicBlock testBlock =
- mainBlock.splitNodeWithLinksAt(dimTest, ir);
- mainBlock.insertOut(trueBlock);
- mainBlock.insertOut(falseBlock);
- OPT_RegisterOperand rhsInnermostElementType =
- getField(continueAt,ir,rhsType.copyU2U(),VM_Entrypoints.innermostElementTypeField);
- OPT_RegisterOperand rhsInnermostElementTypeDimension =
- getField(continueAt, ir, rhsInnermostElementType, VM_Entrypoints.dimensionField);
- continueAt.insertBefore(IfCmp.create(INT_IFCMP, oldGuard,
- rhsInnermostElementTypeDimension,
- IC(0),
- OPT_ConditionOperand.NOT_EQUAL(),
- falseBlock.makeJumpTarget(),
- falseProb));
- return continueAt;
+ if(VM.BuildForJNode) {
+ OPT_RegisterOperand superclassIds =
+ InsertUnary(continueAt, ir, GET_SUPERCLASS_IDS_FROM_TIB,
+ VM_TypeReference.IntArray, RHStib.copy());
+ OPT_RegisterOperand superclassIdsLength =
+ InsertGuardedUnary(continueAt,
+ ir, ARRAYLENGTH, VM_TypeReference.Int,
+ superclassIds, TG());
+
+ //------------------Begin loop---------------------------//
+ OPT_BasicBlock oldBlock = continueAt.getBasicBlock();
+ OPT_BasicBlock loopBlock = oldBlock.splitNodeWithLinksAt(continueAt.prevInstructionInCodeOrder(), ir);
+
+ OPT_RegisterOperand temp = ir.regpool.makeTempInt();
+ OPT_RegisterOperand lastSuperClassAddr = ir.regpool.makeTempInt();
+ OPT_RegisterOperand currentSuperClass = ir.regpool.makeTempInt();
+
+ continueAt.insertBefore(Binary.create(INT_MUL, temp,
+ superclassIdsLength.copy(), IC(BYTES_IN_INT)));
+
+ continueAt.insertBefore(Binary.create(INT_ADD, lastSuperClassAddr,
+ temp.copy(), IC(VM_Array.DATA_OFFSET*BYTES_IN_INT)));
+
+ continueAt.insertBefore(Load.create(INT_LOAD,
+ currentSuperClass, superclassIds.copy(), lastSuperClassAddr, null));
+
+ continueAt.insertBefore(IfCmp.create(REF_IFCMP, oldGuard,
+ currentSuperClass.copy(), classTIB,
+ OPT_ConditionOperand.EQUAL(),
+ trueBlock.makeJumpTarget(),
+ new OPT_BranchProfileOperand()));
+
+ continueAt.insertBefore(Binary.create(INT_SUB, temp.copyRO(),
+ temp.copy(), IC(BYTES_IN_ADDRESS)));
+
+ continueAt.insertBefore(Binary.create(INT_SUB, superclassIdsLength.copyRO(),
+ superclassIdsLength.copy(), IC(1)));
+
+ continueAt.insertBefore(IfCmp.create(INT_IFCMP, oldGuard,
+ superclassIdsLength.copy(), IC(0),
+ OPT_ConditionOperand.EQUAL(),
+ falseBlock.makeJumpTarget(),
+ (OPT_BranchProfileOperand)falseProb.copy()));
+ continueAt.insertBefore(IfCmp.create(INT_IFCMP, oldGuard,
+ superclassIdsLength.copy(), IC(0),
+ OPT_ConditionOperand.NOT_EQUAL(),
+ loopBlock.makeJumpTarget(),
+ (OPT_BranchProfileOperand)falseProb.copy()));
+ //continueAt.insertBefore(Goto.create(GOTO, loopBlock.makeJumpTarget()));
+ //Goto.mutate(continueAt, GOTO, trueBlock.makeJumpTarget());
+ continueAt.remove();
+
+
+ loopBlock.insertOut(trueBlock);
+ loopBlock.insertOut(falseBlock);
+ loopBlock.insertOut(loopBlock);
+ return loopBlock.lastRealInstruction();//continueAt;
+
+
}
+ else {
+ VM_Type innermostElementType = ((VM_Array)LHSArray).getInnermostElementType();
+ // TODO: branch probability calculation is somewhat bogus for this case.
+ OPT_Instruction shortcircuit =
+ IfCmp.create(REF_IFCMP, oldGuard, RHStib, classTIB,
+ OPT_ConditionOperand.EQUAL(),
+ trueBlock.makeJumpTarget(),
+ new OPT_BranchProfileOperand());
+ if (oldGuard != null)
+ oldGuard = oldGuard.copyD2D();
+ continueAt.insertBefore(shortcircuit);
+ OPT_BasicBlock myBlock = shortcircuit.getBasicBlock();
+ OPT_BasicBlock mainBlock =
+ myBlock.splitNodeWithLinksAt(shortcircuit, ir);
+ myBlock.insertOut(trueBlock); // must come after the splitNodeAt
+ OPT_RegisterOperand rhsType =
+ InsertUnary(continueAt, ir, GET_TYPE_FROM_TIB,
+ VM_TypeReference.VM_Type, RHStib.copyD2U());
+ if (innermostElementType.isJavaLangObjectType()) {
+ OPT_IntConstantOperand lhsDimension = IC(LHStype.getDimensionality());
+ OPT_RegisterOperand rhsDimension =
+ getField(continueAt, ir, rhsType, VM_Entrypoints.dimensionField);
+ OPT_Instruction dimTest =
+ IfCmp2.create(INT_IFCMP2, oldGuard, rhsDimension, lhsDimension,
+ OPT_ConditionOperand.GREATER(),
+ trueBlock.makeJumpTarget(),
+ ((OPT_BranchProfileOperand)falseProb.copy()).flip(),
+ OPT_ConditionOperand.LESS(),
+ falseBlock.makeJumpTarget(),
+ (OPT_BranchProfileOperand)falseProb.copy());
+ if (oldGuard != null)
+ oldGuard = oldGuard.copyD2D();
+ continueAt.insertBefore(dimTest);
+ OPT_BasicBlock testBlock =
+ mainBlock.splitNodeWithLinksAt(dimTest, ir);
+ mainBlock.insertOut(trueBlock);
+ mainBlock.insertOut(falseBlock);
+ OPT_RegisterOperand rhsInnermostElementType =
+ getField(continueAt,ir,rhsType.copyU2U(),VM_Entrypoints.innermostElementTypeField);
+ OPT_RegisterOperand rhsInnermostElementTypeDimension =
+ getField(continueAt, ir, rhsInnermostElementType, VM_Entrypoints.dimensionField);
+ continueAt.insertBefore(IfCmp.create(INT_IFCMP, oldGuard,
+ rhsInnermostElementTypeDimension,
+ IC(0),
+ OPT_ConditionOperand.NOT_EQUAL(),
+ falseBlock.makeJumpTarget(...
[truncated message content] |