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;
}
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;
});
}
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;
}
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;
}
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);
}
}
Aggregations