Search in sources :

Example 26 with ResolvedJavaType

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

the class AnalysisType method resolveMethod.

@Override
public AnalysisMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) {
    Object resolvedMethod = resolvedMethods.get(method);
    if (resolvedMethod == null) {
        ResolvedJavaMethod substMethod = universe.substitutions.resolve(((AnalysisMethod) method).wrapped);
        /*
             * We do not want any access checks to be performed, so we use the method's declaring
             * class as the caller type.
             */
        ResolvedJavaType substCallerType = substMethod.getDeclaringClass();
        Object newResolvedMethod = universe.lookup(wrapped.resolveMethod(substMethod, substCallerType));
        if (newResolvedMethod == null) {
            newResolvedMethod = NULL_METHOD;
        }
        Object oldResolvedMethod = resolvedMethods.putIfAbsent(method, newResolvedMethod);
        resolvedMethod = oldResolvedMethod != null ? oldResolvedMethod : newResolvedMethod;
    }
    return resolvedMethod == NULL_METHOD ? null : (AnalysisMethod) resolvedMethod;
}
Also used : AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) ConstantContextSensitiveObject(com.oracle.graal.pointsto.flow.context.object.ConstantContextSensitiveObject) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 27 with ResolvedJavaType

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

the class AnalysisUniverse method lookupAllowUnresolved.

@Override
public JavaType lookupAllowUnresolved(JavaType rawType) {
    if (rawType == null) {
        return null;
    }
    if (!(rawType instanceof ResolvedJavaType)) {
        return rawType;
    }
    assert !(rawType instanceof AnalysisType) : "lookupAllowUnresolved does not support analysis types.";
    ResolvedJavaType hostType = (ResolvedJavaType) rawType;
    ResolvedJavaType type = substitutions.lookup(hostType);
    AnalysisType result = optionalLookup(type);
    if (result == null) {
        result = createType(type, hostType);
    }
    assert typesById[result.getId()].equals(result);
    return result;
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 28 with ResolvedJavaType

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

the class UniverseMetaAccess method lookupJavaType0.

private ResolvedJavaType lookupJavaType0(Class<?> clazz) {
    ResolvedJavaType result = universe.lookup(wrapped.lookupJavaType(clazz));
    ResolvedJavaType existing = typeCache.put(clazz, result);
    assert existing == null || existing.equals(result);
    return result;
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 29 with ResolvedJavaType

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

the class SizeAndSignednessVerifier method visitEnumValueInfo.

@Override
protected void visitEnumValueInfo(EnumValueInfo valueInfo) {
    ResolvedJavaMethod method = (ResolvedJavaMethod) valueInfo.getAnnotatedElement();
    ResolvedJavaType returnType = (ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass());
    EnumInfo enumInfo = (EnumInfo) valueInfo.getParent();
    for (ElementInfo info : enumInfo.getChildren()) {
        if (info instanceof EnumConstantInfo) {
            EnumConstantInfo constantInfo = (EnumConstantInfo) info;
            checkSizeAndSignedness(constantInfo, returnType, method, true);
        }
    }
}
Also used : EnumConstantInfo(com.oracle.svm.hosted.c.info.EnumConstantInfo) ElementInfo(com.oracle.svm.hosted.c.info.ElementInfo) EnumInfo(com.oracle.svm.hosted.c.info.EnumInfo) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 30 with ResolvedJavaType

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

the class CEntryPointCallStubMethod method generatePrologue.

private InvokeNode generatePrologue(HostedProviders providers, SubstrateGraphKit kit, JavaType[] parameterTypes, ValueNode[] args) {
    Class<?> prologueClass = entryPointData.getPrologue();
    if (prologueClass == NoPrologue.class) {
        UserError.guarantee(targetMethod.getAnnotation(Uninterruptible.class) != null, CEntryPointOptions.class.getSimpleName() + "." + NoPrologue.class.getSimpleName() + " is allowed only for methods annotated with @" + Uninterruptible.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
        return null;
    }
    if (prologueClass == CEntryPointOptions.AutomaticPrologue.class) {
        ResolvedJavaType isolateType = providers.getMetaAccess().lookupJavaType(Isolate.class);
        ResolvedJavaType threadType = providers.getMetaAccess().lookupJavaType(IsolateThread.class);
        ResolvedJavaType matchType = null;
        int matchesCount = 0;
        for (JavaType parameterType : parameterTypes) {
            ResolvedJavaType type = (ResolvedJavaType) parameterType;
            if (threadType.isAssignableFrom(type) || isolateType.isAssignableFrom(type)) {
                matchType = type;
                matchesCount++;
            }
        }
        if (matchesCount == 1) {
            if (threadType.isAssignableFrom(matchType)) {
                prologueClass = CEntryPointSetup.EnterPrologue.class;
            } else {
                prologueClass = CEntryPointSetup.EnterIsolatePrologue.class;
            }
        } else {
            throw UserError.abort("@" + CEntryPoint.class.getSimpleName() + " requires exactly one parameter of type " + IsolateThread.class.getSimpleName() + " or " + Isolate.class.getSimpleName() + ": " + targetMethod.format("%H.%n(%p)"));
        }
    }
    ResolvedJavaType prologue = providers.getMetaAccess().lookupJavaType(prologueClass);
    ResolvedJavaMethod[] prologueMethods = prologue.getDeclaredMethods();
    UserError.guarantee(prologueMethods.length == 1 && prologueMethods[0].isStatic(), "Prologue class must declare exactly one static method: " + targetMethod.format("%H.%n(%p)") + " -> " + prologue.toJavaName());
    ValueNode[] prologueArgs = matchPrologueParameters(providers, parameterTypes, args, prologueMethods[0]);
    return kit.createInvoke(prologueMethods[0], InvokeKind.Static, kit.getFrameState(), kit.bci(), prologueArgs);
}
Also used : CEntryPointSetup(com.oracle.svm.core.c.function.CEntryPointSetup) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) CEntryPointOptions(com.oracle.svm.core.c.function.CEntryPointOptions) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) CEntryPoint(org.graalvm.nativeimage.c.function.CEntryPoint) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

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