use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class NullBytecodeExceptionTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
invocationPlugins.register(new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
return throwBytecodeException(b, NullPointerException.class);
}
}, Exceptions.class, "throwNull");
super.registerInvocationPlugins(invocationPlugins);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class PEGraphDecoderTest method registerPlugins.
private static void registerPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, PEGraphDecoderTest.class);
r.register2("readInt", Object.class, long.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode obj, ValueNode offset) {
AddressNode address = b.add(new OffsetAddressNode(obj, offset));
ReadNode read = b.addPush(JavaKind.Int, new ReadNode(address, LocationIdentity.any(), StampFactory.forKind(JavaKind.Int), BarrierType.NONE));
read.setGuard(AbstractBeginNode.prevBegin(read));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class PointerTrackingTest method register.
private void register(Registration r, String fnName) {
ResolvedJavaMethod intrinsic = getResolvedJavaMethod(fnName + "Intrinsic");
BytecodeProvider bytecodeProvider = getSystemClassLoaderBytecodeProvider();
r.register1(fnName, Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
return b.intrinsify(bytecodeProvider, targetMethod, intrinsic, receiver, new ValueNode[] { arg });
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class AMD64GraphBuilderPlugins method registerUnsafePlugins.
private static void registerUnsafePlugins(InvocationPlugins plugins, BytecodeProvider replacementsBytecodeProvider) {
Registration r;
if (Java8OrEarlier) {
r = new Registration(plugins, Unsafe.class);
} else {
r = new Registration(plugins, "jdk.internal.misc.Unsafe", replacementsBytecodeProvider);
}
for (JavaKind kind : new JavaKind[] { JavaKind.Int, JavaKind.Long, JavaKind.Object }) {
Class<?> javaClass = kind == JavaKind.Object ? Object.class : kind.toJavaClass();
r.register4("getAndSet" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) {
// Emits a null-check for the otherwise unused receiver
unsafe.get();
b.addPush(kind, new AtomicReadAndWriteNode(object, offset, value, kind, LocationIdentity.any()));
b.getGraph().markUnsafeAccess();
return true;
}
});
if (kind != JavaKind.Object) {
r.register4("getAndAdd" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode delta) {
// Emits a null-check for the otherwise unused receiver
unsafe.get();
AddressNode address = b.add(new OffsetAddressNode(object, offset));
b.addPush(kind, new AtomicReadAndAddNode(address, delta, LocationIdentity.any()));
b.getGraph().markUnsafeAccess();
return true;
}
});
}
}
for (JavaKind kind : new JavaKind[] { JavaKind.Char, JavaKind.Short, JavaKind.Int, JavaKind.Long }) {
Class<?> javaClass = kind.toJavaClass();
r.registerOptional3("get" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, new UnsafeGetPlugin(kind, false));
r.registerOptional4("put" + kind.name() + "Unaligned", Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, false));
}
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class ClassCastBytecodeExceptionTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
invocationPlugins.register(new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode obj, ValueNode classNode) {
ResolvedJavaType type = b.getConstantReflection().asJavaType(classNode.asConstant());
Constant hub = b.getConstantReflection().asObjectHub(type);
Stamp hubStamp = b.getStampProvider().createHubStamp(StampFactory.object(TypeReference.createExactTrusted(type)));
ConstantNode hubConst = b.add(ConstantNode.forConstant(hubStamp, hub, b.getMetaAccess()));
return throwBytecodeException(b, ClassCastException.class, obj, hubConst);
}
}, Exceptions.class, "throwClassCast", Object.class, Class.class);
super.registerInvocationPlugins(invocationPlugins);
}
Aggregations