use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class BytecodeParser method genPutStatic.
protected void genPutStatic(JavaField field) {
ValueNode value = frameState.pop(field.getJavaKind());
ResolvedJavaField resolvedField = resolveStaticFieldAccess(field, value);
if (resolvedField == null) {
return;
}
if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
graph.recordField(resolvedField);
}
ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedField.getDeclaringClass())) {
FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
classInitializationPlugin.apply(this, resolvedField.getDeclaringClass(), stateBefore);
}
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleStoreStaticField(this, resolvedField, value)) {
return;
}
}
genStoreField(null, resolvedField, value);
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class FrameStateBuilder method create.
/**
* @param pushedValues if non-null, values to {@link #push(JavaKind, ValueNode)} to the stack
* before creating the {@link FrameState}
*/
public FrameState create(int bci, BytecodeParser parent, boolean duringCall, JavaKind[] pushedSlotKinds, ValueNode[] pushedValues) {
if (outerFrameState == null && parent != null) {
assert !parent.parsingIntrinsic() : "must already have the next non-intrinsic ancestor";
outerFrameState = parent.getFrameStateBuilder().create(parent.bci(), parent.getNonIntrinsicAncestor(), true, null, null);
}
if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI && parent != null) {
FrameState newFrameState = outerFrameState.duplicateModified(outerFrameState.bci, true, false, JavaKind.Void, new JavaKind[] { JavaKind.Object }, new ValueNode[] { stack[0] });
return newFrameState;
}
if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) {
throw shouldNotReachHere();
}
if (pushedValues != null) {
assert pushedSlotKinds.length == pushedValues.length;
int stackSizeToRestore = stackSize;
for (int i = 0; i < pushedValues.length; i++) {
push(pushedSlotKinds[i], pushedValues[i]);
}
FrameState res = graph.add(new FrameState(outerFrameState, code, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, duringCall));
stackSize = stackSizeToRestore;
return res;
} else {
if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI) {
assert outerFrameState == null;
clearLocals();
}
return graph.add(new FrameState(outerFrameState, code, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, duringCall));
}
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class SubstrateIntrinsicGraphBuilder method setStateAfter.
@Override
public void setStateAfter(StateSplit sideEffect) {
List<ValueNode> values = new ArrayList<>(Arrays.asList(arguments));
int stackSize = 0;
if (returnValue != null) {
values.add(returnValue);
stackSize++;
if (method.getSignature().getReturnKind().needsTwoSlots()) {
values.add(null);
stackSize++;
}
}
FrameState stateAfter = getGraph().add(new FrameState(null, code, bci, values, arguments.length, stackSize, false, false, null, null));
sideEffect.setStateAfter(stateAfter);
bci++;
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class CallTreePrinter method sourceReference.
private static SourceReference[] sourceReference(InvokeTypeFlow invoke) {
List<SourceReference> sourceReference = new ArrayList<>();
FrameState state = invoke.getSource().invoke().stateAfter();
while (state != null) {
if (state.getCode() != null) {
sourceReference.add(new SourceReference(state.bci, state.getCode().asStackTraceElement(state.bci)));
} else {
sourceReference.add(UNKNOWN_SOURCE_REFERENCE);
}
state = state.outerFrameState();
}
return sourceReference.toArray(new SourceReference[sourceReference.size()]);
}
use of org.graalvm.compiler.nodes.FrameState in project graal by oracle.
the class GraphUtil method approxSourceStackTraceElement.
/**
* Gets an approximate source code location for frame state.
*
* @return the StackTraceElements if an approximate source location is found, null otherwise
*/
public static StackTraceElement[] approxSourceStackTraceElement(FrameState frameState) {
ArrayList<StackTraceElement> elements = new ArrayList<>();
FrameState state = frameState;
while (state != null) {
Bytecode code = state.getCode();
if (code != null) {
elements.add(code.asStackTraceElement(state.bci - 1));
}
state = state.outerFrameState();
}
return elements.toArray(new StackTraceElement[0]);
}
Aggregations