use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class IntrinsifyMethodHandlesInvocationPlugin method registerInvocationPlugins.
private static void registerInvocationPlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, "java.lang.invoke.DirectMethodHandle", bytecodeProvider);
r.register1("ensureInitialized", Receiver.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
/*
* Method handles for static methods have a guard that initializes the class (if the
* class was not yet initialized when the method handle was created). We initialize
* the class during static analysis anyway, so we can just do nothing.
*/
return true;
}
});
r = new Registration(plugins, "java.lang.invoke.Invokers", bytecodeProvider);
r.registerOptional1("maybeCustomize", MethodHandle.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode mh) {
/*
* JDK 8 update 60 added an additional customization possibility for method handles.
* For all use cases that we care about, that seems to be unnecessary, so we can
* just do nothing.
*/
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class DataPatchTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
Registration r = new Registration(invocationPlugins, DataPatchTest.class);
r.register1("compressUncompress", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
CompressEncoding encoding = runtime().getVMConfig().getOopEncoding();
ValueNode compressed = b.add(HotSpotCompressionNode.compress(arg, encoding));
ValueNode proxy = b.add(new OpaqueNode(compressed));
b.addPush(JavaKind.Object, HotSpotCompressionNode.uncompress(proxy, encoding));
return true;
}
});
super.registerInvocationPlugins(invocationPlugins);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerPlatformPlugins.
private static void registerPlatformPlugins(SnippetReflectionProvider snippetReflection, InvocationPlugins plugins) {
Registration r = new Registration(plugins, Platform.class);
r.register1("includedIn", Class.class, new InvocationPlugin() {
@SuppressWarnings("unchecked")
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode classNode) {
Class<? extends Platform> platform = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
boolean result = Platform.includedIn(platform);
b.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(result)));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerArrayPlugins.
private static void registerArrayPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Array.class).setAllowOverwrite(true);
r.register2("newInstance", Class.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode clazz, ValueNode length) {
b.addPush(JavaKind.Object, new SubstrateDynamicNewArrayNode(clazz, length));
return true;
}
});
/*
* We have our own Java-level implementation of Array.getLength(), so we just disable the
* plugin defined in StandardGraphBuilderPlugins.
*/
r.register1("getLength", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver type, ValueNode array) {
return false;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration 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.register1("contains", Class.class, new InvocationPlugin() {
@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.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(result)));
return true;
}
});
r.register1("lookup", Class.class, new InvocationPlugin() {
@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.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Object, ConstantNode.forConstant(snippetReflection.forObject(result), b.getMetaAccess())));
return true;
}
});
}
Aggregations