Mercurial > hg > truffle
diff graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java @ 10854:e1fcdda22831
SPARC: can compile some stubs now but they don't work yet
author | twisti |
---|---|
date | Mon, 22 Jul 2013 22:26:49 -0700 |
parents | 7a8d6ba83a04 |
children | 563c6d1994c0 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Jul 22 21:43:31 2013 -0700 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Jul 22 22:26:49 2013 -0700 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.sparc; +import java.util.*; + import sun.misc.*; import com.oracle.graal.api.code.*; @@ -36,6 +38,7 @@ import com.oracle.graal.hotspot.stubs.Stub; import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; +import com.oracle.graal.lir.sparc.*; import com.oracle.graal.nodes.*; import static com.oracle.graal.sparc.SPARC.*; @@ -93,7 +96,7 @@ } } - class HotSpotFrameContext implements FrameContext { + public class HotSpotFrameContext implements FrameContext { final boolean isStub; @@ -138,6 +141,7 @@ public TargetMethodAssembler newAssembler(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"; Stub stub = gen.getStub(); AbstractAssembler masm = createAssembler(frameMap); @@ -150,6 +154,12 @@ tasm.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); } + if (stub != null) { + // SPARC stubs always enter a frame which saves the registers. + final Set<Register> definedRegisters = new HashSet<>(); + stub.initDestroyedRegisters(definedRegisters); + } + return tasm; } @@ -165,13 +175,15 @@ if (unverifiedStub != null) { tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY); - CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, new JavaType[]{runtime().lookupJavaType(Object.class)}, target, false); + // We need to use JavaCall here because we haven't entered the frame yet. + CallingConvention cc = regConfig.getCallingConvention(JavaCall, null, new JavaType[]{runtime().lookupJavaType(Object.class)}, target, false); Register inlineCacheKlass = g5; // see MacroAssembler::ic_call + Register scratch = g3; Register receiver = asRegister(cc.getArgument(0)); SPARCAddress src = new SPARCAddress(receiver, config.hubOffset); - new Ldx(src, g0).emit(masm); - new Cmp(inlineCacheKlass, g0).emit(masm); + new Ldx(src, scratch).emit(masm); + new Cmp(scratch, inlineCacheKlass).emit(masm); new Bpne(CC.Xcc, unverifiedStub).emit(masm); new Nop().emit(masm); // delay slot } @@ -186,10 +198,9 @@ HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext; if (frameContext != null && !frameContext.isStub) { tasm.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); -// SPARCCall.directCall(tasm, asm, runtime().lookupForeignCall(EXCEPTION_HANDLER), null, false, -// null); + SPARCCall.directCall(tasm, masm, runtime().lookupForeignCall(EXCEPTION_HANDLER), null, false, null); tasm.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); -// SPARCCall.directCall(tasm, asm, runtime().lookupForeignCall(DEOPT_HANDLER), null, false, null); + SPARCCall.directCall(tasm, masm, runtime().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 @@ -198,8 +209,8 @@ if (unverifiedStub != null) { masm.bind(unverifiedStub); -// SPARCCall.directJmp(tasm, asm, runtime().lookupForeignCall(IC_MISS_HANDLER)); - // throw new InternalError("g0 must be scratch register"); + Register scratch = g3; + SPARCCall.indirectJmp(tasm, masm, scratch, runtime().lookupForeignCall(IC_MISS_HANDLER)); } } }