< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/tutorial/StaticAnalysis.java
Print this page
*** 32,43 ****
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
- import org.graalvm.compiler.debug.DebugHandlersFactory;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeMap;
import org.graalvm.compiler.java.GraphBuilderPhase;
import org.graalvm.compiler.nodes.CallTargetNode.InvokeKind;
--- 32,43 ----
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.graalvm.compiler.debug.DebugContext;
+ import org.graalvm.compiler.debug.DebugHandlersFactory;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeMap;
import org.graalvm.compiler.java.GraphBuilderPhase;
import org.graalvm.compiler.nodes.CallTargetNode.InvokeKind;
*** 56,74 ****
import org.graalvm.compiler.nodes.java.LoadFieldNode;
import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
import org.graalvm.compiler.nodes.java.NewArrayNode;
import org.graalvm.compiler.nodes.java.NewInstanceNode;
import org.graalvm.compiler.nodes.java.StoreFieldNode;
! import org.graalvm.compiler.nodes.spi.StampProvider;
import org.graalvm.compiler.nodes.util.GraphUtil;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.graph.StatelessPostOrderNodeIterator;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
- import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
/**
--- 56,73 ----
import org.graalvm.compiler.nodes.java.LoadFieldNode;
import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
import org.graalvm.compiler.nodes.java.NewArrayNode;
import org.graalvm.compiler.nodes.java.NewInstanceNode;
import org.graalvm.compiler.nodes.java.StoreFieldNode;
! import org.graalvm.compiler.nodes.spi.CoreProviders;
import org.graalvm.compiler.nodes.util.GraphUtil;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.phases.OptimisticOptimizations;
import org.graalvm.compiler.phases.graph.StatelessPostOrderNodeIterator;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
/**
*** 87,108 ****
* list} of types assigned to the field; every Java method has {@link Results#lookupMethod one
* state} for each {@link MethodState#formalParameters parameter} as well as the
* {@link MethodState#formalReturn return value}.
*/
public class StaticAnalysis {
! /** Access to type, method, and fields using the Graal API. */
! private final MetaAccessProvider metaAccess;
! /** Access to platform dependent stamps. */
! private final StampProvider stampProvider;
! /** The results of the static analysis. */
private final Results results;
! /** Worklist for fixpoint iteration. */
private final Deque<WorklistEntry> worklist;
! public StaticAnalysis(MetaAccessProvider metaAccess, StampProvider stampProvider) {
! this.metaAccess = metaAccess;
! this.stampProvider = stampProvider;
this.results = new Results();
this.worklist = new ArrayDeque<>();
}
/**
--- 86,110 ----
* list} of types assigned to the field; every Java method has {@link Results#lookupMethod one
* state} for each {@link MethodState#formalParameters parameter} as well as the
* {@link MethodState#formalReturn return value}.
*/
public class StaticAnalysis {
! /**
! * Access to various builtin providers.
! */
! private final CoreProviders providers;
! /**
! * The results of the static analysis.
! */
private final Results results;
! /**
! * Worklist for fixpoint iteration.
! */
private final Deque<WorklistEntry> worklist;
! public StaticAnalysis(CoreProviders providers) {
! this.providers = providers;
this.results = new Results();
this.worklist = new ArrayDeque<>();
}
/**
*** 271,281 ****
* code before static analysis, the profiling information is empty and therefore
* wrong.
*/
OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
! GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(metaAccess, stampProvider, null, null, graphBuilderConfig, optimisticOpts, null);
graphBuilder.apply(graph);
} catch (Throwable ex) {
debug.handle(ex);
}
--- 273,283 ----
* code before static analysis, the profiling information is empty and therefore
* wrong.
*/
OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
! GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(providers, graphBuilderConfig, optimisticOpts, null);
graphBuilder.apply(graph);
} catch (Throwable ex) {
debug.handle(ex);
}
*** 302,312 ****
protected TypeFlow() {
types = new HashSet<>();
uses = new HashSet<>();
}
! /** Returns the types of this element. */
public Set<ResolvedJavaType> getTypes() {
return types;
}
/**
--- 304,316 ----
protected TypeFlow() {
types = new HashSet<>();
uses = new HashSet<>();
}
! /**
! * Returns the types of this element.
! */
public Set<ResolvedJavaType> getTypes() {
return types;
}
/**
*** 347,357 ****
* {@link InvokeKind#Interface interface} calls, the {@link TypeFlow#getTypes() types} of this
* node are the receiver types. When a new receiver type is added, a new callee might be added.
* Adding a new callee means linking the type flow of the actual parameters with the formal
* parameters of the callee, and linking the return value of the callee with the return value
* state of the invocation.
! *
* Statically bindable methods calls ({@link InvokeKind#Static static} and
* {@link InvokeKind#Special special} calls) have only one callee, but use the same code for
* simplicity.
*/
class InvokeTypeFlow extends TypeFlow {
--- 351,361 ----
* {@link InvokeKind#Interface interface} calls, the {@link TypeFlow#getTypes() types} of this
* node are the receiver types. When a new receiver type is added, a new callee might be added.
* Adding a new callee means linking the type flow of the actual parameters with the formal
* parameters of the callee, and linking the return value of the callee with the return value
* state of the invocation.
! * <p>
* Statically bindable methods calls ({@link InvokeKind#Static static} and
* {@link InvokeKind#Special special} calls) have only one callee, but use the same code for
* simplicity.
*/
class InvokeTypeFlow extends TypeFlow {
< prev index next >