use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class PEGraphDecoder method handleFloatingNodeBeforeAdd.
@Override
protected Node handleFloatingNodeBeforeAdd(MethodScope s, LoopScope loopScope, Node n) {
PEMethodScope methodScope = (PEMethodScope) s;
Node node = n;
if (node instanceof ParameterNode) {
ParameterNode param = (ParameterNode) node;
if (methodScope.isInlinedMethod()) {
throw GraalError.shouldNotReachHere("Parameter nodes are already registered when the inlined scope is created");
} else if (parameterPlugin != null) {
assert !methodScope.isInlinedMethod();
GraphBuilderContext graphBuilderContext = new PENonAppendGraphBuilderContext(methodScope, null);
Node result = parameterPlugin.interceptParameter(graphBuilderContext, param.index(), StampPair.create(param.stamp(NodeView.DEFAULT), param.uncheckedStamp()));
if (result != null) {
return result;
}
}
node = param.copyWithInputs();
}
return super.handleFloatingNodeBeforeAdd(methodScope, loopScope, node);
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class BlackholeDirectiveTest method checkLowTierGraph.
@Override
protected boolean checkLowTierGraph(StructuredGraph graph) {
BlackholeSnippet snippet = graph.method().getAnnotation(BlackholeSnippet.class);
ParameterNode arg = graph.getParameter(0);
if (snippet.expectParameterUsage()) {
Assert.assertNotNull("couldn't find ParameterNode(0)", arg);
Assert.assertFalse("expected usages of " + arg, arg.hasNoUsages());
} else {
Assert.assertTrue("expected no usages of ParameterNode", arg == null || arg.hasNoUsages());
}
return true;
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class BytecodeParser method checkPartialIntrinsicExit.
/**
* A partial intrinsic exits by (effectively) calling the intrinsified method. This call must
* use exactly the arguments to the call being intrinsified.
*
* @param originalArgs arguments of original call to intrinsified method
* @param recursiveArgs arguments of recursive call to intrinsified method
*/
private static boolean checkPartialIntrinsicExit(ValueNode[] originalArgs, ValueNode[] recursiveArgs) {
if (originalArgs != null) {
for (int i = 0; i < originalArgs.length; i++) {
ValueNode arg = GraphUtil.unproxify(recursiveArgs[i]);
ValueNode icArg = GraphUtil.unproxify(originalArgs[i]);
assert arg == icArg : String.format("argument %d of call denoting partial intrinsic exit should be %s, not %s", i, icArg, arg);
}
} else {
for (int i = 0; i < recursiveArgs.length; i++) {
ValueNode arg = GraphUtil.unproxify(recursiveArgs[i]);
assert arg instanceof ParameterNode && ((ParameterNode) arg).index() == i : String.format("argument %d of call denoting partial intrinsic exit should be a %s with index %d, not %s", i, ParameterNode.class.getSimpleName(), i, arg);
}
}
return true;
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class FrameStateBuilder method initializeForMethodStart.
public void initializeForMethodStart(Assumptions assumptions, boolean eagerResolve, Plugins plugins) {
int javaIndex = 0;
int index = 0;
ResolvedJavaMethod method = getMethod();
ResolvedJavaType originalType = method.getDeclaringClass();
if (!method.isStatic()) {
// add the receiver
FloatingNode receiver = null;
StampPair receiverStamp = null;
if (plugins != null) {
receiverStamp = plugins.getOverridingStamp(tool, originalType, true);
}
if (receiverStamp == null) {
receiverStamp = StampFactory.forDeclaredType(assumptions, originalType, true);
}
if (plugins != null) {
for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
receiver = plugin.interceptParameter(tool, index, receiverStamp);
if (receiver != null) {
break;
}
}
}
if (receiver == null) {
receiver = new ParameterNode(javaIndex, receiverStamp);
}
locals[javaIndex] = graph.addOrUniqueWithInputs(receiver);
javaIndex = 1;
index = 1;
}
Signature sig = method.getSignature();
int max = sig.getParameterCount(false);
ResolvedJavaType accessingClass = originalType;
for (int i = 0; i < max; i++) {
JavaType type = sig.getParameterType(i, accessingClass);
if (eagerResolve) {
type = type.resolve(accessingClass);
}
JavaKind kind = type.getJavaKind();
StampPair stamp = null;
if (plugins != null) {
stamp = plugins.getOverridingStamp(tool, type, false);
}
if (stamp == null) {
stamp = StampFactory.forDeclaredType(assumptions, type, false);
}
FloatingNode param = null;
if (plugins != null) {
for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
param = plugin.interceptParameter(tool, index, stamp);
if (param != null) {
break;
}
}
}
if (param == null) {
param = new ParameterNode(index, stamp);
}
locals[javaIndex] = graph.addOrUniqueWithInputs(param);
javaIndex++;
if (kind.needsTwoSlots()) {
locals[javaIndex] = TWO_SLOT_MARKER;
javaIndex++;
}
index++;
}
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class SpecialInvokeTypeFlow method linkCallee.
protected void linkCallee(BigBang bb, boolean isStatic, MethodFlowsGraph calleeFlows) {
// iterate over the actual parameters in caller context
for (int i = 0; i < actualParameters.length; i++) {
TypeFlow<?> actualParam = actualParameters[i];
// get the formal parameter from the specific clone
TypeFlow<?> formalParam = calleeFlows.getParameter(i);
/*
* The link between the receiver object and 'this' parameter of instance methods is a
* non-state-transfer link. The link only exists for a proper iteration of type flow
* graphs, but the state update of 'this' parameters is achieved through direct state
* update in VirtualInvokeTypeFlow.update and SpecialInvokeTypeFlow.update by calling
* FormalReceiverTypeFlow.addReceiverState. This happens because the formal receiver ,
* i.e., 'this' parameter, state must ONLY reflect those objects of the actual receiver
* that generated the context for the method clone which it belongs to. A direct link
* would instead transfer all the objects of compatible type from the actual receiver to
* the formal receiver.
*/
if (actualParam != null && formalParam != null) /* && (i != 0 || isStatic) */
{
// create the use link:
// (formalParam, callerContext) -> (actualParam, calleeContext)
// Note: the callerContext is an implicit property of the current InvokeTypeFlow
// clone
actualParam.addUse(bb, formalParam);
}
}
if (actualReturn != null) {
if (PointstoOptions.DivertParameterReturningMethod.getValue(bb.getOptions())) {
ParameterNode paramNode = calleeFlows.getMethod().getTypeFlow().getReturnedParameter();
if (paramNode != null) {
if (isStatic || paramNode.index() != 0) {
TypeFlow<?> actualParam = actualParameters[paramNode.index()];
actualParam.addUse(bb, actualReturn);
}
// else {
// receiver object state is transfered in updateReceiver()
// }
} else {
/*
* The callee may have a return type, hence the actualReturn is non-null, but it
* might throw an exception instead of returning, hence the formal return is
* null.
*/
if (calleeFlows.getResult() != null) {
calleeFlows.getResult().addUse(bb, actualReturn);
}
}
} else {
/*
* The callee may have a return type, hence the actualReturn is non-null, but it
* might throw an exception instead of returning, hence the formal return is null.
*/
if (calleeFlows.getResult() != null) {
calleeFlows.getResult().addUse(bb, actualReturn);
}
}
}
assert this.isClone() && originalInvoke != null;
calleeFlows.getMethod().registerAsImplementationInvoked(originalInvoke);
}
Aggregations