package org.graalvm.compiler.hotspot.stubs;
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_ForeignCallSnippets_objectResultOffset 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_ForeignCallSnippets_objectResultOffset.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injectedGraalHotSpotVMConfig;
int result = org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.objectResultOffset(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;
}
private final org.graalvm.compiler.hotspot.GraalHotSpotVMConfig injectedGraalHotSpotVMConfig;
Plugin_ForeignCallSnippets_objectResultOffset(GeneratedPluginInjectionProvider injection) {
this.injectedGraalHotSpotVMConfig = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}
final class PluginReplacementNode_ForeignCallSnippets_objectResultOffset implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ForeignCallSnippets_objectResultOffset();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
int result = org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.objectResultOffset(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_ForeignCallSnippets_verifyOopBits 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_ForeignCallSnippets_verifyOopBits.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injectedGraalHotSpotVMConfig;
long result = org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.verifyOopBits(arg0);
JavaConstant constant = JavaConstant.forLong(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Long, 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.hotspot.GraalHotSpotVMConfig injectedGraalHotSpotVMConfig;
Plugin_ForeignCallSnippets_verifyOopBits(GeneratedPluginInjectionProvider injection) {
this.injectedGraalHotSpotVMConfig = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}
final class PluginReplacementNode_ForeignCallSnippets_verifyOopBits implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ForeignCallSnippets_verifyOopBits();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
long result = org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.verifyOopBits(arg0);
JavaConstant constant = JavaConstant.forLong(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Long, node);
return true;
}
}
final class Plugin_ForeignCallSnippets_verifyOopMask 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_ForeignCallSnippets_verifyOopMask.FUNCTION);
return true;
}
if (!checkInjectedArgument(b, args[0], targetMethod)) {
return false;
}
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injectedGraalHotSpotVMConfig;
long result = org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.verifyOopMask(arg0);
JavaConstant constant = JavaConstant.forLong(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Long, 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.hotspot.GraalHotSpotVMConfig injectedGraalHotSpotVMConfig;
Plugin_ForeignCallSnippets_verifyOopMask(GeneratedPluginInjectionProvider injection) {
this.injectedGraalHotSpotVMConfig = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}
final class PluginReplacementNode_ForeignCallSnippets_verifyOopMask implements PluginReplacementNode.ReplacementFunction {
static PluginReplacementNode.ReplacementFunction FUNCTION = new PluginReplacementNode_ForeignCallSnippets_verifyOopMask();
@Override
public boolean replace(GraphBuilderContext b, GeneratedPluginInjectionProvider injection, Stamp stamp, NodeInputList<ValueNode> args) {
assert args.get(0).isNullConstant();
org.graalvm.compiler.hotspot.GraalHotSpotVMConfig arg0 = injection.getInjectedArgument(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
long result = org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.verifyOopMask(arg0);
JavaConstant constant = JavaConstant.forLong(result);
ConstantNode node = ConstantNode.forConstant(constant, b.getMetaAccess(), b.getGraph());
b.push(JavaKind.Long, node);
return true;
}
}
public class PluginFactory_ForeignCallSnippets implements GeneratedPluginFactory {
@Override
public void registerPlugins(InvocationPlugins plugins, GeneratedPluginInjectionProvider injection) {
plugins.register(new Plugin_ForeignCallSnippets_objectResultOffset(injection), org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.class, "objectResultOffset", org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
plugins.register(new Plugin_ForeignCallSnippets_verifyOopBits(injection), org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.class, "verifyOopBits", org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
plugins.register(new Plugin_ForeignCallSnippets_verifyOopMask(injection), org.graalvm.compiler.hotspot.stubs.ForeignCallSnippets.class, "verifyOopMask", org.graalvm.compiler.hotspot.GraalHotSpotVMConfig.class);
}
}