use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class MonitorGraphTest method parseAndProcess.
private StructuredGraph parseAndProcess(String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
ParameterNode param = graph.getNodes(ParameterNode.TYPE).first();
if (param != null) {
ConstantNode constant = ConstantNode.forInt(0, graph);
for (Node n : param.usages().snapshot()) {
if (!(n instanceof FrameState)) {
n.replaceFirstInput(param, constant);
}
}
}
Map<Invoke, Double> hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
return graph;
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class TypeFlowGraphBuilder method checkFormalParameterBuilder.
/**
* Check if the formal parameter is a parameter of one of the wait/notify/hashCode methods. If
* so add it as a sink since it must be retained. Don't need to check the position of the
* parameter, since each of the checked methods has at most one object parameter.
*/
public void checkFormalParameterBuilder(TypeFlowBuilder<?> paramBuilder) {
AnalysisMethod method = (AnalysisMethod) ((ParameterNode) paramBuilder.getSource()).graph().method();
String methodFormat = method.format("%H.%n(%P)");
for (String specialMethodFormat : waitNotifyHashCodeMethods) {
if (methodFormat.equals(specialMethodFormat)) {
dataFlowSinkBuilders.add(paramBuilder);
}
}
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class CEntryPointCallStubMethod method adaptParameterTypes.
private EnumInfo[] adaptParameterTypes(HostedProviders providers, NativeLibraries nativeLibraries, HostedGraphKit kit, JavaType[] parameterTypes, JavaType[] parameterLoadTypes, Purpose purpose) {
EnumInfo[] parameterEnumInfos = null;
for (int i = 0; i < parameterTypes.length; i++) {
if (!parameterTypes[i].getJavaKind().isPrimitive() && !providers.getWordTypes().isWord(parameterTypes[i])) {
ElementInfo typeInfo = nativeLibraries.findElementInfo(parameterTypes[i]);
if (typeInfo instanceof EnumInfo) {
UserError.guarantee(typeInfo.getChildren().stream().anyMatch(EnumLookupInfo.class::isInstance), "Enum class " + parameterTypes[i].toJavaName() + " needs a method that is annotated with @" + CEnumLookup.class + " because it is used as a parameter of an entry point method: " + targetMethod.format("%H.%n(%p)"));
if (parameterEnumInfos == null) {
parameterEnumInfos = new EnumInfo[parameterTypes.length];
}
parameterEnumInfos[i] = (EnumInfo) typeInfo;
parameterLoadTypes[i] = providers.getMetaAccess().lookupJavaType(cEnumParameterKind.toJavaClass());
final int parameterIndex = i;
FrameState initialState = kit.getGraph().start().stateAfter();
Iterator<ValueNode> matchingNodes = initialState.values().filter(node -> ((ParameterNode) node).index() == parameterIndex).iterator();
ValueNode parameterNode = matchingNodes.next();
assert !matchingNodes.hasNext() && parameterNode.usages().filter(n -> n != initialState).isEmpty();
parameterNode.setStamp(StampFactory.forKind(cEnumParameterKind));
} else if (purpose != Purpose.ANALYSIS) {
// for analysis test cases: abort only during compilation
throw UserError.abort("Entry point method parameter types are restricted to primitive types, word types and enumerations (@" + CEnum.class.getSimpleName() + "): " + targetMethod.format("%H.%n(%p)"));
}
}
}
return parameterEnumInfos;
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class CompileQueue method ensureCompiled.
protected void ensureCompiled(HostedMethod method, CompileReason reason) {
CompileTask task = new CompileTask(method, reason);
CompileTask oldTask = compilations.putIfAbsent(method, task);
if (oldTask != null) {
// Method is already scheduled for compilation.
if (oldTask.allReasons != null) {
oldTask.allReasons.add(reason);
}
return;
}
if (method.compilationInfo.specializedArguments != null) {
// Do the specialization: replace the argument locals with the constant arguments.
StructuredGraph graph = method.compilationInfo.graph;
int idx = 0;
for (ConstantNode argument : method.compilationInfo.specializedArguments) {
ParameterNode local = graph.getParameter(idx++);
if (local != null) {
local.replaceAndDelete(ConstantNode.forConstant(argument.asJavaConstant(), runtimeConfig.getProviders().getMetaAccess(), graph));
}
}
}
executor.execute(task);
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class InliningUtilities method isTrivialMethod.
public static boolean isTrivialMethod(StructuredGraph graph) {
int numInvokes = 0;
int numOthers = 0;
for (Node n : graph.getNodes()) {
if (n instanceof StartNode || n instanceof ParameterNode || n instanceof FullInfopointNode || n instanceof ValueProxy || n instanceof AssertValueNode) {
continue;
}
if (n instanceof MethodCallTargetNode) {
numInvokes++;
} else {
numOthers++;
}
if (!shouldBeTrivial(numInvokes, numOthers, graph)) {
return false;
}
}
return true;
}
Aggregations