use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class PointstoGraphBuilderPlugins method registerSystemPlugins.
public static void registerSystemPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, System.class).setAllowOverwrite(true);
r.register5("arraycopy", Object.class, int.class, Object.class, int.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcPos, ValueNode dest, ValueNode destPos, ValueNode length) {
b.add(new BasicArrayCopyNode(BasicArrayCopyNode.TYPE, src, srcPos, dest, destPos, length, null, b.bci()));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class PointstoGraphBuilderPlugins method registerArraysPlugins.
public static void registerArraysPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, Arrays.class).setAllowOverwrite(true);
r.register2("copyOf", Object[].class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode original, ValueNode newLength) {
b.addPush(JavaKind.Object, new AnalysisArraysCopyOfNode(b.getInvokeReturnStamp(b.getAssumptions()).getTrustedStamp(), original, newLength));
return true;
}
});
r.register3("copyOf", Object[].class, int.class, Class.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode original, ValueNode newLength, ValueNode newObjectElementType) {
if (newObjectElementType instanceof GetClassNode || newObjectElementType.isConstant()) {
// We can infer the concrete type of the new array
b.addPush(JavaKind.Object, new AnalysisArraysCopyOfNode(b.getInvokeReturnStamp(b.getAssumptions()).getTrustedStamp(), original, newLength, newObjectElementType));
return true;
}
return false;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class LIRTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
Class<? extends LIRTest> c = getClass();
for (Method m : c.getMethods()) {
if (m.getAnnotation(LIRIntrinsic.class) != null) {
assert Modifier.isStatic(m.getModifiers());
Class<?>[] p = m.getParameterTypes();
assert p.length > 0;
assert LIRTestSpecification.class.isAssignableFrom(p[0]);
invocationPlugins.register(lirTestPlugin, c, m.getName(), p);
}
}
InvocationPlugin outputPlugin = new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode spec, ValueNode name, ValueNode expected) {
JavaKind returnKind = targetMethod.getSignature().getReturnKind();
b.addPush(returnKind, new LIRValueNode(getSnippetReflection(), returnKind, spec, name));
return true;
}
};
invocationPlugins.register(outputPlugin, LIRTest.class, "getOutput", new Class<?>[] { LIRTestSpecification.class, String.class, Object.class });
invocationPlugins.register(outputPlugin, LIRTest.class, "getOutput", new Class<?>[] { LIRTestSpecification.class, String.class, int.class });
super.registerInvocationPlugins(invocationPlugins);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class JDKIntrinsicsFeature method registerSystemPlugins.
private static void registerSystemPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, System.class);
r.register5("arraycopy", Object.class, int.class, Object.class, int.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length) {
b.add(new SubstrateArraycopyNode(src, srcPos, dst, dstPos, length, null, b.bci()));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class CEntryPointSupport method registerEntryPointActionsPlugins.
private static void registerEntryPointActionsPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, CEntryPointActions.class);
r.register1("enterCreateIsolate", CEntryPointCreateIsolateParameters.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode parameters) {
b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.CreateIsolate, parameters));
return true;
}
});
r.register1("enterAttachThread", Isolate.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode isolate) {
b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.AttachThread, isolate));
return true;
}
});
r.register1("enter", IsolateThread.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode thread) {
b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.Enter, thread));
return true;
}
});
r.register1("enterIsolate", Isolate.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode isolate) {
b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.EnterIsolate, isolate));
return true;
}
});
InvocationPlugin bailoutPlugin = new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.add(new CEntryPointPrologueBailoutNode(value));
return true;
}
};
r.register1("bailoutInPrologue", WordBase.class, bailoutPlugin);
r.register1("bailoutInPrologue", long.class, bailoutPlugin);
r.register1("bailoutInPrologue", double.class, bailoutPlugin);
r.register1("bailoutInPrologue", boolean.class, bailoutPlugin);
r.register0("bailoutInPrologue", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new CEntryPointPrologueBailoutNode(null));
return true;
}
});
r.register0("leave", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Int, new CEntryPointLeaveNode(LeaveAction.Leave));
return true;
}
});
r.register0("leaveDetachThread", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Int, new CEntryPointLeaveNode(LeaveAction.DetachThread));
return true;
}
});
r.register0("leaveTearDownIsolate", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Int, new CEntryPointLeaveNode(LeaveAction.TearDownIsolate));
return true;
}
});
r.register2("failFatally", int.class, CCharPointer.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg1, ValueNode arg2) {
b.add(new CEntryPointUtilityNode(UtilityAction.FailFatally, arg1, arg2));
return true;
}
});
}
Aggregations