comparison graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/StaticAnalysis.java @ 19073:94e88f0d8eef

Small fixes for Graal tutorial classes
author Christian Wimmer <christian.wimmer@oracle.com>
date Mon, 02 Feb 2015 17:21:33 -0800
parents 75da87c96605
children 7227f5671c87
comparison
equal deleted inserted replaced
19072:deb2467530e4 19073:94e88f0d8eef
73 this.worklist = new ArrayDeque<>(); 73 this.worklist = new ArrayDeque<>();
74 } 74 }
75 75
76 /** 76 /**
77 * Adds a root method to the static analysis. The method must be static and must not have any 77 * Adds a root method to the static analysis. The method must be static and must not have any
78 * parameters, because the possible types of the parametes would not be known. 78 * parameters, because the possible types of the parameters would not be known.
79 */ 79 */
80 public void addMethod(ResolvedJavaMethod method) { 80 public void addMethod(ResolvedJavaMethod method) {
81 if (!method.isStatic() || method.getSignature().getParameterCount(false) > 0) { 81 if (!method.isStatic() || method.getSignature().getParameterCount(false) > 0) {
82 error("Entry point method is not static or has parameters: " + method.format("%H.%n(%p)")); 82 error("Entry point method is not static or has parameters: " + method.format("%H.%n(%p)"));
83 } 83 }
220 * We want all types to be resolved by the graph builder, i.e., we want classes 220 * We want all types to be resolved by the graph builder, i.e., we want classes
221 * referenced by the bytecodes to be loaded and initialized. Since we do not run 221 * referenced by the bytecodes to be loaded and initialized. Since we do not run
222 * the code before static analysis, the classes would otherwise be not loaded 222 * the code before static analysis, the classes would otherwise be not loaded
223 * yet and the bytecode parser would only create a graph. 223 * yet and the bytecode parser would only create a graph.
224 */ 224 */
225 GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getEagerDefault().withOmitAllExceptionEdges(true); 225 GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getEagerDefault();
226 /* 226 /*
227 * For simplicity, we ignore all exception handling during the static analysis. 227 * For simplicity, we ignore all exception handling during the static analysis.
228 * This is a constraint of this example code, a real static analysis needs to 228 * This is a constraint of this example code, a real static analysis needs to
229 * handle the Graal nodes for throwing and handling exceptions. 229 * handle the Graal nodes for throwing and handling exceptions.
230 */ 230 */
309 309
310 /** 310 /**
311 * The active element for method invocations. For {@link InvokeKind#Virtual virtual} and 311 * The active element for method invocations. For {@link InvokeKind#Virtual virtual} and
312 * {@link InvokeKind#Interface interface} calls, the {@link TypeFlow#getTypes() types} of this 312 * {@link InvokeKind#Interface interface} calls, the {@link TypeFlow#getTypes() types} of this
313 * node are the receiver types. When a new receiver type is added, a new callee might be added. 313 * node are the receiver types. When a new receiver type is added, a new callee might be added.
314 * Adding a new callee means liking the type flow of the actual parameters with the formal 314 * Adding a new callee means linking the type flow of the actual parameters with the formal
315 * parameters of the callee, and linking the return value of the callee with the return value 315 * parameters of the callee, and linking the return value of the callee with the return value
316 * state of the invocation. 316 * state of the invocation.
317 * 317 *
318 * Statically bindable methods calls ({@link InvokeKind#Static static} and 318 * Statically bindable methods calls ({@link InvokeKind#Static static} and
319 * {@link InvokeKind#Special special} calls) have only one callee, but use the same code for 319 * {@link InvokeKind#Special special} calls) have only one callee, but use the same code for
320 * simplicity. 320 * simplicity.
321 */ 321 */
322
323 class InvokeTypeFlow extends TypeFlow { 322 class InvokeTypeFlow extends TypeFlow {
324 private final MethodCallTargetNode callTarget; 323 private final MethodCallTargetNode callTarget;
325 private final TypeFlow[] actualParameters; 324 private final TypeFlow[] actualParameters;
326 private final TypeFlow actualReturn; 325 private final TypeFlow actualReturn;
327 private final Set<ResolvedJavaMethod> callees; 326 private final Set<ResolvedJavaMethod> callees;