Search in sources :

Example 16 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class SizeAndSignednessVerifier method checkSizeAndSignedness.

private void checkSizeAndSignedness(SizableInfo sizableInfo, ResolvedJavaType type, ResolvedJavaMethod method, boolean isReturn) {
    TargetDescription target = nativeLibs.getTarget();
    int declaredSize = target.arch.getPlatformKind(type.getJavaKind()).getSizeInBytes();
    int actualSize = sizableInfo.getSizeInfo().getProperty();
    if (declaredSize != actualSize) {
        Class<? extends Annotation> supressionAnnotation = (declaredSize > actualSize) ^ isReturn ? AllowNarrowingCast.class : AllowWideningCast.class;
        if (method.getAnnotation(supressionAnnotation) == null) {
            nativeLibs.addError("Type " + type.toJavaName(false) + " has a size of " + declaredSize + " bytes, but accessed C value has a size of " + actualSize + " bytes; to suppress this error, use the annotation @" + supressionAnnotation.getSimpleName(), method);
        }
    }
    checkSignedness(sizableInfo.isUnsigned(), type, method);
}
Also used : TargetDescription(jdk.vm.ci.code.TargetDescription)

Example 17 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class QueryResultParser method visitConstantInfo.

@Override
protected void visitConstantInfo(ConstantInfo constantInfo) {
    TargetDescription target = nativeLibs.getTarget();
    switch(constantInfo.getKind()) {
        case INTEGER:
            parseIntegerProperty(constantInfo.getSizeInfo());
            parseSignedness(constantInfo.getSignednessInfo());
            parseIntegerConstantValue(constantInfo.getValueInfo());
            /*
                 * From the point of view of the C compiler, plain #define constants have the type
                 * int and therefore size 4. But sometimes we want to access such values as short or
                 * byte to avoid casts. Check the actual value of the constant, and if it fits the
                 * declared type of the constant, then change the actual size to the declared size.
                 */
            ResolvedJavaMethod method = (ResolvedJavaMethod) constantInfo.getAnnotatedElement();
            ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
            JavaKind returnKind = returnType.getJavaKind();
            if (returnKind == JavaKind.Object) {
                returnKind = target.wordJavaKind;
            }
            int declaredSize = target.arch.getPlatformKind(returnKind).getSizeInBytes();
            int actualSize = constantInfo.getSizeInfo().getProperty();
            if (declaredSize != actualSize) {
                long value = (long) constantInfo.getValueInfo().getProperty();
                if (value >= returnKind.getMinValue() && value <= returnKind.getMaxValue()) {
                    constantInfo.getSizeInfo().setProperty(declaredSize);
                }
            }
            break;
        case POINTER:
            parseIntegerProperty(constantInfo.getSizeInfo());
            parseIntegerConstantValue(constantInfo.getValueInfo());
            break;
        case FLOAT:
            parseIntegerProperty(constantInfo.getSizeInfo());
            parseFloatValue(constantInfo.getValueInfo());
            break;
        case STRING:
            parseStringValue(constantInfo.getValueInfo());
            break;
        case BYTEARRAY:
            parseByteArrayValue(constantInfo.getValueInfo());
            break;
        default:
            throw shouldNotReachHere();
    }
}
Also used : TargetDescription(jdk.vm.ci.code.TargetDescription) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 18 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class SPARCHotSpotCounterOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb) {
    SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm;
    TargetDescription target = crb.target;
    // address for counters array
    SPARCAddress countersArrayAddr = new SPARCAddress(thread, config.jvmciCountersThreadOffset);
    try (ScratchRegister scratch = masm.getScratchRegister()) {
        Register countersArrayReg = scratch.getRegister();
        // load counters array
        masm.ldx(countersArrayAddr, countersArrayReg);
        IncrementEmitter emitter = new IncrementEmitter(countersArrayReg, masm);
        forEachCounter(emitter, target);
    }
}
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) TargetDescription(jdk.vm.ci.code.TargetDescription) SPARCMacroAssembler(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 19 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class SPARCHotSpotForeignCallsProvider method initialize.

@Override
public void initialize(HotSpotProviders providers, OptionValues options) {
    GraalHotSpotVMConfig config = runtime.getVMConfig();
    TargetDescription target = providers.getCodeCache().getTarget();
    PlatformKind word = target.arch.getWordKind();
    // The calling convention for the exception handler stub is (only?) defined in
    // TemplateInterpreterGenerator::generate_throw_exception()
    // in templateInterpreter_sparc.cpp around line 1925
    RegisterValue outgoingException = o0.asValue(LIRKind.fromJavaKind(target.arch, JavaKind.Object));
    RegisterValue outgoingExceptionPc = o1.asValue(LIRKind.value(word));
    RegisterValue incomingException = i0.asValue(LIRKind.fromJavaKind(target.arch, JavaKind.Object));
    RegisterValue incomingExceptionPc = i1.asValue(LIRKind.value(word));
    CallingConvention outgoingExceptionCc = new CallingConvention(0, ILLEGAL, outgoingException, outgoingExceptionPc);
    CallingConvention incomingExceptionCc = new CallingConvention(0, ILLEGAL, incomingException, incomingExceptionPc);
    register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, any()));
    register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, any()));
    if (config.useCRC32Intrinsics) {
        // This stub does callee saving
        registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
    }
    if (config.useCRC32CIntrinsics) {
        registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
    }
    super.initialize(providers, options);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterValue(jdk.vm.ci.code.RegisterValue) HotSpotForeignCallLinkageImpl(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkageImpl) TargetDescription(jdk.vm.ci.code.TargetDescription) PlatformKind(jdk.vm.ci.meta.PlatformKind) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)

