use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class VMThreadSTFeature method registerInvocationPlugins.
/**
* Intrinsify the {@code get()} and {@code set()} methods during bytecode parsing. We know that
* every subclass of VMThreadLocal has the same methods. Only the signatures differ based on the
* type of value.
* <p>
* The value is stored in the two arrays that are in the image heap: a Object[] array for thread
* local object variables, and a byte[] array for all thread local primitive variables.
* Therefore, we need the proper read/write barriers. The {@link IsolateThread} parameter is
* ignored.
*/
@Override
public void registerInvocationPlugins(Providers providers, SnippetReflectionProvider snippetReflection, InvocationPlugins invocationPlugins, boolean hosted) {
for (Class<? extends FastThreadLocal> threadLocalClass : VMThreadLocalInfo.THREAD_LOCAL_CLASSES) {
Registration r = new Registration(invocationPlugins, threadLocalClass);
Class<?> valueClass = VMThreadLocalInfo.getValueClass(threadLocalClass);
registerAccessors(r, valueClass, false);
registerAccessors(r, valueClass, true);
/* compareAndSet() method without the VMThread parameter. */
r.register3("compareAndSet", Receiver.class, valueClass, valueClass, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode expect, ValueNode update) {
return handleCompareAndSet(b, targetMethod, receiver, expect, update);
}
});
/* get() method with the VMThread parameter. */
r.register4("compareAndSet", Receiver.class, IsolateThread.class, valueClass, valueClass, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode threadNode, ValueNode expect, ValueNode update) {
return handleCompareAndSet(b, targetMethod, receiver, expect, update);
}
});
}
Class<?>[] typesWithGetAddress = new Class<?>[] { FastThreadLocalBytes.class, FastThreadLocalWord.class };
for (Class<?> type : typesWithGetAddress) {
Registration r = new Registration(invocationPlugins, type);
/* getAddress() method without the VMThread parameter. */
r.register1("getAddress", Receiver.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
return handleGetAddress(b, targetMethod, receiver);
}
});
/* getAddress() method with the VMThread parameter. */
r.register2("getAddress", Receiver.class, IsolateThread.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode threadNode) {
return handleGetAddress(b, targetMethod, receiver);
}
});
}
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class DataPatchInConstantsTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
Registration r = new Registration(invocationPlugins, DataPatchInConstantsTest.class);
r.register1("loadThroughPatch", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
b.addPush(JavaKind.Object, new LoadThroughPatchNode(arg));
return true;
}
});
r.register1("loadThroughCompressedPatch", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
ValueNode compressed = b.add(HotSpotCompressionNode.compress(arg, runtime().getVMConfig().getOopEncoding()));
ValueNode patch = b.add(new LoadThroughPatchNode(compressed));
b.addPush(JavaKind.Object, HotSpotCompressionNode.uncompress(patch, runtime().getVMConfig().getOopEncoding()));
return true;
}
});
super.registerInvocationPlugins(invocationPlugins);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class ShortCircuitOrNodeTest method registerInvocationPlugins.
@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
Registration r = new Registration(invocationPlugins, ShortCircuitOrNodeTest.class);
r.register2("shortCircuitOr", boolean.class, boolean.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode b1, ValueNode b2) {
LogicNode x = b.add(new IntegerEqualsNode(b1, b.add(ConstantNode.forInt(1))));
LogicNode y = b.add(new IntegerEqualsNode(b2, b.add(ConstantNode.forInt(1))));
ShortCircuitOrNode compare = b.add(new ShortCircuitOrNode(x, false, y, false, 0.5));
b.addPush(JavaKind.Boolean, new ConditionalNode(compare, b.add(ConstantNode.forBoolean(true)), b.add(ConstantNode.forBoolean(false))));
return true;
}
});
super.registerInvocationPlugins(invocationPlugins);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class StandardGraphBuilderPlugins method registerMathPlugins.
private static void registerMathPlugins(InvocationPlugins plugins, boolean allowDeoptimization) {
Registration r = new Registration(plugins, Math.class);
if (allowDeoptimization) {
for (JavaKind kind : new JavaKind[] { JavaKind.Int, JavaKind.Long }) {
Class<?> type = kind.toJavaClass();
r.register1("decrementExact", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x) {
b.addPush(kind, new IntegerSubExactNode(x, ConstantNode.forIntegerKind(kind, 1)));
return true;
}
});
r.register1("incrementExact", type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x) {
b.addPush(kind, new IntegerAddExactNode(x, ConstantNode.forIntegerKind(kind, 1)));
return true;
}
});
r.register2("addExact", type, type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.addPush(kind, new IntegerAddExactNode(x, y));
return true;
}
});
r.register2("subtractExact", type, type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.addPush(kind, new IntegerSubExactNode(x, y));
return true;
}
});
r.register2("multiplyExact", type, type, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
b.addPush(kind, new IntegerMulExactNode(x, y));
return true;
}
});
}
}
r.register1("abs", Float.TYPE, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Float, b.append(new AbsNode(value).canonical(null)));
return true;
}
});
r.register1("abs", Double.TYPE, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Double, b.append(new AbsNode(value).canonical(null)));
return true;
}
});
r.register1("sqrt", Double.TYPE, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.push(JavaKind.Double, b.append(SqrtNode.create(value, NodeView.DEFAULT)));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration in project graal by oracle.
the class StandardGraphBuilderPlugins method registerJFRThrowablePlugins.
private static void registerJFRThrowablePlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, "oracle.jrockit.jfr.jdkevents.ThrowableTracer", bytecodeProvider);
r.register2("traceThrowable", Throwable.class, String.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode throwable, ValueNode message) {
b.add(new VirtualizableInvokeMacroNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), throwable, message));
return true;
}
@Override
public boolean inlineOnly() {
return true;
}
});
}
Aggregations