use of org.graalvm.compiler.graph.NodeSourcePosition in project graal by oracle.
the class PointsToStats method reportPrunedTypeFlows.
private static void reportPrunedTypeFlows(BufferedWriter out) {
doWrite(out, String.format("%-35s\n", "Summary"));
doWrite(out, String.format("%-35s\t%-10s\n", "Type Flow Class", "Removed Count"));
typeFlowBuilders.stream().filter(Objects::nonNull).filter(b -> !b.isMaterialized()).collect(Collectors.groupingBy(TypeFlowBuilder::getFlowClass)).forEach((flowClass, providers) -> {
doWrite(out, String.format("%-35s\t%-10d\n", flowClass.getSimpleName(), providers.size()));
});
doWrite(out, String.format("\n%-35s\n", "Removed flows"));
doWrite(out, String.format("%-35s\t%-10s\n", "Type Flow Class", "Location"));
typeFlowBuilders.stream().filter(Objects::nonNull).filter(b -> !b.isMaterialized()).forEach((provider) -> {
Object source = provider.getSource();
String sourceStr;
if (source instanceof ValueNode) {
ValueNode value = (ValueNode) source;
NodeSourcePosition srcPosition = value.getNodeSourcePosition();
if (srcPosition != null) {
sourceStr = srcPosition.toString();
} else {
sourceStr = value.toString() + " @ " + value.graph().method().format("%H.%n(%p)");
}
} else {
sourceStr = source.toString();
}
doWrite(out, String.format("%-35s\t%-10s\n", provider.getFlowClass().getSimpleName(), sourceStr));
});
}
use of org.graalvm.compiler.graph.NodeSourcePosition in project graal by oracle.
the class DeoptimizationSourcePositionEncoder method verifyEncoding.
private boolean verifyEncoding(List<NodeSourcePosition> deoptimzationSourcePositions) {
for (int i = 0; i < deoptimzationSourcePositions.size(); i++) {
NodeSourcePosition originalSourcePosition = deoptimzationSourcePositions.get(i);
NodeSourcePosition decodedSourcePosition = DeoptimizationSourcePositionDecoder.decode(i, deoptimizationStartOffsets, deoptimizationEncodings, deoptimizationObjectConstants);
verifySourcePosition(originalSourcePosition, decodedSourcePosition);
}
return true;
}
use of org.graalvm.compiler.graph.NodeSourcePosition in project graal by oracle.
the class DeoptimizationSourcePositionEncoder method encodeSourcePositions.
private void encodeSourcePositions(List<NodeSourcePosition> deoptimzationSourcePositions, EconomicMap<NodeSourcePosition, Long> sourcePositionStartOffsets, UnsafeArrayTypeWriter encodingBuffer) {
for (int i = 0; i < deoptimzationSourcePositions.size(); i++) {
NodeSourcePosition sourcePosition = deoptimzationSourcePositions.get(i);
int startOffset;
if (sourcePosition == null) {
startOffset = DeoptimizationSourcePositionDecoder.NO_SOURCE_POSITION;
} else {
startOffset = TypeConversion.asS4(encodeSourcePositions(sourcePosition, sourcePositionStartOffsets, encodingBuffer));
assert startOffset > DeoptimizationSourcePositionDecoder.NO_SOURCE_POSITION;
}
deoptimizationStartOffsets[i] = startOffset;
}
}
use of org.graalvm.compiler.graph.NodeSourcePosition in project graal by oracle.
the class DeoptimizationSourcePositionEncoder method encode.
public void encode(List<NodeSourcePosition> deoptimzationSourcePositions) {
addObjectConstants(deoptimzationSourcePositions);
deoptimizationObjectConstants = objectConstants.encodeAll(newObjectArray(objectConstants.getLength()));
UnsafeArrayTypeWriter encodingBuffer = UnsafeArrayTypeWriter.create(ByteArrayReader.supportsUnalignedMemoryAccess());
EconomicMap<NodeSourcePosition, Long> sourcePositionStartOffsets = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE);
deoptimizationStartOffsets = newIntArray(deoptimzationSourcePositions.size());
encodeSourcePositions(deoptimzationSourcePositions, sourcePositionStartOffsets, encodingBuffer);
deoptimizationEncodings = encodingBuffer.toArray(newByteArray(TypeConversion.asS4(encodingBuffer.getBytesWritten())));
verifyEncoding(deoptimzationSourcePositions);
}
use of org.graalvm.compiler.graph.NodeSourcePosition in project graal by oracle.
the class PEGraphDecoder method handleInvoke.
@Override
protected LoopScope handleInvoke(MethodScope s, LoopScope loopScope, InvokeData invokeData) {
PEMethodScope methodScope = (PEMethodScope) s;
/*
* Decode the call target, but do not add it to the graph yet. This avoids adding usages for
* all the arguments, which are expensive to remove again when we can inline the method.
*/
assert invokeData.invoke.callTarget() == null : "callTarget edge is ignored during decoding of Invoke";
CallTargetNode callTarget = (CallTargetNode) decodeFloatingNode(methodScope, loopScope, invokeData.callTargetOrderId);
if (callTarget instanceof MethodCallTargetNode) {
MethodCallTargetNode methodCall = (MethodCallTargetNode) callTarget;
if (methodCall.invokeKind().hasReceiver()) {
invokeData.constantReceiver = methodCall.arguments().get(0).asJavaConstant();
NodeSourcePosition invokePosition = invokeData.invoke.asNode().getNodeSourcePosition();
if (invokeData.constantReceiver != null && invokePosition != null) {
// new NodeSourcePosition(invokeData.constantReceiver,
// invokePosition.getCaller(), invokePosition.getMethod(),
// invokePosition.getBCI());
}
}
LoopScope inlineLoopScope = trySimplifyInvoke(methodScope, loopScope, invokeData, (MethodCallTargetNode) callTarget);
if (inlineLoopScope != null) {
return inlineLoopScope;
}
}
/* We know that we need an invoke, so now we can add the call target to the graph. */
graph.add(callTarget);
registerNode(loopScope, invokeData.callTargetOrderId, callTarget, false, false);
return super.handleInvoke(methodScope, loopScope, invokeData);
}
Aggregations