Example 20 with TargetDescription

use of jdk.vm.ci.code.TargetDescription in project graal by oracle.

the class SPARCHotSpotBackendFactory method createBackend.

@Override
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
    assert host == null;
    GraalHotSpotVMConfig config = runtime.getVMConfig();
    JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
    HotSpotRegistersProvider registers = createRegisters();
    HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
    TargetDescription target = codeCache.getTarget();
    HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
    HotSpotConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
    Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
    HotSpotWordTypes wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
    HotSpotForeignCallsProvider foreignCalls = new SPARCHotSpotForeignCallsProvider(jvmciRuntime, runtime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
    LoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers, constantReflection, target);
    HotSpotStampProvider stampProvider = new HotSpotStampProvider();
    Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
    HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(runtime, constantReflection, wordTypes);
    BytecodeProvider bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
    HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(runtime.getOptions(), p, snippetReflection, bytecodeProvider, target);
    Plugins plugins = createGraphBuilderPlugins(compilerConfiguration, config, metaAccess, constantReflection, foreignCalls, lowerer, stampProvider, snippetReflection, replacements, wordTypes);
    replacements.setGraphBuilderPlugins(plugins);
    HotSpotSuitesProvider suites = createSuites(config, runtime, compilerConfiguration, plugins, replacements);
    HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
    return createBackend(config, runtime, providers);
}
Also used : ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) JVMCIBackend(jdk.vm.ci.runtime.JVMCIBackend) TargetDescription(jdk.vm.ci.code.TargetDescription) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotConstantFieldProvider) LoweringProvider(org.graalvm.compiler.nodes.spi.LoweringProvider) HotSpotLoweringProvider(org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) Providers(org.graalvm.compiler.phases.util.Providers) HotSpotMetaAccessProvider(jdk.vm.ci.hotspot.HotSpotMetaAccessProvider) HotSpotSnippetReflectionProvider(org.graalvm.compiler.hotspot.meta.HotSpotSnippetReflectionProvider) HotSpotReplacementsImpl(org.graalvm.compiler.hotspot.HotSpotReplacementsImpl) HotSpotWordTypes(org.graalvm.compiler.hotspot.word.HotSpotWordTypes) HotSpotRegistersProvider(org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider) HotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.HotSpotSuitesProvider) AddressLoweringHotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.AddressLoweringHotSpotSuitesProvider) Value(jdk.vm.ci.meta.Value) HotSpotConstantReflectionProvider(jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider) HotSpotGraalConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider) HotSpotForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) HotSpotStampProvider(org.graalvm.compiler.hotspot.meta.HotSpotStampProvider) SPARCGraphBuilderPlugins(org.graalvm.compiler.replacements.sparc.SPARCGraphBuilderPlugins) HotSpotGraphBuilderPlugins(org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Aggregations

TargetDescription (jdk.vm.ci.code.TargetDescription)41 CallingConvention (jdk.vm.ci.code.CallingConvention)14 Register (jdk.vm.ci.code.Register)14 RegisterConfig (jdk.vm.ci.code.RegisterConfig)12 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)11 CompilationResult (org.graalvm.compiler.code.CompilationResult)11 Test (org.junit.Test)11 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)10 AMD64Assembler (org.graalvm.compiler.asm.amd64.AMD64Assembler)10 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)8 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)7 LIRKind (org.graalvm.compiler.core.common.LIRKind)6 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)5 Field (java.lang.reflect.Field)4 BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)4 Value (jdk.vm.ci.meta.Value)3 AMD64MacroAssembler (org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)3 HotSpotRegistersProvider (org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider)3 RegisterValue (jdk.vm.ci.code.RegisterValue)2 DataSectionReference (jdk.vm.ci.code.site.DataSectionReference)2