use of org.graalvm.compiler.nodes.spi.SnippetParameterInfo in project graal by oracle.
the class EncodedSnippets method getSnippetParameterInfo.
public SnippetParameterInfo getSnippetParameterInfo(ResolvedJavaMethod method) {
GraphData data = null;
if (graphDatas != null) {
data = graphDatas.get(methodKey(method));
}
assert data != null : method + " " + methodKey(method);
SnippetParameterInfo info = data.info;
assert info != null;
return info;
}
use of org.graalvm.compiler.nodes.spi.SnippetParameterInfo in project graal by oracle.
the class SnippetStub method getGraph.
@Override
@SuppressWarnings("try")
protected StructuredGraph getGraph(DebugContext debug, CompilationIdentifier compilationId) {
// Stubs cannot have optimistic assumptions since they have
// to be valid for the entire run of the VM.
SnippetParameterInfo info = providers.getReplacements().getSnippetParameterInfo(method);
final StructuredGraph graph = buildInitialGraph(debug, compilationId, makeConstArgs(info), SnippetParameterInfo.getNonNullParameters(info));
try (DebugContext.Scope outer = debug.scope("SnippetStub", graph)) {
for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
int index = param.index();
if (info.isNonNullParameter(index)) {
param.setStamp(param.stamp(NodeView.DEFAULT).join(StampFactory.objectNonNull()));
}
}
graph.setGuardsStage(GuardsStage.FLOATING_GUARDS);
CanonicalizerPhase canonicalizer = CanonicalizerPhase.create();
canonicalizer.apply(graph, providers);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, providers);
} catch (Throwable e) {
throw debug.handle(e);
}
return graph;
}
use of org.graalvm.compiler.nodes.spi.SnippetParameterInfo in project graal by oracle.
the class SymbolicSnippetEncoder method registerSnippet.
synchronized void registerSnippet(ResolvedJavaMethod method, ResolvedJavaMethod original, Object receiver, boolean trackNodeSourcePosition) {
if (HotSpotReplacementsImpl.snippetsAreEncoded()) {
throw new GraalError("Snippet encoding has already been done");
}
assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName();
SnippetKey key = new SnippetKey(method, original, receiver);
findSnippetMethod(method);
if (!pendingSnippetGraphs.containsKey(key)) {
if (original != null) {
originalMethods.put(key.keyString(), methodKey(original));
}
SnippetParameterInfo info = new SnippetParameterInfo(method);
snippetParameterInfos.put(key.keyString(), info);
int i = 0;
int offset = 0;
if (!method.isStatic()) {
assert info.isConstantParameter(0) : "receiver is always constant";
ensureSnippetTypeAvailable(method.getDeclaringClass());
i++;
offset = 1;
}
for (; i < info.getParameterCount(); i++) {
if (info.isConstantParameter(i) || info.isVarargsParameter(i)) {
JavaType type = method.getSignature().getParameterType(i - offset, method.getDeclaringClass());
if (type instanceof ResolvedJavaType) {
ResolvedJavaType resolvedJavaType = (ResolvedJavaType) type;
if (info.isVarargsParameter(i)) {
resolvedJavaType = resolvedJavaType.getElementalType();
}
assert resolvedJavaType.isPrimitive() || isGraalClass(resolvedJavaType) : method + ": only Graal classes can be @ConstantParameter or @VarargsParameter: " + type;
ensureSnippetTypeAvailable(resolvedJavaType);
} else {
throw new InternalError(type.toString());
}
}
}
pendingSnippetGraphs.put(key, new BiFunction<>() {
@Override
public StructuredGraph apply(OptionValues cmopileOptions, HotSpotSnippetReplacementsImpl snippetReplacements) {
return buildGraph(method, original, receiver, SnippetParameterInfo.getNonNullParameters(info), trackNodeSourcePosition, cmopileOptions, snippetReplacements);
}
});
}
}
Aggregations