package org.graalvm.compiler.replacements;
import java.lang.annotation.Annotation;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import org.graalvm.compiler.core.common.type.Stamp;
import org.graalvm.compiler.graph.NodeInputList;
import org.graalvm.compiler.nodes.ConstantNode;
import org.graalvm.compiler.nodes.PluginReplacementNode;
import org.graalvm.compiler.nodes.ValueNode;
import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedFoldInvocationPlugin;
import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedPluginFactory;
import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedPluginInjectionProvider;
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
final class Plugin_ReplacementsUtil_arrayIndexScale extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_arrayIndexScale.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
jdk.vm.ci.meta.JavaKind arg1;
if (args[1].isConstant()) {
arg1 = snippetReflection.asObject(jdk.vm.ci.meta.JavaKind.class, args[1].asJavaConstant());
} else {
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_arrayIndexScale.FUNCTION);
return true;
}
assert b.canDeferPlugin(this) : b.getClass().toString();
return false;
}
int result = org.graalvm.compiler.replacements.ReplacementsUtil.arrayIndexScale(arg0, arg1);
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;
}
private final org.graalvm.compiler.api.replacements.SnippetReflectionProvider snippetReflection;
Plugin_ReplacementsUtil_arrayIndexScale(GeneratedPluginInjectionProvider injection) {
this.snippetReflection = injection.getInjectedArgument(org.graalvm.compiler.api.replacements.SnippetReflectionProvider.class);
}
}
final class PluginReplacementNode_ReplacementsUtil_arrayIndexScale implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ReplacementsUtil_arrayIndexScale();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
jdk.vm.ci.meta.JavaKind arg1;
if (args.get(1).isConstant()) {
arg1 = injection.getInjectedArgument(org.graalvm.compiler.api.replacements.SnippetReflectionProvider.class).asObject(jdk.vm.ci.meta.JavaKind.class, args.get(1).asJavaConstant());
} else {
return false;
}
int result = org.graalvm.compiler.replacements.ReplacementsUtil.arrayIndexScale(arg0, arg1);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
final class Plugin_ReplacementsUtil_byteArrayBaseOffset extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_byteArrayBaseOffset.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.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 PluginReplacementNode_ReplacementsUtil_byteArrayBaseOffset implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ReplacementsUtil_byteArrayBaseOffset();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.byteArrayBaseOffset(arg0);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
final class Plugin_ReplacementsUtil_byteArrayIndexScale extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_byteArrayIndexScale.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.byteArrayIndexScale(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 PluginReplacementNode_ReplacementsUtil_byteArrayIndexScale implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ReplacementsUtil_byteArrayIndexScale();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.byteArrayIndexScale(arg0);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
final class Plugin_ReplacementsUtil_charArrayBaseOffset extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_charArrayBaseOffset.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.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;
}
}
final class PluginReplacementNode_ReplacementsUtil_charArrayBaseOffset implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ReplacementsUtil_charArrayBaseOffset();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.charArrayBaseOffset(arg0);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
final class Plugin_ReplacementsUtil_charArrayIndexScale extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_charArrayIndexScale.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.charArrayIndexScale(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 PluginReplacementNode_ReplacementsUtil_charArrayIndexScale implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ReplacementsUtil_charArrayIndexScale();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
int result = org.graalvm.compiler.replacements.ReplacementsUtil.charArrayIndexScale(arg0);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
final class Plugin_ReplacementsUtil_getArrayBaseOffset extends GeneratedFoldInvocationPlugin {
@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
if (!b.isPluginEnabled(this)) {
return false;
}
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_getArrayBaseOffset.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
jdk.vm.ci.meta.JavaKind arg1;
if (args[1].isConstant()) {
arg1 = snippetReflection.asObject(jdk.vm.ci.meta.JavaKind.class, args[1].asJavaConstant());
} else {
if (b.shouldDeferPlugin(this)) {
b.replacePlugin(this, targetMethod, args, PluginReplacementNode_ReplacementsUtil_getArrayBaseOffset.FUNCTION);
return true;
}
assert b.canDeferPlugin(this) : b.getClass().toString();
return false;
}
int result = org.graalvm.compiler.replacements.ReplacementsUtil.getArrayBaseOffset(arg0, arg1);
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;
}
private final org.graalvm.compiler.api.replacements.SnippetReflectionProvider snippetReflection;
Plugin_ReplacementsUtil_getArrayBaseOffset(GeneratedPluginInjectionProvider injection) {
this.snippetReflection = injection.getInjectedArgument(org.graalvm.compiler.api.replacements.SnippetReflectionProvider.class);
}
}
final class PluginReplacementNode_ReplacementsUtil_getArrayBaseOffset implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ReplacementsUtil_getArrayBaseOffset();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
jdk.vm.ci.meta.MetaAccessProvider arg0 = b.getMetaAccess();
jdk.vm.ci.meta.JavaKind arg1;
if (args.get(1).isConstant()) {
arg1 = injection.getInjectedArgument(org.graalvm.compiler.api.replacements.SnippetReflectionProvider.class).asObject(jdk.vm.ci.meta.JavaKind.class, args.get(1).asJavaConstant());
} else {
return false;
}
int result = org.graalvm.compiler.replacements.ReplacementsUtil.getArrayBaseOffset(arg0, arg1);
JavaConstant constant = JavaConstant.forInt(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Int, node);
return true;
}
}
public class PluginFactory_ReplacementsUtil implements GeneratedPluginFactory {
@Override
public void registerPlugins(InvocationPlugins plugins, GeneratedPluginInjectionProvider injection) {
plugins.register(new Plugin_ReplacementsUtil_arrayIndexScale(injection), org.graalvm.compiler.replacements.ReplacementsUtil.class, "arrayIndexScale", jdk.vm.ci.meta.MetaAccessProvider.class, jdk.vm.ci.meta.JavaKind.class);
plugins.register(new Plugin_ReplacementsUtil_byteArrayBaseOffset(), org.graalvm.compiler.replacements.ReplacementsUtil.class, "byteArrayBaseOffset", jdk.vm.ci.meta.MetaAccessProvider.class);
plugins.register(new Plugin_ReplacementsUtil_byteArrayIndexScale(), org.graalvm.compiler.replacements.ReplacementsUtil.class, "byteArrayIndexScale", jdk.vm.ci.meta.MetaAccessProvider.class);
plugins.register(new Plugin_ReplacementsUtil_charArrayBaseOffset(), org.graalvm.compiler.replacements.ReplacementsUtil.class, "charArrayBaseOffset", jdk.vm.ci.meta.MetaAccessProvider.class);
plugins.register(new Plugin_ReplacementsUtil_charArrayIndexScale(), org.graalvm.compiler.replacements.ReplacementsUtil.class, "charArrayIndexScale", jdk.vm.ci.meta.MetaAccessProvider.class);
plugins.register(new Plugin_ReplacementsUtil_getArrayBaseOffset(injection), org.graalvm.compiler.replacements.ReplacementsUtil.class, "getArrayBaseOffset", jdk.vm.ci.meta.MetaAccessProvider.class, jdk.vm.ci.meta.JavaKind.class);
}
}