Search in sources :

Example 11 with SPARCAddress

use of org.graalvm.compiler.asm.sparc.SPARCAddress in project graal by oracle.

the class SPARCHotSpotSafepointOp method emitThreadLocalPoll.

/**
 * Emit a thread-local safepoint poll.
 */
private static void emitThreadLocalPoll(CompilationResultBuilder crb, SPARCMacroAssembler masm, GraalHotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register thread) {
    assert !atReturn || state == null : "state is unneeded at return";
    assert config.threadPollingPageOffset >= 0;
    try (ScratchRegister scratchReg = masm.getScratchRegister()) {
        Register scratch = scratchReg.getRegister();
        masm.ldx(new SPARCAddress(thread, config.threadPollingPageOffset), scratch);
        crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_FAR : config.MARKID_POLL_FAR);
        if (state != null) {
            final int pos = masm.position();
            crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
        }
        masm.ldx(new SPARCAddress(scratch, 0), g0);
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 12 with SPARCAddress

use of org.graalvm.compiler.asm.sparc.SPARCAddress in project graal by oracle.

the class SPARCHotSpotBackend method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner) {
    SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm;
    // TODO: (sa) Fold the two traversals into one
    stuffDelayedControlTransfers(lir);
    int constantSize = calculateConstantSize(lir);
    boolean canUseImmediateConstantLoad = constantSize < (1 << 13);
    masm.setImmediateConstantLoad(canUseImmediateConstantLoad);
    FrameMap frameMap = crb.frameMap;
    RegisterConfig regConfig = frameMap.getRegisterConfig();
    Label unverifiedStub = installedCodeOwner == null || installedCodeOwner.isStatic() ? null : new Label();
    for (int i = 0; i < 2; i++) {
        if (i > 0) {
            crb.resetForEmittingCode();
            lir.resetLabels();
            resetDelayedControlTransfers(lir);
        }
        // Emit the prefix
        if (unverifiedStub != null) {
            crb.recordMark(config.MARKID_UNVERIFIED_ENTRY);
            // We need to use JavaCall here because we haven't entered the frame yet.
            CallingConvention cc = regConfig.getCallingConvention(HotSpotCallingConventionType.JavaCall, null, new JavaType[] { getProviders().getMetaAccess().lookupJavaType(Object.class) }, this);
            // see MacroAssembler::ic_call
            Register inlineCacheKlass = g5;
            try (ScratchRegister sc = masm.getScratchRegister()) {
                Register scratch = sc.getRegister();
                Register receiver = asRegister(cc.getArgument(0));
                SPARCAddress src = new SPARCAddress(receiver, config.hubOffset);
                masm.ldx(src, scratch);
                masm.cmp(scratch, inlineCacheKlass);
            }
            BPCC.emit(masm, Xcc, NotEqual, NOT_ANNUL, PREDICT_NOT_TAKEN, unverifiedStub);
            // delay slot
            masm.nop();
        }
        masm.align(config.codeEntryAlignment);
        crb.recordMark(config.MARKID_OSR_ENTRY);
        crb.recordMark(config.MARKID_VERIFIED_ENTRY);
        // Emit code for the LIR
        crb.emit(lir);
    }
    profileInstructions(lir, crb);
    HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
    HotSpotForeignCallsProvider foreignCalls = getProviders().getForeignCalls();
    if (!frameContext.isStub) {
        crb.recordMark(config.MARKID_EXCEPTION_HANDLER_ENTRY);
        SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, null);
        crb.recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
        SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER), null, 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
    }
    if (unverifiedStub != null) {
        masm.bind(unverifiedStub);
        try (ScratchRegister sc = masm.getScratchRegister()) {
            Register scratch = sc.getRegister();
            SPARCCall.indirectJmp(crb, masm, scratch, foreignCalls.lookupForeignCall(IC_MISS_HANDLER));
        }
    }
    masm.peephole();
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCFrameMap(org.graalvm.compiler.lir.sparc.SPARCFrameMap) FrameMap(org.graalvm.compiler.lir.framemap.FrameMap) Label(org.graalvm.compiler.asm.Label) Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCAssembler.isGlobalRegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isGlobalRegister) SPARCMacroAssembler(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler) HotSpotForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 13 with SPARCAddress

use of org.graalvm.compiler.asm.sparc.SPARCAddress in project graal by oracle.

the class SPARCHotSpotSafepointOp method emitGlobalPoll.

/**
 * Emit a global safepoint poll.
 */
private static void emitGlobalPoll(CompilationResultBuilder crb, SPARCMacroAssembler masm, GraalHotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register safepointPollAddress) {
    crb.recordMark(atReturn ? config.MARKID_POLL_RETURN_FAR : config.MARKID_POLL_FAR);
    if (state != null) {
        final int pos = masm.position();
        crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
    }
    masm.ldx(new SPARCAddress(safepointPollAddress, 0), g0);
}
Also used : SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 14 with SPARCAddress

use of org.graalvm.compiler.asm.sparc.SPARCAddress in project graal by oracle.

the class SPARCMove method const2stack.

public static void const2stack(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Register constantTableBase, SPARCDelayedControlTransfer delaySlotLir, JavaConstant constant) {
    if (constant.isDefaultForKind() || constant.isNull()) {
        SPARCAddress resultAddress = (SPARCAddress) crb.asAddress(result);
        emitStore(g0.asValue(LIRKind.combine(result)), resultAddress, result.getPlatformKind(), delaySlotLir, null, crb, masm);
    } else {
        try (ScratchRegister sc = masm.getScratchRegister()) {
            Value scratchRegisterValue = sc.getRegister().asValue(LIRKind.combine(result));
            const2reg(crb, masm, scratchRegisterValue, constantTableBase, constant, SPARCDelayedControlTransfer.DUMMY);
            SPARCAddress resultAddress = (SPARCAddress) crb.asAddress(result);
            emitStore(scratchRegisterValue, resultAddress, result.getPlatformKind(), delaySlotLir, null, crb, masm);
        }
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 15 with SPARCAddress

use of org.graalvm.compiler.asm.sparc.SPARCAddress in project graal by oracle.

the class SPARCMove method emitLoad.

public static void emitLoad(CompilationResultBuilder crb, SPARCMacroAssembler masm, SPARCAddress address, Value result, boolean signExtend, PlatformKind kind, SPARCDelayedControlTransfer delayedControlTransfer, LIRFrameState state) {
    try (ScratchRegister sc = masm.getScratchRegister()) {
        Register scratch = sc.getRegister();
        final SPARCAddress addr = generateSimm13OffsetLoad(address, masm, scratch);
        final Register dst = asRegister(result);
        delayedControlTransfer.emitControlTransfer(crb, masm);
        if (state != null) {
            crb.recordImplicitException(masm.position(), state);
        }
        int byteCount = kind.getSizeInBytes();
        masm.ld(addr, dst, byteCount, signExtend);
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCAssembler.isSingleFloatRegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isSingleFloatRegister) SPARCAssembler.isCPURegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isCPURegister) SPARCAssembler.isDoubleFloatRegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isDoubleFloatRegister) Register(jdk.vm.ci.code.Register) ValueUtil.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Aggregations

SPARCAddress (org.graalvm.compiler.asm.sparc.SPARCAddress)20 Register (jdk.vm.ci.code.Register)14 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)12 ScratchRegister (org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister)11 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)5 Label (org.graalvm.compiler.asm.Label)4 SPARCMacroAssembler (org.graalvm.compiler.asm.sparc.SPARCMacroAssembler)4 SPARCAssembler.isCPURegister (org.graalvm.compiler.asm.sparc.SPARCAssembler.isCPURegister)3 SPARCAssembler.isDoubleFloatRegister (org.graalvm.compiler.asm.sparc.SPARCAssembler.isDoubleFloatRegister)3 SPARCAssembler.isSingleFloatRegister (org.graalvm.compiler.asm.sparc.SPARCAssembler.isSingleFloatRegister)3 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 Value (jdk.vm.ci.meta.Value)2 SPARCAssembler.isGlobalRegister (org.graalvm.compiler.asm.sparc.SPARCAssembler.isGlobalRegister)2 CallingConvention (jdk.vm.ci.code.CallingConvention)1 RegisterConfig (jdk.vm.ci.code.RegisterConfig)1 RegisterValue (jdk.vm.ci.code.RegisterValue)1 StackSlot (jdk.vm.ci.code.StackSlot)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 ValueUtil.asStackSlot (jdk.vm.ci.code.ValueUtil.asStackSlot)1 ValueUtil.isStackSlot (jdk.vm.ci.code.ValueUtil.isStackSlot)1