use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin in project graal by oracle.
the class SPARCGraphBuilderPlugins method registerMathPlugins.
private static void registerMathPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Math.class);
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.register2("pow", Double.TYPE, Double.TYPE, new InvocationPlugin() {
@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;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin in project graal by oracle.
the class ArrayStoreBytecodeExceptionTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
invocationPlugins.register(new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode obj) {
return throwBytecodeException(b, ArrayStoreException.class, obj);
}
}, Exceptions.class, "throwArrayStore", Object.class);
super.registerInvocationPlugins(invocationPlugins);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin in project graal by oracle.
the class AArch64GraphBuilderPlugins method registerIntegerLongPlugins.
private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, BytecodeProvider bytecodeProvider) {
Class<?> declaringClass = kind.toBoxedJavaClass();
Class<?> type = kind.toJavaClass();
Registration r = new Registration(plugins, declaringClass, bytecodeProvider);
r.register1("numberOfLeadingZeros", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
ValueNode folded = AArch64CountLeadingZerosNode.tryFold(value);
if (folded != null) {
b.addPush(JavaKind.Int, folded);
} else {
b.addPush(JavaKind.Int, new AArch64CountLeadingZerosNode(value));
}
return true;
}
});
r.register1("numberOfTrailingZeros", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
ValueNode folded = AArch64CountTrailingZerosNode.tryFold(value);
if (folded != null) {
b.addPush(JavaKind.Int, folded);
} else {
b.addPush(JavaKind.Int, new AArch64CountTrailingZerosNode(value));
}
return true;
}
});
r.registerMethodSubstitution(substituteDeclaringClass, "bitCount", type);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin in project graal by oracle.
the class AMD64GraphBuilderPlugins method registerIntegerLongPlugins.
private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, AMD64 arch, BytecodeProvider bytecodeProvider) {
Class<?> declaringClass = kind.toBoxedJavaClass();
Class<?> type = kind.toJavaClass();
Registration r = new Registration(plugins, declaringClass, bytecodeProvider);
if (arch.getFeatures().contains(AMD64.CPUFeature.LZCNT) && arch.getFlags().contains(AMD64.Flag.UseCountLeadingZerosInstruction)) {
r.register1("numberOfLeadingZeros", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
ValueNode folded = AMD64CountLeadingZerosNode.tryFold(value);
if (folded != null) {
b.addPush(JavaKind.Int, folded);
} else {
b.addPush(JavaKind.Int, new AMD64CountLeadingZerosNode(value));
}
return true;
}
});
} else {
r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type);
}
if (arch.getFeatures().contains(AMD64.CPUFeature.BMI1) && arch.getFlags().contains(AMD64.Flag.UseCountTrailingZerosInstruction)) {
r.register1("numberOfTrailingZeros", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
ValueNode folded = AMD64CountTrailingZerosNode.tryFold(value);
if (folded != null) {
b.addPush(JavaKind.Int, folded);
} else {
b.addPush(JavaKind.Int, new AMD64CountTrailingZerosNode(value));
}
return true;
}
});
} else {
r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type);
}
if (arch.getFeatures().contains(AMD64.CPUFeature.POPCNT)) {
r.register1("bitCount", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Int, b.append(new BitCountNode(value).canonical(null)));
return true;
}
});
}
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin in project graal by oracle.
the class GuardedIntrinsicTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
Registration r = new Registration(invocationPlugins, Super.class);
r.register1("getAge", Receiver.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ConstantNode res = b.add(ConstantNode.forInt(new Super().getAge()));
b.add(new OpaqueNode(res));
b.push(JavaKind.Int, res);
return true;
}
});
super.registerInvocationPlugins(invocationPlugins);
}
Aggregations