use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class Target_com_oracle_truffle_api_interop_java_ObjectProxyHandler method beforeCompilation.
@Override
public void beforeCompilation(BeforeCompilationAccess config) {
BeforeCompilationAccessImpl access = (BeforeCompilationAccessImpl) config;
if (GraalFeature.Options.PrintRuntimeCompileMethods.getValue() && blacklistViolations.size() > 0) {
System.out.println();
System.out.println("=== Found " + blacklistViolations.size() + " compilation blacklist violations ===");
System.out.println();
for (GraalFeature.CallTreeNode node : blacklistViolations) {
System.out.println("Blacklisted method");
System.out.println(node.getImplementationMethod().format(" %H.%n(%p)"));
System.out.println("called from");
for (GraalFeature.CallTreeNode cur = node; cur != null; cur = cur.getParent()) {
System.out.println(" " + cur.getSourceReference());
}
}
}
if (warnViolations.size() > 0) {
/*
* It is enough to print one warning message with one stack trace. Take the shortest
* stack trace.
*/
GraalFeature.CallTreeNode printNode = null;
int printLength = Integer.MAX_VALUE;
for (GraalFeature.CallTreeNode warnNode : warnViolations) {
int warnLength = 0;
for (GraalFeature.CallTreeNode cur = warnNode; cur != null; cur = cur.getParent()) {
warnLength++;
}
if (warnLength < printLength) {
printNode = warnNode;
printLength = warnLength;
}
}
System.out.println("WARNING: suspicious method reachable for runtime compilation: " + printNode.getImplementationMethod().format("%H.%n(%p)"));
System.out.println("Check the complete tree of reachable methods using the option " + GraalFeature.Options.PrintRuntimeCompileMethods.getDescriptor().getFieldName());
System.out.println("Suspicious method is called from");
for (GraalFeature.CallTreeNode cur = printNode; cur != null; cur = cur.getParent()) {
System.out.println(" " + cur.getSourceReference());
}
}
if (neverPartOfCompilationViolations.size() > 0) {
System.out.println("ERROR: CompilerAsserts.neverPartOfCompilation reachable for runtime compilation from " + neverPartOfCompilationViolations.size() + " places:");
for (GraalFeature.CallTreeNode neverPartOfCompilationNode : neverPartOfCompilationViolations) {
System.out.println("called from");
for (GraalFeature.CallTreeNode cur = neverPartOfCompilationNode; cur != null; cur = cur.getParent()) {
System.out.println(" " + cur.getSourceReference());
}
}
throw VMError.shouldNotReachHere("CompilerAsserts.neverPartOfCompilation reachable for runtime compilation");
}
if (Options.TruffleCheckFrameImplementation.getValue() && useTruffleCompiler()) {
/*
* Check that only one Frame implementation is seen as instantiated by the static
* analysis. That allows de-virtualization of all calls to Frame methods in the
* interpreter.
*
* The DefaultTruffleRuntime uses multiple Frame implementations (DefaultVirtualFrame,
* DefaultMaterializedFrame, ReadOnlyFrame) to detect wrong usages of the Frame API, so
* we can only check when running with compilation enabled.
*/
Optional<? extends ResolvedJavaType> optionalFrameType = access.getMetaAccess().optionalLookupJavaType(Frame.class);
if (optionalFrameType.isPresent()) {
HostedType frameType = (HostedType) optionalFrameType.get();
Set<HostedType> implementations = new HashSet<>();
collectImplementations(frameType, implementations);
if (implementations.size() > 1) {
throw UserError.abort("More than one implementation of " + Frame.class.getTypeName() + " found. For performance reasons, Truffle languages must not provide new implementations, and instead only use the single implementation provided by the Truffle runtime. " + "To disable this check, add " + SubstrateOptionsParser.commandArgument(Options.TruffleCheckFrameImplementation, "-") + " to the native-image command line. " + "Found classes: " + implementations.stream().map(m -> m.toJavaName(true)).collect(Collectors.joining(", ")));
} else {
assert implementations.size() == 0 || implementations.iterator().next() == frameType.getSingleImplementor();
}
}
}
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class JNIFieldAccessorMethod method createSignature.
private JNISignature createSignature(MetaAccessProvider metaAccess) {
Class<?> valueClass = fieldKind.toJavaClass();
if (fieldKind.isObject()) {
valueClass = JNIObjectHandle.class;
}
ResolvedJavaType objectHandle = metaAccess.lookupJavaType(JNIObjectHandle.class);
List<JavaType> args = new ArrayList<>();
args.add(metaAccess.lookupJavaType(JNIEnvironment.class));
// this (instance field) or class (static field)
args.add(objectHandle);
args.add(metaAccess.lookupJavaType(JNIFieldId.class));
if (isSetter) {
args.add(metaAccess.lookupJavaType(valueClass));
}
ResolvedJavaType returnType;
if (isSetter) {
returnType = metaAccess.lookupJavaType(Void.TYPE);
} else {
returnType = metaAccess.lookupJavaType(valueClass);
}
return new JNISignature(args, returnType);
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class JVMCIInfopointErrorTest method testDuplicateVirtualObject.
@Test(expected = JVMCIError.class)
public void testDuplicateVirtualObject() {
ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
test((tool, state, safepoint) -> {
VirtualObject o1 = VirtualObject.get(obj, 0);
o1.setValues(new JavaValue[0], new JavaKind[0]);
VirtualObject o2 = VirtualObject.get(obj, 0);
o2.setValues(new JavaValue[0], new JavaKind[0]);
safepoint.accept(new LIRFrameState(state.topFrame, new VirtualObject[] { o1, o2 }, state.exceptionEdge));
});
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class JVMCIInfopointErrorTest method testUndefinedVirtualObject.
@Test(expected = JVMCIError.class)
public void testUndefinedVirtualObject() {
ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
test((tool, state, safepoint) -> {
VirtualObject o0 = VirtualObject.get(obj, 0);
o0.setValues(new JavaValue[0], new JavaKind[0]);
VirtualObject o1 = VirtualObject.get(obj, 1);
o1.setValues(new JavaValue[0], new JavaKind[0]);
LIRFrameState newState = modifyTopFrame(state, new VirtualObject[] { o0 }, new JavaValue[] { o1 }, new JavaKind[] { JavaKind.Object }, 1, 0, 0);
safepoint.accept(newState);
});
}
use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.
the class JVMCIInfopointErrorTest method testInvalidVirtualObjectId.
@Test(expected = JVMCIError.class)
public void testInvalidVirtualObjectId() {
ResolvedJavaType obj = getMetaAccess().lookupJavaType(Object.class);
test((tool, state, safepoint) -> {
VirtualObject o = VirtualObject.get(obj, 5);
o.setValues(new JavaValue[0], new JavaKind[0]);
safepoint.accept(new LIRFrameState(state.topFrame, new VirtualObject[] { o }, state.exceptionEdge));
});
}
Aggregations