use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext 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.GraphBuilderContext in project graal by oracle.
the class HotSpotInvokeDynamicPluginTest method getDefaultGraphBuilderPlugins.
@Override
protected Plugins getDefaultGraphBuilderPlugins() {
Plugins plugins = super.getDefaultGraphBuilderPlugins();
plugins.setClassInitializationPlugin(new HotSpotClassInitializationPlugin());
plugins.setInvokeDynamicPlugin(new HotSpotInvokeDynamicPlugin() {
@Override
public boolean isResolvedDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
// Allow invokedynamic testing with older JVMCI
ResolvedJavaMethod m = builder.getMethod();
if (m.getName().startsWith("invokeDynamic") && m.getDeclaringClass().getName().equals("Lorg/graalvm/compiler/hotspot/test/HotSpotInvokeDynamicPluginTest;")) {
return false;
}
return super.isResolvedDynamicInvoke(builder, index, opcode);
}
@Override
public boolean supportsDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
// Allow invokehandle testing with older JVMCI
ResolvedJavaMethod m = builder.getMethod();
if (m.getName().startsWith("invokeHandle") && m.getDeclaringClass().getName().equals("Lorg/graalvm/compiler/hotspot/test/HotSpotInvokeDynamicPluginTest;")) {
return true;
}
return super.supportsDynamicInvoke(builder, index, opcode);
}
});
return plugins;
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class GraalCompilerTest method registerInvocationPlugins.
/**
* Registers extra invocation plugins for this test. The extra plugins are removed in the
* {@link #afterTest()} method.
*
* Subclasses overriding this method should always call the same method on the super class in
* case it wants to register plugins.
*
* @param invocationPlugins
*/
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
invocationPlugins.register(new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new BreakpointNode());
return true;
}
}, GraalCompilerTest.class, "breakpoint");
invocationPlugins.register(new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg0) {
b.add(new BreakpointNode(arg0));
return true;
}
}, GraalCompilerTest.class, "breakpoint", int.class);
invocationPlugins.register(new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new NotOptimizedNode());
return true;
}
}, GraalCompilerTest.class, "shouldBeOptimizedAway");
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class DerivedOopTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
Registration r = new Registration(invocationPlugins, DerivedOopTest.class);
ClassfileBytecodeProvider bytecodeProvider = getSystemClassLoaderBytecodeProvider();
ResolvedJavaMethod intrinsic = getResolvedJavaMethod("getRawPointerIntrinsic");
r.register1("getRawPointer", 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 });
}
});
super.registerInvocationPlugins(invocationPlugins);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class IndexOobBytecodeExceptionTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
invocationPlugins.register(new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode idx) {
return throwBytecodeException(b, ArrayIndexOutOfBoundsException.class, idx);
}
}, Exceptions.class, "throwOutOfBounds", int.class);
super.registerInvocationPlugins(invocationPlugins);
}
Aggregations