use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class ReadNode method canonicalizeRead.
public static ValueNode canonicalizeRead(ValueNode read, AddressNode address, LocationIdentity locationIdentity, CanonicalizerTool tool) {
NodeView view = NodeView.from(tool);
MetaAccessProvider metaAccess = tool.getMetaAccess();
if (tool.canonicalizeReads() && address instanceof OffsetAddressNode) {
OffsetAddressNode objAddress = (OffsetAddressNode) address;
ValueNode object = objAddress.getBase();
if (metaAccess != null && object.isConstant() && !object.isNullConstant() && objAddress.getOffset().isConstant()) {
long displacement = objAddress.getOffset().asJavaConstant().asLong();
int stableDimension = ((ConstantNode) object).getStableDimension();
if (locationIdentity.isImmutable() || stableDimension > 0) {
Constant constant = read.stamp(view).readConstant(tool.getConstantReflection().getMemoryAccessProvider(), object.asConstant(), displacement);
boolean isDefaultStable = locationIdentity.isImmutable() || ((ConstantNode) object).isDefaultStable();
if (constant != null && (isDefaultStable || !constant.isDefaultForKind())) {
return ConstantNode.forConstant(read.stamp(view), constant, Math.max(stableDimension - 1, 0), isDefaultStable, metaAccess);
}
}
}
if (locationIdentity.equals(ARRAY_LENGTH_LOCATION)) {
ValueNode length = GraphUtil.arrayLength(object);
if (length != null) {
return length;
}
}
if (locationIdentity instanceof CanonicalizableLocation) {
CanonicalizableLocation canonicalize = (CanonicalizableLocation) locationIdentity;
ValueNode result = canonicalize.canonicalizeRead(read, address, object, tool);
assert result != null && result.stamp(view).isCompatible(read.stamp(view));
return result;
}
}
return read;
}
use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class CompareAndSetVMThreadLocalNode 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));
LogicCompareAndSwapNode atomic = graph().add(new LogicCompareAndSwapNode(address, threadLocalInfo.locationIdentity, expect, update, barrierType));
atomic.setStateAfter(stateAfter());
graph().replaceFixedWithFixed(this, atomic);
}
use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class StoreVMThreadLocalNode method lower.
@Override
public void lower(LoweringTool tool) {
assert threadLocalInfo.offset >= 0;
ConstantNode offset = ConstantNode.forIntegerKind(FrameAccess.getWordKind(), threadLocalInfo.offset, graph());
AddressNode address = graph().unique(new OffsetAddressNode(holder, offset));
AbstractWriteNode write;
if (SubstrateOptions.MultiThreaded.getValue()) {
write = new CInterfaceWriteNode(address, threadLocalInfo.locationIdentity, value, barrierType, threadLocalInfo.name);
} else {
write = new JavaWriteNode(threadLocalInfo.storageKind, address, threadLocalInfo.locationIdentity, value, barrierType, true);
}
write = graph().add(write);
write.setStateAfter(stateAfter());
graph().replaceFixedWithFixed(this, write);
if (!SubstrateOptions.MultiThreaded.getValue()) {
tool.getLowerer().lower(write, tool);
}
}
use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class HotSpotGraphBuilderPlugins method getMetaspaceConstantPool.
/**
* Emits a node to get the metaspace {@code ConstantPool} pointer given the value of the
* {@code constantPoolOop} field in a ConstantPool value.
*
* @param constantPoolOop value of the {@code constantPoolOop} field in a ConstantPool value
* @return a node representing the metaspace {@code ConstantPool} pointer associated with
* {@code constantPoolOop}
*/
private static ValueNode getMetaspaceConstantPool(GraphBuilderContext b, ValueNode constantPoolOop, WordTypes wordTypes, GraalHotSpotVMConfig config) {
// ConstantPool.constantPoolOop is in fact the holder class.
ValueNode value = b.nullCheckedValue(constantPoolOop, DeoptimizationAction.None);
ValueNode klass = b.add(ClassGetHubNode.create(value, b.getMetaAccess(), b.getConstantReflection(), false));
boolean notCompressible = false;
AddressNode constantsAddress = b.add(new OffsetAddressNode(klass, b.add(ConstantNode.forLong(config.instanceKlassConstantsOffset))));
return WordOperationPlugin.readOp(b, wordTypes.getWordKind(), constantsAddress, INSTANCE_KLASS_CONSTANTS, BarrierType.NONE, notCompressible);
}
use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerThreadPlugins.
private static void registerThreadPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, WordTypes wordTypes, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) {
Registration r = new Registration(plugins, Thread.class, bytecodeProvider);
r.register0("currentThread", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
CurrentJavaThreadNode thread = b.add(new CurrentJavaThreadNode(wordTypes.getWordKind()));
ValueNode offset = b.add(ConstantNode.forLong(config.threadObjectOffset));
AddressNode address = b.add(new OffsetAddressNode(thread, offset));
// JavaThread::_threadObj is never compressed
ObjectStamp stamp = StampFactory.objectNonNull(TypeReference.create(b.getAssumptions(), metaAccess.lookupJavaType(Thread.class)));
b.addPush(JavaKind.Object, new ReadNode(address, JAVA_THREAD_THREAD_OBJECT_LOCATION, stamp, BarrierType.NONE));
return true;
}
});
r.registerMethodSubstitution(ThreadSubstitutions.class, "isInterrupted", Receiver.class, boolean.class);
}
Aggregations