package org.graalvm.compiler.java;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext;
import org.graalvm.compiler.nodes.spi.CoreProviders;
import org.graalvm.compiler.phases.BasePhase;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.tiers.HighTierContext;
import jdk.vm.ci.meta.ResolvedJavaMethod;
public class GraphBuilderPhase extends BasePhase<HighTierContext> {
private final GraphBuilderConfiguration graphBuilderConfig;
public GraphBuilderPhase(GraphBuilderConfiguration config) {
this.graphBuilderConfig = config;
}
@Override
public boolean checkContract() {
return false;
}
@Override
protected void run(StructuredGraph graph, HighTierContext context) {
new Instance(context, graphBuilderConfig, context.getOptimisticOptimizations(), null).run(graph);
}
public GraphBuilderConfiguration getGraphBuilderConfig() {
return graphBuilderConfig;
}
public static class Instance extends org.graalvm.compiler.phases.Phase {
protected final CoreProviders providers;
protected final GraphBuilderConfiguration graphBuilderConfig;
protected final OptimisticOptimizations optimisticOpts;
private final IntrinsicContext initialIntrinsicContext;
public Instance(CoreProviders providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
this.graphBuilderConfig = graphBuilderConfig;
this.optimisticOpts = optimisticOpts;
this.providers = providers;
this.initialIntrinsicContext = initialIntrinsicContext;
}
@Override
public boolean checkContract() {
return false;
}
@Override
protected void run(StructuredGraph graph) {
createBytecodeParser(graph, null, graph.method(), graph.getEntryBCI(), initialIntrinsicContext).buildRootMethod();
}
protected BytecodeParser createBytecodeParser(StructuredGraph graph, BytecodeParser parent, ResolvedJavaMethod method, int entryBCI, IntrinsicContext intrinsicContext) {
return new BytecodeParser(this, graph, parent, method, entryBCI, intrinsicContext);
}
}
}