use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class CEntryPointSupport method registerEntryPointContextPlugins.
private static void registerEntryPointContextPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, CEntryPointContext.class);
r.register0("getCurrentIsolateThread", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
if (SubstrateOptions.MultiThreaded.getValue()) {
b.addPush(JavaKind.Object, ReadRegisterFixedNode.forIsolateThread());
} else if (SubstrateOptions.SpawnIsolates.getValue()) {
ValueNode heapBase = b.add(ReadRegisterFixedNode.forHeapBase());
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.register0("getCurrentIsolate", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
if (SubstrateOptions.SpawnIsolates.getValue()) {
b.addPush(JavaKind.Object, ReadRegisterFixedNode.forHeapBase());
} else {
b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_SENTINEL.rawValue()));
}
return true;
}
});
r.register1("isCurrentThreadAttachedTo", Isolate.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode isolate) {
b.addPush(JavaKind.Boolean, new CEntryPointUtilityNode(UtilityAction.IsAttached, isolate));
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerSystemPlugins.
private static void registerSystemPlugins(InvocationPlugins plugins, ForeignCallsProvider foreignCalls) {
Registration r = new Registration(plugins, System.class);
r.register0("currentTimeMillis", new ForeignCallPlugin(foreignCalls, HotSpotHostForeignCallsProvider.JAVA_TIME_MILLIS));
r.register0("nanoTime", new ForeignCallPlugin(foreignCalls, HotSpotHostForeignCallsProvider.JAVA_TIME_NANOS));
r.register1("identityHashCode", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
b.addPush(JavaKind.Int, new IdentityHashCodeNode(object));
return true;
}
@Override
public boolean inlineOnly() {
return 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 dst, ValueNode dstPos, ValueNode length) {
b.add(new ArrayCopyNode(b.bci(), src, srcPos, dst, dstPos, length));
return true;
}
@Override
public boolean inlineOnly() {
return true;
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerObjectPlugins.
private static void registerObjectPlugins(InvocationPlugins plugins, OptionValues options, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, Object.class, bytecodeProvider);
if (!GeneratePIC.getValue(options)) {
// FIXME: clone() requires speculation and requires a fix in here (to check that
// b.getAssumptions() != null), and in ReplacementImpl.getSubstitution() where there is
// an instantiation of IntrinsicGraphBuilder using a constructor that sets
// AllowAssumptions to YES automatically. The former has to inherit the assumptions
// settings from the root compile instead. So, for now, I'm disabling it for
// GeneratePIC.
r.register1("clone", Receiver.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode object = receiver.get();
b.addPush(JavaKind.Object, new ObjectCloneNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), object));
return true;
}
@Override
public boolean inlineOnly() {
return true;
}
});
}
r.registerMethodSubstitution(ObjectSubstitutions.class, "hashCode", Receiver.class);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerConstantPoolPlugins.
private static void registerConstantPoolPlugins(InvocationPlugins plugins, WordTypes wordTypes, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, constantPoolClass, bytecodeProvider);
r.register2("getSize0", Receiver.class, Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop) {
boolean notCompressible = false;
ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config);
AddressNode lengthAddress = b.add(new OffsetAddressNode(constants, b.add(ConstantNode.forLong(config.constantPoolLengthOffset))));
ValueNode length = WordOperationPlugin.readOp(b, JavaKind.Int, lengthAddress, CONSTANT_POOL_LENGTH, BarrierType.NONE, notCompressible);
b.addPush(JavaKind.Int, length);
return true;
}
});
r.register3("getIntAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Int, wordTypes, config);
}
});
r.register3("getLongAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Long, wordTypes, config);
}
});
r.register3("getFloatAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Float, wordTypes, config);
}
});
r.register3("getDoubleAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Double, wordTypes, config);
}
});
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerCallSitePlugins.
private static void registerCallSitePlugins(InvocationPlugins plugins) {
InvocationPlugin plugin = new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
ValueNode callSite = receiver.get();
ValueNode folded = CallSiteTargetNode.tryFold(GraphUtil.originalValue(callSite), b.getMetaAccess(), b.getAssumptions());
if (folded != null) {
b.addPush(JavaKind.Object, folded);
} else {
b.addPush(JavaKind.Object, new CallSiteTargetNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), callSite));
}
return true;
}
@Override
public boolean inlineOnly() {
return true;
}
};
plugins.register(plugin, ConstantCallSite.class, "getTarget", Receiver.class);
plugins.register(plugin, MutableCallSite.class, "getTarget", Receiver.class);
plugins.register(plugin, VolatileCallSite.class, "getTarget", Receiver.class);
}
Aggregations