Search in sources :

Example 1 with JavaField

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

the class BytecodeParser method genGetStatic.

protected void genGetStatic(int cpi, int opcode) {
    JavaField field = lookupField(cpi, opcode);
    genGetStatic(field);
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) JavaField(jdk.vm.ci.meta.JavaField)

Example 2 with JavaField

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

the class BytecodeParser method genPutStatic.

protected void genPutStatic(int cpi, int opcode) {
    JavaField field = lookupField(cpi, opcode);
    genPutStatic(field);
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) JavaField(jdk.vm.ci.meta.JavaField)

Example 3 with JavaField

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

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

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

the class BytecodeParser method genPutField.

protected void genPutField(int cpi, int opcode) {
    JavaField field = lookupField(cpi, opcode);
    genPutField(field);
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) JavaField(jdk.vm.ci.meta.JavaField)

Aggregations

JavaField (jdk.vm.ci.meta.JavaField)6 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)6 RuntimeConstraint (jdk.vm.ci.meta.DeoptimizationReason.RuntimeConstraint)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1