use of org.graalvm.word.LocationIdentity in project graal by oracle.
the class ExceptionObjectNode method lower.
@Override
public void lower(LoweringTool tool) {
if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
/*
* Now the lowering to BeginNode+LoadExceptionNode can be performed, since no more
* deopts can float in between the begin node and the load exception node.
*/
LocationIdentity locationsKilledByInvoke = ((InvokeWithExceptionNode) predecessor()).getLocationIdentity();
AbstractBeginNode entry = graph().add(KillingBeginNode.create(locationsKilledByInvoke));
LoadExceptionObjectNode loadException = graph().add(new LoadExceptionObjectNode(stamp(NodeView.DEFAULT)));
loadException.setStateAfter(stateAfter());
replaceAtUsages(InputType.Value, loadException);
graph().replaceFixedWithFixed(this, entry);
entry.graph().addAfterFixed(entry, loadException);
loadException.lower(tool);
}
}
use of org.graalvm.word.LocationIdentity in project graal by oracle.
the class UnsafeAccessNode method canonical.
@Override
public Node canonical(CanonicalizerTool tool) {
if (!isAnyLocationForced() && getLocationIdentity().isAny()) {
if (offset().isConstant()) {
long constantOffset = offset().asJavaConstant().asLong();
// Try to canonicalize to a field access.
ResolvedJavaType receiverType = StampTool.typeOrNull(object());
if (receiverType != null) {
ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(constantOffset, accessKind());
// never a valid access of an arbitrary address.
if (field != null && field.getJavaKind() == this.accessKind()) {
assert !graph().isAfterFloatingReadPhase() : "cannot add more precise memory location after floating read phase";
return cloneAsFieldAccess(graph().getAssumptions(), field);
}
}
}
ResolvedJavaType receiverType = StampTool.typeOrNull(object());
// Try to build a better location identity.
if (receiverType != null && receiverType.isArray()) {
LocationIdentity identity = NamedLocationIdentity.getArrayLocation(receiverType.getComponentType().getJavaKind());
assert !graph().isAfterFloatingReadPhase() : "cannot add more precise memory location after floating read phase";
return cloneAsArrayAccess(offset(), identity);
}
}
return this;
}
use of org.graalvm.word.LocationIdentity in project graal by oracle.
the class ArrayCopySnippets method unrolledArraycopyWork.
private static void unrolledArraycopyWork(Object nonNullSrc, int srcPos, Object nonNullDest, int destPos, int length, JavaKind elementKind) {
int scale = arrayIndexScale(elementKind);
int arrayBaseOffset = arrayBaseOffset(elementKind);
LocationIdentity arrayLocation = getArrayLocation(elementKind);
long sourceOffset = arrayBaseOffset + (long) srcPos * scale;
long destOffset = arrayBaseOffset + (long) destPos * scale;
long position = 0;
long delta = scale;
if (probability(NOT_FREQUENT_PROBABILITY, nonNullSrc == nonNullDest && srcPos < destPos)) {
// bad aliased case so we need to copy the array from back to front
position = (long) (length - 1) * scale;
delta = -delta;
}
// the length was already checked before - we can emit unconditional instructions
ExplodeLoopNode.explodeLoop();
for (int iteration = 0; iteration < length; iteration++) {
Object value = RawLoadNode.load(nonNullSrc, sourceOffset + position, elementKind, arrayLocation);
RawStoreNode.storeObject(nonNullDest, destOffset + position, value, elementKind, arrayLocation, false);
position += delta;
}
}
use of org.graalvm.word.LocationIdentity in project graal by oracle.
the class FloatingReadPhase method mergeMemoryMaps.
public static MemoryMapImpl mergeMemoryMaps(AbstractMergeNode merge, List<? extends MemoryMap> states) {
MemoryMapImpl newState = new MemoryMapImpl();
EconomicSet<LocationIdentity> keys = EconomicSet.create(Equivalence.DEFAULT);
for (MemoryMap other : states) {
keys.addAll(other.getLocations());
}
assert checkNoImmutableLocations(keys);
for (LocationIdentity key : keys) {
int mergedStatesCount = 0;
boolean isPhi = false;
MemoryNode merged = null;
for (MemoryMap state : states) {
MemoryNode last = state.getLastLocationAccess(key);
if (isPhi) {
((MemoryPhiNode) merged).addInput(ValueNodeUtil.asNode(last));
} else {
if (merged == last) {
// nothing to do
} else if (merged == null) {
merged = last;
} else {
MemoryPhiNode phi = merge.graph().addWithoutUnique(new MemoryPhiNode(merge, key));
for (int j = 0; j < mergedStatesCount; j++) {
phi.addInput(ValueNodeUtil.asNode(merged));
}
phi.addInput(ValueNodeUtil.asNode(last));
merged = phi;
isPhi = true;
}
}
mergedStatesCount++;
}
newState.lastMemorySnapshot.put(key, merged);
}
return newState;
}
use of org.graalvm.word.LocationIdentity in project graal by oracle.
the class MemoryMapNode method checkOrder.
private boolean checkOrder(EconomicMap<LocationIdentity, MemoryNode> mmap) {
for (int i = 0; i < locationIdentities.size(); i++) {
LocationIdentity locationIdentity = locationIdentities.get(i);
ValueNode n = nodes.get(i);
assertTrue(mmap.get(locationIdentity) == n, "iteration order of keys differs from values in input map");
}
return true;
}
Aggregations