use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class TruffleGraphBuilderPlugins method registerCompilerAssertsPlugins.
public static void registerCompilerAssertsPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification) {
final ResolvedJavaType compilerAssertsType = getRuntime().resolveType(metaAccess, "com.oracle.truffle.api.CompilerAsserts");
Registration r = new Registration(plugins, new ResolvedJavaSymbol(compilerAssertsType));
r.register(new PEConstantPlugin(canDelayIntrinsification, Object.class));
r.register(new PEConstantPlugin(canDelayIntrinsification, int.class));
r.register(new PEConstantPlugin(canDelayIntrinsification, long.class));
r.register(new PEConstantPlugin(canDelayIntrinsification, float.class));
r.register(new PEConstantPlugin(canDelayIntrinsification, double.class));
r.register(new PEConstantPlugin(canDelayIntrinsification, boolean.class));
r.register(new RequiredInvocationPlugin("neverPartOfCompilation") {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new NeverPartOfCompilationNode("CompilerAsserts.neverPartOfCompilation()"));
return true;
}
});
r.register(new RequiredInvocationPlugin("neverPartOfCompilation", String.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) {
if (message.isConstant()) {
String messageString = message.asConstant().toValueString();
b.add(new NeverPartOfCompilationNode(messageString));
return true;
} else {
throw b.bailout("message for never part of compilation is non-constant");
}
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class JNIRegistrationSupport method registerLoadLibraryPlugin.
public void registerLoadLibraryPlugin(Plugins plugins, Class<?> clazz) {
Registration r = new Registration(plugins.getInvocationPlugins(), clazz);
r.register(new RequiredInvocationPlugin("loadLibrary", String.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode libnameNode) {
/*
* Support for automatic discovery of standard JDK libraries. This works because all
* of the JDK uses System.loadLibrary or jdk.internal.loader.BootLoader with literal
* String arguments.
*/
if (libnameNode.isConstant()) {
registerLibrary((String) SubstrateObjectConstant.asObject(libnameNode.asConstant()));
}
/* We never want to do any actual intrinsification, process the original invoke. */
return false;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class HotSpotTruffleGraphBuilderPlugins method registerCompilationFinalReferencePlugins.
static void registerCompilationFinalReferencePlugins(InvocationPlugins plugins, boolean canDelayIntrinsification, HotSpotKnownTruffleTypes types) {
InvocationPlugins.Registration r = new InvocationPlugins.Registration(plugins, Reference.class);
r.register(new RequiredInvocationPlugin("get", InvocationPlugin.Receiver.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
if (!canDelayIntrinsification && receiver.isConstant()) {
JavaConstant constant = (JavaConstant) receiver.get().asConstant();
if (constant.isNonNull()) {
if (types.classWeakReference.isInstance(constant) || types.classSoftReference.isInstance(constant)) {
JavaConstant referent = b.getConstantReflection().readFieldValue(types.referenceReferent, constant);
b.addPush(JavaKind.Object, ConstantNode.forConstant(referent, b.getMetaAccess()));
return true;
}
}
}
return false;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class HotSpotTruffleGraphBuilderPlugins method registerHotspotThreadLocalStubPlugins.
/**
* These HotSpot thread local plugins are intended for the interpreter access stubs.
*/
static void registerHotspotThreadLocalStubPlugins(InvocationPlugins plugins, WordTypes wordTypes, int jvmciReservedReference0Offset) {
GraalError.guarantee(jvmciReservedReference0Offset != -1, "jvmciReservedReference0Offset is not available but used.");
InvocationPlugins.Registration tl = new InvocationPlugins.Registration(plugins, "org.graalvm.compiler.truffle.runtime.hotspot.HotSpotFastThreadLocal");
tl.register(new RequiredInvocationPlugin("getJVMCIReservedReference") {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.addPush(JavaKind.Object, new HotSpotLoadReservedReferenceNode(b.getMetaAccess(), wordTypes, jvmciReservedReference0Offset));
return true;
}
});
tl.register(new RequiredInvocationPlugin("setJVMCIReservedReference", Object[].class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
b.add(new HotSpotStoreReservedReferenceNode(wordTypes, value, jvmciReservedReference0Offset));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.
the class CEntryPointSupport method registerCurrentIsolatePlugins.
private static void registerCurrentIsolatePlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, CurrentIsolate.class);
r.register(new RequiredInvocationPlugin("getCurrentThread") {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
if (SubstrateOptions.MultiThreaded.getValue()) {
b.addPush(JavaKind.Object, ReadReservedRegister.createReadIsolateThreadNode(b.getGraph()));
} else if (SubstrateOptions.SpawnIsolates.getValue()) {
ValueNode heapBase = b.add(ReadReservedRegister.createReadHeapBaseNode(b.getGraph()));
ConstantNode addend = b.add(ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND));
b.addPush(JavaKind.Object, new AddNode(heapBase, addend));
} else {
b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_THREAD_SENTINEL.rawValue()));
}
return true;
}
});
r.register(new RequiredInvocationPlugin("getIsolate") {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
if (SubstrateOptions.SpawnIsolates.getValue()) {
b.addPush(JavaKind.Object, ReadReservedRegister.createReadHeapBaseNode(b.getGraph()));
} else {
b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_SENTINEL.rawValue()));
}
return true;
}
});
}
Aggregations