package org.graalvm.compiler.hotspot.replacements.arraycopy;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import org.graalvm.compiler.serviceprovider.ServiceProvider;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedInvocationPlugin;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
import org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import org.graalvm.compiler.nodes.ConstantNode;
@ServiceProvider(NodeIntrinsicPluginFactory.class)
public class PluginFactory_ArrayCopySnippets implements NodeIntrinsicPluginFactory {
private static final class ArrayCopySnippets_getArrayLocation extends GeneratedInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
jdk.vm.ci.meta.JavaKind arg0;
if (args[0].isConstant()) {
arg0 = snippetReflection.asObject(jdk.vm.ci.meta.JavaKind.class, args[0].asJavaConstant());
} else {
return false;
}
org.graalvm.word.LocationIdentity result = org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopySnippets.getArrayLocation(arg0);
JavaConstant constant = snippetReflection.forObject(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Object, node);
b.notifyReplacedCall(targetMethod, node);
return true;
}
private final org.graalvm.compiler.api.replacements.SnippetReflectionProvider snippetReflection;
private ArrayCopySnippets_getArrayLocation(InjectionProvider injection) {
this.snippetReflection = injection.getInjectedArgument(org.graalvm.compiler.api.replacements.SnippetReflectionProvider.class);
}
}
@Override
public void registerPlugins(InvocationPlugins plugins, InjectionProvider injection) {
plugins.register(new ArrayCopySnippets_getArrayLocation(injection), org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopySnippets.class, "getArrayLocation", jdk.vm.ci.meta.JavaKind.class);
}
}