Search in sources :

Example 31 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class CEntryPointCallStubMethod method generateEpilogue.

private InvokeNode generateEpilogue(HostedProviders providers, SubstrateGraphKit kit) {
    Class<?> epilogueClass = entryPointData.getEpilogue();
    if (epilogueClass == NoEpilogue.class) {
        UserError.guarantee(targetMethod.getAnnotation(Uninterruptible.class) != null, CEntryPointOptions.class.getSimpleName() + "." + NoEpilogue.class.getSimpleName() + " is allowed only for methods annotated with @" + Uninterruptible.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
        return null;
    }
    ResolvedJavaType epilogue = providers.getMetaAccess().lookupJavaType(epilogueClass);
    ResolvedJavaMethod[] epilogueMethods = epilogue.getDeclaredMethods();
    UserError.guarantee(epilogueMethods.length == 1 && epilogueMethods[0].isStatic() && epilogueMethods[0].getSignature().getParameterCount(false) == 0, "Epilogue class must declare exactly one static method without parameters: " + targetMethod.format("%H.%n(%p)") + " -> " + epilogue.toJavaName());
    return kit.createInvoke(epilogueMethods[0], InvokeKind.Static, kit.getFrameState(), kit.bci());
}
Also used : CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 32 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class CEntryPointCallStubMethod method create.

static CEntryPointCallStubMethod create(AnalysisMethod targetMethod, CEntryPointData entryPointData, AnalysisMetaAccess metaAccess) {
    ResolvedJavaMethod unwrappedMethod = targetMethod.getWrapped();
    MetaAccessProvider unwrappedMetaAccess = metaAccess.getWrapped();
    ResolvedJavaType declaringClass = unwrappedMetaAccess.lookupJavaType(CEntryPointCallStubs.class);
    ConstantPool constantPool = CEntryPointCallStubs.getConstantPool(unwrappedMetaAccess);
    return new CEntryPointCallStubMethod(entryPointData, unwrappedMethod, declaringClass, constantPool);
}
Also used : ConstantPool(jdk.vm.ci.meta.ConstantPool) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 33 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class NativeLibraries method findElementInfo.

public ElementInfo findElementInfo(Object e) {
    Object element = unwrap(e);
    ElementInfo result = elementToInfo.get(element);
    if (result == null && element instanceof ResolvedJavaType && ((ResolvedJavaType) element).getInterfaces().length == 1) {
        result = findElementInfo(((ResolvedJavaType) element).getInterfaces()[0]);
    }
    return result;
}
Also used : ElementInfo(com.oracle.svm.hosted.c.info.ElementInfo) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 34 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class InfoTreeBuilder method accessorValid.

private boolean accessorValid(AccessorInfo accessorInfo) {
    ResolvedJavaMethod method = (ResolvedJavaMethod) accessorInfo.getAnnotatedElement();
    int expectedParamCount = accessorInfo.parameterCount(false);
    int actualParamCount = method.getSignature().getParameterCount(false);
    if (actualParamCount != expectedParamCount) {
        nativeLibs.addError("Wrong number of parameters: expected " + expectedParamCount + "; found " + actualParamCount, method);
        return false;
    }
    if (accessorInfo.isIndexed()) {
        ResolvedJavaType paramType = (ResolvedJavaType) method.getSignature().getParameterType(accessorInfo.indexParameterNumber(false), method.getDeclaringClass());
        if (paramType.getJavaKind() != JavaKind.Int && paramType.getJavaKind() != JavaKind.Long && !nativeLibs.isSigned(paramType)) {
            nativeLibs.addError("Wrong type of index parameter 0: expected int, long, or Signed; found " + paramType.toJavaName(true), method);
            return false;
        }
    }
    if (accessorInfo.hasLocationIdentityParameter() && accessorInfo.hasUniqueLocationIdentity()) {
        nativeLibs.addError("Method cannot have annotation @" + UniqueLocationIdentity.class.getSimpleName() + " and a LocationIdentity parameter", method);
        return false;
    }
    if (accessorInfo.hasLocationIdentityParameter()) {
        ResolvedJavaType paramType = (ResolvedJavaType) method.getSignature().getParameterType(accessorInfo.locationIdentityParameterNumber(false), method.getDeclaringClass());
        if (!nativeLibs.getLocationIdentityType().equals(paramType)) {
            nativeLibs.addError("Wrong type of locationIdentity parameter: expected " + nativeLibs.getLocationIdentityType().toJavaName(true) + "; found " + paramType.toJavaName(true), method);
            return false;
        }
    }
    ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
    if (accessorInfo.getAccessorKind() == AccessorKind.ADDRESS) {
        if (!nativeLibs.isPointerBase(returnType) || nativeLibs.isSigned(returnType) || nativeLibs.isUnsigned(returnType)) {
            nativeLibs.addError("Wrong return type: expected a pointer type; found " + returnType.toJavaName(true), method);
            return false;
        }
    }
    if (accessorInfo.getAccessorKind() == AccessorKind.OFFSET) {
        if (!(returnType.getJavaKind().isNumericInteger() || nativeLibs.isUnsigned(returnType))) {
            nativeLibs.addError("Wrong return type: expected an integer numeric type or Unsigned; found " + returnType.toJavaName(true), method);
            return false;
        }
    }
    if (!checkObjectType(returnType, method)) {
        return false;
    }
    for (int i = 0; i < method.getSignature().getParameterCount(false); i++) {
        ResolvedJavaType paramType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
        if (!checkObjectType(paramType, method)) {
            return false;
        }
    }
    return true;
}
Also used : UniqueLocationIdentity(org.graalvm.nativeimage.c.struct.UniqueLocationIdentity) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 35 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class InfoTreeBuilder method createConstantInfo.

protected void createConstantInfo(ResolvedJavaMethod method) {
    int actualParamCount = method.getSignature().getParameterCount(false);
    if (actualParamCount != 0) {
        nativeLibs.addError("Wrong number of parameters: expected 0; found " + actualParamCount, method);
        return;
    }
    ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
    if (returnType.getJavaKind() == JavaKind.Void || (returnType.getJavaKind() == JavaKind.Object && !nativeLibs.isString(returnType) && !nativeLibs.isByteArray(returnType) && !nativeLibs.isWordBase(returnType))) {
        nativeLibs.addError("Wrong return type: expected a primitive type, String, or a Word type; found " + returnType.toJavaName(true), method);
        return;
    }
    String constantName = getConstantName(method);
    ElementKind elementKind = elementKind(returnType);
    ConstantInfo constantInfo = new ConstantInfo(constantName, elementKind, method);
    nativeCodeInfo.adoptChild(constantInfo);
    nativeLibs.registerElementInfo(method, constantInfo);
}
Also used : ElementKind(com.oracle.svm.hosted.c.info.SizableInfo.ElementKind) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)161 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)63 ValueNode (org.graalvm.compiler.nodes.ValueNode)60 JavaKind (jdk.vm.ci.meta.JavaKind)25 JavaType (jdk.vm.ci.meta.JavaType)25 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)19 Stamp (org.graalvm.compiler.core.common.type.Stamp)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)17 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)16 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)13 TypeReference (org.graalvm.compiler.core.common.type.TypeReference)13 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)13 Signature (jdk.vm.ci.meta.Signature)11 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)11 LogicNode (org.graalvm.compiler.nodes.LogicNode)11 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)11 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)11 ArrayList (java.util.ArrayList)10 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)10 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)9