comparison graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java @ 9763:4a8b9117327a

Removed MethodProfile testcases.
author Christian Haeubl <haeubl@ssw.jku.at>
date Fri, 17 May 2013 17:34:48 +0200
parents c76b43ed5089
children fe9a97ee352b
comparison
equal deleted inserted replaced
9762:57e5211846f9 9763:4a8b9117327a
103 return -3; 103 return -3;
104 } 104 }
105 } 105 }
106 106
107 @Test 107 @Test
108 public void testProfileInvokeVirtual() throws NoSuchMethodException { 108 public void testProfileInvokeVirtual() {
109 testTypeProfile("invokeVirtualSnippet", 1); 109 testTypeProfile("invokeVirtualSnippet", 1);
110 testMethodProfile("invokeVirtualSnippet", 1, "hashCode");
111 } 110 }
112 111
113 public static int invokeVirtualSnippet(Object obj) { 112 public static int invokeVirtualSnippet(Object obj) {
114 return obj.hashCode(); 113 return obj.hashCode();
115 } 114 }
116 115
117 @Test 116 @Test
118 public void testTypeProfileInvokeInterface() throws NoSuchMethodException { 117 public void testTypeProfileInvokeInterface() {
119 testTypeProfile("invokeInterfaceSnippet", 1); 118 testTypeProfile("invokeInterfaceSnippet", 1);
120 testMethodProfile("invokeInterfaceSnippet", 1, "length");
121 } 119 }
122 120
123 public static int invokeInterfaceSnippet(CharSequence a) { 121 public static int invokeInterfaceSnippet(CharSequence a) {
124 return a.length(); 122 return a.length();
125 } 123 }
165 resetProfile(testSnippet); 163 resetProfile(testSnippet);
166 typeProfile = info.getTypeProfile(bci); 164 typeProfile = info.getTypeProfile(bci);
167 Assert.assertNull(typeProfile); 165 Assert.assertNull(typeProfile);
168 } 166 }
169 167
170 private void testMethodProfile(String testSnippet, int bci, String expectedProfiledMethod) throws NoSuchMethodException {
171 ResolvedJavaMethod stringMethod = runtime.lookupJavaMethod(String.class.getMethod(expectedProfiledMethod));
172 ResolvedJavaMethod stringBuilderMethod = runtime.lookupJavaMethod(StringBuilder.class.getMethod(expectedProfiledMethod));
173
174 ProfilingInfo info = profile(testSnippet, "ABC");
175 JavaMethodProfile methodProfile = info.getMethodProfile(bci);
176 Assert.assertEquals(0.0, methodProfile.getNotRecordedProbability(), DELTA);
177 Assert.assertEquals(1, methodProfile.getMethods().length);
178 Assert.assertEquals(stringMethod, methodProfile.getMethods()[0].getMethod());
179 Assert.assertEquals(1.0, methodProfile.getMethods()[0].getProbability(), DELTA);
180
181 continueProfiling(testSnippet, new StringBuilder());
182 methodProfile = info.getMethodProfile(bci);
183 Assert.assertEquals(0.0, methodProfile.getNotRecordedProbability(), DELTA);
184 Assert.assertEquals(2, methodProfile.getMethods().length);
185 Assert.assertEquals(stringMethod, methodProfile.getMethods()[0].getMethod());
186 Assert.assertEquals(stringBuilderMethod, methodProfile.getMethods()[1].getMethod());
187 Assert.assertEquals(0.5, methodProfile.getMethods()[0].getProbability(), DELTA);
188 Assert.assertEquals(0.5, methodProfile.getMethods()[1].getProbability(), DELTA);
189
190 resetProfile(testSnippet);
191 methodProfile = info.getMethodProfile(bci);
192 Assert.assertNull(methodProfile);
193 }
194
195 @Test 168 @Test
196 public void testExceptionSeen() { 169 public void testExceptionSeen() {
197 // NullPointerException 170 // NullPointerException
198 ProfilingInfo info = profile("nullPointerExceptionSnippet", 5); 171 ProfilingInfo info = profile("nullPointerExceptionSnippet", 5);
199 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); 172 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1));