Search in sources :

Example 36 with ResolvedJavaType

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

the class InfoTreeBuilder method elementKind.

private ElementKind elementKind(Collection<AccessorInfo> accessorInfos) {
    ElementKind overallKind = ElementKind.UNKNOWN;
    AccessorInfo overallKindAccessor = null;
    for (AccessorInfo accessorInfo : accessorInfos) {
        ResolvedJavaMethod method = (ResolvedJavaMethod) accessorInfo.getAnnotatedElement();
        ElementKind newKind;
        switch(accessorInfo.getAccessorKind()) {
            case GETTER:
                newKind = elementKind((ResolvedJavaType) method.getSignature().getReturnType(method.getDeclaringClass()));
                break;
            case SETTER:
                newKind = elementKind((ResolvedJavaType) method.getSignature().getParameterType(accessorInfo.valueParameterNumber(false), method.getDeclaringClass()));
                break;
            default:
                continue;
        }
        if (overallKind == ElementKind.UNKNOWN) {
            overallKind = newKind;
            overallKindAccessor = accessorInfo;
        } else if (overallKind != newKind) {
            nativeLibs.addError("Accessor methods mix integer, floating point, and pointer kinds", overallKindAccessor.getAnnotatedElement(), method);
        }
    }
    return overallKind;
}
Also used : ElementKind(com.oracle.svm.hosted.c.info.SizableInfo.ElementKind) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 37 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType 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 38 with ResolvedJavaType

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

the class BytecodeParser method genNewMultiArray.

private void genNewMultiArray(int cpi) {
    JavaType type = lookupType(cpi, MULTIANEWARRAY);
    int rank = getStream().readUByte(bci() + 3);
    ValueNode[] dims = new ValueNode[rank];
    if (!(type instanceof ResolvedJavaType)) {
        for (int i = rank - 1; i >= 0; i--) {
            dims[i] = frameState.pop(JavaKind.Int);
        }
        handleUnresolvedNewMultiArray(type, dims);
        return;
    }
    ResolvedJavaType resolvedType = (ResolvedJavaType) type;
    ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
    if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType)) {
        FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
        classInitializationPlugin.apply(this, resolvedType, stateBefore);
    }
    for (int i = rank - 1; i >= 0; i--) {
        dims[i] = frameState.pop(JavaKind.Int);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleNewMultiArray(this, resolvedType, dims)) {
            return;
        }
    }
    frameState.push(JavaKind.Object, append(createNewMultiArray(resolvedType, dims)));
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) FrameState(org.graalvm.compiler.nodes.FrameState) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) RuntimeConstraint(jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 39 with ResolvedJavaType

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

the class BytecodeParser method genNewInstance.

void genNewInstance(JavaType type) {
    if (!(type instanceof ResolvedJavaType)) {
        handleUnresolvedNewInstance(type);
        return;
    }
    ResolvedJavaType resolvedType = (ResolvedJavaType) type;
    ClassInitializationPlugin classInitializationPlugin = graphBuilderConfig.getPlugins().getClassInitializationPlugin();
    if (!resolvedType.isInitialized() && classInitializationPlugin == null) {
        handleUnresolvedNewInstance(type);
        return;
    }
    ResolvedJavaType[] skippedExceptionTypes = this.graphBuilderConfig.getSkippedExceptionTypes();
    if (skippedExceptionTypes != null) {
        for (ResolvedJavaType exceptionType : skippedExceptionTypes) {
            if (exceptionType.isAssignableFrom(resolvedType)) {
                append(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, RuntimeConstraint));
                return;
            }
        }
    }
    if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType)) {
        FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
        classInitializationPlugin.apply(this, resolvedType, stateBefore);
    }
    for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
        if (plugin.handleNewInstance(this, resolvedType)) {
            return;
        }
    }
    frameState.push(JavaKind.Object, append(createNewInstance(resolvedType, true)));
}
Also used : NodePlugin(org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FrameState(org.graalvm.compiler.nodes.FrameState) ClassInitializationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ClassInitializationPlugin) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 40 with ResolvedJavaType

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

the class BytecodeParser method lookupField.

protected JavaField lookupField(int cpi, int opcode) {
    maybeEagerlyResolve(cpi, opcode);
    JavaField result = constantPool.lookupField(cpi, method, opcode);
    assert !graphBuilderConfig.unresolvedIsError() || result instanceof ResolvedJavaField : "Not resolved: " + result;
    if (parsingIntrinsic() || eagerInitializing) {
        if (result instanceof ResolvedJavaField) {
            ResolvedJavaType declaringClass = ((ResolvedJavaField) result).getDeclaringClass();
            if (!declaringClass.isInitialized()) {
                // See StaticInterfaceFieldTest
                assert !eagerInitializing || declaringClass.isInterface() : "Declaring class not initialized but not an interface? " + declaringClass;
                initialize(declaringClass);
            }
        }
    }
    assert !uninitializedIsError || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized()) : result;
    return result;
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) JavaField(jdk.vm.ci.meta.JavaField) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

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