use of org.graalvm.compiler.hotspot.replacements.HotSpotReflectionGetCallerClassNode 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;
}
});
}
Aggregations