Search in sources :

Example 6 with SubstrateTargetDescription

use of com.oracle.svm.core.SubstrateTargetDescription in project graal by oracle.

the class AMD64CalleeSavedRegisters method emitSave.

/**
 * The increasing different size and number of registers of SSE vs. AVX vs. AVX512 complicates
 * saving and restoring when AOT compilation and JIT compilation use different CPU features: A
 * JIT compiled caller could expect AVX512 registes to be saved, but the AOT compiled callee
 * only saves the SSE registers. Therefore, AOT and JIT compiled code need to have the same CPU
 * features right now. See {@link AMD64CPUFeatureAccess#enableFeatures}.
 */
public void emitSave(AMD64MacroAssembler asm, int frameSize) {
    SubstrateTargetDescription target = ConfigurationValues.getTarget();
    AMD64 arch = (AMD64) target.arch;
    boolean hasAVX = arch.getFeatures().contains(AMD64.CPUFeature.AVX);
    boolean hasAVX512 = arch.getFeatures().contains(AMD64.CPUFeature.AVX512F);
    for (Register register : calleeSavedRegisters) {
        AMD64Address address = calleeSaveAddress(asm, frameSize, register);
        RegisterCategory category = register.getRegisterCategory();
        if (category.equals(AMD64.CPU)) {
            asm.movq(address, register);
        } else if (category.equals(AMD64.XMM)) {
            if (hasAVX512) {
                asm.evmovdqu64(address, register);
            } else if (hasAVX) {
                asm.vmovdqu(address, register);
            } else {
                asm.movdqu(address, register);
            }
        } else if (category.equals(AMD64.MASK)) {
            /* Graal does not use the AVX512 mask registers yet. */
            throw VMError.unimplemented();
        } else {
            throw VMError.shouldNotReachHere();
        }
    }
}
Also used : AMD64(jdk.vm.ci.amd64.AMD64) RegisterCategory(jdk.vm.ci.code.Register.RegisterCategory) Register(jdk.vm.ci.code.Register) SubstrateTargetDescription(com.oracle.svm.core.SubstrateTargetDescription) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address)

Example 7 with SubstrateTargetDescription

use of com.oracle.svm.core.SubstrateTargetDescription in project graal by oracle.

the class AMD64CalleeSavedRegisters method createAndRegister.

@Platforms(Platform.HOSTED_ONLY.class)
public static void createAndRegister() {
    SubstrateTargetDescription target = ConfigurationValues.getTarget();
    SubstrateRegisterConfig registerConfig = new SubstrateAMD64RegisterConfig(SubstrateRegisterConfig.ConfigKind.NORMAL, null, target, SubstrateOptions.PreserveFramePointer.getValue());
    Register frameRegister = registerConfig.getFrameRegister();
    List<Register> calleeSavedRegisters = new ArrayList<>(registerConfig.getAllocatableRegisters().asList());
    /*
         * Reverse list so that CPU registers are spilled close to the beginning of the frame, i.e.,
         * with a closer-to-0 negative reference map index in the caller frame. That makes the
         * reference map encoding of the caller frame a bit smaller.
         */
    Collections.reverse(calleeSavedRegisters);
    int offset = 0;
    Map<Register, Integer> calleeSavedRegisterOffsets = new HashMap<>();
    for (Register register : calleeSavedRegisters) {
        calleeSavedRegisterOffsets.put(register, offset);
        offset += target.arch.getLargestStorableKind(register.getRegisterCategory()).getSizeInBytes();
    }
    int calleeSavedRegistersSizeInBytes = offset;
    int saveAreaOffsetInFrame = -(FrameAccess.returnAddressSize() + (SubstrateOptions.PreserveFramePointer.getValue() ? FrameAccess.wordSize() : 0) + calleeSavedRegistersSizeInBytes);
    ImageSingletons.add(CalleeSavedRegisters.class, new AMD64CalleeSavedRegisters(frameRegister, calleeSavedRegisters, calleeSavedRegisterOffsets, calleeSavedRegistersSizeInBytes, saveAreaOffsetInFrame));
}
Also used : Register(jdk.vm.ci.code.Register) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SubstrateRegisterConfig(com.oracle.svm.core.graal.meta.SubstrateRegisterConfig) SubstrateTargetDescription(com.oracle.svm.core.SubstrateTargetDescription) Platforms(org.graalvm.nativeimage.Platforms)

Aggregations

SubstrateTargetDescription (com.oracle.svm.core.SubstrateTargetDescription)7 Register (jdk.vm.ci.code.Register)4 AMD64 (jdk.vm.ci.amd64.AMD64)3 SubstrateRegisterConfig (com.oracle.svm.core.graal.meta.SubstrateRegisterConfig)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RegisterCategory (jdk.vm.ci.code.Register.RegisterCategory)2 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)2 AnalysisObjectScanningObserver (com.oracle.graal.pointsto.AnalysisObjectScanningObserver)1 HeapSnapshotVerifier (com.oracle.graal.pointsto.heap.HeapSnapshotVerifier)1 ImageHeap (com.oracle.graal.pointsto.heap.ImageHeap)1 ImageHeapScanner (com.oracle.graal.pointsto.heap.ImageHeapScanner)1 WrappedJavaMethod (com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod)1 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 PointsToAnalysisMethod (com.oracle.graal.pointsto.meta.PointsToAnalysisMethod)1 StopTimer (com.oracle.graal.pointsto.util.Timer.StopTimer)1 SubstrateOptions (com.oracle.svm.core.SubstrateOptions)1 ObjectLayout (com.oracle.svm.core.config.ObjectLayout)1