use of org.graalvm.compiler.nodes.java.MonitorExitNode in project graal by oracle.
the class InliningUtil method handleAfterBciFrameState.
private static FrameState handleAfterBciFrameState(FrameState frameState, Invoke invoke, boolean alwaysDuplicateStateAfter) {
FrameState stateAtReturn = invoke.stateAfter();
JavaKind invokeReturnKind = invoke.asNode().getStackKind();
FrameState stateAfterReturn = stateAtReturn;
if (frameState.getCode() == null) {
// that was parsed for post-parse intrinsification
for (Node usage : frameState.usages()) {
if (usage instanceof ForeignCallNode) {
// A foreign call inside an intrinsic needs to have
// the BCI of the invoke being intrinsified
ForeignCallNode foreign = (ForeignCallNode) usage;
foreign.setBci(invoke.bci());
}
}
}
// value (top of stack)
assert !frameState.rethrowException() : frameState;
if (frameState.stackSize() > 0 && (alwaysDuplicateStateAfter || stateAfterReturn.stackAt(0) != frameState.stackAt(0))) {
// A non-void return value.
stateAfterReturn = stateAtReturn.duplicateModified(invokeReturnKind, invokeReturnKind, frameState.stackAt(0));
} else {
// A void return value.
stateAfterReturn = stateAtReturn.duplicate();
}
assert stateAfterReturn.bci != BytecodeFrame.UNKNOWN_BCI;
// Return value does no longer need to be limited by the monitor exit.
for (MonitorExitNode n : frameState.usages().filter(MonitorExitNode.class)) {
n.clearEscapedReturnValue();
}
frameState.replaceAndDelete(stateAfterReturn);
return stateAfterReturn;
}
use of org.graalvm.compiler.nodes.java.MonitorExitNode in project graal by oracle.
the class LockEliminationPhase method run.
@Override
protected void run(StructuredGraph graph) {
for (MonitorExitNode monitorExitNode : graph.getNodes(MonitorExitNode.TYPE)) {
FixedNode next = monitorExitNode.next();
if ((next instanceof MonitorEnterNode || next instanceof RawMonitorEnterNode)) {
// start
assert !(next instanceof OSRMonitorEnterNode);
AccessMonitorNode monitorEnterNode = (AccessMonitorNode) next;
if (GraphUtil.unproxify(monitorEnterNode.object()) == GraphUtil.unproxify(monitorExitNode.object())) {
/*
* We've coarsened the lock so use the same monitor id for the whole region,
* otherwise the monitor operations appear to be unrelated.
*/
MonitorIdNode enterId = monitorEnterNode.getMonitorId();
MonitorIdNode exitId = monitorExitNode.getMonitorId();
if (enterId != exitId) {
enterId.replaceAndDelete(exitId);
}
GraphUtil.removeFixedWithUnusedInputs(monitorEnterNode);
GraphUtil.removeFixedWithUnusedInputs(monitorExitNode);
}
}
}
}
Aggregations