use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerReflectionPlugins.
private static void registerReflectionPlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, reflectionClass, bytecodeProvider);
r.register0("getCallerClass", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, new ReflectionGetCallerClassNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions())));
return true;
}
@Override
public boolean inlineOnly() {
return true;
}
});
r.registerMethodSubstitution(ReflectionSubstitutions.class, "getClassAccessFlags", Class.class);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver 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));
}
}
Aggregations