# HG changeset patch # User Doug Simon # Date 1386064276 -3600 # Node ID 1a66453f73db7a5c0aad48fba8c8486587e96c24 # Parent 0b4d38339708b1542ca9591d94da61747f1ca9fc renamed TargetMethodAssembler to CompilationResultBuilder diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.asm/src/com/oracle/graal/asm/AbstractAssembler.java --- a/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/AbstractAssembler.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/AbstractAssembler.java Tue Dec 03 10:51:16 2013 +0100 @@ -115,7 +115,7 @@ } /** - * This is used by the TargetMethodAssembler to convert a {@link StackSlot} to an + * This is used by the CompilationResultBuilder to convert a {@link StackSlot} to an * {@link AbstractAddress}. */ public abstract AbstractAddress makeAddress(Register base, int displacement); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Dec 03 10:51:16 2013 +0100 @@ -281,9 +281,9 @@ } public static void emitCode(Backend backend, long[] leafGraphIds, Assumptions assumptions, LIRGenerator lirGen, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner) { - TargetMethodAssembler tasm = backend.newAssembler(lirGen, compilationResult); - backend.emitCode(tasm, lirGen, installedCodeOwner); - tasm.finish(); + CompilationResultBuilder crb = backend.newCompilationResultBuilder(lirGen, compilationResult); + backend.emitCode(crb, lirGen, installedCodeOwner); + crb.finish(); if (!assumptions.isEmpty()) { compilationResult.setAssumptions(assumptions); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Tue Dec 03 10:51:16 2013 +0100 @@ -67,9 +67,15 @@ public abstract LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir); + /** + * Creates the assembler used to emit the machine code. + */ protected abstract AbstractAssembler createAssembler(FrameMap frameMap); - public abstract TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult); + /** + * Creates the object used to fill in the details of a given compilation result. + */ + public abstract CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult); public abstract boolean shouldAllocateRegisters(); @@ -80,5 +86,5 @@ * {@linkplain InstalledCode#getMethod() associated} with once installed. This * argument can be null. */ - public abstract void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner); + public abstract void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -39,7 +39,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Call.directCall(tasm, masm, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Call.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue Dec 03 10:51:16 2013 +0100 @@ -83,11 +83,11 @@ * @param isVerifiedEntryPoint specifies if the code buffer is currently at the verified entry * point */ - protected static void emitStackOverflowCheck(TargetMethodAssembler tasm, boolean afterFrameInit, boolean isVerifiedEntryPoint) { + protected static void emitStackOverflowCheck(CompilationResultBuilder crb, boolean afterFrameInit, boolean isVerifiedEntryPoint) { if (StackShadowPages.getValue() > 0) { - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - int frameSize = tasm.frameMap.frameSize(); + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + int frameSize = crb.frameMap.frameSize(); if (frameSize > 0) { int lastFramePage = frameSize / unsafe.pageSize(); // emit multiple stack bangs for methods with frames larger than a page @@ -96,7 +96,7 @@ if (afterFrameInit) { disp -= frameSize; } - tasm.blockComment("[stack overflow check]"); + crb.blockComment("[stack overflow check]"); int pos = asm.codeBuffer.position(); asm.movq(new AMD64Address(rsp, -disp), AMD64.rax); assert i > 0 || !isVerifiedEntryPoint || asm.codeBuffer.position() - pos >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; @@ -127,10 +127,10 @@ } @Override - public void enter(TargetMethodAssembler tasm) { - FrameMap frameMap = tasm.frameMap; + public void enter(CompilationResultBuilder crb) { + FrameMap frameMap = crb.frameMap; int frameSize = frameMap.frameSize(); - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; if (omitFrame) { if (!isStub) { asm.nop(PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE); @@ -138,7 +138,7 @@ } else { int verifiedEntryPointOffset = asm.codeBuffer.position(); if (!isStub) { - emitStackOverflowCheck(tasm, false, true); + emitStackOverflowCheck(crb, false, true); assert asm.codeBuffer.position() - verifiedEntryPointOffset >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; } if (!isStub && asm.codeBuffer.position() == verifiedEntryPointOffset) { @@ -163,19 +163,19 @@ } @Override - public void leave(TargetMethodAssembler tasm) { + public void leave(CompilationResultBuilder crb) { if (!omitFrame) { - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - CalleeSaveLayout csl = tasm.frameMap.registerConfig.getCalleeSaveLayout(); + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + CalleeSaveLayout csl = crb.frameMap.registerConfig.getCalleeSaveLayout(); if (csl != null && csl.size != 0) { - tasm.compilationResult.setRegisterRestoreEpilogueOffset(asm.codeBuffer.position()); + crb.compilationResult.setRegisterRestoreEpilogueOffset(asm.codeBuffer.position()); // saved all registers, restore all registers - int frameToCSA = tasm.frameMap.offsetToCalleeSaveArea(); + int frameToCSA = crb.frameMap.offsetToCalleeSaveArea(); asm.restore(csl, frameToCSA); } - int frameSize = tasm.frameMap.frameSize(); + int frameSize = crb.frameMap.frameSize(); asm.incrementq(rsp, frameSize); } } @@ -187,7 +187,7 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult) { // Omit the frame if the method: // - has no spill slots or other slots allocated during register allocation // - has no callee-saved registers @@ -203,11 +203,11 @@ Stub stub = gen.getStub(); AbstractAssembler masm = createAssembler(frameMap); HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null, omitFrame); - TargetMethodAssembler tasm = new TargetMethodAssembler(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(frameMap.frameSize()); + CompilationResultBuilder crb = new CompilationResultBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(frameMap.frameSize()); StackSlot deoptimizationRescueSlot = gen.deoptimizationRescueSlot; if (deoptimizationRescueSlot != null && stub == null) { - tasm.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); + crb.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); } if (stub != null) { @@ -215,25 +215,25 @@ updateStub(stub, definedRegisters, gen.calleeSaveInfo, frameMap); } - return tasm; + return crb; } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - FrameMap frameMap = tasm.frameMap; + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + FrameMap frameMap = crb.frameMap; RegisterConfig regConfig = frameMap.registerConfig; HotSpotVMConfig config = getRuntime().getConfig(); Label verifiedStub = new Label(); // Emit the prefix - emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub); + emitCodePrefix(installedCodeOwner, crb, asm, regConfig, config, verifiedStub); // Emit code for the LIR - emitCodeBody(installedCodeOwner, tasm, lirGen); + emitCodeBody(installedCodeOwner, crb, lirGen); // Emit the suffix - emitCodeSuffix(installedCodeOwner, tasm, lirGen, asm, frameMap); + emitCodeSuffix(installedCodeOwner, crb, lirGen, asm, frameMap); } /** @@ -241,10 +241,10 @@ * * @param installedCodeOwner see {@link Backend#emitCode} */ - public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) { + public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) { HotSpotProviders providers = getProviders(); if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) { - tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY); + crb.recordMark(Marks.MARK_UNVERIFIED_ENTRY); CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, new JavaType[]{providers.getMetaAccess().lookupJavaType(Object.class)}, getTarget(), false); Register inlineCacheKlass = rax; // see definition of IC_Klass in // c1_LIRAssembler_x86.cpp @@ -259,13 +259,13 @@ } else { asm.cmpq(inlineCacheKlass, src); } - AMD64Call.directConditionalJmp(tasm, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual); + AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual); } asm.align(config.codeEntryAlignment); - tasm.recordMark(Marks.MARK_OSR_ENTRY); + crb.recordMark(Marks.MARK_OSR_ENTRY); asm.bind(verifiedStub); - tasm.recordMark(Marks.MARK_VERIFIED_ENTRY); + crb.recordMark(Marks.MARK_VERIFIED_ENTRY); } /** @@ -273,22 +273,22 @@ * * @param installedCodeOwner see {@link Backend#emitCode} */ - public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen) { - lirGen.lir.emitCode(tasm); + public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, LIRGenerator lirGen) { + lirGen.lir.emitCode(crb); } /** * @param installedCodeOwner see {@link Backend#emitCode} */ - public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) { + public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) { HotSpotProviders providers = getProviders(); - HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext; + HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext; if (frameContext != null && !frameContext.isStub) { HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls(); - tasm.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); - AMD64Call.directCall(tasm, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); - tasm.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); - AMD64Call.directCall(tasm, asm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); + crb.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); + AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); + crb.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); + AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); } else { // No need to emit the stubs for entries back into the method since // it has no calls that can cause such "return" entries diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallEpilogueOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -42,7 +42,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // reset last Java frame: masm.movslq(new AMD64Address(thread, threadLastJavaSpOffset), 0); masm.movslq(new AMD64Address(thread, threadLastJavaFpOffset), 0); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallPrologueOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallPrologueOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallPrologueOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -42,7 +42,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // save last Java frame masm.movq(new AMD64Address(thread, threadLastJavaSpOffset), rsp); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotDeoptimizeCallerOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotDeoptimizeCallerOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotDeoptimizeCallerOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -36,8 +36,8 @@ final class AMD64HotSpotDeoptimizeCallerOp extends AMD64HotSpotEpilogueOp { @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); - AMD64Call.directJmp(tasm, masm, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); + AMD64Call.directJmp(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -47,18 +47,18 @@ @Use({REG, STACK}) protected AllocatableValue savedRbp = PLACEHOLDER; - protected void leaveFrameAndRestoreRbp(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + protected void leaveFrameAndRestoreRbp(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (isStackSlot(savedRbp)) { // Restoring RBP from the stack must be done before the frame is removed - masm.movq(rbp, (AMD64Address) tasm.asAddress(savedRbp)); + masm.movq(rbp, (AMD64Address) crb.asAddress(savedRbp)); } else { Register framePointer = asRegister(savedRbp); if (!framePointer.equals(rbp)) { masm.movq(rbp, framePointer); } } - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); + if (crb.frameContext != null) { + crb.frameContext.leave(crb); } } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotJumpToExceptionHandlerInCallerOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -55,8 +55,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); // Discard the return address, thus completing restoration of caller frame masm.incrementq(rsp, 8); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Tue Dec 03 10:51:16 2013 +0100 @@ -126,7 +126,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.movq(asRegister(scratch), asRegister(input)); if (kind == Kind.Object) { encodePointer(masm, asRegister(scratch), heapBaseReg, heapBase, shift, alignment); @@ -134,7 +134,7 @@ encodeKlassPointer(masm, asRegister(scratch), heapBaseReg, klassBase, heapBase, shift, alignment); } if (state != null) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + crb.recordImplicitException(masm.codeBuffer.position(), state); } masm.movl(address.toAddress(), asRegister(scratch)); } @@ -169,12 +169,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - compareAndSwapCompressed(tasm, masm, result, address, cmpValue, newValue, scratch, base, shift, alignment, heapBaseReg); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + compareAndSwapCompressed(crb, masm, result, address, cmpValue, newValue, scratch, base, shift, alignment, heapBaseReg); } } - protected static void compareAndSwapCompressed(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, + protected static void compareAndSwapCompressed(CompilationResultBuilder crb, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue, AllocatableValue scratch, long base, int shift, int alignment, Register heapBaseReg) { assert AMD64.rax.equals(asRegister(cmpValue)) && AMD64.rax.equals(asRegister(result)); final Register scratchRegister = asRegister(scratch); @@ -184,7 +184,7 @@ encodePointer(masm, cmpRegister, heapBase, base, shift, alignment); masm.movq(scratchRegister, newRegister); encodePointer(masm, scratchRegister, heapBase, base, shift, alignment); - if (tasm.target.isMP) { + if (crb.target.isMP) { masm.lock(); } masm.cmpxchgl(scratchRegister, address.toAddress()); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPatchReturnAddressOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPatchReturnAddressOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPatchReturnAddressOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -45,8 +45,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - int frameSize = tasm.frameMap.frameSize(); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + int frameSize = crb.frameMap.frameSize(); masm.movq(new AMD64Address(rsp, frameSize), asRegister(address)); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -49,10 +49,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); - if (!isStub && (tasm.frameContext != null || !OptEliminateSafepoints.getValue())) { - AMD64HotSpotSafepointOp.emitCode(tasm, masm, runtime().getConfig(), true, null, scratchForSafepointOnReturn); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); + if (!isStub && (crb.frameContext != null || !OptEliminateSafepoints.getValue())) { + AMD64HotSpotSafepointOp.emitCode(crb, masm, runtime().getConfig(), true, null, scratchForSafepointOnReturn); } masm.ret(0); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -53,9 +53,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) { RegisterValue scratch = (RegisterValue) temp; - emitCode(tasm, asm, config, false, state, scratch.getRegister()); + emitCode(crb, asm, config, false, state, scratch.getRegister()); } /** @@ -68,19 +68,19 @@ return !NumUtil.isInt(pollingPageAddress - config.codeCacheLowBoundary()) || !NumUtil.isInt(pollingPageAddress - config.codeCacheHighBoundary()); } - public static void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { + public static void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { final int pos = asm.codeBuffer.position(); if (isPollingPageFar(config)) { asm.movq(scratch, config.safepointPollingAddress); - tasm.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR); + crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR); if (state != null) { - tasm.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); + crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } asm.movq(scratch, new AMD64Address(scratch)); } else { - tasm.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); + crb.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); if (state != null) { - tasm.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); + crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } // The C++ code transforms the polling page offset into an RIP displacement // to the real address at that offset in the polling page. diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -47,10 +47,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); - ForeignCallLinkage linkage = tasm.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); + ForeignCallLinkage linkage = crb.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); CallingConvention cc = linkage.getOutgoingCallingConvention(); assert cc.getArgumentCount() == 2; assert exception.equals(cc.getArgument(0)); @@ -59,6 +59,6 @@ Register returnAddress = asRegister(cc.getArgument(1)); masm.movq(returnAddress, new AMD64Address(rsp, 0)); - AMD64Call.directJmp(tasm, masm, linkage); + AMD64Call.directJmp(crb, masm, linkage); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -51,12 +51,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - AMD64Move.move(tasm, masm, AMD64.rbx.asValue(Kind.Long), metaspaceMethod); - tasm.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); - AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); - super.emitCode(tasm, masm); + AMD64Move.move(crb, masm, AMD64.rbx.asValue(Kind.Long), metaspaceMethod); + crb.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); + AMD64Move.move(crb, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); + super.emitCode(crb, masm); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -51,11 +51,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - tasm.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); - AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); - super.emitCode(tasm, masm); + crb.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); + AMD64Move.move(crb, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); + super.emitCode(crb, masm); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -57,11 +57,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - tasm.recordMark(Marks.MARK_INLINE_INVOKE); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + crb.recordMark(Marks.MARK_INLINE_INVOKE); Register callReg = asRegister(targetAddress); assert !callReg.equals(METHOD); - AMD64Call.indirectCall(tasm, masm, callReg, callTarget, state); + AMD64Call.indirectCall(crb, masm, callReg, callTarget, state); } @Override diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64TailcallOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64TailcallOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64TailcallOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -47,7 +47,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // destroy the current frame (now the return address is the top of stack) masm.leave(); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Tue Dec 03 10:51:16 2013 +0100 @@ -95,12 +95,12 @@ class HotSpotFrameContext implements FrameContext { @Override - public void enter(TargetMethodAssembler tasm) { + public void enter(CompilationResultBuilder crb) { Debug.log("Nothing to do here"); } @Override - public void leave(TargetMethodAssembler tasm) { + public void leave(CompilationResultBuilder crb) { Debug.log("Nothing to do here"); } } @@ -111,20 +111,20 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult) { FrameMap frameMap = lirGen.frameMap; AbstractAssembler masm = createAssembler(frameMap); HotSpotFrameContext frameContext = new HotSpotFrameContext(); - TargetMethodAssembler tasm = new TargetMethodAssembler(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(frameMap.frameSize()); - return tasm; + CompilationResultBuilder crb = new CompilationResultBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(frameMap.frameSize()); + return crb; } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod method) { + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod method) { assert method != null : lirGen.getGraph() + " is not associated with a method"; // Emit the prologue. - codeBuffer = tasm.asm.codeBuffer; + codeBuffer = crb.asm.codeBuffer; codeBuffer.emitString0("version 0:95: $full : $large;"); codeBuffer.emitString(""); @@ -176,7 +176,7 @@ codeBuffer.emitString0("kernel &run ("); codeBuffer.emitString(""); - FrameMap frameMap = tasm.frameMap; + FrameMap frameMap = crb.frameMap; RegisterConfig regConfig = frameMap.registerConfig; // Build list of param types which does include the gid (for cc register mapping query). JavaType[] ccParamTypes = new JavaType[nonConstantParamCount + 1]; @@ -280,9 +280,9 @@ } } // Prologue done, Emit code for the LIR. - lirGen.lir.emitCode(tasm); + lirGen.lir.emitCode(crb); // Now that code is emitted go back and figure out what the upper Bound stack size was. - long maxStackSize = ((HSAILAssembler) tasm.asm).upperBoundStackSize(); + long maxStackSize = ((HSAILAssembler) crb.asm).upperBoundStackSize(); String spillsegStringFinal; if (maxStackSize == 0) { // If no spilling, get rid of spillseg declaration. diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Tue Dec 03 10:51:16 2013 +0100 @@ -157,17 +157,17 @@ class PTXFrameContext implements FrameContext { @Override - public void enter(TargetMethodAssembler tasm) { + public void enter(CompilationResultBuilder crb) { // codeBuffer.emitString(".address_size 32"); // PTX ISA version 2.3 } @Override - public void leave(TargetMethodAssembler tasm) { + public void leave(CompilationResultBuilder crb) { } } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult) { // Omit the frame of the method: // - has no spill slots or other slots allocated during register allocation // - has no callee-saved registers @@ -176,9 +176,9 @@ FrameMap frameMap = lirGen.frameMap; AbstractAssembler masm = createAssembler(frameMap); PTXFrameContext frameContext = new PTXFrameContext(); - TargetMethodAssembler tasm = new TargetMethodAssembler(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(0); - return tasm; + CompilationResultBuilder crb = new CompilationResultBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(0); + return crb; } @Override @@ -191,14 +191,14 @@ return new PTXLIRGenerator(graph, getProviders(), frameMap, cc, lir); } - private static void emitKernelEntry(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { + private static void emitKernelEntry(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { // Emit PTX kernel entry text based on PTXParameterOp // instructions in the start block. Remove the instructions // once kernel entry text and directives are emitted to // facilitate seemless PTX code generation subsequently. assert codeCacheOwner != null : lirGen.getGraph() + " is not associated with a method"; final String name = codeCacheOwner.getName(); - Buffer codeBuffer = tasm.asm.codeBuffer; + Buffer codeBuffer = crb.asm.codeBuffer; // Emit initial boiler-plate directives. codeBuffer.emitString(".version 3.0"); @@ -216,7 +216,7 @@ // instruction. for (LIRInstruction op : lirGen.lir.lir(startBlock)) { if (op instanceof PTXParameterOp) { - op.emitCode(tasm); + op.emitCode(crb); deleteOps.add(op); } } @@ -232,11 +232,11 @@ } // Emit .reg space declarations - private static void emitRegisterDecl(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { + private static void emitRegisterDecl(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { assert codeCacheOwner != null : lirGen.getGraph() + " is not associated with a method"; - Buffer codeBuffer = tasm.asm.codeBuffer; + Buffer codeBuffer = crb.asm.codeBuffer; RegisterAnalysis registerAnalysis = new RegisterAnalysis(); for (Block b : lirGen.lir.codeEmittingOrder()) { @@ -261,15 +261,15 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { assert codeCacheOwner != null : lirGen.getGraph() + " is not associated with a method"; - Buffer codeBuffer = tasm.asm.codeBuffer; + Buffer codeBuffer = crb.asm.codeBuffer; // Emit the prologue - emitKernelEntry(tasm, lirGen, codeCacheOwner); + emitKernelEntry(crb, lirGen, codeCacheOwner); // Emit register declarations try { - emitRegisterDecl(tasm, lirGen, codeCacheOwner); + emitRegisterDecl(crb, lirGen, codeCacheOwner); } catch (GraalInternalError e) { e.printStackTrace(); // TODO : Better error handling needs to be done once @@ -280,7 +280,7 @@ } // Emit code for the LIR try { - lirGen.lir.emitCode(tasm); + lirGen.lir.emitCode(crb); } catch (GraalInternalError e) { e.printStackTrace(); // TODO : Better error handling needs to be done once diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -39,7 +39,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // TODO the patched call address looks odd (and is invalid) compared to other runtime calls: // 0xffffffff749bb5fc: call 0xffffffff415a720c ; {runtime_call} // [Exception Handler] @@ -48,6 +48,6 @@ // [Deopt Handler Code] // 0xffffffff749bb60c: call 0xffffffff748da540 ; {runtime_call} // 0xffffffff749bb610: nop - SPARCCall.directCall(tasm, masm, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); + SPARCCall.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Tue Dec 03 10:51:16 2013 +0100 @@ -81,10 +81,10 @@ * @param afterFrameInit specifies if the stack pointer has already been adjusted to allocate * the current frame */ - protected static void emitStackOverflowCheck(TargetMethodAssembler tasm, boolean afterFrameInit) { + protected static void emitStackOverflowCheck(CompilationResultBuilder crb, boolean afterFrameInit) { if (StackShadowPages.getValue() > 0) { - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; - final int frameSize = tasm.frameMap.totalFrameSize(); + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; + final int frameSize = crb.frameMap.totalFrameSize(); if (frameSize > 0) { int lastFramePage = frameSize / unsafe.pageSize(); // emit multiple stack bangs for methods with frames larger than a page @@ -93,7 +93,7 @@ if (afterFrameInit) { disp -= frameSize; } - tasm.blockComment("[stack overflow check]"); + crb.blockComment("[stack overflow check]"); // Use SPARCAddress to get the final displacement including the stack bias. SPARCAddress address = new SPARCAddress(sp, -disp); if (SPARCAssembler.isSimm13(address.getDisplacement())) { @@ -116,12 +116,12 @@ } @Override - public void enter(TargetMethodAssembler tasm) { - final int frameSize = tasm.frameMap.totalFrameSize(); + public void enter(CompilationResultBuilder crb) { + final int frameSize = crb.frameMap.totalFrameSize(); - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; if (!isStub) { - emitStackOverflowCheck(tasm, false); + emitStackOverflowCheck(crb, false); } new Save(sp, -frameSize, sp).emit(masm); @@ -135,8 +135,8 @@ } @Override - public void leave(TargetMethodAssembler tasm) { - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; + public void leave(CompilationResultBuilder crb) { + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; new RestoreWindow().emit(masm); } } @@ -147,7 +147,7 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult) { SPARCHotSpotLIRGenerator gen = (SPARCHotSpotLIRGenerator) lirGen; FrameMap frameMap = gen.frameMap; assert gen.deoptimizationRescueSlot == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame"; @@ -156,11 +156,11 @@ AbstractAssembler masm = createAssembler(frameMap); // On SPARC we always use stack frames. HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null); - TargetMethodAssembler tasm = new TargetMethodAssembler(getProviders().getCodeCache(), getProviders().getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(frameMap.frameSize()); + CompilationResultBuilder crb = new CompilationResultBuilder(getProviders().getCodeCache(), getProviders().getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(frameMap.frameSize()); StackSlot deoptimizationRescueSlot = gen.deoptimizationRescueSlot; if (deoptimizationRescueSlot != null && stub == null) { - tasm.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); + crb.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); } if (stub != null) { @@ -170,13 +170,13 @@ updateStub(stub, destroyedRegisters, calleeSaveInfo, frameMap); } - return tasm; + return crb; } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; - FrameMap frameMap = tasm.frameMap; + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; + FrameMap frameMap = crb.frameMap; RegisterConfig regConfig = frameMap.registerConfig; HotSpotVMConfig config = getRuntime().getConfig(); Label unverifiedStub = installedCodeOwner == null || isStatic(installedCodeOwner.getModifiers()) ? null : new Label(); @@ -184,7 +184,7 @@ // Emit the prefix if (unverifiedStub != null) { - tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY); + crb.recordMark(Marks.MARK_UNVERIFIED_ENTRY); // We need to use JavaCall here because we haven't entered the frame yet. CallingConvention cc = regConfig.getCallingConvention(JavaCall, null, new JavaType[]{getProviders().getMetaAccess().lookupJavaType(Object.class)}, getTarget(), false); Register inlineCacheKlass = g5; // see MacroAssembler::ic_call @@ -199,19 +199,19 @@ } masm.align(config.codeEntryAlignment); - tasm.recordMark(Marks.MARK_OSR_ENTRY); - tasm.recordMark(Marks.MARK_VERIFIED_ENTRY); + crb.recordMark(Marks.MARK_OSR_ENTRY); + crb.recordMark(Marks.MARK_VERIFIED_ENTRY); // Emit code for the LIR - lirGen.lir.emitCode(tasm); + lirGen.lir.emitCode(crb); - HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext; + HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext; HotSpotForeignCallsProvider foreignCalls = getProviders().getForeignCalls(); if (frameContext != null && !frameContext.isStub) { - tasm.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); - SPARCCall.directCall(tasm, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); - tasm.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); - SPARCCall.directCall(tasm, masm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); + crb.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); + SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); + crb.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); + SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); } else { // No need to emit the stubs for entries back into the method since // it has no calls that can cause such "return" entries @@ -221,7 +221,7 @@ if (unverifiedStub != null) { masm.bind(unverifiedStub); Register scratch = g3; - SPARCCall.indirectJmp(tasm, masm, scratch, foreignCalls.lookupForeignCall(IC_MISS_HANDLER)); + SPARCCall.indirectJmp(crb, masm, scratch, foreignCalls.lookupForeignCall(IC_MISS_HANDLER)); } } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallEpilogueOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -49,7 +49,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // Restore the thread register when coming back from the runtime. new Mov(l7, thread).emit(masm); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallPrologueOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallPrologueOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallPrologueOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -47,7 +47,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // Save last Java frame. new Add(stackPointer, new SPARCAddress(stackPointer, 0).getDisplacement(), g4).emit(masm); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -38,17 +38,17 @@ final class SPARCHotSpotDeoptimizeCallerOp extends SPARCHotSpotEpilogueOp { @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - leaveFrame(tasm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + leaveFrame(crb); // SPARCHotSpotBackend backend = (SPARCHotSpotBackend) // HotSpotGraalRuntime.runtime().getBackend(); // final boolean isStub = true; // HotSpotFrameContext frameContext = backend.new HotSpotFrameContext(isStub); - // frameContext.enter(tasm); + // frameContext.enter(crb); Register scratch = g3; - SPARCCall.indirectJmp(tasm, masm, scratch, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); + SPARCCall.indirectJmp(crb, masm, scratch, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); - // frameContext.leave(tasm); + // frameContext.leave(crb); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEpilogueOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEpilogueOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEpilogueOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -30,9 +30,9 @@ */ abstract class SPARCHotSpotEpilogueOp extends SPARCLIRInstruction { - protected void leaveFrame(TargetMethodAssembler tasm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); + protected void leaveFrame(CompilationResultBuilder crb) { + if (crb.frameContext != null) { + crb.frameContext.leave(crb); } } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotJumpToExceptionHandlerInCallerOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -60,8 +60,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - leaveFrame(tasm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + leaveFrame(crb); // Restore SP from L7 if the exception PC is a method handle call site. SPARCAddress dst = new SPARCAddress(thread, isMethodHandleReturnOffset); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -45,10 +45,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // FIXME This is non-trivial. On SPARC we need to flush all register windows first before we // can patch the return address (see: frame::patch_pc). - // int frameSize = tasm.frameMap.frameSize(); + // int frameSize = crb.frameMap.frameSize(); // new Stx(asRegister(address), new SPARCAddress(sp, frameSize)); new Ldx(new SPARCAddress(g0, 0x123), g0).emit(masm); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -48,12 +48,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - if (!isStub && (tasm.frameContext != null || !OptEliminateSafepoints.getValue())) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + if (!isStub && (crb.frameContext != null || !OptEliminateSafepoints.getValue())) { // Using the same scratch register as LIR_Assembler::return_op // in c1_LIRAssembler_sparc.cpp - SPARCHotSpotSafepointOp.emitCode(tasm, masm, runtime().getConfig(), true, null, SPARC.l0); + SPARCHotSpotSafepointOp.emitCode(crb, masm, runtime().getConfig(), true, null, SPARC.l0); } - ReturnOp.emitCodeHelper(tasm, masm); + ReturnOp.emitCodeHelper(crb, masm); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -53,17 +53,17 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { Register scratch = ((RegisterValue) temp).getRegister(); - emitCode(tasm, masm, config, false, state, scratch); + emitCode(crb, masm, config, false, state, scratch); } - public static void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { + public static void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { final int pos = masm.codeBuffer.position(); new Setx(config.safepointPollingAddress, scratch).emit(masm); - tasm.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); + crb.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); if (state != null) { - tasm.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); + crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } new Ldx(new SPARCAddress(scratch, 0), g0).emit(masm); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotUnwindOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotUnwindOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotUnwindOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -48,10 +48,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - leaveFrame(tasm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + leaveFrame(crb); - ForeignCallLinkage linkage = tasm.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); + ForeignCallLinkage linkage = crb.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); CallingConvention cc = linkage.getOutgoingCallingConvention(); assert cc.getArgumentCount() == 2; assert exception.equals(cc.getArgument(0)); @@ -61,6 +61,6 @@ new Mov(o7, returnAddress).emit(masm); Register scratch = g5; - SPARCCall.indirectJmp(tasm, masm, scratch, linkage); + SPARCCall.indirectJmp(crb, masm, scratch, linkage); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -54,13 +54,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - SPARCMove.move(tasm, masm, g5.asValue(Kind.Long), metaspaceMethod); - tasm.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); - // SPARCMove.move(tasm, masm, g3.asValue(Kind.Long), Constant.LONG_0); + SPARCMove.move(crb, masm, g5.asValue(Kind.Long), metaspaceMethod); + crb.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); + // SPARCMove.move(crb, masm, g3.asValue(Kind.Long), Constant.LONG_0); new Setx(nonOopBits, g3, true).emit(masm); - super.emitCode(tasm, masm); + super.emitCode(crb, masm); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -51,11 +51,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - tasm.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); + crb.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); new Setx(HotSpotGraalRuntime.runtime().getConfig().nonOopBits, g3, true).emit(masm); - super.emitCode(tasm, masm); + super.emitCode(crb, masm); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -57,11 +57,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - tasm.recordMark(Marks.MARK_INLINE_INVOKE); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + crb.recordMark(Marks.MARK_INLINE_INVOKE); Register callReg = asRegister(targetAddress); assert !callReg.equals(METHOD); - SPARCCall.indirectCall(tasm, masm, callReg, callTarget, state); + SPARCCall.indirectCall(crb, masm, callReg, callTarget, state); } @Override diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Tue Dec 03 10:51:16 2013 +0100 @@ -74,8 +74,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -95,9 +95,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result); } } @@ -120,9 +120,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -152,9 +152,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -183,9 +183,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -214,12 +214,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (sameRegister(result, y)) { - emit(tasm, masm, opcode, result, x, null); + emit(crb, masm, opcode, result, x, null); } else { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } } @@ -248,9 +248,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -279,8 +279,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, opcode, null, y, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, opcode, null, y, state); } @Override @@ -312,7 +312,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { AMD64Address tmp = new AMD64Address(AMD64.rsp); masm.subq(AMD64.rsp, 8); if (opcode == FREM) { @@ -356,7 +356,7 @@ } @SuppressWarnings("unused") - protected static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AMD64Arithmetic opcode, AllocatableValue result) { + protected static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, AMD64Arithmetic opcode, AllocatableValue result) { switch (opcode) { case INEG: masm.negl(asIntReg(result)); @@ -381,7 +381,7 @@ } } - public static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AMD64Arithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, AMD64Arithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; if (isRegister(src)) { switch (opcode) { @@ -584,103 +584,103 @@ } else if (isConstant(src)) { switch (opcode) { case IADD: - masm.incrementl(asIntReg(dst), tasm.asIntConst(src)); + masm.incrementl(asIntReg(dst), crb.asIntConst(src)); break; case ISUB: - masm.decrementl(asIntReg(dst), tasm.asIntConst(src)); + masm.decrementl(asIntReg(dst), crb.asIntConst(src)); break; case IMUL: - masm.imull(asIntReg(dst), asIntReg(dst), tasm.asIntConst(src)); + masm.imull(asIntReg(dst), asIntReg(dst), crb.asIntConst(src)); break; case IAND: - masm.andl(asIntReg(dst), tasm.asIntConst(src)); + masm.andl(asIntReg(dst), crb.asIntConst(src)); break; case IOR: - masm.orl(asIntReg(dst), tasm.asIntConst(src)); + masm.orl(asIntReg(dst), crb.asIntConst(src)); break; case IXOR: - masm.xorl(asIntReg(dst), tasm.asIntConst(src)); + masm.xorl(asIntReg(dst), crb.asIntConst(src)); break; case ISHL: - masm.shll(asIntReg(dst), tasm.asIntConst(src) & 31); + masm.shll(asIntReg(dst), crb.asIntConst(src) & 31); break; case ISHR: - masm.sarl(asIntReg(dst), tasm.asIntConst(src) & 31); + masm.sarl(asIntReg(dst), crb.asIntConst(src) & 31); break; case IUSHR: - masm.shrl(asIntReg(dst), tasm.asIntConst(src) & 31); + masm.shrl(asIntReg(dst), crb.asIntConst(src) & 31); break; case LADD: - masm.addq(asLongReg(dst), tasm.asIntConst(src)); + masm.addq(asLongReg(dst), crb.asIntConst(src)); break; case LSUB: - masm.subq(asLongReg(dst), tasm.asIntConst(src)); + masm.subq(asLongReg(dst), crb.asIntConst(src)); break; case LMUL: - masm.imulq(asLongReg(dst), asLongReg(dst), tasm.asIntConst(src)); + masm.imulq(asLongReg(dst), asLongReg(dst), crb.asIntConst(src)); break; case LAND: - masm.andq(asLongReg(dst), tasm.asIntConst(src)); + masm.andq(asLongReg(dst), crb.asIntConst(src)); break; case LOR: - masm.orq(asLongReg(dst), tasm.asIntConst(src)); + masm.orq(asLongReg(dst), crb.asIntConst(src)); break; case LXOR: - masm.xorq(asLongReg(dst), tasm.asIntConst(src)); + masm.xorq(asLongReg(dst), crb.asIntConst(src)); break; case LSHL: - masm.shlq(asLongReg(dst), tasm.asIntConst(src) & 63); + masm.shlq(asLongReg(dst), crb.asIntConst(src) & 63); break; case LSHR: - masm.sarq(asLongReg(dst), tasm.asIntConst(src) & 63); + masm.sarq(asLongReg(dst), crb.asIntConst(src) & 63); break; case LUSHR: - masm.shrq(asLongReg(dst), tasm.asIntConst(src) & 63); + masm.shrq(asLongReg(dst), crb.asIntConst(src) & 63); break; case FADD: - masm.addss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.addss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case FSUB: - masm.subss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.subss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case FMUL: - masm.mulss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.mulss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case FAND: - masm.andps(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src, 16)); + masm.andps(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src, 16)); break; case FOR: - masm.orps(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src, 16)); + masm.orps(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src, 16)); break; case FXOR: - masm.xorps(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src, 16)); + masm.xorps(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src, 16)); break; case FDIV: - masm.divss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.divss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case DADD: - masm.addsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.addsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DSUB: - masm.subsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.subsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DMUL: - masm.mulsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.mulsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DDIV: - masm.divsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.divsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DAND: - masm.andpd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src, 16)); + masm.andpd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src, 16)); break; case DOR: - masm.orpd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src, 16)); + masm.orpd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src, 16)); break; case DXOR: - masm.xorpd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src, 16)); + masm.xorpd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src, 16)); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -688,123 +688,123 @@ } else { switch (opcode) { case IADD: - masm.addl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.addl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case ISUB: - masm.subl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.subl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IAND: - masm.andl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.andl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IMUL: - masm.imull(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.imull(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IOR: - masm.orl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.orl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IXOR: - masm.xorl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.xorl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case LADD: - masm.addq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.addq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LSUB: - masm.subq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.subq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LMUL: - masm.imulq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.imulq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LAND: - masm.andq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.andq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LOR: - masm.orq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.orq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LXOR: - masm.xorq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.xorq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case FADD: - masm.addss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.addss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case FSUB: - masm.subss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.subss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case FMUL: - masm.mulss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.mulss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case FDIV: - masm.divss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.divss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case DADD: - masm.addsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.addsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case DSUB: - masm.subsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.subsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case DMUL: - masm.mulsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.mulsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case DDIV: - masm.divsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.divsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case SQRT: - masm.sqrtsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.sqrtsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case I2B: - masm.movsxb(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movsxb(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case I2S: - masm.movsxw(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movsxw(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case I2L: - masm.movslq(asLongReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movslq(asLongReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case F2D: - masm.cvtss2sd(asDoubleReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.cvtss2sd(asDoubleReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case D2F: - masm.cvtsd2ss(asFloatReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.cvtsd2ss(asFloatReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case I2F: - masm.cvtsi2ssl(asFloatReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.cvtsi2ssl(asFloatReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case I2D: - masm.cvtsi2sdl(asDoubleReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.cvtsi2sdl(asDoubleReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case L2F: - masm.cvtsi2ssq(asFloatReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.cvtsi2ssq(asFloatReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case L2D: - masm.cvtsi2sdq(asDoubleReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.cvtsi2sdq(asDoubleReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case F2I: - masm.cvttss2sil(asIntReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.cvttss2sil(asIntReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case D2I: - masm.cvttsd2sil(asIntReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.cvttsd2sil(asIntReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case F2L: - masm.cvttss2siq(asLongReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.cvttss2siq(asLongReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case D2L: - masm.cvttsd2siq(asLongReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.cvttsd2siq(asLongReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case MOV_I2F: - masm.movss(asFloatReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movss(asFloatReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case MOV_L2D: - masm.movsd(asDoubleReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.movsd(asDoubleReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case MOV_F2I: - masm.movl(asIntReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.movl(asIntReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case MOV_D2L: - masm.movq(asLongReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.movq(asLongReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; default: @@ -814,7 +814,7 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -45,7 +45,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { Register dst = ValueUtil.asIntReg(result); if (ValueUtil.isRegister(input)) { Register src = ValueUtil.asRegister(input); @@ -67,7 +67,7 @@ break; } } else { - AMD64Address src = (AMD64Address) tasm.asAddress(input); + AMD64Address src = (AMD64Address) crb.asAddress(input); switch (opcode) { case IPOPCNT: masm.popcntl(dst, src); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BreakpointOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BreakpointOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BreakpointOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -45,7 +45,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) { asm.int3(); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ByteSwapOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ByteSwapOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ByteSwapOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -40,8 +40,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, input); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, input); switch (input.getKind()) { case Int: masm.bswapl(ValueUtil.asIntReg(result)); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Tue Dec 03 10:51:16 2013 +0100 @@ -75,8 +75,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - directCall(tasm, masm, callTarget, null, true, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + directCall(crb, masm, callTarget, null, true, state); } } @@ -91,8 +91,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - indirectCall(tasm, masm, asRegister(targetAddress), callTarget, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + indirectCall(crb, masm, asRegister(targetAddress), callTarget, state); } @Override @@ -125,8 +125,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - directCall(tasm, masm, callTarget, null, false, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + directCall(crb, masm, callTarget, null, false, state); } } @@ -141,14 +141,14 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - directCall(tasm, masm, callTarget, ((RegisterValue) callTemp).getRegister(), false, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + directCall(crb, masm, callTarget, ((RegisterValue) callTemp).getRegister(), false, state); } } - public static void directCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { + public static void directCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { if (align) { - emitAlignmentForDirectCall(tasm, masm); + emitAlignmentForDirectCall(crb, masm); } int before = masm.codeBuffer.position(); if (scratch != null) { @@ -160,43 +160,43 @@ masm.call(); } int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordDirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); masm.ensureUniquePC(); } - protected static void emitAlignmentForDirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + protected static void emitAlignmentForDirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // make sure that the displacement word of the call ends up word aligned int offset = masm.codeBuffer.position(); - offset += tasm.target.arch.getMachineCodeCallDisplacementOffset(); - int modulus = tasm.target.wordSize; + offset += crb.target.arch.getMachineCodeCallDisplacementOffset(); + int modulus = crb.target.wordSize; if (offset % modulus != 0) { masm.nop(modulus - offset % modulus); } } - public static void directJmp(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget target) { + public static void directJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target) { int before = masm.codeBuffer.position(); masm.jmp(0, true); int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, target, null); + crb.recordDirectCall(before, after, target, null); masm.ensureUniquePC(); } - public static void directConditionalJmp(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) { + public static void directConditionalJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) { int before = masm.codeBuffer.position(); masm.jcc(cond, 0, true); int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, target, null); + crb.recordDirectCall(before, after, target, null); masm.ensureUniquePC(); } - public static void indirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { + public static void indirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { int before = masm.codeBuffer.position(); masm.call(dst); int after = masm.codeBuffer.position(); - tasm.recordIndirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordIndirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); masm.ensureUniquePC(); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Tue Dec 03 10:51:16 2013 +0100 @@ -47,8 +47,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, opcode, x, y); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, opcode, x, y); } @Override @@ -62,7 +62,7 @@ } } - public static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AMD64Compare opcode, Value x, Value y) { + public static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, AMD64Compare opcode, Value x, Value y) { if (isRegister(y)) { switch (opcode) { case ICMP: masm.cmpl(asIntReg(x), asIntReg(y)); break; @@ -74,25 +74,25 @@ } } else if (isConstant(y)) { switch (opcode) { - case ICMP: masm.cmpl(asIntReg(x), tasm.asIntConst(y)); break; - case LCMP: masm.cmpq(asLongReg(x), tasm.asIntConst(y)); break; + case ICMP: masm.cmpl(asIntReg(x), crb.asIntConst(y)); break; + case LCMP: masm.cmpq(asLongReg(x), crb.asIntConst(y)); break; case ACMP: if (((Constant) y).isNull()) { masm.cmpq(asObjectReg(x), 0); break; } else { throw GraalInternalError.shouldNotReachHere("Only null object constants are allowed in comparisons"); } - case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) tasm.asFloatConstRef(y)); break; - case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) tasm.asDoubleConstRef(y)); break; + case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) crb.asFloatConstRef(y)); break; + case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) crb.asDoubleConstRef(y)); break; default: throw GraalInternalError.shouldNotReachHere(); } } else { switch (opcode) { - case ICMP: masm.cmpl(asIntReg(x), (AMD64Address) tasm.asIntAddr(y)); break; - case LCMP: masm.cmpq(asLongReg(x), (AMD64Address) tasm.asLongAddr(y)); break; - case ACMP: masm.cmpptr(asObjectReg(x), (AMD64Address) tasm.asObjectAddr(y)); break; - case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) tasm.asFloatAddr(y)); break; - case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) tasm.asDoubleAddr(y)); break; + case ICMP: masm.cmpl(asIntReg(x), (AMD64Address) crb.asIntAddr(y)); break; + case LCMP: masm.cmpq(asLongReg(x), (AMD64Address) crb.asLongAddr(y)); break; + case ACMP: masm.cmpptr(asObjectReg(x), (AMD64Address) crb.asObjectAddr(y)); break; + case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) crb.asFloatAddr(y)); break; + case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) crb.asDoubleAddr(y)); break; default: throw GraalInternalError.shouldNotReachHere(); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Tue Dec 03 10:51:16 2013 +0100 @@ -50,9 +50,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + if (crb.frameContext != null) { + crb.frameContext.leave(crb); } masm.ret(0); } @@ -73,7 +73,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.jcc(condition, destination.label()); } @@ -99,7 +99,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { floatJcc(masm, condition, unorderedIsTrue, destination.label()); } @@ -127,8 +127,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + tableswitch(crb, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); } } @@ -149,12 +149,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (key.getKind() == Kind.Int) { Register intKey = asIntReg(key); for (int i = 0; i < keyConstants.length; i++) { - if (tasm.codeCache.needsDataPatch(keyConstants[i])) { - tasm.recordDataReferenceInCode(keyConstants[i], 0, true); + if (crb.codeCache.needsDataPatch(keyConstants[i])) { + crb.recordDataReferenceInCode(keyConstants[i], 0, true); } long lc = keyConstants[i].asLong(); assert NumUtil.isInt(lc); @@ -164,14 +164,14 @@ } else if (key.getKind() == Kind.Long) { Register longKey = asLongReg(key); for (int i = 0; i < keyConstants.length; i++) { - masm.cmpq(longKey, (AMD64Address) tasm.asLongConstRef(keyConstants[i])); + masm.cmpq(longKey, (AMD64Address) crb.asLongConstRef(keyConstants[i])); masm.jcc(ConditionFlag.Equal, keyTargets[i].label()); } } else if (key.getKind() == Kind.Object) { Register objectKey = asObjectReg(key); Register temp = asObjectReg(scratch); for (int i = 0; i < keyConstants.length; i++) { - AMD64Move.move(tasm, masm, temp.asValue(Kind.Object), keyConstants[i]); + AMD64Move.move(crb, masm, temp.asValue(Kind.Object), keyConstants[i]); masm.cmpptr(objectKey, temp); masm.jcc(ConditionFlag.Equal, keyTargets[i].label()); } @@ -212,7 +212,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { assert isSorted(lowKeys) && isSorted(highKeys); Label actualDefaultTarget = defaultTarget == null ? new Label() : defaultTarget.label(); @@ -288,8 +288,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - cmove(tasm, masm, result, false, condition, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + cmove(crb, masm, result, false, condition, false, trueValue, falseValue); } } @@ -311,12 +311,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + cmove(crb, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); } } - private static void tableswitch(TargetMethodAssembler tasm, AMD64MacroAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { + private static void tableswitch(CompilationResultBuilder crb, AMD64MacroAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { Buffer buf = masm.codeBuffer; // Compare index against jump table bounds int highKey = lowKey + targets.length - 1; @@ -371,7 +371,7 @@ } JumpTable jt = new JumpTable(jumpTablePos, lowKey, highKey, 4); - tasm.compilationResult.addAnnotation(jt); + crb.compilationResult.addAnnotation(jt); } private static void floatJcc(AMD64MacroAssembler masm, ConditionFlag condition, boolean unorderedIsTrue, Label label) { @@ -385,23 +385,23 @@ masm.bind(endLabel); } - private static void cmove(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + private static void cmove(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { // check that we don't overwrite an input operand before it is used. assert !result.equals(trueValue); - AMD64Move.move(tasm, masm, result, falseValue); - cmove(tasm, masm, result, condition, trueValue); + AMD64Move.move(crb, masm, result, falseValue); + cmove(crb, masm, result, condition, trueValue); if (isFloat) { if (unorderedIsTrue && !trueOnUnordered(condition)) { - cmove(tasm, masm, result, ConditionFlag.Parity, trueValue); + cmove(crb, masm, result, ConditionFlag.Parity, trueValue); } else if (!unorderedIsTrue && trueOnUnordered(condition)) { - cmove(tasm, masm, result, ConditionFlag.Parity, falseValue); + cmove(crb, masm, result, ConditionFlag.Parity, falseValue); } } } - private static void cmove(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, ConditionFlag cond, Value other) { + private static void cmove(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, ConditionFlag cond, Value other) { if (isRegister(other)) { assert !asRegister(other).equals(asRegister(result)) : "other already overwritten by previous move"; switch (other.getKind()) { @@ -410,7 +410,7 @@ default: throw GraalInternalError.shouldNotReachHere(); } } else { - AMD64Address addr = (AMD64Address) tasm.asAddress(other); + AMD64Address addr = (AMD64Address) crb.asAddress(other); switch (other.getKind()) { case Int: masm.cmovl(cond, asRegister(result), addr); break; case Long: masm.cmovq(cond, asRegister(result), addr); break; diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java Tue Dec 03 10:51:16 2013 +0100 @@ -32,9 +32,9 @@ public abstract class AMD64LIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (AMD64MacroAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (AMD64MacroAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -48,7 +48,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { switch (opcode) { case LOG: masm.flog(asDoubleReg(result), asDoubleReg(input), false); break; case LOG10: masm.flog(asDoubleReg(result), asDoubleReg(input), true); break; diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Tue Dec 03 10:51:16 2013 +0100 @@ -53,8 +53,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -80,8 +80,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -110,9 +110,9 @@ protected abstract void emitMemAccess(AMD64MacroAssembler masm); @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (state != null) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + crb.recordImplicitException(masm.codeBuffer.position(), state); } emitMemAccess(masm); } @@ -270,7 +270,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.leaq(asLongReg(result), address.toAddress()); } } @@ -286,8 +286,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - masm.leaq(asLongReg(result), (AMD64Address) tasm.asAddress(slot)); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + masm.leaq(asLongReg(result), (AMD64Address) crb.asAddress(slot)); } } @@ -300,7 +300,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.membar(barriers); } } @@ -316,8 +316,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + crb.recordImplicitException(masm.codeBuffer.position(), state); masm.nullCheck(asRegister(input)); } @@ -346,31 +346,31 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - compareAndSwap(tasm, masm, result, address, cmpValue, newValue); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + compareAndSwap(crb, masm, result, address, cmpValue, newValue); } } - public static void move(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { if (isRegister(input)) { if (isRegister(result)) { reg2reg(masm, result, input); } else if (isStackSlot(result)) { - reg2stack(tasm, masm, result, input); + reg2stack(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isStackSlot(input)) { if (isRegister(result)) { - stack2reg(tasm, masm, result, input); + stack2reg(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isConstant(input)) { if (isRegister(result)) { - const2reg(tasm, masm, result, (Constant) input); + const2reg(crb, masm, result, (Constant) input); } else if (isStackSlot(result)) { - const2stack(tasm, masm, result, (Constant) input); + const2stack(crb, masm, result, (Constant) input); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -404,8 +404,8 @@ } } - private static void reg2stack(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Value input) { - AMD64Address dest = (AMD64Address) tasm.asAddress(result); + private static void reg2stack(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { + AMD64Address dest = (AMD64Address) crb.asAddress(result); switch (input.getKind()) { case Int: masm.movl(dest, asRegister(input)); @@ -427,8 +427,8 @@ } } - private static void stack2reg(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Value input) { - AMD64Address src = (AMD64Address) tasm.asAddress(input); + private static void stack2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { + AMD64Address src = (AMD64Address) crb.asAddress(input); switch (input.getKind()) { case Int: masm.movl(asRegister(result), src); @@ -450,7 +450,7 @@ } } - private static void const2reg(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Constant input) { + private static void const2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Constant input) { /* * Note: we use the kind of the input operand (and not the kind of the result operand) * because they don't match in all cases. For example, an object constant can be loaded to a @@ -459,8 +459,8 @@ */ switch (input.getKind().getStackKind()) { case Int: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); } // Do not optimize with an XOR as this instruction may be between // a CMP and a Jcc in which case the XOR will modify the condition @@ -469,8 +469,8 @@ break; case Long: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); } // Do not optimize with an XOR as this instruction may be between // a CMP and a Jcc in which case the XOR will modify the condition @@ -480,19 +480,19 @@ case Float: // This is *not* the same as 'constant == 0.0f' in the case where constant is -0.0f if (Float.floatToRawIntBits(input.asFloat()) == Float.floatToRawIntBits(0.0f)) { - assert !tasm.codeCache.needsDataPatch(input); + assert !crb.codeCache.needsDataPatch(input); masm.xorps(asFloatReg(result), asFloatReg(result)); } else { - masm.movflt(asFloatReg(result), (AMD64Address) tasm.asFloatConstRef(input)); + masm.movflt(asFloatReg(result), (AMD64Address) crb.asFloatConstRef(input)); } break; case Double: // This is *not* the same as 'constant == 0.0d' in the case where constant is -0.0d if (Double.doubleToRawLongBits(input.asDouble()) == Double.doubleToRawLongBits(0.0d)) { - assert !tasm.codeCache.needsDataPatch(input); + assert !crb.codeCache.needsDataPatch(input); masm.xorpd(asDoubleReg(result), asDoubleReg(result)); } else { - masm.movdbl(asDoubleReg(result), (AMD64Address) tasm.asDoubleConstRef(input)); + masm.movdbl(asDoubleReg(result), (AMD64Address) crb.asDoubleConstRef(input)); } break; case Object: @@ -501,11 +501,11 @@ // flags and interfere with the Jcc. if (input.isNull()) { masm.movq(asRegister(result), 0x0L); - } else if (tasm.target.inlineObjects) { - tasm.recordDataReferenceInCode(input, 0, true); + } else if (crb.target.inlineObjects) { + crb.recordDataReferenceInCode(input, 0, true); masm.movq(asRegister(result), 0xDEADDEADDEADDEADL); } else { - masm.movq(asRegister(result), (AMD64Address) tasm.recordDataReferenceInCode(input, 0, false)); + masm.movq(asRegister(result), (AMD64Address) crb.recordDataReferenceInCode(input, 0, false)); } break; default: @@ -513,9 +513,9 @@ } } - private static void const2stack(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Constant input) { - assert !tasm.codeCache.needsDataPatch(input); - AMD64Address dest = (AMD64Address) tasm.asAddress(result); + private static void const2stack(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Constant input) { + assert !crb.codeCache.needsDataPatch(input); + AMD64Address dest = (AMD64Address) crb.asAddress(result); switch (input.getKind().getStackKind()) { case Int: masm.movl(dest, input.asInt()); @@ -541,10 +541,10 @@ } } - protected static void compareAndSwap(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { + protected static void compareAndSwap(CompilationResultBuilder crb, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { assert asRegister(cmpValue).equals(AMD64.rax) && asRegister(result).equals(AMD64.rax); - if (tasm.target.isMP) { + if (crb.target.isMP) { masm.lock(); } switch (cmpValue.getKind()) { diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -54,17 +54,17 @@ return save.savedRegisters; } - protected void restoreRegister(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Register register, StackSlot input) { + protected void restoreRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register register, StackSlot input) { RegisterValue result = register.asValue(input.getKind()); - AMD64Move.move(tasm, masm, result, input); + AMD64Move.move(crb, masm, result, input); } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { Register[] savedRegisters = getSavedRegisters(); for (int i = 0; i < savedRegisters.length; i++) { if (savedRegisters[i] != null) { - restoreRegister(tasm, masm, savedRegisters[i], slots[i]); + restoreRegister(crb, masm, savedRegisters[i], slots[i]); } } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -66,16 +66,16 @@ this.supportsRemove = supportsRemove; } - protected void saveRegister(TargetMethodAssembler tasm, AMD64MacroAssembler masm, StackSlot result, Register register) { + protected void saveRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, StackSlot result, Register register) { RegisterValue input = register.asValue(result.getKind()); - AMD64Move.move(tasm, masm, result, input); + AMD64Move.move(crb, masm, result, input); } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { for (int i = 0; i < savedRegisters.length; i++) { if (savedRegisters[i] != null) { - saveRegister(tasm, masm, slots[i], savedRegisters[i]); + saveRegister(crb, masm, slots[i], savedRegisters[i]); } } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -41,8 +41,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, x, y); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, x, y); } @Override @@ -51,7 +51,7 @@ assert (x.getKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (x.getKind() == Kind.Long && y.getKind() == Kind.Long) : x + " " + y; } - public static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value x, Value y) { + public static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value x, Value y) { if (isRegister(y)) { switch (x.getKind()) { case Int: @@ -66,10 +66,10 @@ } else if (isConstant(y)) { switch (x.getKind()) { case Int: - masm.testl(asIntReg(x), tasm.asIntConst(y)); + masm.testl(asIntReg(x), crb.asIntConst(y)); break; case Long: - masm.testq(asLongReg(x), tasm.asIntConst(y)); + masm.testq(asLongReg(x), crb.asIntConst(y)); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -77,10 +77,10 @@ } else { switch (x.getKind()) { case Int: - masm.testl(asIntReg(x), (AMD64Address) tasm.asIntAddr(y)); + masm.testl(asIntReg(x), (AMD64Address) crb.asIntAddr(y)); break; case Long: - masm.testq(asLongReg(x), (AMD64Address) tasm.asLongAddr(y)); + masm.testq(asLongReg(x), (AMD64Address) crb.asLongAddr(y)); break; default: throw GraalInternalError.shouldNotReachHere(); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -56,11 +56,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { for (int i = 0; i < zappedRegisters.length; i++) { if (zappedRegisters[i] != null) { RegisterValue registerValue = zappedRegisters[i].asValue(zapValues[i].getPlatformKind()); - AMD64Move.move(tasm, masm, registerValue, zapValues[i]); + AMD64Move.move(crb, masm, registerValue, zapValues[i]); } } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java Tue Dec 03 10:51:16 2013 +0100 @@ -114,7 +114,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitConvert(result, x, to, from); } } @@ -131,8 +131,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -150,8 +150,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -173,8 +173,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -192,8 +192,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -217,7 +217,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { throw GraalInternalError.shouldNotReachHere(); } @@ -242,8 +242,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -270,8 +270,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, y, state); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, y, state); } @Override @@ -282,14 +282,14 @@ } @SuppressWarnings("unused") - protected static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value result) { + protected static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value result) { switch (opcode) { default: throw GraalInternalError.shouldNotReachHere(); } } - public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; if (isRegister(src)) { switch (opcode) { @@ -322,11 +322,11 @@ } if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } - public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { /** * First check if one of src1 or src2 is an AddressValue. If it is, convert the address to a * register using an lda instruction. We can just reuse the eventual dst register for this. @@ -334,12 +334,12 @@ if (src1 instanceof HSAILAddressValue) { assert (!(src2 instanceof HSAILAddressValue)); masm.emitLda(dst, ((HSAILAddressValue) src1).toAddress()); - emit(tasm, masm, opcode, dst, dst, src2, info); + emit(crb, masm, opcode, dst, dst, src2, info); return; } else if (src2 instanceof HSAILAddressValue) { assert (!(src1 instanceof HSAILAddressValue)); masm.emitLda(dst, ((HSAILAddressValue) src2).toAddress()); - emit(tasm, masm, opcode, dst, src1, dst, info); + emit(crb, masm, opcode, dst, src1, dst, info); return; } int exceptionOffset = -1; @@ -411,7 +411,7 @@ } if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -48,7 +48,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { switch (opcode) { case IPOPCNT: throw GraalInternalError.shouldNotReachHere(); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Tue Dec 03 10:51:16 2013 +0100 @@ -54,8 +54,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, condition, x, y, z, unordered); } @Override @@ -67,7 +67,7 @@ } @SuppressWarnings("unused") - public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, Condition condition, Value x, Value y, Value z, boolean unorderedIsTrue) { + public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, Condition condition, Value x, Value y, Value z, boolean unorderedIsTrue) { emitCompare(masm, condition, x, y, unorderedIsTrue); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Tue Dec 03 10:51:16 2013 +0100 @@ -104,11 +104,11 @@ * routines with keys of type Long or Object. Currently we only support the * IntegerSwitchNode so we throw an exception if the key isn't of type int. * - * @param tasm the TargetMethodAssembler + * @param crb the CompilationResultBuilder * @param masm the HSAIL assembler */ @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { if (key.getKind() == Kind.Int) { for (int i = 0; i < keyConstants.length; i++) { // Generate cascading compare and branches for each case. @@ -136,9 +136,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + if (crb.frameContext != null) { + crb.frameContext.leave(crb); } masm.exit(); } @@ -155,7 +155,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitComment("//ForeignCall to " + callName + " would have gone here"); } } @@ -213,8 +213,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, x, y, z, unordered); masm.cbr(masm.nameOf(destination.label())); } } @@ -234,8 +234,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, x, y, z, unordered); masm.cbr(masm.nameOf(destination.label())); } } @@ -255,8 +255,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, x, y, z, unordered); masm.cbr(masm.nameOf(destination.label())); } } @@ -274,7 +274,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.cbr(masm.nameOf(destination.label())); } @@ -297,7 +297,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.cbr(masm.nameOf(destination.label())); } } @@ -323,9 +323,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, left, right, right, false); - cmove(tasm, masm, result, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, left, right, right, false); + cmove(crb, masm, result, false, trueValue, falseValue); } } @@ -339,14 +339,14 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, left, right, right, unorderedIsTrue); - cmove(tasm, masm, result, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, left, right, right, unorderedIsTrue); + cmove(crb, masm, result, false, trueValue, falseValue); } } @SuppressWarnings("unused") - private static void cmove(TargetMethodAssembler tasm, HSAILAssembler masm, Value result, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + private static void cmove(CompilationResultBuilder crb, HSAILAssembler masm, Value result, boolean unorderedIsTrue, Value trueValue, Value falseValue) { // Check that we don't overwrite an input operand before it is used. assert (result.getKind() == trueValue.getKind() && result.getKind() == falseValue.getKind()); int width; diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java Tue Dec 03 10:51:16 2013 +0100 @@ -32,9 +32,9 @@ public abstract class HSAILLIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (HSAILAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (HSAILAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, HSAILAssembler masm); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Tue Dec 03 10:51:16 2013 +0100 @@ -60,8 +60,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -87,8 +87,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -114,8 +114,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -144,9 +144,9 @@ protected abstract void emitMemAccess(HSAILAssembler masm); @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { if (state != null) { - // tasm.recordImplicitException(masm.codeBuffer.position(), state); + // crb.recordImplicitException(masm.codeBuffer.position(), state); throw new InternalError("NYI"); } emitMemAccess(masm); @@ -162,7 +162,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitMembar(barriers); } } @@ -249,13 +249,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitMov(scratch, input); boolean testForNull = (kind == Kind.Object); encodePointer(masm, scratch, base, shift, alignment, testForNull); if (state != null) { throw new InternalError("NYI"); - // tasm.recordImplicitException(masm.codeBuffer.position(), state); + // crb.recordImplicitException(masm.codeBuffer.position(), state); } masm.emitStore(scratch, address.toAddress(), "u32"); } @@ -292,7 +292,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { throw new InternalError("NYI"); } } @@ -308,7 +308,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { throw new InternalError("NYI"); } } @@ -329,7 +329,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitAtomicCas(result, address.toAddress(), cmpValue, newValue); } } @@ -361,7 +361,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { // assume any encoded or decoded value could be null boolean testForNull = true; // set up scratch registers to be encoded versions @@ -392,13 +392,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { Debug.log("NullCheckOp unimplemented"); } } @SuppressWarnings("unused") - public static void move(TargetMethodAssembler tasm, HSAILAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, HSAILAssembler masm, Value result, Value input) { if (isRegister(input)) { if (isRegister(result)) { masm.emitMov(result, input); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Tue Dec 03 10:51:16 2013 +0100 @@ -56,7 +56,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { Variable dst = (Variable) result; Variable src = (Variable) x; if (from == Kind.Long && to == Kind.Int) { @@ -81,8 +81,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -100,8 +100,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -125,8 +125,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -150,12 +150,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { if (sameRegister(result, y)) { - emit(tasm, masm, opcode, result, x, null); + emit(crb, masm, opcode, result, x, null); } else { - PTXMove.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + PTXMove.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } } @@ -180,8 +180,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -208,8 +208,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, y, state); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, y, state); } @Override @@ -219,7 +219,7 @@ } } - public static void emit(TargetMethodAssembler tasm, PTXMacroAssembler masm, PTXArithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, PTXMacroAssembler masm, PTXArithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; Variable dest = (Variable) dst; @@ -267,11 +267,11 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } - public static void emit(TargetMethodAssembler tasm, PTXMacroAssembler masm, PTXArithmetic opcode, + public static void emit(CompilationResultBuilder crb, PTXMacroAssembler masm, PTXArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { int exceptionOffset = -1; Variable dest = (Variable) dst; @@ -337,7 +337,7 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXBitManipulationOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXBitManipulationOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXBitManipulationOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -46,7 +46,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { Register dst = ValueUtil.asIntReg(result); Register src = ValueUtil.asRegister(input); switch (opcode) { diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Tue Dec 03 10:51:16 2013 +0100 @@ -54,7 +54,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { emit(masm, opcode, condition, x, y, predRegNum); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Tue Dec 03 10:51:16 2013 +0100 @@ -49,9 +49,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + if (crb.frameContext != null) { + crb.frameContext.leave(crb); } masm.exit(); } @@ -63,9 +63,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + if (crb.frameContext != null) { + crb.frameContext.leave(crb); } masm.ret(); } @@ -84,7 +84,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { masm.bra(masm.nameOf(destination.label()), predRegNum); } @@ -117,8 +117,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - cmove(tasm, masm, result, false, condition, false, trueValue, falseValue, predicate); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + cmove(crb, masm, result, false, condition, false, trueValue, falseValue, predicate); } } @@ -141,25 +141,25 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue, predicate); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + cmove(crb, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue, predicate); } } - private static void cmove(TargetMethodAssembler tasm, PTXMacroAssembler asm, Value result, boolean isFloat, Condition condition, boolean unorderedIsTrue, Value trueValue, Value falseValue, + private static void cmove(CompilationResultBuilder crb, PTXMacroAssembler asm, Value result, boolean isFloat, Condition condition, boolean unorderedIsTrue, Value trueValue, Value falseValue, int predicateRegister) { // check that we don't overwrite an input operand before it is used. assert !result.equals(trueValue); - PTXMove.move(tasm, asm, result, falseValue); + PTXMove.move(crb, asm, result, falseValue); cmove(asm, result, trueValue, predicateRegister); if (isFloat) { if (unorderedIsTrue && !trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, trueValue); + // cmove(crb, masm, result, ConditionFlag.Parity, trueValue); throw GraalInternalError.unimplemented(); } else if (!unorderedIsTrue && trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, falseValue); + // cmove(crb, masm, result, ConditionFlag.Parity, falseValue); throw GraalInternalError.unimplemented(); } } @@ -218,20 +218,20 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { Kind keyKind = key.getKind(); if (keyKind == Kind.Int || keyKind == Kind.Long) { for (int i = 0; i < keyConstants.length; i++) { - if (tasm.codeCache.needsDataPatch(keyConstants[i])) { - tasm.recordDataReferenceInCode(keyConstants[i], 0, true); + if (crb.codeCache.needsDataPatch(keyConstants[i])) { + crb.recordDataReferenceInCode(keyConstants[i], 0, true); } new Setp(EQ, keyConstants[i], key, predRegNum).emit(masm); masm.bra(masm.nameOf(keyTargets[i].label()), predRegNum); } } else if (keyKind == Kind.Object) { for (int i = 0; i < keyConstants.length; i++) { - PTXMove.move(tasm, masm, scratch, keyConstants[i]); + PTXMove.move(crb, masm, scratch, keyConstants[i]); new Setp(EQ, keyConstants[i], scratch, predRegNum).emit(masm); masm.bra(keyTargets[i].label().toString(), predRegNum); } @@ -276,13 +276,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, index, scratch, predRegNum); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + tableswitch(crb, masm, lowKey, defaultTarget, targets, index, scratch, predRegNum); } } @SuppressWarnings("unused") - private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value value, Value scratch, int predNum) { + private static void tableswitch(CompilationResultBuilder crb, PTXAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value value, Value scratch, int predNum) { Buffer buf = masm.codeBuffer; // Compare index against jump table bounds @@ -311,7 +311,7 @@ // bra(Value, name); - tasm.compilationResult.addAnnotation(jt); + crb.compilationResult.addAnnotation(jt); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java Tue Dec 03 10:51:16 2013 +0100 @@ -32,9 +32,9 @@ public abstract class PTXLIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (PTXMacroAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (PTXMacroAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -51,7 +51,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Byte: @@ -87,7 +87,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Byte: @@ -122,7 +122,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Byte: @@ -159,7 +159,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Int: @@ -191,7 +191,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Tue Dec 03 10:51:16 2013 +0100 @@ -49,8 +49,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -76,8 +76,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -103,8 +103,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -129,7 +129,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { throw new InternalError("NYI"); } } @@ -145,7 +145,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { throw new InternalError("NYI"); } } @@ -166,12 +166,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - compareAndSwap(tasm, masm, result, address, cmpValue, newValue); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + compareAndSwap(crb, masm, result, address, cmpValue, newValue); } } - public static void move(TargetMethodAssembler tasm, PTXMacroAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, Value input) { if (isVariable(input)) { if (isVariable(result)) { reg2reg(masm, result, input); @@ -180,7 +180,7 @@ } } else if (isConstant(input)) { if (isVariable(result)) { - const2reg(tasm, masm, result, (Constant) input); + const2reg(crb, masm, result, (Constant) input); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -209,25 +209,25 @@ } } - private static void const2reg(TargetMethodAssembler tasm, PTXMacroAssembler masm, Value result, Constant input) { + private static void const2reg(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, Constant input) { Variable dest = (Variable) result; switch (input.getKind().getStackKind()) { case Int: case Long: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); } new Mov(dest, input).emit(masm); break; case Object: if (input.isNull()) { new Mov(dest, Constant.forLong(0x0L)).emit(masm); - } else if (tasm.target.inlineObjects) { - tasm.recordDataReferenceInCode(input, 0, true); + } else if (crb.target.inlineObjects) { + crb.recordDataReferenceInCode(input, 0, true); new Mov(dest, Constant.forLong(0xDEADDEADDEADDEADL)).emit(masm); } else { - // new Mov(dest, tasm.recordDataReferenceInCode(input, 0, false)); + // new Mov(dest, crb.recordDataReferenceInCode(input, 0, false)); } break; default: @@ -236,7 +236,7 @@ } @SuppressWarnings("unused") - protected static void compareAndSwap(TargetMethodAssembler tasm, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { + protected static void compareAndSwap(CompilationResultBuilder crb, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { throw new InternalError("NYI"); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -44,8 +44,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { - PTXMacroAssembler masm = (PTXMacroAssembler) tasm.asm; + public void emitCode(CompilationResultBuilder crb) { + PTXMacroAssembler masm = (PTXMacroAssembler) crb.asm; // Emit parameter directives for arguments int argCount = params.length; for (int i = 0; i < argCount; i++) { diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -44,7 +44,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { emit(masm, x, y, predicate); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Tue Dec 03 10:51:16 2013 +0100 @@ -63,8 +63,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -81,8 +81,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -101,8 +101,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -131,8 +131,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -160,8 +160,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -189,8 +189,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -215,9 +215,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { assert !(x instanceof SPARCAddressValue); - emit(tasm, masm, opcode, result, x, y, null); + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -249,8 +249,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, scratch1, scratch2, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, scratch1, scratch2, state); } @Override @@ -260,18 +260,18 @@ } } - public static void emit(TargetMethodAssembler tasm, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { int exceptionOffset = -1; if (isConstant(src1)) { switch (opcode) { case ISUB: - assert isSimm13(tasm.asIntConst(src1)); - new Add(asIntReg(src2), -(tasm.asIntConst(src1)), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src1)); + new Add(asIntReg(src2), -(crb.asIntConst(src1)), asIntReg(dst)).emit(masm); break; case IAND: throw GraalInternalError.unimplemented(); case IDIV: - assert isSimm13(tasm.asIntConst(src1)); + assert isSimm13(crb.asIntConst(src1)); throw GraalInternalError.unimplemented(); // new Sdivx(masm, asIntReg(src1), asIntReg(src2), // asIntReg(dst)); @@ -285,85 +285,85 @@ } else if (isConstant(src2)) { switch (opcode) { case IADD: - assert isSimm13(tasm.asIntConst(src2)); - new Add(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Add(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case ISUB: - assert isSimm13(tasm.asIntConst(src2)); - new Sub(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sub(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IMUL: - assert isSimm13(tasm.asIntConst(src2)); - new Mulx(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Mulx(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IDIV: - assert isSimm13(tasm.asIntConst(src2)); + assert isSimm13(crb.asIntConst(src2)); new Signx(asIntReg(src1), asIntReg(src1)).emit(masm); - new Sdivx(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + new Sdivx(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IAND: - assert isSimm13(tasm.asIntConst(src2)); - new And(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new And(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case ISHL: - assert isSimm13(tasm.asIntConst(src2)); - new Sll(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sll(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case ISHR: - assert isSimm13(tasm.asIntConst(src2)); - new Sra(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sra(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IUSHR: - assert isSimm13(tasm.asIntConst(src2)); - new Srl(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Srl(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IOR: - assert isSimm13(tasm.asIntConst(src2)); - new Or(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Or(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IXOR: - assert isSimm13(tasm.asIntConst(src2)); - new Xor(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Xor(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case LADD: - assert isSimm13(tasm.asIntConst(src2)); - new Add(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Add(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LSUB: - assert isSimm13(tasm.asIntConst(src2)); - new Sub(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sub(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LMUL: - assert isSimm13(tasm.asIntConst(src2)); - new Mulx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Mulx(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LDIV: throw GraalInternalError.unimplemented(); case LUDIV: throw GraalInternalError.unimplemented(); case LAND: - assert isSimm13(tasm.asIntConst(src2)); - new And(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new And(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LOR: - assert isSimm13(tasm.asIntConst(src2)); - new Or(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Or(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LXOR: - assert isSimm13(tasm.asIntConst(src2)); - new Xor(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Xor(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LSHL: - assert isSimm13(tasm.asIntConst(src2)); - new Sllx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sllx(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LSHR: - assert isSimm13(tasm.asIntConst(src2)); - new Srax(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Srax(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LUSHR: - assert isSimm13(tasm.asIntConst(src2)); - new Srlx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Srlx(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case FADD: case FMUL: @@ -477,11 +477,11 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } - public static void emit(TargetMethodAssembler tasm, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, Value scratch1, Value scratch2, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, Value scratch1, Value scratch2, LIRFrameState info) { int exceptionOffset = -1; if (isConstant(src1)) { switch (opcode) { @@ -491,9 +491,9 @@ } else if (isConstant(src2)) { switch (opcode) { case LREM: - assert isSimm13(tasm.asIntConst(src2)); - new Sdivx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(scratch1)).emit(masm); - new Mulx(asLongReg(scratch1), tasm.asIntConst(src2), asLongReg(scratch2)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sdivx(asLongReg(src1), crb.asIntConst(src2), asLongReg(scratch1)).emit(masm); + new Mulx(asLongReg(scratch1), crb.asIntConst(src2), asLongReg(scratch2)).emit(masm); new Sub(asLongReg(src1), asLongReg(scratch2), asLongReg(dst)).emit(masm); break; case LUREM: @@ -513,12 +513,12 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } @SuppressWarnings("unused") - public static void emit(TargetMethodAssembler tasm, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; if (isRegister(src)) { switch (opcode) { @@ -574,7 +574,7 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -57,7 +57,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { Register dst = asIntReg(result); if (isRegister(input)) { Register src = asRegister(input); @@ -130,20 +130,20 @@ throw GraalInternalError.shouldNotReachHere(); } - } else if (isConstant(input) && isSimm13(tasm.asIntConst(input))) { + } else if (isConstant(input) && isSimm13(crb.asIntConst(input))) { switch (opcode) { case IPOPCNT: - new Popc(tasm.asIntConst(input), dst).emit(masm); + new Popc(crb.asIntConst(input), dst).emit(masm); break; case LPOPCNT: - new Popc(tasm.asIntConst(input), dst).emit(masm); + new Popc(crb.asIntConst(input), dst).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere(); } } else { throw GraalInternalError.shouldNotReachHere(); - // SPARCAddress src = (SPARCAddress) tasm.asAddress(input); + // SPARCAddress src = (SPARCAddress) crb.asAddress(input); // switch (opcode) { // case IPOPCNT: // new Ldsw(src, tmp).emit(masm); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBreakpointOp.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBreakpointOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBreakpointOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -52,7 +52,7 @@ @Override @SuppressWarnings("unused") - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { new Trap(masm, ST_RESERVED_FOR_USER_0); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -40,8 +40,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - SPARCMove.move(tasm, masm, result, input); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + SPARCMove.move(crb, masm, result, input); switch (input.getKind()) { case Int: // masm.bswapl(ValueUtil.asIntReg(result)); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Tue Dec 03 10:51:16 2013 +0100 @@ -75,8 +75,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - directCall(tasm, masm, callTarget, null, true, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + directCall(crb, masm, callTarget, null, true, state); } } @@ -91,8 +91,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - indirectCall(tasm, masm, asRegister(targetAddress), callTarget, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + indirectCall(crb, masm, asRegister(targetAddress), callTarget, state); } @Override @@ -125,8 +125,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - directCall(tasm, masm, callTarget, null, false, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + directCall(crb, masm, callTarget, null, false, state); } } @@ -138,12 +138,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - directCall(tasm, masm, callTarget, o7, false, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + directCall(crb, masm, callTarget, o7, false, state); } } - public static void directCall(TargetMethodAssembler tasm, SPARCMacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { + public static void directCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { if (align) { // We don't need alignment on SPARC. } @@ -157,28 +157,28 @@ new Call(0).emit(masm); } int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordDirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); new Nop().emit(masm); // delay slot masm.ensureUniquePC(); } - public static void indirectJmp(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Register dst, InvokeTarget target) { + public static void indirectJmp(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register dst, InvokeTarget target) { int before = masm.codeBuffer.position(); new Sethix(0L, dst, true).emit(masm); new Jmp(new SPARCAddress(dst, 0)).emit(masm); int after = masm.codeBuffer.position(); - tasm.recordIndirectCall(before, after, target, null); + crb.recordIndirectCall(before, after, target, null); new Nop().emit(masm); // delay slot masm.ensureUniquePC(); } - public static void indirectCall(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { + public static void indirectCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { int before = masm.codeBuffer.position(); new Jmpl(dst, 0, o7).emit(masm); int after = masm.codeBuffer.position(); - tasm.recordIndirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordIndirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); new Nop().emit(masm); // delay slot masm.ensureUniquePC(); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Tue Dec 03 10:51:16 2013 +0100 @@ -49,8 +49,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, x, y); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, x, y); } @Override @@ -62,7 +62,7 @@ } } - public static void emit(TargetMethodAssembler tasm, SPARCMacroAssembler masm, SPARCCompare opcode, Value x, Value y) { + public static void emit(CompilationResultBuilder crb, SPARCMacroAssembler masm, SPARCCompare opcode, Value x, Value y) { if (isRegister(y)) { switch (opcode) { case ICMP: @@ -87,12 +87,12 @@ assert isConstant(y); switch (opcode) { case ICMP: - assert isSimm13(tasm.asIntConst(y)); - new Cmp(asIntReg(x), tasm.asIntConst(y)).emit(masm); + assert isSimm13(crb.asIntConst(y)); + new Cmp(asIntReg(x), crb.asIntConst(y)).emit(masm); break; case LCMP: - assert isSimm13(tasm.asIntConst(y)); - new Cmp(asLongReg(x), tasm.asIntConst(y)).emit(masm); + assert isSimm13(crb.asIntConst(y)); + new Cmp(asLongReg(x), crb.asIntConst(y)).emit(masm); break; case ACMP: if (((Constant) y).isNull()) { @@ -102,10 +102,10 @@ throw GraalInternalError.shouldNotReachHere("Only null object constants are allowed in comparisons"); } case FCMP: - // masm.ucomiss(asFloatReg(x), (AMD64Address) tasm.asFloatConstRef(y)); + // masm.ucomiss(asFloatReg(x), (AMD64Address) crb.asFloatConstRef(y)); // break; case DCMP: - // masm.ucomisd(asDoubleReg(x), (AMD64Address) tasm.asDoubleConstRef(y)); + // masm.ucomisd(asDoubleReg(x), (AMD64Address) crb.asDoubleConstRef(y)); // break; default: throw GraalInternalError.shouldNotReachHere(); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Tue Dec 03 10:51:16 2013 +0100 @@ -54,7 +54,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { assert kind == Kind.Int || kind == Kind.Long || kind == Kind.Object; CC cc = kind == Kind.Int ? CC.Icc : CC.Xcc; switch (condition) { @@ -123,8 +123,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - cmove(tasm, masm, result, false, condition, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + cmove(crb, masm, result, false, condition, false, trueValue, falseValue); } } @@ -146,32 +146,32 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + cmove(crb, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); } } - private static void cmove(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + private static void cmove(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { // check that we don't overwrite an input operand before it is used. assert !result.equals(trueValue); - SPARCMove.move(tasm, masm, result, falseValue); - cmove(tasm, masm, result, condition, trueValue); + SPARCMove.move(crb, masm, result, falseValue); + cmove(crb, masm, result, condition, trueValue); if (isFloat) { if (unorderedIsTrue && !trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, trueValue); + // cmove(crb, masm, result, ConditionFlag.Parity, trueValue); throw GraalInternalError.unimplemented(); } else if (!unorderedIsTrue && trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, falseValue); + // cmove(crb, masm, result, ConditionFlag.Parity, falseValue); throw GraalInternalError.unimplemented(); } } } - private static void cmove(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, ConditionFlag cond, Value other) { + private static void cmove(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, ConditionFlag cond, Value other) { if (!isRegister(other)) { - SPARCMove.move(tasm, masm, result, other); + SPARCMove.move(crb, masm, result, other); throw new InternalError("result should be scratch"); } assert !asRegister(other).equals(asRegister(result)) : "other already overwritten by previous move"; @@ -246,14 +246,14 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emitCodeHelper(tasm, masm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emitCodeHelper(crb, masm); } - public static void emitCodeHelper(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public static void emitCodeHelper(CompilationResultBuilder crb, SPARCMacroAssembler masm) { new Ret().emit(masm); // On SPARC we always leave the frame (in the delay slot). - tasm.frameContext.leave(tasm); + crb.frameContext.leave(crb); } } @@ -275,12 +275,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (key.getKind() == Kind.Int) { Register intKey = asIntReg(key); for (int i = 0; i < keyConstants.length; i++) { - if (tasm.codeCache.needsDataPatch(keyConstants[i])) { - tasm.recordDataReferenceInCode(keyConstants[i], 0, true); + if (crb.codeCache.needsDataPatch(keyConstants[i])) { + crb.recordDataReferenceInCode(keyConstants[i], 0, true); } long lc = keyConstants[i].asLong(); assert NumUtil.isInt(lc); @@ -292,7 +292,7 @@ Register longKey = asLongReg(key); Register temp = asLongReg(scratch); for (int i = 0; i < keyConstants.length; i++) { - SPARCMove.move(tasm, masm, temp.asValue(Kind.Long), keyConstants[i]); + SPARCMove.move(crb, masm, temp.asValue(Kind.Long), keyConstants[i]); new Cmp(longKey, temp).emit(masm); new Bpe(CC.Xcc, keyTargets[i].label()).emit(masm); new Nop().emit(masm); // delay slot @@ -301,7 +301,7 @@ Register objectKey = asObjectReg(key); Register temp = asObjectReg(scratch); for (int i = 0; i < keyConstants.length; i++) { - SPARCMove.move(tasm, masm, temp.asValue(Kind.Object), keyConstants[i]); + SPARCMove.move(crb, masm, temp.asValue(Kind.Object), keyConstants[i]); new Cmp(objectKey, temp).emit(masm); new Bpe(CC.Ptrcc, keyTargets[i].label()).emit(masm); new Nop().emit(masm); // delay slot @@ -344,7 +344,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { assert isSorted(lowKeys) && isSorted(highKeys); Label actualDefaultTarget = defaultTarget == null ? new Label() : defaultTarget.label(); @@ -422,12 +422,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + tableswitch(crb, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); } } - private static void tableswitch(TargetMethodAssembler tasm, SPARCAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { + private static void tableswitch(CompilationResultBuilder crb, SPARCAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { Buffer buf = masm.codeBuffer; // Compare index against jump table bounds int highKey = lowKey + targets.length - 1; @@ -455,7 +455,7 @@ int tablePos = buf.position(); JumpTable jt = new JumpTable(tablePos, lowKey, highKey, 4); - tasm.compilationResult.addAnnotation(jt); + crb.compilationResult.addAnnotation(jt); // SPARC: unimp: tableswitch extract throw GraalInternalError.unimplemented(); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java Tue Dec 03 10:51:16 2013 +0100 @@ -32,9 +32,9 @@ public abstract class SPARCLIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (SPARCMacroAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (SPARCMacroAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -48,7 +48,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { switch (opcode) { case SQRT: new Fsqrtd(asDoubleReg(input), asDoubleReg(result)).emit(masm); diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Tue Dec 03 10:51:16 2013 +0100 @@ -51,8 +51,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -78,8 +78,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -108,9 +108,9 @@ protected abstract void emitMemAccess(SPARCMacroAssembler masm); @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (state != null) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + crb.recordImplicitException(masm.codeBuffer.position(), state); } emitMemAccess(masm); } @@ -179,7 +179,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { SPARCAddress addr = address.toAddress(); if (addr.hasIndex()) { new Add(addr.getBase(), addr.getIndex(), asLongReg(result)).emit(masm); @@ -198,7 +198,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { new Membar(barriers).emit(masm); } } @@ -214,8 +214,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + crb.recordImplicitException(masm.codeBuffer.position(), state); new Ldx(new SPARCAddress(asRegister(input), 0), r0).emit(masm); } @@ -243,7 +243,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { compareAndSwap(masm, address, cmpValue, newValue); } } @@ -259,8 +259,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - SPARCAddress address = (SPARCAddress) tasm.asAddress(slot); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + SPARCAddress address = (SPARCAddress) crb.asAddress(slot); new Add(address.getBase(), address.getDisplacement(), asLongReg(result)).emit(masm); } } @@ -349,24 +349,24 @@ } } - public static void move(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Value input) { if (isRegister(input)) { if (isRegister(result)) { reg2reg(masm, result, input); } else if (isStackSlot(result)) { - reg2stack(tasm, masm, result, input); + reg2stack(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isStackSlot(input)) { if (isRegister(result)) { - stack2reg(tasm, masm, result, input); + stack2reg(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isConstant(input)) { if (isRegister(result)) { - const2reg(tasm, masm, result, (Constant) input); + const2reg(crb, masm, result, (Constant) input); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -392,8 +392,8 @@ } } - private static void reg2stack(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Value input) { - SPARCAddress dst = (SPARCAddress) tasm.asAddress(result); + private static void reg2stack(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Value input) { + SPARCAddress dst = (SPARCAddress) crb.asAddress(result); Register src = asRegister(input); switch (input.getKind()) { case Int: @@ -410,8 +410,8 @@ } } - private static void stack2reg(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Value input) { - SPARCAddress src = (SPARCAddress) tasm.asAddress(input); + private static void stack2reg(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Value input) { + SPARCAddress src = (SPARCAddress) crb.asAddress(input); Register dst = asRegister(result); switch (input.getKind()) { case Int: @@ -428,11 +428,11 @@ } } - private static void const2reg(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Constant input) { + private static void const2reg(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Constant input) { switch (input.getKind().getStackKind()) { case Int: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); new Setuw(input.asInt(), asRegister(result)).emit(masm); } else { if (input.isDefaultForKind()) { @@ -443,8 +443,8 @@ } break; case Long: { - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); new Setx(input.asLong(), asRegister(result), true).emit(masm); } else { if (input.isDefaultForKind()) { @@ -458,13 +458,13 @@ case Object: { if (input.isNull()) { new Clr(asRegister(result)).emit(masm); - } else if (tasm.target.inlineObjects) { - tasm.recordDataReferenceInCode(input, 0, true); + } else if (crb.target.inlineObjects) { + crb.recordDataReferenceInCode(input, 0, true); new Setx(0xDEADDEADDEADDEADL, asRegister(result), true).emit(masm); } else { Register dst = asRegister(result); new Rdpc(dst).emit(masm); - tasm.asObjectConstRef(input); + crb.asObjectConstRef(input); new Ldx(new SPARCAddress(dst, 0), dst).emit(masm); throw GraalInternalError.shouldNotReachHere("the patched offset might be too big for the load"); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -43,7 +43,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (isRegister(y)) { switch (x.getKind()) { case Int: @@ -58,10 +58,10 @@ } else if (isConstant(y)) { switch (x.getKind()) { case Int: - new Cmp(asIntReg(x), tasm.asIntConst(y)).emit(masm); + new Cmp(asIntReg(x), crb.asIntConst(y)).emit(masm); break; case Long: - new Cmp(asLongReg(x), tasm.asIntConst(y)).emit(masm); + new Cmp(asLongReg(x), crb.asIntConst(y)).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -69,11 +69,11 @@ } else { switch (x.getKind()) { case Int: - new Ldsw((SPARCAddress) tasm.asIntAddr(y), asIntReg(y)).emit(masm); + new Ldsw((SPARCAddress) crb.asIntAddr(y), asIntReg(y)).emit(masm); new Cmp(asIntReg(x), asIntReg(y)).emit(masm); break; case Long: - new Ldx((SPARCAddress) tasm.asLongAddr(y), asLongReg(y)).emit(masm); + new Ldx((SPARCAddress) crb.asLongAddr(y), asLongReg(y)).emit(masm); new Cmp(asLongReg(x), asLongReg(y)).emit(masm); break; default: diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InfopointOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InfopointOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InfopointOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -41,7 +41,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { - tasm.recordInfopoint(tasm.asm.codeBuffer.position(), state, reason); + public void emitCode(CompilationResultBuilder crb) { + crb.recordInfopoint(crb.asm.codeBuffer.position(), state, reason); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Tue Dec 03 10:51:16 2013 +0100 @@ -136,34 +136,34 @@ firstVariableNumber = num; } - public void emitCode(TargetMethodAssembler tasm) { - if (tasm.frameContext != null) { - tasm.frameContext.enter(tasm); + public void emitCode(CompilationResultBuilder crb) { + if (crb.frameContext != null) { + crb.frameContext.enter(crb); } for (Block b : codeEmittingOrder()) { - emitBlock(tasm, b); + emitBlock(crb, b); } } - private void emitBlock(TargetMethodAssembler tasm, Block block) { + private void emitBlock(CompilationResultBuilder crb, Block block) { if (Debug.isDumpEnabled()) { - tasm.blockComment(String.format("block B%d %s", block.getId(), block.getLoop())); + crb.blockComment(String.format("block B%d %s", block.getId(), block.getLoop())); } for (LIRInstruction op : lir(block)) { if (Debug.isDumpEnabled()) { - tasm.blockComment(String.format("%d %s", op.id(), op)); + crb.blockComment(String.format("%d %s", op.id(), op)); } - emitOp(tasm, op); + emitOp(crb, op); } } - private static void emitOp(TargetMethodAssembler tasm, LIRInstruction op) { + private static void emitOp(CompilationResultBuilder crb, LIRInstruction op) { try { try { - op.emitCode(tasm); + op.emitCode(crb); } catch (AssertionError t) { throw new GraalInternalError(t); } catch (RuntimeException t) { diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Tue Dec 03 10:51:16 2013 +0100 @@ -223,7 +223,7 @@ id = -1; } - public abstract void emitCode(TargetMethodAssembler tasm); + public abstract void emitCode(CompilationResultBuilder crb); public final int id() { return id; diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Tue Dec 03 10:51:16 2013 +0100 @@ -94,11 +94,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { + public void emitCode(CompilationResultBuilder crb) { if (align) { - tasm.asm.align(tasm.target.wordSize * 2); + crb.asm.align(crb.target.wordSize * 2); } - tasm.asm.bind(label); + crb.asm.bind(label); } public Label getLabel() { @@ -120,8 +120,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { - tasm.asm.jmp(destination.label()); + public void emitCode(CompilationResultBuilder crb) { + crb.asm.jmp(destination.label()); } public LabelRef destination() { @@ -209,7 +209,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { + public void emitCode(CompilationResultBuilder crb) { throw new GraalInternalError(this + " should have been replaced"); } } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Tue Dec 03 10:51:16 2013 +0100 @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.asm; + +import static com.oracle.graal.api.code.ValueUtil.*; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.asm.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.lir.*; + +/** + * Fills in a {@link CompilationResult} as its code is being assembled. + */ +public class CompilationResultBuilder { + + private static class ExceptionInfo { + + public final int codeOffset; + public final LabelRef exceptionEdge; + + public ExceptionInfo(int pcOffset, LabelRef exceptionEdge) { + this.codeOffset = pcOffset; + this.exceptionEdge = exceptionEdge; + } + } + + public final AbstractAssembler asm; + public final CompilationResult compilationResult; + public final TargetDescription target; + public final CodeCacheProvider codeCache; + public final ForeignCallsProvider foreignCalls; + public final FrameMap frameMap; + + /** + * The object that emits code for managing a method's frame. If null, no frame is used by the + * method. + */ + public final FrameContext frameContext; + + private List exceptionInfoList; + + public CompilationResultBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, + CompilationResult compilationResult) { + this.target = codeCache.getTarget(); + this.codeCache = codeCache; + this.foreignCalls = foreignCalls; + this.frameMap = frameMap; + this.asm = asm; + this.compilationResult = compilationResult; + this.frameContext = frameContext; + } + + public void setFrameSize(int frameSize) { + compilationResult.setFrameSize(frameSize); + } + + private static final CompilationResult.Mark[] NO_REFS = {}; + + public CompilationResult.Mark recordMark(Object id) { + return compilationResult.recordMark(asm.codeBuffer.position(), id, NO_REFS); + } + + public CompilationResult.Mark recordMark(Object id, CompilationResult.Mark... references) { + return compilationResult.recordMark(asm.codeBuffer.position(), id, references); + } + + public void blockComment(String s) { + compilationResult.addAnnotation(new CompilationResult.CodeComment(asm.codeBuffer.position(), s)); + } + + /** + * Sets the {@linkplain CompilationResult#setTargetCode(byte[], int) code} and + * {@linkplain CompilationResult#recordExceptionHandler(int, int) exception handler} fields of + * the compilation result. + */ + public void finish() { + // Install code, data and frame size + compilationResult.setTargetCode(asm.codeBuffer.close(false), asm.codeBuffer.position()); + + // Record exception handlers if they exist + if (exceptionInfoList != null) { + for (ExceptionInfo ei : exceptionInfoList) { + int codeOffset = ei.codeOffset; + compilationResult.recordExceptionHandler(codeOffset, ei.exceptionEdge.label().position()); + } + } + } + + public void recordExceptionHandlers(int pcOffset, LIRFrameState info) { + if (info != null) { + if (info.exceptionEdge != null) { + if (exceptionInfoList == null) { + exceptionInfoList = new ArrayList<>(4); + } + exceptionInfoList.add(new ExceptionInfo(pcOffset, info.exceptionEdge)); + } + } + } + + public void recordImplicitException(int pcOffset, LIRFrameState info) { + // record an implicit exception point + if (info != null) { + compilationResult.recordInfopoint(pcOffset, info.debugInfo(), InfopointReason.IMPLICIT_EXCEPTION); + assert info.exceptionEdge == null; + } + } + + public void recordDirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { + DebugInfo debugInfo = info != null ? info.debugInfo() : null; + compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, true); + } + + public void recordIndirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { + DebugInfo debugInfo = info != null ? info.debugInfo() : null; + compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, false); + } + + public void recordInfopoint(int pos, LIRFrameState info, InfopointReason reason) { + // infopoints always need debug info + DebugInfo debugInfo = info.debugInfo(); + compilationResult.recordInfopoint(pos, debugInfo, reason); + } + + public AbstractAddress recordDataReferenceInCode(Constant data, int alignment, boolean inlined) { + assert data != null; + int pos = asm.codeBuffer.position(); + Debug.log("Data reference in code: pos = %d, data = %s", pos, data.toString()); + compilationResult.recordDataReference(pos, data, alignment, inlined); + return asm.getPlaceholder(); + } + + public AbstractAddress recordDataReferenceInCode(byte[] data, int alignment) { + assert data != null; + int pos = asm.codeBuffer.position(); + Debug.log("Raw data reference in code: pos = %d, data = %s", pos, data.toString()); + compilationResult.recordDataReference(pos, data, alignment); + return asm.getPlaceholder(); + } + + /** + * Returns the integer value of any constant that can be represented by a 32-bit integer value, + * including long constants that fit into the 32-bit range. + */ + public int asIntConst(Value value) { + assert (value.getKind().isNumericInteger()) && isConstant(value); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + long c = constant.asLong(); + if (!NumUtil.isInt(c)) { + throw GraalInternalError.shouldNotReachHere(); + } + return (int) c; + } + + /** + * Returns the float value of any constant that can be represented by a 32-bit float value. + */ + public float asFloatConst(Value value) { + assert (value.getKind().getStackKind() == Kind.Float && isConstant(value)); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + return constant.asFloat(); + } + + /** + * Returns the long value of any constant that can be represented by a 64-bit long value. + */ + public long asLongConst(Value value) { + assert (value.getKind().getStackKind() == Kind.Long && isConstant(value)); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + return constant.asLong(); + } + + /** + * Returns the double value of any constant that can be represented by a 64-bit float value. + */ + public double asDoubleConst(Value value) { + assert (value.getKind().getStackKind() == Kind.Double && isConstant(value)); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + return constant.asDouble(); + } + + /** + * Returns the address of a float constant that is embedded as a data reference into the code. + */ + public AbstractAddress asFloatConstRef(Value value) { + return asFloatConstRef(value, 4); + } + + public AbstractAddress asFloatConstRef(Value value, int alignment) { + assert value.getKind() == Kind.Float && isConstant(value); + return recordDataReferenceInCode((Constant) value, alignment, false); + } + + /** + * Returns the address of a double constant that is embedded as a data reference into the code. + */ + public AbstractAddress asDoubleConstRef(Value value) { + return asDoubleConstRef(value, 8); + } + + public AbstractAddress asDoubleConstRef(Value value, int alignment) { + assert value.getKind() == Kind.Double && isConstant(value); + return recordDataReferenceInCode((Constant) value, alignment, false); + } + + /** + * Returns the address of a long constant that is embedded as a data reference into the code. + */ + public AbstractAddress asLongConstRef(Value value) { + assert value.getKind() == Kind.Long && isConstant(value); + return recordDataReferenceInCode((Constant) value, 8, false); + } + + /** + * Returns the address of an object constant that is embedded as a data reference into the code. + */ + public AbstractAddress asObjectConstRef(Value value) { + assert value.getKind() == Kind.Object && isConstant(value); + return recordDataReferenceInCode((Constant) value, 8, false); + } + + public AbstractAddress asIntAddr(Value value) { + assert value.getKind() == Kind.Int; + return asAddress(value); + } + + public AbstractAddress asLongAddr(Value value) { + assert value.getKind() == Kind.Long; + return asAddress(value); + } + + public AbstractAddress asObjectAddr(Value value) { + assert value.getKind() == Kind.Object; + return asAddress(value); + } + + public AbstractAddress asFloatAddr(Value value) { + assert value.getKind() == Kind.Float; + return asAddress(value); + } + + public AbstractAddress asDoubleAddr(Value value) { + assert value.getKind() == Kind.Double; + return asAddress(value); + } + + public AbstractAddress asAddress(Value value) { + assert isStackSlot(value); + StackSlot slot = asStackSlot(value); + return asm.makeAddress(frameMap.registerConfig.getFrameRegister(), frameMap.offsetForStackSlot(slot)); + } +} diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/FrameContext.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/FrameContext.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/FrameContext.java Tue Dec 03 10:51:16 2013 +0100 @@ -35,7 +35,7 @@ *
  • stack overflow checking
  • * */ - void enter(TargetMethodAssembler tasm); + void enter(CompilationResultBuilder crb); /** * Emits code to be executed just prior to returning from a method. This may include: @@ -45,5 +45,5 @@ *
  • destroying the stack frame
  • * */ - void leave(TargetMethodAssembler tasm); + void leave(CompilationResultBuilder crb); } diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java Tue Dec 03 10:08:35 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,277 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.asm; - -import static com.oracle.graal.api.code.ValueUtil.*; - -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.lir.*; - -public class TargetMethodAssembler { - - private static class ExceptionInfo { - - public final int codeOffset; - public final LabelRef exceptionEdge; - - public ExceptionInfo(int pcOffset, LabelRef exceptionEdge) { - this.codeOffset = pcOffset; - this.exceptionEdge = exceptionEdge; - } - } - - public final AbstractAssembler asm; - public final CompilationResult compilationResult; - public final TargetDescription target; - public final CodeCacheProvider codeCache; - public final ForeignCallsProvider foreignCalls; - public final FrameMap frameMap; - - /** - * The object that emits code for managing a method's frame. If null, no frame is used by the - * method. - */ - public final FrameContext frameContext; - - private List exceptionInfoList; - - public TargetMethodAssembler(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, - CompilationResult compilationResult) { - this.target = codeCache.getTarget(); - this.codeCache = codeCache; - this.foreignCalls = foreignCalls; - this.frameMap = frameMap; - this.asm = asm; - this.compilationResult = compilationResult; - this.frameContext = frameContext; - } - - public void setFrameSize(int frameSize) { - compilationResult.setFrameSize(frameSize); - } - - private static final CompilationResult.Mark[] NO_REFS = {}; - - public CompilationResult.Mark recordMark(Object id) { - return compilationResult.recordMark(asm.codeBuffer.position(), id, NO_REFS); - } - - public CompilationResult.Mark recordMark(Object id, CompilationResult.Mark... references) { - return compilationResult.recordMark(asm.codeBuffer.position(), id, references); - } - - public void blockComment(String s) { - compilationResult.addAnnotation(new CompilationResult.CodeComment(asm.codeBuffer.position(), s)); - } - - /** - * Sets the {@linkplain CompilationResult#setTargetCode(byte[], int) code} and - * {@linkplain CompilationResult#recordExceptionHandler(int, int) exception handler} fields of - * the compilation result. - */ - public void finish() { - // Install code, data and frame size - compilationResult.setTargetCode(asm.codeBuffer.close(false), asm.codeBuffer.position()); - - // Record exception handlers if they exist - if (exceptionInfoList != null) { - for (ExceptionInfo ei : exceptionInfoList) { - int codeOffset = ei.codeOffset; - compilationResult.recordExceptionHandler(codeOffset, ei.exceptionEdge.label().position()); - } - } - } - - public void recordExceptionHandlers(int pcOffset, LIRFrameState info) { - if (info != null) { - if (info.exceptionEdge != null) { - if (exceptionInfoList == null) { - exceptionInfoList = new ArrayList<>(4); - } - exceptionInfoList.add(new ExceptionInfo(pcOffset, info.exceptionEdge)); - } - } - } - - public void recordImplicitException(int pcOffset, LIRFrameState info) { - // record an implicit exception point - if (info != null) { - compilationResult.recordInfopoint(pcOffset, info.debugInfo(), InfopointReason.IMPLICIT_EXCEPTION); - assert info.exceptionEdge == null; - } - } - - public void recordDirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { - DebugInfo debugInfo = info != null ? info.debugInfo() : null; - compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, true); - } - - public void recordIndirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { - DebugInfo debugInfo = info != null ? info.debugInfo() : null; - compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, false); - } - - public void recordInfopoint(int pos, LIRFrameState info, InfopointReason reason) { - // infopoints always need debug info - DebugInfo debugInfo = info.debugInfo(); - compilationResult.recordInfopoint(pos, debugInfo, reason); - } - - public AbstractAddress recordDataReferenceInCode(Constant data, int alignment, boolean inlined) { - assert data != null; - int pos = asm.codeBuffer.position(); - Debug.log("Data reference in code: pos = %d, data = %s", pos, data.toString()); - compilationResult.recordDataReference(pos, data, alignment, inlined); - return asm.getPlaceholder(); - } - - public AbstractAddress recordDataReferenceInCode(byte[] data, int alignment) { - assert data != null; - int pos = asm.codeBuffer.position(); - Debug.log("Raw data reference in code: pos = %d, data = %s", pos, data.toString()); - compilationResult.recordDataReference(pos, data, alignment); - return asm.getPlaceholder(); - } - - /** - * Returns the integer value of any constant that can be represented by a 32-bit integer value, - * including long constants that fit into the 32-bit range. - */ - public int asIntConst(Value value) { - assert (value.getKind().isNumericInteger()) && isConstant(value); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - long c = constant.asLong(); - if (!NumUtil.isInt(c)) { - throw GraalInternalError.shouldNotReachHere(); - } - return (int) c; - } - - /** - * Returns the float value of any constant that can be represented by a 32-bit float value. - */ - public float asFloatConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Float && isConstant(value)); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - return constant.asFloat(); - } - - /** - * Returns the long value of any constant that can be represented by a 64-bit long value. - */ - public long asLongConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Long && isConstant(value)); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - return constant.asLong(); - } - - /** - * Returns the double value of any constant that can be represented by a 64-bit float value. - */ - public double asDoubleConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Double && isConstant(value)); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - return constant.asDouble(); - } - - /** - * Returns the address of a float constant that is embedded as a data reference into the code. - */ - public AbstractAddress asFloatConstRef(Value value) { - return asFloatConstRef(value, 4); - } - - public AbstractAddress asFloatConstRef(Value value, int alignment) { - assert value.getKind() == Kind.Float && isConstant(value); - return recordDataReferenceInCode((Constant) value, alignment, false); - } - - /** - * Returns the address of a double constant that is embedded as a data reference into the code. - */ - public AbstractAddress asDoubleConstRef(Value value) { - return asDoubleConstRef(value, 8); - } - - public AbstractAddress asDoubleConstRef(Value value, int alignment) { - assert value.getKind() == Kind.Double && isConstant(value); - return recordDataReferenceInCode((Constant) value, alignment, false); - } - - /** - * Returns the address of a long constant that is embedded as a data reference into the code. - */ - public AbstractAddress asLongConstRef(Value value) { - assert value.getKind() == Kind.Long && isConstant(value); - return recordDataReferenceInCode((Constant) value, 8, false); - } - - /** - * Returns the address of an object constant that is embedded as a data reference into the code. - */ - public AbstractAddress asObjectConstRef(Value value) { - assert value.getKind() == Kind.Object && isConstant(value); - return recordDataReferenceInCode((Constant) value, 8, false); - } - - public AbstractAddress asIntAddr(Value value) { - assert value.getKind() == Kind.Int; - return asAddress(value); - } - - public AbstractAddress asLongAddr(Value value) { - assert value.getKind() == Kind.Long; - return asAddress(value); - } - - public AbstractAddress asObjectAddr(Value value) { - assert value.getKind() == Kind.Object; - return asAddress(value); - } - - public AbstractAddress asFloatAddr(Value value) { - assert value.getKind() == Kind.Float; - return asAddress(value); - } - - public AbstractAddress asDoubleAddr(Value value) { - assert value.getKind() == Kind.Double; - return asAddress(value); - } - - public AbstractAddress asAddress(Value value) { - assert isStackSlot(value); - StackSlot slot = asStackSlot(value); - return asm.makeAddress(frameMap.registerConfig.getFrameRegister(), frameMap.offsetForStackSlot(slot)); - } -} diff -r 0b4d38339708 -r 1a66453f73db graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java --- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java Tue Dec 03 10:08:35 2013 +0100 +++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java Tue Dec 03 10:51:16 2013 +0100 @@ -99,8 +99,8 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { - return original.newAssembler(lirGen, compilationResult); + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult) { + return original.newCompilationResultBuilder(lirGen, compilationResult); } @Override @@ -109,15 +109,15 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - FrameMap frameMap = tasm.frameMap; + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + FrameMap frameMap = crb.frameMap; RegisterConfig regConfig = frameMap.registerConfig; HotSpotVMConfig config = original.getRuntime().getConfig(); Label verifiedStub = new Label(); // Emit the prefix - original.emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub); + original.emitCodePrefix(installedCodeOwner, crb, asm, regConfig, config, verifiedStub); if (getInstrumentedMethod().equals(installedCodeOwner)) { // Inject code for {@link OptimizedCallTarget#call(PackedFrame, Arguments)} @@ -125,10 +125,10 @@ } // Emit code for the LIR - original.emitCodeBody(installedCodeOwner, tasm, lirGen); + original.emitCodeBody(installedCodeOwner, crb, lirGen); // Emit the suffix - original.emitCodeSuffix(installedCodeOwner, tasm, lirGen, asm, frameMap); + original.emitCodeSuffix(installedCodeOwner, crb, lirGen, asm, frameMap); } private void injectCode(AMD64MacroAssembler asm, HotSpotVMConfig config) {