From a51b7a088f57f6c199c2bb18121f158014ddcb6f Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 23 Apr 2009 12:09:17 +0100 Subject: [PATCH] Support for building the DBT/PearColator project into MRP. --- build.xml | 19 ++++- rvm/src/Dummy.java | 1 + .../jikesrvm/classloader/NormalMethod.java | 70 +++++++++++++------ .../org/jikesrvm/classloader/RVMMethod.java | 2 +- .../jikesrvm/compilers/opt/bc2ir/BC2IR.java | 7 +- .../opt/bc2ir/GenerationContext.java | 2 +- 6 files changed, 73 insertions(+), 28 deletions(-) diff --git a/build.xml b/build.xml index e8921a917..bfc3127ce 100755 --- a/build.xml +++ b/build.xml @@ -1212,7 +1212,7 @@ Check to make sure all required properties are specified. This includes properti - + @@ -1290,7 +1290,9 @@ Check to make sure all required properties are specified. This includes properti - + + + @@ -1917,6 +1919,19 @@ const char *rvm_target_configuration = "${target.file}"; + + + + + + + + + + + diff --git a/rvm/src/Dummy.java b/rvm/src/Dummy.java index c84e68652..0070217d8 100644 --- a/rvm/src/Dummy.java +++ b/rvm/src/Dummy.java @@ -39,4 +39,5 @@ class Dummy { static org.vmmagic.unboxed.WordArray x; static org.vmmagic.unboxed.OffsetArray y; static org.vmmagic.unboxed.ExtentArray z; + static org.jikesrvm.ppc.Disassembler project1; // needed by projects/dbt } diff --git a/rvm/src/org/jikesrvm/classloader/NormalMethod.java b/rvm/src/org/jikesrvm/classloader/NormalMethod.java index 9d9df281f..d60f0ca18 100644 --- a/rvm/src/org/jikesrvm/classloader/NormalMethod.java +++ b/rvm/src/org/jikesrvm/classloader/NormalMethod.java @@ -16,6 +16,9 @@ import org.jikesrvm.compilers.common.BootImageCompiler; import org.jikesrvm.compilers.common.CompiledMethod; import org.jikesrvm.compilers.common.RuntimeCompiler; +import org.jikesrvm.compilers.opt.bc2ir.BC2IR; +import org.jikesrvm.compilers.opt.bc2ir.GenerationContext; +import org.jikesrvm.compilers.opt.ir.HIRGenerator; import org.jikesrvm.runtime.DynamicLink; import org.jikesrvm.util.HashMapRVM; import org.vmmagic.pragma.Uninterruptible; @@ -23,7 +26,7 @@ /** * A method of a java class that has bytecodes. */ -public final class NormalMethod extends RVMMethod implements BytecodeConstants { +public class NormalMethod extends RVMMethod implements BytecodeConstants { /* As we read the bytecodes for the method, we compute * a simple summary of some interesting properties of the method. @@ -68,29 +71,29 @@ public final class NormalMethod extends RVMMethod implements BytecodeConstants { public static final int SWITCH_COST = CALL_COST; // Definition of flag bits - private static final char HAS_MAGIC = 0x8000; - private static final char HAS_SYNCH = 0x4000; - private static final char HAS_ALLOCATION = 0x2000; - private static final char HAS_THROW = 0x1000; - private static final char HAS_INVOKE = 0x0800; - private static final char HAS_FIELD_READ = 0x0400; - private static final char HAS_FIELD_WRITE = 0x0200; - private static final char HAS_ARRAY_READ = 0x0100; - private static final char HAS_ARRAY_WRITE = 0x0080; - private static final char HAS_JSR = 0x0040; - private static final char HAS_COND_BRANCH = 0x0020; - private static final char HAS_SWITCH = 0x0010; - private static final char HAS_BACK_BRANCH = 0x0008; - private static final char IS_RS_METHOD = 0x0004; + protected static final char HAS_MAGIC = 0x8000; + protected static final char HAS_SYNCH = 0x4000; + protected static final char HAS_ALLOCATION = 0x2000; + protected static final char HAS_THROW = 0x1000; + protected static final char HAS_INVOKE = 0x0800; + protected static final char HAS_FIELD_READ = 0x0400; + protected static final char HAS_FIELD_WRITE = 0x0200; + protected static final char HAS_ARRAY_READ = 0x0100; + protected static final char HAS_ARRAY_WRITE = 0x0080; + protected static final char HAS_JSR = 0x0040; + protected static final char HAS_COND_BRANCH = 0x0020; + protected static final char HAS_SWITCH = 0x0010; + protected static final char HAS_BACK_BRANCH = 0x0008; + protected static final char IS_RS_METHOD = 0x0004; /** * storage for bytecode summary flags */ - private char summaryFlags; + protected char summaryFlags; /** * storage for bytecode summary size */ - private char summarySize; + protected char summarySize; /** * words needed for local variables (including parameters) @@ -159,9 +162,12 @@ public final class NormalMethod extends RVMMethod implements BytecodeConstants { * @param parameterAnnotations array of runtime visible paramter annotations * @param ad annotation default value for that appears in annotation classes */ - NormalMethod(TypeReference dc, MemberReference mr, short mo, TypeReference[] et, short lw, short ow, - byte[] bc, ExceptionHandlerMap eMap, int[] lm, LocalVariableTable lvt, int[] constantPool, Atom sig, - RVMAnnotation[] annotations, RVMAnnotation[][] parameterAnnotations, Object ad) { + protected NormalMethod(TypeReference dc, MemberReference mr, short mo, + TypeReference[] et, short lw, short ow, + byte[] bc, ExceptionHandlerMap eMap, int[] lm, + LocalVariableTable lvt, int[] constantPool, Atom sig, + RVMAnnotation[] annotations, RVMAnnotation[][] parameterAnnotations, + Object ad) { super(dc, mr, mo, et, sig, annotations, parameterAnnotations, ad); localWords = lw; operandWords = ow; @@ -213,7 +219,7 @@ public BytecodeStream getBytecodes() { * @param dynamicLink the dynamicLink object to initialize * @param bcIndex the bcIndex of the invoke instruction */ - @Uninterruptible + @Uninterruptible("Called from within GC map iterators") public void getDynamicLink(DynamicLink dynamicLink, int bcIndex) { if (VM.VerifyAssertions) VM._assert(bytecodes != null); if (VM.VerifyAssertions) VM._assert(bcIndex + 2 < bytecodes.length); @@ -799,4 +805,26 @@ private void computeSummary(int[] constantPool) { public LocalVariableTable getLocalVariableTable() { return localVariableTables.get(this); } + + /** + * Create an optimizing compiler HIR code generator for this type of method + * + * @param context + * the generation context for the HIR generation + * @return a HIR generator + */ + public HIRGenerator createHIRGenerator(GenerationContext context) { + return new BC2IR(context); + } + + /** + * Must this method be OPT compiled? + * + * @param context + * the generation context for the HIR generation + * @return a HIR generator + */ + public boolean optCompileOnly() { + return false; + } } diff --git a/rvm/src/org/jikesrvm/classloader/RVMMethod.java b/rvm/src/org/jikesrvm/classloader/RVMMethod.java index 5b31e72b7..4b6a8a569 100644 --- a/rvm/src/org/jikesrvm/classloader/RVMMethod.java +++ b/rvm/src/org/jikesrvm/classloader/RVMMethod.java @@ -755,7 +755,7 @@ public final synchronized void compile() { * ("type information blocks") * for this class and its subclasses */ - public final synchronized void replaceCompiledMethod(CompiledMethod compiledMethod) { + public synchronized void replaceCompiledMethod(CompiledMethod compiledMethod) { if (VM.VerifyAssertions) VM._assert(getDeclaringClass().isInstantiated()); // If we're replacing with a non-null compiledMethod, ensure that is still valid! if (compiledMethod != null) { diff --git a/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java b/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java index 845a1842b..fb589b84f 100644 --- a/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java +++ b/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java @@ -64,6 +64,7 @@ import org.jikesrvm.compilers.opt.ir.Goto; import org.jikesrvm.compilers.opt.ir.GuardedBinary; import org.jikesrvm.compilers.opt.ir.GuardedUnary; +import org.jikesrvm.compilers.opt.ir.HIRGenerator; import org.jikesrvm.compilers.opt.ir.IRTools; import org.jikesrvm.compilers.opt.ir.IfCmp; import org.jikesrvm.compilers.opt.ir.InstanceOf; @@ -149,7 +150,7 @@ * @see ConvertBCtoHIR */ public final class BC2IR - implements IRGenOptions, Operators, BytecodeConstants, ClassLoaderConstants, OptConstants, OSRConstants { + implements IRGenOptions, Operators, BytecodeConstants, ClassLoaderConstants, OptConstants, OSRConstants, HIRGenerator { /** * Dummy slot. * Used to deal with the fact the longs/doubles take @@ -291,7 +292,7 @@ private BC2IR() {} * * @param context the context to generate HIR into */ - private BC2IR(GenerationContext context) { + public BC2IR(GenerationContext context) { start(context); for (int argIdx = 0, localIdx = 0; argIdx < context.arguments.length;) { TypeReference argType = context.arguments[argIdx].getType(); @@ -358,7 +359,7 @@ private void finish(GenerationContext context) { /** * Main generation loop. */ - private void generateHIR() { + public void generateHIR() { // Constructor initialized generation state to start // generating from bytecode 0, so get the ball rolling. if (DBG_BB || DBG_SELECTED) db("bbl: " + printBlocks()); diff --git a/rvm/src/org/jikesrvm/compilers/opt/bc2ir/GenerationContext.java b/rvm/src/org/jikesrvm/compilers/opt/bc2ir/GenerationContext.java index 53163b34d..f04b6f206 100644 --- a/rvm/src/org/jikesrvm/compilers/opt/bc2ir/GenerationContext.java +++ b/rvm/src/org/jikesrvm/compilers/opt/bc2ir/GenerationContext.java @@ -160,7 +160,7 @@ public final class GenerationContext implements org.jikesrvm.compilers.opt.drive * The Register to which BC2IR should assign the return value(s) * of the method. It will be null when the method has a void return. */ - Register resultReg; + public Register resultReg; /** * The enclosing exception handlers (null if there are none).