use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver 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);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerJFRThrowablePlugins.
/*
* When Java Flight Recorder is enabled during image generation, the bytecodes of some methods
* get instrumented. Undo the instrumentation so that it does not end up in the generated image.
*/
private static void registerJFRThrowablePlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, "oracle.jrockit.jfr.jdkevents.ThrowableTracer", bytecodeProvider).setAllowOverwrite(true);
r.register2("traceError", Error.class, String.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode throwable, ValueNode message) {
return true;
}
});
r.register2("traceThrowable", Throwable.class, String.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode throwable, ValueNode message) {
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerClassPlugins.
private static void registerClassPlugins(InvocationPlugins plugins) {
/*
* We have our own Java-level implementation of isAssignableFrom() in DynamicHub, so we do
* not need to intrinsifiy that to a Graal node. Therefore, we overwrite and deactivate the
* invocation plugin registered in StandardGraphBuilderPlugins.
*
* TODO we should remove the implementation from DynamicHub to a lowering of
* ClassIsAssignableFromNode. Then we can remove this code.
*/
Registration r = new Registration(plugins, Class.class).setAllowOverwrite(true);
r.register2("isAssignableFrom", Receiver.class, Class.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver type, ValueNode otherType) {
return false;
}
});
r.register2("cast", Receiver.class, Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
ValueNode toType = receiver.get();
LogicNode condition = b.append(InstanceOfDynamicNode.create(b.getAssumptions(), b.getConstantReflection(), toType, object, true));
if (condition.isTautology()) {
b.addPush(JavaKind.Object, object);
} else {
FixedGuardNode fixedGuard = b.add(new FixedGuardNode(condition, DeoptimizationReason.ClassCastException, DeoptimizationAction.InvalidateReprofile, false));
b.addPush(JavaKind.Object, DynamicPiNode.create(b.getAssumptions(), b.getConstantReflection(), object, fixedGuard, toType));
}
return true;
}
});
r.register2("isInstance", Receiver.class, Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
ValueNode type = receiver.get();
LogicNode condition = b.append(InstanceOfDynamicNode.create(null, b.getConstantReflection(), type, object, false));
b.push(JavaKind.Boolean.getStackKind(), b.append(new ConditionalNode(condition).canonical(null)));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerStackValuePlugins.
private static void registerStackValuePlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, StackValue.class);
r.register1("get", int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode sizeNode) {
long size = longValue(b, targetMethod, sizeNode, "size");
StackSlotIdentity slotIdentity = new StackSlotIdentity(b.getGraph().method().asStackTraceElement(b.bci()).toString());
b.addPush(JavaKind.Object, new StackValueNode(1, size, slotIdentity));
return true;
}
});
r.register2("get", int.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode numElementsNode, ValueNode elementSizeNode) {
long numElements = longValue(b, targetMethod, numElementsNode, "numElements");
long elementSize = longValue(b, targetMethod, elementSizeNode, "elementSize");
StackSlotIdentity slotIdentity = new StackSlotIdentity(b.getGraph().method().asStackTraceElement(b.bci()).toString());
b.addPush(JavaKind.Object, new StackValueNode(numElements, elementSize, slotIdentity));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerUnsafePlugins.
private static void registerUnsafePlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Unsafe.class).setAllowOverwrite(true);
r.register2("allocateInstance", Receiver.class, Class.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode clazz) {
ValueNode clazzNonNull = b.nullCheckedValue(clazz, DeoptimizationAction.None);
b.addPush(JavaKind.Object, new SubstrateDynamicNewInstanceNode(clazzNonNull));
return true;
}
});
}
Aggregations