use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerEdgesPlugins.
private static void registerEdgesPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) {
Registration r = new Registration(plugins, Edges.class).setAllowOverwrite(true);
for (Class<?> c : new Class<?>[] { Node.class, NodeList.class }) {
r.register(new RequiredInvocationPlugin("get" + ClassUtil.getUnqualifiedName(c) + "Unsafe", Node.class, long.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode node, ValueNode offset) {
b.addPush(JavaKind.Object, new UnsafePartitionLoadNode(node, offset, JavaKind.Object, LocationIdentity.any(), GraalEdgeUnsafePartition.get(), metaAccess.lookupJavaType(c)));
return true;
}
});
r.register(new RequiredInvocationPlugin("put" + ClassUtil.getUnqualifiedName(c) + "Unsafe", Node.class, long.class, c) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode node, ValueNode offset, ValueNode value) {
b.add(new UnsafePartitionStoreNode(node, offset, value, JavaKind.Object, LocationIdentity.any(), GraalEdgeUnsafePartition.get(), metaAccess.lookupJavaType(c)));
return true;
}
});
}
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerVMConfigurationPlugins.
private static void registerVMConfigurationPlugins(SnippetReflectionProvider snippetReflection, InvocationPlugins plugins) {
Registration r = new Registration(plugins, ImageSingletons.class);
r.register(new RequiredInvocationPlugin("contains", Class.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode classNode) {
Class<?> key = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
boolean result = ImageSingletons.contains(key);
b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(result));
return true;
}
});
r.register(new RequiredInvocationPlugin("lookup", Class.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode classNode) {
Class<?> key = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
Object result = ImageSingletons.lookup(key);
b.addPush(JavaKind.Object, ConstantNode.forConstant(snippetReflection.forObject(result), b.getMetaAccess()));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerProxyPlugins.
private static void registerProxyPlugins(SnippetReflectionProvider snippetReflection, AnnotationSubstitutionProcessor annotationSubstitutions, InvocationPlugins plugins, ParsingReason reason) {
if (SubstrateOptions.parseOnce() || reason == ParsingReason.PointsToAnalysis) {
Registration proxyRegistration = new Registration(plugins, Proxy.class);
proxyRegistration.register(new RequiredInvocationPlugin("getProxyClass", ClassLoader.class, Class[].class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode classLoaderNode, ValueNode interfacesNode) {
interceptProxyInterfaces(b, targetMethod, snippetReflection, annotationSubstitutions, interfacesNode);
return false;
}
});
proxyRegistration.register(new RequiredInvocationPlugin("newProxyInstance", ClassLoader.class, Class[].class, InvocationHandler.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode classLoaderNode, ValueNode interfacesNode, ValueNode invocationHandlerNode) {
interceptProxyInterfaces(b, targetMethod, snippetReflection, annotationSubstitutions, interfacesNode);
return false;
}
});
}
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerAWTPlugins.
/**
* To prevent AWT linkage error on {@link OS#LINUX} that happens with 'awt_headless' in headless
* mode, we eliminate native methods that depend on 'awt_xawt' library in the call-tree.
*/
private static void registerAWTPlugins(InvocationPlugins plugins) {
if (Platform.includedIn(Platform.LINUX.class)) {
Registration r = new Registration(plugins, GraphicsEnvironment.class);
r.register(new RequiredInvocationPlugin("isHeadless") {
@SuppressWarnings("unchecked")
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
boolean isHeadless = GraphicsEnvironment.isHeadless();
b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(isHeadless));
return true;
}
});
}
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerObjectPlugins.
private static void registerObjectPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Object.class);
r.register(new RequiredInvocationPlugin("clone", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Object, new SubstrateObjectCloneWithExceptionNode(MacroParams.of(b, targetMethod, object)));
return true;
}
});
r.register(new RequiredInvocationPlugin("hashCode", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Int, new SubstrateIdentityHashCodeNode(object, b.bci()));
return true;
}
});
}
Aggregations