Search in sources :

Example 6 with ResolvedJavaField

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

the class ReferenceGetLoopTest method checkMidTierGraph.

@Override
protected boolean checkMidTierGraph(StructuredGraph graph) {
    final LoopsData loops = new LoopsData(graph);
    boolean found = false;
    for (LoopEx loop : loops.loops()) {
        for (Node node : loop.inside().nodes()) {
            if (node instanceof Access) {
                Access access = (Access) node;
                LocationIdentity location = access.getLocationIdentity();
                if (location instanceof FieldLocationIdentity) {
                    ResolvedJavaField field = ((FieldLocationIdentity) location).getField();
                    if (field.getName().equals("referent") && field.getDeclaringClass().equals(getMetaAccess().lookupJavaType(Reference.class))) {
                        found = true;
                    }
                }
            }
        }
    }
    if (!found) {
        assertTrue(false, "Reference.referent not found in loop: " + getCanonicalGraphString(graph, true, false));
    }
    return true;
}
Also used : FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) LoopsData(org.graalvm.compiler.loop.LoopsData) LoopEx(org.graalvm.compiler.loop.LoopEx) Node(org.graalvm.compiler.graph.Node) Access(org.graalvm.compiler.nodes.memory.Access) FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) LocationIdentity(org.graalvm.word.LocationIdentity) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 7 with ResolvedJavaField

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

the class ObjectTreePrinter method forScannedConstant.

@Override
protected void forScannedConstant(JavaConstant scannedValue, Object reason) {
    JVMCIError.guarantee(scannedValue != null, "scannedValue is null");
    constantToNode.computeIfAbsent(scannedValue, c -> {
        ObjectNodeBase node;
        if (reason instanceof ResolvedJavaField) {
            ResolvedJavaField field = (ResolvedJavaField) reason;
            if (field.isStatic()) {
                node = ObjectNodeBase.fromConstant(bb, scannedValue, new RootSource(field));
            } else {
                node = ObjectNodeBase.fromConstant(bb, scannedValue);
            }
        } else if (reason instanceof ResolvedJavaMethod) {
            ResolvedJavaMethod method = (ResolvedJavaMethod) reason;
            node = ObjectNodeBase.fromConstant(bb, scannedValue, new RootSource(method));
        } else {
            node = ObjectNodeBase.fromConstant(bb, scannedValue);
        }
        return node;
    });
}
Also used : ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 8 with ResolvedJavaField

use of jdk.vm.ci.meta.ResolvedJavaField 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)

Example 9 with ResolvedJavaField

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

the class BytecodeParser method tryFastInlineAccessor.

/**
 * Tries to inline {@code targetMethod} if it is an instance field accessor. This avoids the
 * overhead of creating and using a nested {@link BytecodeParser} object.
 */
@SuppressWarnings("try")
private boolean tryFastInlineAccessor(ValueNode[] args, ResolvedJavaMethod targetMethod) {
    byte[] bytecode = targetMethod.getCode();
    if (bytecode != null && bytecode.length == ACCESSOR_BYTECODE_LENGTH && Bytes.beU1(bytecode, 0) == ALOAD_0 && Bytes.beU1(bytecode, 1) == GETFIELD) {
        int b4 = Bytes.beU1(bytecode, 4);
        if (b4 >= IRETURN && b4 <= ARETURN) {
            int cpi = Bytes.beU2(bytecode, 2);
            JavaField field = targetMethod.getConstantPool().lookupField(cpi, targetMethod, GETFIELD);
            if (field instanceof ResolvedJavaField) {
                ValueNode receiver = invocationPluginReceiver.init(targetMethod, args).get();
                ResolvedJavaField resolvedField = (ResolvedJavaField) field;
                try (DebugCloseable context = openNodeContext(targetMethod, 1)) {
                    genGetField(resolvedField, receiver);
                    notifyBeforeInline(targetMethod);
                    printInlining(targetMethod, targetMethod, true, "inline accessor method (bytecode parsing)");
                    notifyAfterInline(targetMethod);
                }
                return true;
            }
        }
    }
    return false;
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) JavaField(jdk.vm.ci.meta.JavaField) ValueNode(org.graalvm.compiler.nodes.ValueNode) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) RuntimeConstraint(jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 10 with ResolvedJavaField

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

the class BytecodeParser method genGetField.

private void genGetField(JavaField field, ValueNode receiverInput) {
    ValueNode receiver = emitExplicitExceptions(receiverInput);
    if (field instanceof ResolvedJavaField) {
        ResolvedJavaField resolvedField = (ResolvedJavaField) field;
        genGetField(resolvedField, receiver);
    } else {
        handleUnresolvedLoadField(field, receiver);
    }
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Aggregations

ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)45 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)10 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 ArrayList (java.util.ArrayList)7 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)4 Field (java.lang.reflect.Field)4 JavaKind (jdk.vm.ci.meta.JavaKind)4 Invoke (org.graalvm.compiler.nodes.Invoke)4 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)4 SnippetReflectionProvider (org.graalvm.compiler.api.replacements.SnippetReflectionProvider)3 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)3 NodePlugin (org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin)3 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)3 LocationIdentity (org.graalvm.word.LocationIdentity)3 Delete (com.oracle.svm.core.annotate.Delete)2 Method (java.lang.reflect.Method)2 JavaField (jdk.vm.ci.meta.JavaField)2 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)2