54 |
54 |
55 protected StructuredGraph testGraph(final String snippet) { |
55 protected StructuredGraph testGraph(final String snippet) { |
56 return testGraph(snippet, null); |
56 return testGraph(snippet, null); |
57 } |
57 } |
58 |
58 |
59 @SuppressWarnings("try") |
59 protected StructuredGraph testGraph(final String snippet, boolean assertInvoke) { |
|
60 return testGraph(snippet, null, assertInvoke); |
|
61 } |
|
62 |
60 protected StructuredGraph testGraph(final String snippet, String name) { |
63 protected StructuredGraph testGraph(final String snippet, String name) { |
61 return testGraph(getResolvedJavaMethod(snippet), name); |
64 return testGraph(snippet, name, false); |
62 } |
65 } |
63 |
66 |
64 @SuppressWarnings("try") |
67 @SuppressWarnings("try") |
65 protected StructuredGraph testGraph(final ResolvedJavaMethod method, String name) { |
68 protected StructuredGraph testGraph(final String snippet, String name, boolean assertInvoke) { |
|
69 return testGraph(getResolvedJavaMethod(snippet), name, assertInvoke); |
|
70 } |
|
71 |
|
72 @SuppressWarnings("try") |
|
73 protected StructuredGraph testGraph(final ResolvedJavaMethod method, String name, boolean assertInvoke) { |
66 DebugContext debug = getDebugContext(); |
74 DebugContext debug = getDebugContext(); |
67 try (DebugContext.Scope s = debug.scope("MethodSubstitutionTest", method)) { |
75 try (DebugContext.Scope s = debug.scope("MethodSubstitutionTest", method)) { |
68 StructuredGraph graph = parseEager(method, AllowAssumptions.YES, debug); |
76 StructuredGraph graph = parseEager(method, AllowAssumptions.YES, debug); |
69 HighTierContext context = getDefaultHighTierContext(); |
77 HighTierContext context = getDefaultHighTierContext(); |
70 debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph"); |
78 debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph"); |
84 for (Node node : graph.getNodes()) { |
92 for (Node node : graph.getNodes()) { |
85 if (node instanceof Invoke) { |
93 if (node instanceof Invoke) { |
86 Invoke invoke = (Invoke) node; |
94 Invoke invoke = (Invoke) node; |
87 if (invoke.callTarget() instanceof MethodCallTargetNode) { |
95 if (invoke.callTarget() instanceof MethodCallTargetNode) { |
88 MethodCallTargetNode call = (MethodCallTargetNode) invoke.callTarget(); |
96 MethodCallTargetNode call = (MethodCallTargetNode) invoke.callTarget(); |
89 assertTrue(!call.targetMethod().getName().equals(name), "Unexpected invoke of intrinsic %s", call.targetMethod()); |
97 boolean found = call.targetMethod().getName().equals(name); |
|
98 if (assertInvoke) { |
|
99 assertTrue(found, "Expected to find a call to %s", name); |
|
100 } else { |
|
101 assertFalse(found, "Unexpected call to %s", name); |
|
102 } |
90 } |
103 } |
91 } |
104 } |
92 |
105 |
93 } |
106 } |
94 } else { |
107 } else { |
95 assertNotInGraph(graph, Invoke.class); |
108 if (assertInvoke) { |
|
109 assertInGraph(graph, Invoke.class); |
|
110 } else { |
|
111 assertNotInGraph(graph, Invoke.class); |
|
112 } |
96 } |
113 } |
97 return graph; |
114 return graph; |
98 } catch (Throwable e) { |
115 } catch (Throwable e) { |
99 throw debug.handle(e); |
116 throw debug.handle(e); |
100 } |
117 } |