package org.graalvm.compiler.replacements;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import java.lang.annotation.Annotation;
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;
final class Plugin_ConstantStringIndexOfSnippets_byteArrayBaseOffset extends GeneratedInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ConstantStringIndexOfSnippets.byteArrayBaseOffset(arg0);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
b.notifyReplacedCall(targetMethod, node);
return true;
}
@Override
public Class<? extends Annotation> getSource() {
return org.graalvm.compiler.api.replacements.Fold.class;
}
}
final class Plugin_ConstantStringIndexOfSnippets_charArrayBaseOffset extends GeneratedInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ConstantStringIndexOfSnippets.charArrayBaseOffset(arg0);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
b.notifyReplacedCall(targetMethod, node);
return true;
}
@Override
public Class<? extends Annotation> getSource() {
return org.graalvm.compiler.api.replacements.Fold.class;
}
}
public class PluginFactory_ConstantStringIndexOfSnippets implements NodeIntrinsicPluginFactory {
@Override
public void registerPlugins(InvocationPlugins plugins, NodeIntrinsicPluginFactory.InjectionProvider injection) {
plugins.register(new Plugin_ConstantStringIndexOfSnippets_byteArrayBaseOffset(), org.graalvm.compiler.replacements.ConstantStringIndexOfSnippets.class, "byteArrayBaseOffset", jdk.vm.ci.meta.MetaAccessProvider.class);
plugins.register(new Plugin_ConstantStringIndexOfSnippets_charArrayBaseOffset(), org.graalvm.compiler.replacements.ConstantStringIndexOfSnippets.class, "charArrayBaseOffset", jdk.vm.ci.meta.MetaAccessProvider.class);
}
}