use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class LoadVMThreadLocalNode method lower.
@Override
public void lower(LoweringTool tool) {
assert threadLocalInfo.offset >= 0;
ConstantNode offset = ConstantNode.forIntegerKind(FrameAccess.getWordKind(), threadLocalInfo.offset, holder.graph());
AddressNode address = graph().unique(new OffsetAddressNode(holder, offset));
FixedAccessNode read;
if (SubstrateOptions.MultiThreaded.getValue()) {
read = new CInterfaceReadNode(address, threadLocalInfo.locationIdentity, stamp(NodeView.DEFAULT), barrierType, threadLocalInfo.name);
} else {
read = new JavaReadNode(threadLocalInfo.storageKind, address, threadLocalInfo.locationIdentity, barrierType, true);
}
read = graph().add(read);
graph().replaceFixedWithFixed(this, read);
if (!SubstrateOptions.MultiThreaded.getValue()) {
tool.getLowerer().lower(read, tool);
}
}
use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode 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.memory.address.OffsetAddressNode in project graal by oracle.
the class HotSpotGraphBuilderPlugins method readMetaspaceConstantPoolElement.
/**
* Emits a node representing an element in a metaspace {@code ConstantPool}.
*
* @param constantPoolOop value of the {@code constantPoolOop} field in a ConstantPool value
*/
private static boolean readMetaspaceConstantPoolElement(GraphBuilderContext b, ValueNode constantPoolOop, ValueNode index, JavaKind elementKind, WordTypes wordTypes, GraalHotSpotVMConfig config) {
ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config);
int shift = CodeUtil.log2(wordTypes.getWordKind().getByteCount());
ValueNode scaledIndex = b.add(new LeftShiftNode(IntegerConvertNode.convert(index, StampFactory.forKind(JavaKind.Long), NodeView.DEFAULT), b.add(ConstantNode.forInt(shift))));
ValueNode offset = b.add(new AddNode(scaledIndex, b.add(ConstantNode.forLong(config.constantPoolSize))));
AddressNode elementAddress = b.add(new OffsetAddressNode(constants, offset));
boolean notCompressible = false;
ValueNode elementValue = WordOperationPlugin.readOp(b, elementKind, elementAddress, NamedLocationIdentity.getArrayLocation(elementKind), BarrierType.NONE, notCompressible);
b.addPush(elementKind, elementValue);
return true;
}
use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class PushNodesThroughPiTest method test1.
@Ignore
@Test
@SuppressWarnings("try")
public void test1() {
final String snippet = "test1Snippet";
DebugContext debug = getDebugContext();
try (DebugContext.Scope s = debug.scope("PushThroughPi", new DebugDumpScope(snippet))) {
StructuredGraph graph = compileTestSnippet(snippet);
for (ReadNode rn : graph.getNodes().filter(ReadNode.class)) {
OffsetAddressNode address = (OffsetAddressNode) rn.getAddress();
long disp = address.getOffset().asJavaConstant().asLong();
ResolvedJavaType receiverType = StampTool.typeOrNull(address.getBase());
ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(disp, rn.getStackKind());
assert field != null : "Node " + rn + " tries to access a field which doesn't exists for this type";
if (field.getName().equals("x")) {
Assert.assertTrue(address.getBase() instanceof ParameterNode);
} else {
Assert.assertTrue(address.getBase().toString(), address.getBase() instanceof PiNode);
}
}
Assert.assertTrue(graph.getNodes().filter(IsNullNode.class).count() == 1);
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class DefaultJavaLoweringProvider method createArrayAddress.
public AddressNode createArrayAddress(StructuredGraph graph, ValueNode array, JavaKind elementKind, ValueNode index) {
ValueNode wordIndex;
if (target.wordSize > 4) {
wordIndex = graph.unique(new SignExtendNode(index, target.wordSize * 8));
} else {
assert target.wordSize == 4 : "unsupported word size";
wordIndex = index;
}
int shift = CodeUtil.log2(arrayScalingFactor(elementKind));
ValueNode scaledIndex = graph.unique(new LeftShiftNode(wordIndex, ConstantNode.forInt(shift, graph)));
int base = arrayBaseOffset(elementKind);
ValueNode offset = graph.unique(new AddNode(scaledIndex, ConstantNode.forIntegerKind(target.wordJavaKind, base, graph)));
return graph.unique(new OffsetAddressNode(array, offset));
}
Aggregations