From: <mic...@us...> - 2007-08-14 15:32:08
|
Revision: 164 http://pearcolator.svn.sourceforge.net/pearcolator/?rev=164&view=rev Author: michael_baer Date: 2007-08-14 08:32:09 -0700 (Tue, 14 Aug 2007) Log Message: ----------- - Various smaller performance fixes - Added functions to inline a call to CodeTranslator Modified Paths: -------------- src/org/binarytranslator/DBT_Options.java src/org/binarytranslator/Main.java src/org/binarytranslator/arch/arm/decoder/ARM2IR.java src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java src/org/binarytranslator/arch/arm/decoder/ARM_Options.java src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java src/org/binarytranslator/arch/arm/os/abi/semihosting/AngelSystemCalls.java src/org/binarytranslator/arch/arm/os/process/ARM_ProcessSpace.java src/org/binarytranslator/arch/arm/os/process/image/ARM_ImageProcessSpace.java src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java src/org/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace.java src/org/binarytranslator/arch/x86/os/process/X86_ProcessSpace.java src/org/binarytranslator/generic/decoder/CodeTranslator.java src/org/binarytranslator/generic/execution/StagedEmulationController.java src/org/binarytranslator/generic/memory/CallBasedMemory.java src/org/binarytranslator/generic/memory/IntAddressedMemory.java src/org/binarytranslator/generic/memory/IntAddressedPreSwappedMemory.java src/org/binarytranslator/generic/os/loader/elf/ELF_File.java src/org/binarytranslator/generic/os/process/ProcessSpace.java src/org/binarytranslator/vmInterface/DBT_Trace.java Modified: src/org/binarytranslator/DBT_Options.java =================================================================== --- src/org/binarytranslator/DBT_Options.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/DBT_Options.java 2007-08-14 15:32:09 UTC (rev 164) @@ -108,6 +108,9 @@ /** Print out messages from the memory system */ public static boolean debugMemory = false; + + /** Inline calls to descendents of callbased memory? */ + public static boolean inlineCallbasedMemory = false; /** The user ID for the user running the command */ public final static int UID = 1000; @@ -184,7 +187,7 @@ ARM_Options.optimizeTranslationByProfiling = Boolean.parseBoolean(value); } else if (key.equalsIgnoreCase("flagEvaluation")) { ARM_Options.flagEvaluation = ARM_Options.FlagBehaviour.valueOf(value); - } else if (key.equalsIgnoreCase("inlining")) { + } else if (key.equalsIgnoreCase("inline")) { ARM_Options.inlining = ARM_Options.InliningBehaviour.valueOf(value); } else { @@ -229,6 +232,8 @@ saveProfileToFile = value; } else if (key.equalsIgnoreCase("minTraceValue")) { minTraceValue = Integer.parseInt(value); + } else if (key.equalsIgnoreCase("inlineCallbasedMemory")) { + inlineCallbasedMemory = Boolean.parseBoolean(value); } else { throw new Error("Unknown DBT option: " + key); Modified: src/org/binarytranslator/Main.java =================================================================== --- src/org/binarytranslator/Main.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/Main.java 2007-08-14 15:32:09 UTC (rev 164) @@ -85,6 +85,10 @@ System.err.println("The specified executable '" + DBT_Options.executableFile + "' could not be found."); return; } + + if (DBT.VerifyAssertions) { + System.err.println("WARNING: Assertions are enabled."); + } try { report("Loading " + DBT_Options.executableFile); Modified: src/org/binarytranslator/arch/arm/decoder/ARM2IR.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM2IR.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/arm/decoder/ARM2IR.java 2007-08-14 15:32:09 UTC (rev 164) @@ -477,12 +477,27 @@ else return super.inlineBranchInstruction(targetPc, jump); + case FunctionCalls: + if (jump.type == BranchType.CALL) + return true; + else + return super.inlineBranchInstruction(targetPc, jump); + + case FunctionReturns: + if (jump.type == BranchType.CALL) + return true; + else + return super.inlineBranchInstruction(targetPc, jump); + case Functions: if (jump.type == BranchType.CALL || jump.type == BranchType.RETURN) return true; else return super.inlineBranchInstruction(targetPc, jump); + case All: + return true; + default: throw new RuntimeException("Unexpected inlining type."); } @@ -782,6 +797,9 @@ * The operand which is to be rotated. * @param rotation * The amount of rotation that is to be applied to the operand. + * + * @param inline + * Shall the invokation of this rotate right be inlined? */ public void appendRotateRight(OPT_RegisterOperand result, OPT_Operand rotatedOperand, OPT_Operand rotation) { VM_TypeReference IntegerType = VM_TypeReference Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java 2007-08-14 15:32:09 UTC (rev 164) @@ -374,7 +374,7 @@ /** The successor of this instruction, if the condition evaluates to false.*/ private final int conditionFalseSuccessor; - /** The address of the successor of this instrction if it is constant, otherwise -1. */ + /** The address of the successor of this instruction if it is constant, otherwise -1. */ private final int successorInstruction; /** The address of this instruction. */ @@ -406,7 +406,10 @@ } if (successorInstruction != -1) { - ps.branchInfo.profileBranch(instructionAddress, conditionTrueSuccessor); + if (conditionTrueSuccessor == conditionFalseSuccessor) + ps.branchInfo.profileBranch(instructionAddress, instructionAddress); + else + ps.branchInfo.profileBranch(instructionAddress, conditionTrueSuccessor); } } else { Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Options.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Options.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Options.java 2007-08-14 15:32:09 UTC (rev 164) @@ -10,7 +10,10 @@ public enum InliningBehaviour { Default, Functions, - DynamicJumps + FunctionCalls, + FunctionReturns, + DynamicJumps, + All, } /** Set to true to enable a fastpath for the decoding of data processing instructions.. */ @@ -22,5 +25,6 @@ /** This variable describes, if the translated program shall be optimized using lazy evaluation.*/ public static FlagBehaviour flagEvaluation = FlagBehaviour.Lazy; + /** Describes the default behaviour for dealing with ARM function calls and indirect jumps. */ public static InliningBehaviour inlining = InliningBehaviour.Default; } Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java 2007-08-14 15:32:09 UTC (rev 164) @@ -764,7 +764,7 @@ */ private float getSkipProbability() { - if (ARM_Options.optimizeTranslationByProfiling) + if (!ARM_Options.optimizeTranslationByProfiling) return -1f; return ps.branchInfo.getBranchProbability(pc, pc + (inThumb() ? 2 : 4)); @@ -1279,7 +1279,7 @@ } } - /** Subtract. <code>Rd = op1 - op2 </code>.*/ + /** Subtract. <code>Rd = op1 - op2</code>.*/ private final class DataProcessing_Sub extends DataProcessing { public DataProcessing_Sub(ARM_Instructions.DataProcessing instr) { Modified: src/org/binarytranslator/arch/arm/os/abi/semihosting/AngelSystemCalls.java =================================================================== --- src/org/binarytranslator/arch/arm/os/abi/semihosting/AngelSystemCalls.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/arm/os/abi/semihosting/AngelSystemCalls.java 2007-08-14 15:32:09 UTC (rev 164) @@ -48,6 +48,18 @@ /** The directory in which temporary files are created. Note that the path is expected to end with a path delimiter.*/ private final static String TEMP_FILE_DIR = "/tmp/"; + /** The first address on the heap. */ + private int heapBegin; + + /** The last address on the heap. */ + private int heapEnd; + + /** The first address on the stack. */ + private int stackBegin; + + /** The last address on the stack*/ + private int stackEnd; + /** The file handle that is distributed with the next call to {@link #addFile(RandomAccessFile)}. * Valid Angle handles are non-zero values (i.e. >= 1).*/ private int nextFileHandle = 1; @@ -55,7 +67,7 @@ /** */ private AngelSystemCall[] sysCalls; - public AngelSystemCalls(ARM_ProcessSpace ps) { + public AngelSystemCalls(ARM_ProcessSpace ps, int heapBegin, int heapEnd, int stackBegin, int stackEnd) { this.ps = ps; sysCalls = new AngelSystemCall[0x32]; @@ -84,6 +96,12 @@ sysCalls[0x18] = new Sys_Exit(); sysCalls[0x30] = new Sys_Elapsed(); sysCalls[0x31] = new Sys_TickFreq(); + + this.heapBegin = heapBegin; + this.heapEnd = heapEnd; + + this.stackBegin = stackBegin; + this.stackEnd = stackEnd; } public void doSysCall(int callNum) { @@ -128,7 +146,7 @@ } } - private interface AngelFileStream { + private static interface AngelFileStream { boolean isTty(); int getLength(); @@ -143,7 +161,7 @@ void seek(long pos) throws IOException; } - private class ConsoleStream implements AngelFileStream { + private static class ConsoleStream implements AngelFileStream { private String previousInputLine = null; @@ -203,7 +221,7 @@ } } - private class FileStream implements AngelFileStream { + private static class FileStream implements AngelFileStream { private final RandomAccessFile file; @@ -630,11 +648,11 @@ String cmdLine = DBT_Options.executableFile; - if (cmdLine.contains(" ")) + if (cmdLine.contains(" ") && !cmdLine.contains("\"")) cmdLine = '"' + cmdLine + '"'; for(String s : DBT_Options.executableArguments) { - if (s.contains(" ")) { + if (s.contains(" ") && !s.contains("\"")) { s = '"' + s + '"'; } @@ -659,10 +677,10 @@ int ptrParamBlock = ps.registers.get(1); //return that we couldn't calculate any of the requested heap size values - ps.memory.store32(ptrParamBlock, 0); - ps.memory.store32(ptrParamBlock + 4, 0); - ps.memory.store32(ptrParamBlock + 8, 0); - ps.memory.store32(ptrParamBlock + 12, 0); + ps.memory.store32(ptrParamBlock, heapBegin); + ps.memory.store32(ptrParamBlock + 4, heapEnd); + ps.memory.store32(ptrParamBlock + 8, stackBegin); + ps.memory.store32(ptrParamBlock + 12, stackEnd); } } Modified: src/org/binarytranslator/arch/arm/os/process/ARM_ProcessSpace.java =================================================================== --- src/org/binarytranslator/arch/arm/os/process/ARM_ProcessSpace.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/arm/os/process/ARM_ProcessSpace.java 2007-08-14 15:32:09 UTC (rev 164) @@ -9,7 +9,7 @@ import org.binarytranslator.arch.arm.os.process.linux.ARM_LinuxProcessSpace; import org.binarytranslator.generic.decoder.CodeTranslator; import org.binarytranslator.generic.decoder.Interpreter; -import org.binarytranslator.generic.memory.ByteAddressedMemory; +import org.binarytranslator.generic.memory.IntAddressedMemory; import org.binarytranslator.generic.os.loader.Loader; import org.binarytranslator.generic.os.process.ProcessSpace; import org.binarytranslator.vmInterface.DBT_Trace; @@ -38,7 +38,7 @@ protected ARM_ProcessSpace() { registers = new ARM_Registers(); - memory = new ByteAddressedMemory(); + memory = new IntAddressedMemory(); } /** @@ -49,6 +49,7 @@ * the generation context for the HIR generation * @return a HIR generator */ + @Override public CodeTranslator createTranslator(OPT_GenerationContext context, DBT_Trace trace) { return new ARM2IR(context, trace); } Modified: src/org/binarytranslator/arch/arm/os/process/image/ARM_ImageProcessSpace.java =================================================================== --- src/org/binarytranslator/arch/arm/os/process/image/ARM_ImageProcessSpace.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/arm/os/process/image/ARM_ImageProcessSpace.java 2007-08-14 15:32:09 UTC (rev 164) @@ -1,26 +1,55 @@ package org.binarytranslator.arch.arm.os.process.image; import org.binarytranslator.DBT; +import org.binarytranslator.DBT_Options; import org.binarytranslator.arch.arm.decoder.ARM_InstructionDecoder; import org.binarytranslator.arch.arm.decoder.ARM_Instructions; import org.binarytranslator.arch.arm.os.abi.semihosting.AngelSystemCalls; import org.binarytranslator.arch.arm.os.process.ARM_ProcessSpace; import org.binarytranslator.arch.arm.os.process.ARM_Registers; import org.binarytranslator.generic.execution.GdbController.GdbTarget; -import org.binarytranslator.generic.memory.AutoMappingMemory; +import org.binarytranslator.generic.fault.InsufficientMemoryException; import org.binarytranslator.generic.os.loader.Loader; public class ARM_ImageProcessSpace extends ARM_ProcessSpace { - private AngelSystemCalls sysCalls = new AngelSystemCalls(this); + private AngelSystemCalls sysCalls; + private final int STACK_SIZE = 4096 * 10; + private final int HEAP_SIZE = 4096 * 10; public ARM_ImageProcessSpace() { super(); //make sure that pages of memory are automatically mapped in as they are requested. - memory = new AutoMappingMemory(memory); + //memory = new AutoMappingMemory(memory); } + private int allocateFreeMemoryArea(int stackSize) throws InsufficientMemoryException + { + int pagesize = memory.getPageSize(); + int stackStart = -1; + int checkedAddress = stackStart; + + while (checkedAddress < 0 || checkedAddress > pagesize) { + if (memory.isMapped(checkedAddress)) { + //we cannot extend the stack into this page + stackStart = checkedAddress - pagesize; + } + else { + int stackspace = Math.abs(stackStart - checkedAddress) + pagesize; + + if (stackspace >= stackSize) { + memory.ensureMapped(stackStart - stackSize + 1, stackStart); + return stackStart - stackSize + 1; + } + } + + checkedAddress -= pagesize; + } + + throw new InsufficientMemoryException(this, "Allocate free memory area for ARM stack and heap."); + } + @Override public void doSysCall() { @@ -91,6 +120,15 @@ @Override public void initialise(Loader loader) { registers.set(ARM_Registers.PC, loader.getEntryPoint()); + int stackBegin = allocateFreeMemoryArea(STACK_SIZE); + int heapBegin = allocateFreeMemoryArea(HEAP_SIZE); + + if (DBT_Options.debugMemory || DBT_Options.debugLoader) { + System.out.println(String.format("Placing ARM Heap from 0x%x to 0x%x.", heapBegin, heapBegin + HEAP_SIZE - 1)); + System.out.println(String.format("Placing ARM Stack from 0x%x to 0x%x.", stackBegin, stackBegin + STACK_SIZE - 1)); + } + + sysCalls = new AngelSystemCalls(this, heapBegin, heapBegin + HEAP_SIZE, stackBegin, stackBegin + STACK_SIZE); } } Modified: src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java =================================================================== --- src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java 2007-08-14 15:32:09 UTC (rev 164) @@ -29,6 +29,7 @@ import org.jikesrvm.compilers.opt.ir.OPT_AddressConstantOperand; import org.jikesrvm.compilers.opt.ir.OPT_GenerationContext; import org.jikesrvm.compilers.opt.ir.OPT_HIRGenerator; +import org.jikesrvm.compilers.opt.ir.OPT_IR; import org.jikesrvm.compilers.opt.ir.OPT_IntConstantOperand; import org.jikesrvm.compilers.opt.ir.OPT_LocationOperand; import org.jikesrvm.compilers.opt.ir.OPT_Operators; @@ -272,6 +273,18 @@ report("CFG at end of constructor:\n" + gc.cfg); } } + + /** + * Should a trace follow a branch and link instruction or should it terminate + * the trace? + * + * @param pc + * the address of the branch and link instruction + * @return whether the trace should continue + */ + public boolean traceContinuesAfterBranchAndLink(int pc) { + return shallTraceStop() == false; + } /** * Translate the instruction at the given pc Modified: src/org/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace.java =================================================================== --- src/org/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace.java 2007-08-14 15:32:09 UTC (rev 164) @@ -140,6 +140,7 @@ * the generation context for the HIR generation * @return a HIR generator */ + @Override public CodeTranslator createTranslator(OPT_GenerationContext context, DBT_Trace trace) { return new PPC2IR(context, trace); } Modified: src/org/binarytranslator/arch/x86/os/process/X86_ProcessSpace.java =================================================================== --- src/org/binarytranslator/arch/x86/os/process/X86_ProcessSpace.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/arch/x86/os/process/X86_ProcessSpace.java 2007-08-14 15:32:09 UTC (rev 164) @@ -12,7 +12,6 @@ import java.util.Hashtable; import org.jikesrvm.compilers.opt.ir.OPT_GenerationContext; - import org.binarytranslator.DBT_Options; import org.binarytranslator.generic.os.process.ProcessSpace; import org.binarytranslator.generic.memory.ByteAddressedMemory; @@ -149,6 +148,7 @@ * @param context the generation context for the HIR generation * @return a HIR generator */ + @Override public CodeTranslator createTranslator(OPT_GenerationContext context, DBT_Trace trace) { return new X862IR(context, trace); } Modified: src/org/binarytranslator/generic/decoder/CodeTranslator.java =================================================================== --- src/org/binarytranslator/generic/decoder/CodeTranslator.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/generic/decoder/CodeTranslator.java 2007-08-14 15:32:09 UTC (rev 164) @@ -29,6 +29,7 @@ import org.jikesrvm.classloader.VM_MethodReference; import org.jikesrvm.classloader.VM_TypeReference; import org.jikesrvm.compilers.opt.OPT_Constants; +import org.jikesrvm.compilers.opt.OPT_InlineDecision; import org.jikesrvm.compilers.opt.ir.Athrow; import org.jikesrvm.compilers.opt.ir.BBend; import org.jikesrvm.compilers.opt.ir.Call; @@ -45,6 +46,7 @@ import org.jikesrvm.compilers.opt.ir.OPT_ConditionOperand; import org.jikesrvm.compilers.opt.ir.OPT_GenerationContext; import org.jikesrvm.compilers.opt.ir.OPT_HIRGenerator; +import org.jikesrvm.compilers.opt.ir.OPT_Inliner; import org.jikesrvm.compilers.opt.ir.OPT_Instruction; import org.jikesrvm.compilers.opt.ir.OPT_IntConstantOperand; import org.jikesrvm.compilers.opt.ir.OPT_MethodOperand; @@ -130,7 +132,7 @@ public final ProcessSpace ps; /** The VM method's generation context. */ - protected OPT_GenerationContext gc; + protected final OPT_GenerationContext gc; /** The OPT_BasicBlock in which instructions are currently being inserted */ protected OPT_BasicBlock currentBlock; @@ -208,7 +210,7 @@ * @param context * The JRVM generation context for this trace. */ - protected CodeTranslator(OPT_GenerationContext context, + protected CodeTranslator(OPT_GenerationContext context, DBT_Trace trace) { // Store the trace that we're invoked from @@ -284,7 +286,12 @@ printNextBlocks(preFillBlock, 50); } + try { ((DBT_Trace) gc.method).setNumberOfInstructions(numberOfInstructions); + } + catch (ClassCastException e) { + System.err.println("Error casting " + gc.method + " to DBT_Trace."); + } } @@ -531,7 +538,7 @@ /** * Get the generation context. */ - public OPT_GenerationContext getGenerationContext() { + public final OPT_GenerationContext getGenerationContext() { return gc; } @@ -545,7 +552,7 @@ * @param hirBlock * The block that is to be registered. */ - protected void registerMapping(int pc, Laziness lazy, OPT_BasicBlock hirBlock) { + protected final void registerMapping(int pc, Laziness lazy, OPT_BasicBlock hirBlock) { blockMap.put(lazy.makeKey(pc), hirBlock); } @@ -559,7 +566,7 @@ * The lazy state assumed within the returned trace. * @return An appropriate basic block or null if no translation exists. */ - protected OPT_BasicBlock findMapping(int pc, Laziness lazy) { + protected final OPT_BasicBlock findMapping(int pc, Laziness lazy) { return blockMap.get(lazy.makeKey(pc)); } @@ -757,13 +764,24 @@ * within the code cache c) The trace is already too long d) the branch is * supposedly a CALL or RETURN */ + + boolean decision = DBT_Options.singleInstrTranslation == false && jump.type == BranchType.DIRECT_BRANCH && !shallTraceStop(); + if (!decision) { + + if (DBT_Options.debugBranchResolution) { + String text = (!decision ? "Not inlining " : "Inlining "); + text += jump.type + " to 0x" + Integer.toHexString(targetPc); + System.out.println(text); + } + + return false; + } + + //only query the code cache if we have to DBT_Trace compiledTrace = ps.codeCache.tryGet(targetPc); + decision = (compiledTrace == null || compiledTrace.getNumberOfInstructions() < 20) ; - boolean decision = DBT_Options.singleInstrTranslation == false - && (compiledTrace == null || compiledTrace.getNumberOfInstructions() < 20) && !shallTraceStop() - && jump.type != BranchType.CALL && jump.type != BranchType.RETURN; - if (DBT_Options.debugBranchResolution) { String text = (!decision ? "Not inlining " : "Inlining "); text += jump.type + " to 0x" + Integer.toHexString(targetPc); @@ -967,18 +985,6 @@ } /** - * Should a trace follow a branch and link instruction or should it terminate - * the trace? - * - * @param pc - * the address of the branch and link instruction - * @return whether the trace should continue - */ - public boolean traceContinuesAfterBranchAndLink(int pc) { - return shallTraceStop() == false; - } - - /** * Load all the registers from the ProcessSpace into the pre-fill block */ private void preFillAllRegisters() { @@ -1169,6 +1175,7 @@ if (intTemps == null) { intTemps = new OPT_Register[10]; } + OPT_Register result = intTemps[num]; if (result == null) { OPT_RegisterOperand regOp = gc.temps.makeTempInt(); @@ -1459,7 +1466,60 @@ callInstruction.bcIndex = trace.registerDynamicLink(methodRef, callType); appendInstruction(callInstruction); } + + /** + * Execute an inlining decision inlDec for the CALL instruction + * callSite that is contained in ir. + * + * @param inlDec the inlining decision to execute + * @param ir the governing IR + * @param callSite the call site to inline + */ + public void appendInlinedCall(OPT_Instruction callSite) { + + if (DBT.VerifyAssertions) + DBT._assert(Call.conforms(callSite)); + + OPT_BasicBlock next = createBlockAfterCurrent(); + + //Find out where the call site is and isolate it in its own basic block. + currentBlock = createBlockAfterCurrent(); + currentBlock.appendInstruction(callSite); + + OPT_BasicBlock in = currentBlock.prevBasicBlockInCodeOrder(); + OPT_BasicBlock out = currentBlock.nextBasicBlockInCodeOrder(); + + // Clear the sratch object of any register operands being + // passed as parameters. + // BC2IR uses this field for its own purposes, and will be confused + // if the scratch object has been used by someone else and not cleared. + for (int i = 0; i < Call.getNumberOfParams(callSite); i++) { + OPT_Operand arg = Call.getParam(callSite, i); + if (arg instanceof OPT_RegisterOperand) { + ((OPT_RegisterOperand) arg).scratchObject = null; + } + } + // Execute the inlining decision, updating ir.gc's state. + OPT_InlineDecision inlDec = OPT_InlineDecision.YES(Call.getMethod(callSite).getTarget(), ""); + OPT_GenerationContext childgc = OPT_Inliner.execute(inlDec, gc, null, callSite); + + // Splice the callee into the caller's code order + gc.cfg.removeFromCFGAndCodeOrder(currentBlock); + gc.cfg.breakCodeOrder(in, out); + gc.cfg.linkInCodeOrder(in, childgc.cfg.firstInCodeOrder()); + gc.cfg.linkInCodeOrder(childgc.cfg.lastInCodeOrder(), out); + + // Splice the callee into the caller's CFG + in.insertOut(childgc.prologue); + + if (childgc.epilogue != null) { + childgc.epilogue.insertOut(out); + } + + currentBlock = next; + } + /** Report some debug output */ protected abstract void report(String str); @@ -1470,8 +1530,7 @@ * Plant instructions modifying a lazy state into one with no laziness * * @param laziness - * the laziness to modify - */ + * the laziness to modify */ public abstract void resolveLaziness(Laziness laziness); /** @@ -1481,20 +1540,17 @@ * the status of the lazy evaluation * @param pc * the program counter for the instruction - * @return the next instruction address or -1 - */ + * @return the next instruction address or -1 */ protected abstract int translateInstruction(Laziness lazy, int pc); /** * Fill all the registers from the ProcessSpace, that is take the register - * values from the process space and place them in the traces registers. - */ + * values from the process space and place them in the traces registers. */ protected abstract void fillAllRegisters(); /** * Spill all the registers, that is put them from the current running trace - * into the process space - */ + * into the process space. */ protected abstract void spillAllRegisters(); /** Return an array of unused registers */ Modified: src/org/binarytranslator/generic/execution/StagedEmulationController.java =================================================================== --- src/org/binarytranslator/generic/execution/StagedEmulationController.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/generic/execution/StagedEmulationController.java 2007-08-14 15:32:09 UTC (rev 164) @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.TreeMap; import org.binarytranslator.DBT; import org.binarytranslator.DBT_Options; @@ -38,7 +39,7 @@ } /** Maps a dynamic basic block to the address of the first instruction within that block. */ - private final HashMap<Integer, DynamicBasicBlock> traceCache = new HashMap<Integer, DynamicBasicBlock>(); + private final TreeMap<Integer, DynamicBasicBlock> traceCache = new TreeMap<Integer, DynamicBasicBlock>(); /** The interpreter that is used to perform the actual execution of single instructions. */ private final Interpreter interpreter; @@ -70,10 +71,13 @@ //No, so stop and create a trace from the decoded instructions DynamicBasicBlock newTrace = new DynamicBasicBlock(instructions); - if (instructions.size() > 3) { +// add this trace to the trace cache + traceCache.put(traceStart, newTrace); + + /*if (instructions.size() > 3) { //add this trace to the trace cache, if it contains enough instructions traceCache.put(traceStart, newTrace); - } + }*/ return newTrace; } @@ -94,6 +98,8 @@ trace.compiledTrace = new DBT_Trace(ps, pc); trace.compiledTrace.compile(); trace.instructions = null; + + ps.codeCache.add(pc, trace.compiledTrace); } /** Modified: src/org/binarytranslator/generic/memory/CallBasedMemory.java =================================================================== --- src/org/binarytranslator/generic/memory/CallBasedMemory.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/generic/memory/CallBasedMemory.java 2007-08-14 15:32:09 UTC (rev 164) @@ -99,7 +99,7 @@ /** * A translation helper for generating code */ - protected CodeTranslator helper; + protected CodeTranslator translator; /** * The generation context we're translating within @@ -162,7 +162,7 @@ * page table into a register */ public void initTranslate(CodeTranslator helper) { - this.helper = helper; + this.translator = helper; this.gc = helper.getGenerationContext(); OPT_RegisterOperand memoryOp = helper.makeTemp(memoryType); helper.appendInstruction(GetField.create(GETFIELD, memoryOp, @@ -187,21 +187,27 @@ */ private void translateLoad(VM_Method loadMethod, int bcIndex, OPT_Operand addr, OPT_RegisterOperand dest) { - OPT_Instruction s = Call.create(CALL, dest, null, null, null, 2); + OPT_Instruction s = Call.create(CALL, dest.copyRO(), null, null, null, 2); VM_MethodReference loadMethRef = loadMethod.getMemberRef() .asMethodReference(); - OPT_MethodOperand methOp = OPT_MethodOperand.VIRTUAL(loadMethRef, - loadMethod); + OPT_MethodOperand methOp = OPT_MethodOperand.VIRTUAL(loadMethRef, loadMethod); OPT_RegisterOperand memoryOp = new OPT_RegisterOperand(memory, memoryType); Call.setParam(s, 0, memoryOp); // Sets 'this' pointer - Call.setParam(s, 1, addr); + Call.setParam(s, 1, addr.copy()); Call.setGuard(s, new OPT_TrueGuardOperand()); Call.setMethod(s, methOp); Call.setAddress(s, new OPT_AddressConstantOperand(loadMethod.getOffset())); - s.position = gc.inlineSequence; - s.bcIndex = bcIndex; - helper.appendInstruction(s); + + if (DBT_Options.inlineCallbasedMemory) { + translator.appendInlinedCall(s); + } + else + { + s.position = gc.inlineSequence; + s.bcIndex = bcIndex; + translator.appendInstruction(s); + } } /** @@ -335,14 +341,21 @@ storeMethod); OPT_RegisterOperand memoryOp = new OPT_RegisterOperand(memory, memoryType); Call.setParam(s, 0, memoryOp); // Sets 'this' pointer - Call.setParam(s, 1, addr); - Call.setParam(s, 2, src); + Call.setParam(s, 1, addr.copy()); + Call.setParam(s, 2, src.copy()); Call.setGuard(s, new OPT_TrueGuardOperand()); Call.setMethod(s, methOp); Call.setAddress(s, new OPT_AddressConstantOperand(storeMethod.getOffset())); - s.position = gc.inlineSequence; - s.bcIndex = bcIndex; - helper.appendInstruction(s); + + if (DBT_Options.inlineCallbasedMemory) { + translator.appendInlinedCall(s); + } + else + { + s.position = gc.inlineSequence; + s.bcIndex = bcIndex; + translator.appendInstruction(s); + } } /** Modified: src/org/binarytranslator/generic/memory/IntAddressedMemory.java =================================================================== --- src/org/binarytranslator/generic/memory/IntAddressedMemory.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/generic/memory/IntAddressedMemory.java 2007-08-14 15:32:09 UTC (rev 164) @@ -14,6 +14,7 @@ import org.binarytranslator.DBT_Options; import org.binarytranslator.generic.fault.SegmentationFault; import org.jikesrvm.VM_Configuration; +import org.vmmagic.pragma.Inline; /** * IntAddressedMemory: @@ -85,6 +86,7 @@ /** * Return the offset part of the address */ + @Inline protected int getOffset(int address) { return (address & (PAGE_SIZE - 1)) >>> 2; } @@ -92,6 +94,7 @@ /** * Return the page table entry part of the address */ + @Inline private static final int getPTE(int address) { return address >>> OFFSET_BITS; } @@ -311,9 +314,10 @@ MemoryMapException.unalignedAddress(addr); } // Check file offset is page aligned - if ((offset % PAGE_SIZE) != 0) { + /*if ((offset % PAGE_SIZE) != 0) { MemoryMapException.unalignedFileOffset(offset); - } + }*/ + if (DBT_Options.debugRuntime) { System.out.println("Mapping file " + file + " offset=" + offset + " addr=0x" + Integer.toHexString(addr) + " len=" + len Modified: src/org/binarytranslator/generic/memory/IntAddressedPreSwappedMemory.java =================================================================== --- src/org/binarytranslator/generic/memory/IntAddressedPreSwappedMemory.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/generic/memory/IntAddressedPreSwappedMemory.java 2007-08-14 15:32:09 UTC (rev 164) @@ -420,29 +420,29 @@ // Extract the memory page number from addr. OPT_RegisterOperand vpnRegOp = new OPT_RegisterOperand(vpnReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_USHR, vpnRegOp, + translator.appendInstruction(Binary.create(INT_USHR, vpnRegOp, addr, new OPT_IntConstantOperand(OFFSET_BITS))); // Extract the location of the address within the page. OPT_RegisterOperand offsetRegOp = new OPT_RegisterOperand(offsetReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_AND, offsetRegOp, + translator.appendInstruction(Binary.create(INT_AND, offsetRegOp, addr.copyRO(), new OPT_IntConstantOperand(PAGE_SIZE - 1))); - helper.appendInstruction(Binary.create(INT_USHR, offsetRegOp + translator.appendInstruction(Binary.create(INT_USHR, offsetRegOp .copyRO(), offsetRegOp.copyRO(), new OPT_IntConstantOperand(2))); // Retrieve the int[] for the correct page into pageReg. OPT_RegisterOperand pageRegOp = new OPT_RegisterOperand(pageReg, VM_TypeReference.IntArray); - helper.appendInstruction(ALoad.create(REF_ALOAD, pageRegOp, + translator.appendInstruction(ALoad.create(REF_ALOAD, pageRegOp, new OPT_RegisterOperand(readableMemoryReg, VM_TypeReference.ObjectReferenceArray), vpnRegOp.copyRO(), new OPT_LocationOperand(VM_TypeReference.IntArray), new OPT_TrueGuardOperand())); // Copy to reg from the correct array element. - helper.appendInstruction(ALoad.create(INT_ALOAD, dest, + translator.appendInstruction(ALoad.create(INT_ALOAD, dest, pageRegOp.copyRO(), offsetRegOp.copyRO(), new OPT_LocationOperand( VM_TypeReference.Int), new OPT_TrueGuardOperand())); } @@ -461,15 +461,15 @@ // Load as 32-bit then mask out what we need translateAlignedLoad32(addr, dest); // addr = (addr & 0x3) * 8 - helper.appendInstruction(Binary.create(INT_AND, + translator.appendInstruction(Binary.create(INT_AND, addr.copyRO(), addr.copyRO(), new OPT_IntConstantOperand(3))); - helper.appendInstruction(Binary.create(INT_SHL, + translator.appendInstruction(Binary.create(INT_SHL, addr.copyRO(), addr.copyRO(), new OPT_IntConstantOperand(3))); // rD <<= addr - helper.appendInstruction(Binary.create(INT_SHL, + translator.appendInstruction(Binary.create(INT_SHL, dest.copyRO(), dest.copyRO(), addr.copyRO())); // rD >>>= 24 - helper.appendInstruction(Binary.create(INT_USHR, dest + translator.appendInstruction(Binary.create(INT_USHR, dest .copyRO(), dest.copyRO(), new OPT_IntConstantOperand(24))); } @@ -487,17 +487,17 @@ // Load as 32-bit then mask out what we need translateAlignedLoad32(addr, dest); // addr = (3 - (addr & 0x3)) * 8 - helper.appendInstruction(Binary.create(INT_AND, + translator.appendInstruction(Binary.create(INT_AND, addr.copyRO(), addr.copyRO(), new OPT_IntConstantOperand(3))); - helper.appendInstruction(Binary.create(INT_SUB, + translator.appendInstruction(Binary.create(INT_SUB, addr.copyRO(), new OPT_IntConstantOperand(3), addr.copyRO())); - helper.appendInstruction(Binary.create(INT_SHL, + translator.appendInstruction(Binary.create(INT_SHL, addr.copyRO(), addr.copyRO(), new OPT_IntConstantOperand(3))); // rD >>>= addr - helper.appendInstruction(Binary.create(INT_USHR, dest + translator.appendInstruction(Binary.create(INT_USHR, dest .copyRO(), dest.copyRO(), addr.copyRO())); // rD &= 0xff - helper.appendInstruction(Binary.create(INT_AND, + translator.appendInstruction(Binary.create(INT_AND, dest.copyRO(), dest.copyRO(), new OPT_IntConstantOperand(0xff))); } @@ -514,43 +514,43 @@ OPT_RegisterOperand dest) { // The block after this load - NB could still need to plant an update for // this instruction in here - OPT_BasicBlock nextBlock = helper.createBlockAfterCurrent(); + OPT_BasicBlock nextBlock = translator.createBlockAfterCurrent(); // Put call based version for (addr & 3 == 3) in aligned3 - OPT_BasicBlock aligned3 = helper.createBlockAfterCurrent(); + OPT_BasicBlock aligned3 = translator.createBlockAfterCurrent(); // Put all other cases in aligned - OPT_BasicBlock aligned = helper.createBlockAfterCurrent(); + OPT_BasicBlock aligned = translator.createBlockAfterCurrent(); // Compute tempReg = addr & 3 OPT_RegisterOperand tempRegOp = new OPT_RegisterOperand(tempReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_AND, tempRegOp, + translator.appendInstruction(Binary.create(INT_AND, tempRegOp, addr.copyRO(), new OPT_IntConstantOperand(0x3))); // Create if (addr & 3) == 3 goto aligned3 - helper.appendInstruction(IfCmp.create(INT_IFCMP, null, + translator.appendInstruction(IfCmp.create(INT_IFCMP, null, tempRegOp.copyRO(), new OPT_IntConstantOperand(0x3), - OPT_ConditionOperand.EQUAL(), aligned3.makeJumpTarget(), helper + OPT_ConditionOperand.EQUAL(), aligned3.makeJumpTarget(), translator .getConditionalBranchProfileOperand(false))); - helper.getCurrentBlock().insertOut(aligned3); + translator.getCurrentBlock().insertOut(aligned3); // Create aligned code - helper.setCurrentBlock(aligned); + translator.setCurrentBlock(aligned); translateAlignedLoad32(addr, dest); // tempReg = (addr & 0x3) * 8 - helper.appendInstruction(Binary.create(INT_SHL, tempRegOp + translator.appendInstruction(Binary.create(INT_SHL, tempRegOp .copyRO(), tempRegOp.copyRO(), new OPT_IntConstantOperand(3))); // rD <<= tempReg - helper.appendInstruction(Binary.create(INT_SHL, + translator.appendInstruction(Binary.create(INT_SHL, dest.copyRO(), dest.copyRO(), tempRegOp.copyRO())); // rD >>= 16 - helper.appendInstruction(Binary.create(INT_SHR, + translator.appendInstruction(Binary.create(INT_SHR, dest.copyRO(), dest.copyRO(), new OPT_IntConstantOperand(16))); - helper.appendInstruction(Goto.create(GOTO, nextBlock + translator.appendInstruction(Goto.create(GOTO, nextBlock .makeJumpTarget())); aligned.deleteNormalOut(); aligned.insertOut(nextBlock); // Create aligned3 code - helper.setCurrentBlock(aligned3); + translator.setCurrentBlock(aligned3); translateCallBasedLoadSigned16(addr.copyRO(), dest.copyRO()); // Move to empty block for rest of load instruction - helper.setCurrentBlock(nextBlock); + translator.setCurrentBlock(nextBlock); } /** @@ -566,45 +566,45 @@ OPT_RegisterOperand dest) { // The block after this load - NB could still need to plant an update for // this instruction in here - OPT_BasicBlock nextBlock = helper.createBlockAfterCurrent(); + OPT_BasicBlock nextBlock = translator.createBlockAfterCurrent(); // Put call based version for (addr & 3 == 3) in aligned3 - OPT_BasicBlock aligned3 = helper.createBlockAfterCurrent(); + OPT_BasicBlock aligned3 = translator.createBlockAfterCurrent(); // Put all other cases in aligned - OPT_BasicBlock aligned = helper.createBlockAfterCurrent(); + OPT_BasicBlock aligned = translator.createBlockAfterCurrent(); // Compute tempReg = addr & 3 OPT_RegisterOperand tempRegOp = new OPT_RegisterOperand(tempReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_AND, tempRegOp, + translator.appendInstruction(Binary.create(INT_AND, tempRegOp, addr.copyRO(), new OPT_IntConstantOperand(0x3))); // Create if (addr & 3) == 3 goto aligned3 - helper.appendInstruction(IfCmp.create(INT_IFCMP, null, + translator.appendInstruction(IfCmp.create(INT_IFCMP, null, tempRegOp.copyRO(), new OPT_IntConstantOperand(0x3), - OPT_ConditionOperand.EQUAL(), aligned3.makeJumpTarget(), helper + OPT_ConditionOperand.EQUAL(), aligned3.makeJumpTarget(), translator .getConditionalBranchProfileOperand(false))); - helper.getCurrentBlock().insertOut(aligned3); + translator.getCurrentBlock().insertOut(aligned3); // Create aligned code - helper.setCurrentBlock(aligned); + translator.setCurrentBlock(aligned); translateAlignedLoad32(addr, dest); // tempReg = (2 - (addr & 0x3)) * 8 - helper.appendInstruction(Binary.create(INT_SUB, tempRegOp + translator.appendInstruction(Binary.create(INT_SUB, tempRegOp .copyRO(), new OPT_IntConstantOperand(2), tempRegOp.copyRO())); - helper.appendInstruction(Binary.create(INT_SHL, tempRegOp + translator.appendInstruction(Binary.create(INT_SHL, tempRegOp .copyRO(), tempRegOp.copyRO(), new OPT_IntConstantOperand(3))); // rD >>>= tempReg - helper.appendInstruction(Binary.create(INT_USHR, dest + translator.appendInstruction(Binary.create(INT_USHR, dest .copyRO(), dest.copyRO(), tempRegOp.copyRO())); // rD &= 0xffff - helper.appendInstruction(Binary.create(INT_AND, + translator.appendInstruction(Binary.create(INT_AND, dest.copyRO(), dest.copyRO(), new OPT_IntConstantOperand(0xffff))); - helper.appendInstruction(Goto.create(GOTO, nextBlock + translator.appendInstruction(Goto.create(GOTO, nextBlock .makeJumpTarget())); aligned.deleteNormalOut(); aligned.insertOut(nextBlock); // Create aligned3 code - helper.setCurrentBlock(aligned3); + translator.setCurrentBlock(aligned3); translateCallBasedLoadUnsigned16(addr.copyRO(), dest.copyRO()); // Move to empty block for rest of load instruction - helper.setCurrentBlock(nextBlock); + translator.setCurrentBlock(nextBlock); } /** @@ -618,34 +618,34 @@ public void translateLoad32(OPT_RegisterOperand addr, OPT_RegisterOperand dest) { // The block after this load - NB could still need to plant an update for // this instruction in here - OPT_BasicBlock nextBlock = helper.createBlockAfterCurrent(); + OPT_BasicBlock nextBlock = translator.createBlockAfterCurrent(); // Put call based version for (addr & 3 != 0) in aligned123 - OPT_BasicBlock aligned123 = helper.createBlockAfterCurrent(); + OPT_BasicBlock aligned123 = translator.createBlockAfterCurrent(); // Put case (addr & 3 == 0) in aligned - OPT_BasicBlock aligned = helper.createBlockAfterCurrent(); + OPT_BasicBlock aligned = translator.createBlockAfterCurrent(); // Compute tempReg = addr & 3 OPT_RegisterOperand tempRegOp = new OPT_RegisterOperand(tempReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_AND, tempRegOp, + translator.appendInstruction(Binary.create(INT_AND, tempRegOp, addr.copyRO(), new OPT_IntConstantOperand(0x3))); // Create if (addr & 3) == 3 goto aligned3 - helper.appendInstruction(IfCmp.create(INT_IFCMP, null, + translator.appendInstruction(IfCmp.create(INT_IFCMP, null, tempRegOp.copyRO(), new OPT_IntConstantOperand(0), OPT_ConditionOperand - .NOT_EQUAL(), aligned123.makeJumpTarget(), helper + .NOT_EQUAL(), aligned123.makeJumpTarget(), translator .getConditionalBranchProfileOperand(false))); - helper.getCurrentBlock().insertOut(aligned123); + translator.getCurrentBlock().insertOut(aligned123); // Create aligned code - helper.setCurrentBlock(aligned); + translator.setCurrentBlock(aligned); translateAlignedLoad32(addr, dest); - helper.appendInstruction(Goto.create(GOTO, nextBlock + translator.appendInstruction(Goto.create(GOTO, nextBlock .makeJumpTarget())); aligned.deleteNormalOut(); aligned.insertOut(nextBlock); // Create aligned3 code - helper.setCurrentBlock(aligned123); + translator.setCurrentBlock(aligned123); translateCallBasedLoad32(addr.copyRO(), dest.copyRO()); // Move to empty block for rest of load instruction - helper.setCurrentBlock(nextBlock); + translator.setCurrentBlock(nextBlock); } /** @@ -662,29 +662,29 @@ // Extract the memory page number from addr. OPT_RegisterOperand vpnRegOp = new OPT_RegisterOperand(vpnReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_USHR, vpnRegOp, + translator.appendInstruction(Binary.create(INT_USHR, vpnRegOp, addr, new OPT_IntConstantOperand(OFFSET_BITS))); // Extract the location of the address within the page. OPT_RegisterOperand offsetRegOp = new OPT_RegisterOperand(offsetReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_AND, offsetRegOp, + translator.appendInstruction(Binary.create(INT_AND, offsetRegOp, addr.copyRO(), new OPT_IntConstantOperand(PAGE_SIZE - 1))); - helper.appendInstruction(Binary.create(INT_USHR, offsetRegOp + translator.appendInstruction(Binary.create(INT_USHR, offsetRegOp .copyRO(), offsetRegOp.copyRO(), new OPT_IntConstantOperand(2))); // Retrieve the int[] for the correct page into pageReg. OPT_RegisterOperand pageRegOp = new OPT_RegisterOperand(pageReg, VM_TypeReference.IntArray); - helper.appendInstruction(ALoad.create(REF_ALOAD, pageRegOp, + translator.appendInstruction(ALoad.create(REF_ALOAD, pageRegOp, new OPT_RegisterOperand(writableMemoryReg, VM_TypeReference.ObjectReferenceArray), vpnRegOp.copyRO(), new OPT_LocationOperand(VM_TypeReference.IntArray), new OPT_TrueGuardOperand())); // Copy to reg from the correct array element. - helper.appendInstruction(ALoad.create(INT_ALOAD, dest, + translator.appendInstruction(ALoad.create(INT_ALOAD, dest, pageRegOp.copyRO(), offsetRegOp.copyRO(), new OPT_LocationOperand( VM_TypeReference.Int), new OPT_TrueGuardOperand())); } @@ -703,29 +703,29 @@ // Extract the memory page number from addr. OPT_RegisterOperand vpnRegOp = new OPT_RegisterOperand(vpnReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_USHR, vpnRegOp, + translator.appendInstruction(Binary.create(INT_USHR, vpnRegOp, addr, new OPT_IntConstantOperand(OFFSET_BITS))); // Extract the location of the address within the page. OPT_RegisterOperand offsetRegOp = new OPT_RegisterOperand(offsetReg, VM_TypeReference.Int); - helper.appendInstruction(Binary.create(INT_AND, offsetRegOp, + translator.appendInstruction(Binary.create(INT_AND, offsetRegOp, addr.copyRO(), new OPT_IntConstantOperand(PAGE_SIZE - 1))); - helper.appendInstruction(Binary.create(INT_USHR, offsetRegOp + translator.appendInstruction(Binary.create(INT_USHR, offsetRegOp .copyRO(), offsetRegOp.copyRO(), new OPT_IntConstantOperand(2))); // Retrieve the int[] for the correct page into pageReg. OPT_RegisterOperand pageRegOp = new OPT_RegisterOperand(pageReg, VM_TypeReference.IntArray); - helper.appendInstruction(ALoad.create(REF_ALOAD, pageRegOp, + translator.appendInstruction(ALoad.create(REF_ALOAD, pageRegOp, new OPT_RegisterOperand(writableMemoryReg, VM_TypeReference.ObjectReferenceArray), vpnRegOp.copyRO(), new OPT_LocationOperand(VM_TypeReference.IntArray), new OPT_TrueGuardOperand())); // Copy to reg from the correct array element. - helper.appendInstruction(ALoad.create(INT_ASTORE, src, + translator.appendInstruction(ALoad.create(INT_ASTORE, src, pageRegOp.copyRO(), offsetRegOp.copyRO(), new OPT_LocationOperand( VM_TypeReference.Int), new OPT_TrueGuardOperand())); } Modified: src/org/binarytranslator/generic/os/loader/elf/ELF_File.java =================================================================== --- src/org/binarytranslator/generic/os/loader/elf/ELF_File.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/generic/os/loader/elf/ELF_File.java 2007-08-14 15:32:09 UTC (rev 164) @@ -215,7 +215,7 @@ public static boolean conforms(String filename) { RandomAccessFile rFile = null; - report("Testing is file is ELF: " + filename); + report("Testing if file is ELF: " + filename); try { rFile = new RandomAccessFile(filename, "r"); Modified: src/org/binarytranslator/generic/os/process/ProcessSpace.java =================================================================== --- src/org/binarytranslator/generic/os/process/ProcessSpace.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/generic/os/process/ProcessSpace.java 2007-08-14 15:32:09 UTC (rev 164) @@ -70,8 +70,7 @@ * @param trace * @return a HIR generator */ - public abstract CodeTranslator createTranslator( - OPT_GenerationContext context, DBT_Trace trace) throws UnsupportedOperationException ; + public abstract CodeTranslator createTranslator(OPT_GenerationContext context, DBT_Trace trace) throws UnsupportedOperationException ; /** * Returns an instance of {@link Interpreter} that can be used to interpret instructions Modified: src/org/binarytranslator/vmInterface/DBT_Trace.java =================================================================== --- src/org/binarytranslator/vmInterface/DBT_Trace.java 2007-08-11 11:28:50 UTC (rev 163) +++ src/org/binarytranslator/vmInterface/DBT_Trace.java 2007-08-14 15:32:09 UTC (rev 164) @@ -117,7 +117,7 @@ * This list stores at which bytecode index a specific method call is executed. * The index of an element plus {@link #CUSTOM_CALL_BCINDEX_BASE} equals the bytecode index * for the call.*/ - private List<CustomCallInformation> customCalls = new ArrayList<CustomCallInformation>(); + private final List<CustomCallInformation> customCalls = new ArrayList<CustomCallInformation>(); /** * Create an optimizing compiler HIR code generator for this trace @@ -126,7 +126,9 @@ * the generation context for the HIR generation * @return a HIR generator */ + @Override public OPT_HIRGenerator createHIRGenerator(OPT_GenerationContext context) { + return ps.createTranslator(context, this); } @@ -322,7 +324,7 @@ * Size of bytecodes for this method */ public int getBytecodeLength() { - return 256; + return numberOfInstructions == 0 ? 256 : numberOfInstructions; } public int getNumberOfInstructions() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |