Search in sources :

Example 1 with CompressEncoding

use of org.graalvm.compiler.core.common.CompressEncoding in project graal by oracle.

the class AArch64HotSpotLIRGenerator method emitNullCheck.

@Override
public void emitNullCheck(Value address, LIRFrameState state) {
    if (address.getValueKind().getPlatformKind() == AArch64Kind.DWORD) {
        CompressEncoding encoding = config.getOopEncoding();
        Value uncompressed = emitUncompress(address, encoding, false);
        append(new AArch64Move.NullCheckOp(asAddressValue(uncompressed), state));
    } else {
        super.emitNullCheck(address, state);
    }
}
Also used : AArch64Move(org.graalvm.compiler.lir.aarch64.AArch64Move) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) LIRValueUtil.isConstantValue(org.graalvm.compiler.lir.LIRValueUtil.isConstantValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) AArch64AddressValue(org.graalvm.compiler.lir.aarch64.AArch64AddressValue) RegisterValue(jdk.vm.ci.code.RegisterValue)

Example 2 with CompressEncoding

use of org.graalvm.compiler.core.common.CompressEncoding in project graal by oracle.

the class AMD64HotSpotMove method decodeKlassPointer.

public static void decodeKlassPointer(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register register, Register scratch, AMD64Address address, GraalHotSpotVMConfig config) {
    CompressEncoding encoding = config.getKlassEncoding();
    masm.movl(register, address);
    if (encoding.getShift() != 0) {
        masm.shlq(register, encoding.getShift());
    }
    boolean pic = GeneratePIC.getValue(crb.getOptions());
    if (pic || encoding.hasBase()) {
        if (pic) {
            masm.movq(scratch, masm.getPlaceholder(-1));
            crb.recordMark(config.MARKID_NARROW_KLASS_BASE_ADDRESS);
        } else {
            assert encoding.getBase() != 0;
            masm.movq(scratch, encoding.getBase());
        }
        masm.addq(register, scratch);
    }
}
Also used : CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding)

Example 3 with CompressEncoding

use of org.graalvm.compiler.core.common.CompressEncoding in project graal by oracle.

the class SPARCTruffleCallBoundaryInstumentationFactory method createBuilder.

@Override
public CompilationResultBuilder createBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, DataBuilder dataBuilder, FrameContext frameContext, OptionValues options, DebugContext debug, CompilationResult compilationResult) {
    return new TruffleCallBoundaryInstrumentation(metaAccess, codeCache, foreignCalls, frameMap, asm, dataBuilder, frameContext, options, debug, compilationResult, config, registers) {

        @Override
        protected void injectTailCallCode(int installedCodeOffset, int entryPointOffset) {
            SPARCMacroAssembler masm = (SPARCMacroAssembler) this.asm;
            try (ScratchRegister scratch = masm.getScratchRegister()) {
                Register thisRegister = codeCache.getRegisterConfig().getCallingConventionRegisters(JavaCall, Object).get(0);
                Register spillRegister = scratch.getRegister();
                Label doProlog = new Label();
                if (config.useCompressedOops) {
                    CompressEncoding encoding = config.getOopEncoding();
                    masm.ld(new SPARCAddress(thisRegister, installedCodeOffset), spillRegister, 4, false);
                    Register baseReg = encoding.hasBase() ? registers.getHeapBaseRegister() : null;
                    SPARCHotSpotMove.UncompressPointer.emitUncompressCode(masm, spillRegister, spillRegister, baseReg, encoding.getShift(), true);
                } else {
                    masm.ldx(new SPARCAddress(thisRegister, installedCodeOffset), spillRegister);
                }
                masm.ldx(new SPARCAddress(spillRegister, entryPointOffset), spillRegister);
                masm.compareBranch(spillRegister, 0, Equal, Xcc, doProlog, PREDICT_NOT_TAKEN, null);
                masm.jmp(spillRegister);
                masm.nop();
                masm.bind(doProlog);
            }
        }
    };
}
Also used : TruffleCallBoundaryInstrumentation(org.graalvm.compiler.truffle.compiler.hotspot.TruffleCallBoundaryInstrumentation) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) Register(jdk.vm.ci.code.Register) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) Label(org.graalvm.compiler.asm.Label) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) SPARCMacroAssembler(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 4 with CompressEncoding

use of org.graalvm.compiler.core.common.CompressEncoding in project graal by oracle.

the class AMD64TruffleCallBoundaryInstrumentationFactory method createBuilder.

@Override
public CompilationResultBuilder createBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, DataBuilder dataBuilder, FrameContext frameContext, OptionValues options, DebugContext debug, CompilationResult compilationResult) {
    return new TruffleCallBoundaryInstrumentation(metaAccess, codeCache, foreignCalls, frameMap, asm, dataBuilder, frameContext, options, debug, compilationResult, config, registers) {

        @Override
        protected void injectTailCallCode(int installedCodeOffset, int entryPointOffset) {
            AMD64MacroAssembler masm = (AMD64MacroAssembler) this.asm;
            Register thisRegister = codeCache.getRegisterConfig().getCallingConventionRegisters(JavaCall, JavaKind.Object).get(0);
            Register spillRegister = AMD64.r10;
            Label doProlog = new Label();
            int pos = masm.position();
            if (config.useCompressedOops) {
                // First instruction must be at least 5 bytes long to be safe for patching
                masm.movl(spillRegister, new AMD64Address(thisRegister, installedCodeOffset), true);
                assert masm.position() - pos >= AMD64HotSpotBackend.PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE;
                CompressEncoding encoding = config.getOopEncoding();
                Register heapBaseRegister = AMD64Move.UncompressPointerOp.hasBase(options, encoding) ? registers.getHeapBaseRegister() : null;
                AMD64Move.UncompressPointerOp.emitUncompressCode(masm, spillRegister, encoding.getShift(), heapBaseRegister, true);
            } else {
                // First instruction must be at least 5 bytes long to be safe for patching
                masm.movq(spillRegister, new AMD64Address(thisRegister, installedCodeOffset), true);
                assert masm.position() - pos >= AMD64HotSpotBackend.PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE;
            }
            masm.movq(spillRegister, new AMD64Address(spillRegister, entryPointOffset));
            masm.testq(spillRegister, spillRegister);
            masm.jcc(ConditionFlag.Equal, doProlog);
            masm.jmp(spillRegister);
            masm.bind(doProlog);
        }
    };
}
Also used : TruffleCallBoundaryInstrumentation(org.graalvm.compiler.truffle.compiler.hotspot.TruffleCallBoundaryInstrumentation) Register(jdk.vm.ci.code.Register) AMD64MacroAssembler(org.graalvm.compiler.asm.amd64.AMD64MacroAssembler) Label(org.graalvm.compiler.asm.Label) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address)

Example 5 with CompressEncoding

use of org.graalvm.compiler.core.common.CompressEncoding in project graal by oracle.

the class NativeImageGenerator method createSuites.

public static Suites createSuites(FeatureHandler featureHandler, RuntimeConfiguration runtimeConfig, SnippetReflectionProvider snippetReflection, boolean hosted) {
    Providers runtimeCallProviders = runtimeConfig.getBackendForNormalMethod().getProviders();
    OptionValues options = hosted ? HostedOptionValues.singleton() : RuntimeOptionValues.singleton();
    Suites suites = GraalConfiguration.instance().createSuites(options, hosted);
    PhaseSuite<HighTierContext> highTier = suites.getHighTier();
    PhaseSuite<MidTierContext> midTier = suites.getMidTier();
    PhaseSuite<LowTierContext> lowTier = suites.getLowTier();
    ListIterator<BasePhase<? super HighTierContext>> position;
    if (hosted) {
        position = GraalConfiguration.instance().createHostedInliners(highTier);
    } else {
        /* Find the runtime inliner. */
        position = highTier.findPhase(InliningPhase.class);
    }
    if (position != null) {
        /* These two phases must be after all method inlining. */
        position.add(new DeadStoreRemovalPhase());
        position.add(new RemoveUnwindPhase());
    } else {
        /* There is no inlining, so prepend them in reverse order. */
        highTier.prependPhase(new RemoveUnwindPhase());
        highTier.prependPhase(new DeadStoreRemovalPhase());
    }
    highTier.appendPhase(new StackValuePhase());
    lowTier.addBeforeLast(new OptimizeExceptionCallsPhase());
    CompressEncoding compressEncoding = ImageSingletons.lookup(CompressEncoding.class);
    SubstrateAMD64RegisterConfig registerConfig = (SubstrateAMD64RegisterConfig) runtimeCallProviders.getCodeCache().getRegisterConfig();
    SubstrateAMD64AddressLowering addressLowering = new SubstrateAMD64AddressLowering(compressEncoding, registerConfig);
    lowTier.findPhase(FixReadsPhase.class).add(new AddressLoweringPhase(addressLowering));
    if (SubstrateOptions.MultiThreaded.getValue()) {
        /*
             * Graal inserts only loop safepoints. We want a SafepointNode also before every return.
             */
        midTier.findPhase(LoopSafepointInsertionPhase.class).add(new MethodSafepointInsertionPhase());
    } else {
        /* No need for safepoints when we have only one thread. */
        VMError.guarantee(midTier.removePhase(LoopSafepointInsertionPhase.class));
    }
    if (hosted) {
        lowTier.appendPhase(new VerifyNoGuardsPhase());
        /* Disable the Graal method inlining, since we have our own inlining system. */
        highTier.removePhase(InliningPhase.class);
        /* Remove phases that are not suitable for AOT compilation. */
        highTier.findPhase(ConvertDeoptimizeToGuardPhase.class, true).remove();
        midTier.findPhase(DeoptimizationGroupingPhase.class).remove();
    } else {
        ListIterator<BasePhase<? super MidTierContext>> it = midTier.findPhase(DeoptimizationGroupingPhase.class);
        it.previous();
        it.add(new CollectDeoptimizationSourcePositionsPhase());
    }
    featureHandler.forEachGraalFeature(feature -> feature.registerGraalPhases(runtimeCallProviders, snippetReflection, suites, hosted));
    return suites;
}
Also used : LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) HostedOptionValues(com.oracle.svm.core.option.HostedOptionValues) RuntimeOptionValues(com.oracle.svm.core.option.RuntimeOptionValues) OptionValues(org.graalvm.compiler.options.OptionValues) StackValuePhase(com.oracle.svm.core.graal.stackvalue.StackValuePhase) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) SubstrateAMD64RegisterConfig(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig) DeadStoreRemovalPhase(com.oracle.svm.core.graal.phases.DeadStoreRemovalPhase) Providers(org.graalvm.compiler.phases.util.Providers) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) RemoveUnwindPhase(com.oracle.svm.core.graal.phases.RemoveUnwindPhase) SubstrateAMD64AddressLowering(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64AddressLowering) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) OptimizeExceptionCallsPhase(com.oracle.svm.core.graal.phases.OptimizeExceptionCallsPhase) BasePhase(org.graalvm.compiler.phases.BasePhase) AddressLoweringPhase(org.graalvm.compiler.phases.common.AddressLoweringPhase) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites) LoopSafepointInsertionPhase(org.graalvm.compiler.phases.common.LoopSafepointInsertionPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase) FixReadsPhase(org.graalvm.compiler.phases.common.FixReadsPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) MethodSafepointInsertionPhase(com.oracle.svm.core.graal.phases.MethodSafepointInsertionPhase) DeoptimizationGroupingPhase(org.graalvm.compiler.phases.common.DeoptimizationGroupingPhase) CollectDeoptimizationSourcePositionsPhase(com.oracle.svm.core.graal.phases.CollectDeoptimizationSourcePositionsPhase) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) VerifyNoGuardsPhase(com.oracle.svm.hosted.phases.VerifyNoGuardsPhase)

Aggregations

CompressEncoding (org.graalvm.compiler.core.common.CompressEncoding)14 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)2 HostedOptionValues (com.oracle.svm.core.option.HostedOptionValues)2 RuntimeOptionValues (com.oracle.svm.core.option.RuntimeOptionValues)2 Register (jdk.vm.ci.code.Register)2 RegisterValue (jdk.vm.ci.code.RegisterValue)2 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 Value (jdk.vm.ci.meta.Value)2 Label (org.graalvm.compiler.asm.Label)2 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)2 LIRValueUtil.isConstantValue (org.graalvm.compiler.lir.LIRValueUtil.isConstantValue)2 TruffleCallBoundaryInstrumentation (org.graalvm.compiler.truffle.compiler.hotspot.TruffleCallBoundaryInstrumentation)2 AnalysisPolicy (com.oracle.graal.pointsto.AnalysisPolicy)1 UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)1 SubstitutionProcessor (com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor)1 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)1 AnalysisUniverse (com.oracle.graal.pointsto.meta.AnalysisUniverse)1