use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin in project graal by oracle.
the class ConditionalEliminationRegressionTest method editGraphBuilderConfiguration.
@Override
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
Registration r = new Registration(conf.getPlugins().getInvocationPlugins(), ConditionalEliminationRegressionTest.class);
r.register(new InlineOnlyInvocationPlugin("deoptimizeAndInvalidateUnreached") {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.UnreachedCode));
return true;
}
});
r.register(new InlineOnlyInvocationPlugin("guardingBoolean", Object.class, boolean.class, boolean.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value, ValueNode condition, ValueNode negatedConstant) {
if (!(condition instanceof ConditionalNode)) {
return false;
}
LogicNode l = ((ConditionalNode) condition).condition();
boolean isNullCheck = l instanceof IsNullNode;
boolean negated = ((PrimitiveConstant) negatedConstant.asConstant()).asInt() == 1;
GuardingNode guardingNode;
if (isNullCheck) {
guardingNode = b.append(new FixedGuardNode(l, DeoptimizationReason.NullCheckException, DeoptimizationAction.InvalidateRecompile, negated));
} else {
guardingNode = b.append(new FixedGuardNode(l, DeoptimizationReason.ClassCastException, DeoptimizationAction.InvalidateRecompile, negated));
}
b.addPush(value.getStackKind(), PiNode.create(value, objectNonNull(), guardingNode.asNode()));
return true;
}
});
return super.editGraphBuilderConfiguration(conf);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerSystemPlugins.
private static void registerSystemPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, System.class);
r.register(new ForeignCallPlugin(HotSpotHostForeignCallsProvider.JAVA_TIME_MILLIS, "currentTimeMillis"));
r.register(new ForeignCallPlugin(HotSpotHostForeignCallsProvider.JAVA_TIME_NANOS, "nanoTime"));
r.register(new InlineOnlyInvocationPlugin("identityHashCode", Object.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
b.addPush(JavaKind.Int, new HotSpotIdentityHashCodeNode(object, b.bci()));
return true;
}
});
ArrayCopySnippets.registerSystemArraycopyPlugin(r);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerObjectPlugins.
private static void registerObjectPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
Registration r = new Registration(plugins, Object.class, replacements);
r.register(new InlineOnlyInvocationPlugin("clone", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Object, new ObjectCloneNode(MacroParams.of(b, targetMethod, object)));
return true;
}
});
r.register(new InlineOnlyInvocationPlugin("hashCode", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Int, new HotSpotIdentityHashCodeNode(object, b.bci()));
return true;
}
});
if (config.inlineNotify()) {
r.register(new InlineOnlyInvocationPlugin("notify", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.add(new FastNotifyNode(object, false, b.bci()));
return true;
}
});
}
if (config.inlineNotifyAll()) {
r.register(new InlineOnlyInvocationPlugin("notifyAll", Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.add(new FastNotifyNode(object, true, b.bci()));
return true;
}
});
}
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerReflectionPlugins.
private static void registerReflectionPlugins(InvocationPlugins plugins, Replacements replacements, GraalHotSpotVMConfig config) {
Registration r = new Registration(plugins, reflectionClass, replacements);
r.register(new InlineOnlyInvocationPlugin("getCallerClass") {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, new HotSpotReflectionGetCallerClassNode(MacroParams.of(b, targetMethod)));
return true;
}
});
r.register(new InvocationPlugin("getClassAccessFlags", Class.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
try (HotSpotInvocationPluginHelper helper = new HotSpotInvocationPluginHelper(b, targetMethod, config)) {
ValueNode klass = helper.readKlassFromClass(b.nullCheckedValue(arg));
// Primitive Class case
ValueNode klassNonNull = helper.emitNullReturnGuard(klass, ConstantNode.forInt(Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC), GraalDirectives.UNLIKELY_PROBABILITY);
// Return (Klass::_access_flags & jvmAccWrittenFlags)
ValueNode accessFlags = helper.readKlassAccessFlags(klassNonNull);
helper.emitFinalReturn(JavaKind.Int, new AndNode(accessFlags, ConstantNode.forInt(config.jvmAccWrittenFlags)));
}
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin in project graal by oracle.
the class AArch64GraphBuilderPlugins method registerMathPlugins.
private static void registerMathPlugins(InvocationPlugins plugins, boolean registerForeignCallMath) {
Registration r = new Registration(plugins, Math.class);
if (registerForeignCallMath) {
registerUnaryMath(r, "sin", SIN);
registerUnaryMath(r, "cos", COS);
registerUnaryMath(r, "tan", TAN);
registerUnaryMath(r, "exp", EXP);
registerUnaryMath(r, "log", LOG);
registerUnaryMath(r, "log10", LOG10);
r.register(new InlineOnlyInvocationPlugin("pow", double.class, double.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.push(JavaKind.Double, b.append(BinaryMathIntrinsicNode.create(x, y, BinaryMathIntrinsicNode.BinaryOperation.POW)));
return true;
}
});
}
registerFMA(r);
registerIntegerAbs(r);
r.register(new InvocationPlugin("multiplyHigh", long.class, long.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.push(JavaKind.Long, b.append(new IntegerMulHighNode(x, y)));
return true;
}
});
registerMinMax(r);
r.register(new InvocationPlugin("copySign", float.class, float.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode magnitude, ValueNode sign) {
b.addPush(JavaKind.Float, new CopySignNode(magnitude, sign));
return true;
}
});
r.register(new InvocationPlugin("copySign", double.class, double.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode magnitude, ValueNode sign) {
b.addPush(JavaKind.Double, new CopySignNode(magnitude, sign));
return true;
}
});
}
Aggregations