use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class BytecodeParser method genNewInstance.
void genNewInstance(JavaType type) {
if (!(type instanceof ResolvedJavaType)) {
handleUnresolvedNewInstance(type);
return;
}
ResolvedJavaType resolvedType = (ResolvedJavaType) type;
ClassInitializationPlugin classInitializationPlugin = graphBuilderConfig.getPlugins().getClassInitializationPlugin();
if (!resolvedType.isInitialized() && classInitializationPlugin == null) {
handleUnresolvedNewInstance(type);
return;
}
ResolvedJavaType[] skippedExceptionTypes = this.graphBuilderConfig.getSkippedExceptionTypes();
if (skippedExceptionTypes != null) {
for (ResolvedJavaType exceptionType : skippedExceptionTypes) {
if (exceptionType.isAssignableFrom(resolvedType)) {
append(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, RuntimeConstraint));
return;
}
}
}
if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedType)) {
FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
classInitializationPlugin.apply(this, resolvedType, stateBefore);
}
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleNewInstance(this, resolvedType)) {
return;
}
}
frameState.push(JavaKind.Object, append(createNewInstance(resolvedType, true)));
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class DebugInfoBuilder method build.
public LIRFrameState build(FrameState topState, LabelRef exceptionEdge) {
assert virtualObjects.size() == 0;
assert objectStates.size() == 0;
assert pendingVirtualObjects.size() == 0;
// collect all VirtualObjectField instances:
FrameState current = topState;
do {
if (current.virtualObjectMappingCount() > 0) {
for (EscapeObjectState state : current.virtualObjectMappings()) {
if (!objectStates.containsKey(state.object())) {
if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) {
objectStates.put(state.object(), state);
}
}
}
}
current = current.outerFrameState();
} while (current != null);
BytecodeFrame frame = computeFrameForState(topState);
VirtualObject[] virtualObjectsArray = null;
if (virtualObjects.size() != 0) {
// fill in the VirtualObject values
VirtualObjectNode vobjNode;
while ((vobjNode = pendingVirtualObjects.poll()) != null) {
VirtualObject vobjValue = virtualObjects.get(vobjNode);
assert vobjValue.getValues() == null;
JavaValue[] values;
JavaKind[] slotKinds;
int entryCount = vobjNode.entryCount();
if (entryCount == 0) {
values = NO_JAVA_VALUES;
slotKinds = NO_JAVA_KINDS;
} else {
values = new JavaValue[entryCount];
slotKinds = new JavaKind[entryCount];
}
if (values.length > 0) {
VirtualObjectState currentField = (VirtualObjectState) objectStates.get(vobjNode);
assert currentField != null;
int pos = 0;
for (int i = 0; i < entryCount; i++) {
ValueNode value = currentField.values().get(i);
if (value == null) {
JavaKind entryKind = vobjNode.entryKind(i);
values[pos] = JavaConstant.defaultForKind(entryKind.getStackKind());
slotKinds[pos] = entryKind.getStackKind();
pos++;
} else if (!value.isConstant() || value.asJavaConstant().getJavaKind() != JavaKind.Illegal) {
values[pos] = toJavaValue(value);
slotKinds[pos] = toSlotKind(value);
pos++;
} else {
assert value.getStackKind() == JavaKind.Illegal;
ValueNode previousValue = currentField.values().get(i - 1);
assert (previousValue != null && previousValue.getStackKind().needsTwoSlots()) : vobjNode + " " + i + " " + previousValue + " " + currentField.values().snapshot();
if (previousValue == null || !previousValue.getStackKind().needsTwoSlots()) {
// Don't allow the IllegalConstant to leak into the debug info
JavaKind entryKind = vobjNode.entryKind(i);
values[pos] = JavaConstant.defaultForKind(entryKind.getStackKind());
slotKinds[pos] = entryKind.getStackKind();
pos++;
}
}
}
if (pos != entryCount) {
values = Arrays.copyOf(values, pos);
slotKinds = Arrays.copyOf(slotKinds, pos);
}
}
assert checkValues(vobjValue.getType(), values, slotKinds);
vobjValue.setValues(values, slotKinds);
}
virtualObjectsArray = new VirtualObject[virtualObjects.size()];
int index = 0;
for (VirtualObject value : virtualObjects.getValues()) {
virtualObjectsArray[index++] = value;
}
virtualObjects.clear();
}
objectStates.clear();
return newLIRFrameState(exceptionEdge, frame, virtualObjectsArray);
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class IntrinsicGraphBuilder method setStateAfter.
@Override
public void setStateAfter(StateSplit sideEffect) {
assert sideEffect.hasSideEffect();
FrameState stateAfter = getGraph().add(new FrameState(BytecodeFrame.BEFORE_BCI));
sideEffect.setStateAfter(stateAfter);
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class PEGraphDecoder method ensureOuterStateDecoded.
protected void ensureOuterStateDecoded(PEMethodScope methodScope) {
if (methodScope.outerState == null && methodScope.caller != null) {
FrameState stateAtReturn = methodScope.invokeData.invoke.stateAfter();
if (stateAtReturn == null) {
stateAtReturn = (FrameState) decodeFloatingNode(methodScope.caller, methodScope.callerLoopScope, methodScope.invokeData.stateAfterOrderId);
}
JavaKind invokeReturnKind = methodScope.invokeData.invoke.asNode().getStackKind();
FrameState outerState = stateAtReturn.duplicateModified(graph, methodScope.invokeData.invoke.bci(), stateAtReturn.rethrowException(), true, invokeReturnKind, null, null);
/*
* When the encoded graph has methods inlining, we can already have a proper caller
* state. If not, we set the caller state here.
*/
if (outerState.outerFrameState() == null && methodScope.caller != null) {
ensureOuterStateDecoded(methodScope.caller);
outerState.setOuterFrameState(methodScope.caller.outerState);
}
methodScope.outerState = outerState;
}
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class GraphOrder method visitForward.
private static void visitForward(ArrayList<Node> nodes, NodeBitMap visited, Node node, boolean floatingOnly) {
try {
assert node == null || node.isAlive() : node + " not alive";
if (node != null && !visited.isMarked(node)) {
if (floatingOnly && node instanceof FixedNode) {
throw new GraalError("unexpected reference to fixed node: %s (this indicates an unexpected cycle)", node);
}
visited.mark(node);
FrameState stateAfter = null;
if (node instanceof StateSplit) {
stateAfter = ((StateSplit) node).stateAfter();
}
for (Node input : node.inputs()) {
if (input != stateAfter) {
visitForward(nodes, visited, input, true);
}
}
if (node instanceof EndNode) {
EndNode end = (EndNode) node;
for (PhiNode phi : end.merge().phis()) {
visitForward(nodes, visited, phi.valueAt(end), true);
}
}
nodes.add(node);
if (node instanceof AbstractMergeNode) {
for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
visited.mark(phi);
nodes.add(phi);
}
}
if (stateAfter != null) {
visitForward(nodes, visited, stateAfter, true);
}
}
} catch (GraalError e) {
throw GraalGraphError.transformAndAddContext(e, node);
}
}
Aggregations