Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java @ 13771:8576dbd00554
Merge
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Mon, 27 Jan 2014 15:28:50 -0800 |
parents | af344056124f |
children | 86ec7f6f71b3 |
rev | line source |
---|---|
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
4 * |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
8 * |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
14 * |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
18 * |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
22 */ |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler.test; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
24 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
25 import java.io.*; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
26 import java.lang.reflect.*; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
27 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
28 import org.junit.*; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
29 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.api.meta.ProfilingInfo.TriState; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
32 |
13270
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
33 /** |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
34 * Tests profiling information provided by the runtime. |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
35 * <p> |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
36 * NOTE: These tests are actually not very robust. The problem is that only partial profiling |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
37 * information may be gathered for any given method. For example, HotSpot's advanced compilation |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
38 * policy can decide to only gather partial profiles in a first level compilation (see |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
39 * AdvancedThresholdPolicy::common(...) in advancedThresholdPolicy.cpp). Because of this, |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
40 * occasionally tests for {@link ProfilingInfo#getNullSeen(int)} can fail since HotSpot only set's |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
41 * the null_seen bit when doing full profiling. |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
42 */ |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
43 public class ProfilingInfoTest extends GraalCompilerTest { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
44 |
13270
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
45 private static final int N = 10; |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
46 private static final double DELTA = 1d / Integer.MAX_VALUE; |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
47 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
48 @Test |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
49 public void testBranchTakenProbability() { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
50 ProfilingInfo info = profile("branchProbabilitySnippet", 0); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
51 Assert.assertEquals(0.0, info.getBranchTakenProbability(1), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
52 Assert.assertEquals(N, info.getExecutionCount(1)); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
53 Assert.assertEquals(-1.0, info.getBranchTakenProbability(8), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
54 Assert.assertEquals(0, info.getExecutionCount(8)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
55 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
56 info = profile("branchProbabilitySnippet", 1); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
57 Assert.assertEquals(1.0, info.getBranchTakenProbability(1), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
58 Assert.assertEquals(N, info.getExecutionCount(1)); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
59 Assert.assertEquals(0.0, info.getBranchTakenProbability(8), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
60 Assert.assertEquals(N, info.getExecutionCount(8)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
61 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
62 info = profile("branchProbabilitySnippet", 2); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
63 Assert.assertEquals(1.0, info.getBranchTakenProbability(1), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
64 Assert.assertEquals(N, info.getExecutionCount(1)); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
65 Assert.assertEquals(1.0, info.getBranchTakenProbability(8), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
66 Assert.assertEquals(N, info.getExecutionCount(8)); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
67 |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
68 continueProfiling(3 * N, "branchProbabilitySnippet", 0); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
69 Assert.assertEquals(0.25, info.getBranchTakenProbability(1), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
70 Assert.assertEquals(4 * N, info.getExecutionCount(1)); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
71 Assert.assertEquals(1.0, info.getBranchTakenProbability(8), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
72 Assert.assertEquals(N, info.getExecutionCount(8)); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
73 |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
74 resetProfile("branchProbabilitySnippet"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
75 Assert.assertEquals(-1.0, info.getBranchTakenProbability(1), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
76 Assert.assertEquals(0, info.getExecutionCount(1)); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
77 Assert.assertEquals(-1.0, info.getBranchTakenProbability(8), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
78 Assert.assertEquals(0, info.getExecutionCount(8)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
79 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
80 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
81 public static int branchProbabilitySnippet(int value) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
82 if (value == 0) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
83 return -1; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
84 } else if (value == 1) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
85 return -2; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
86 } else { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
87 return -3; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
88 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
89 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
90 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
91 @Test |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
92 public void testSwitchProbabilities() { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
93 ProfilingInfo info = profile("switchProbabilitySnippet", 0); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
94 Assert.assertArrayEquals(new double[]{1.0, 0.0, 0.0}, info.getSwitchProbabilities(1), DELTA); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
95 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
96 info = profile("switchProbabilitySnippet", 1); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
97 Assert.assertArrayEquals(new double[]{0.0, 1.0, 0.0}, info.getSwitchProbabilities(1), DELTA); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
98 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
99 info = profile("switchProbabilitySnippet", 2); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
100 Assert.assertArrayEquals(new double[]{0.0, 0.0, 1.0}, info.getSwitchProbabilities(1), DELTA); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
101 |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
102 resetProfile("switchProbabilitySnippet"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
103 Assert.assertNull(info.getSwitchProbabilities(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
104 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
105 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
106 public static int switchProbabilitySnippet(int value) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
107 switch (value) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
108 case 0: |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
109 return -1; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
110 case 1: |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
111 return -2; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
112 default: |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
113 return -3; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
114 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
115 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
116 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
117 @Test |
9763
4a8b9117327a
Removed MethodProfile testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
118 public void testProfileInvokeVirtual() { |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
119 testTypeProfile("invokeVirtualSnippet", 1); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
120 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
121 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
122 public static int invokeVirtualSnippet(Object obj) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
123 return obj.hashCode(); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
124 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
125 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
126 @Test |
9763
4a8b9117327a
Removed MethodProfile testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
127 public void testTypeProfileInvokeInterface() { |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
128 testTypeProfile("invokeInterfaceSnippet", 1); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
129 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
130 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
131 public static int invokeInterfaceSnippet(CharSequence a) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
132 return a.length(); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
133 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
134 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
135 @Test |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
136 public void testTypeProfileCheckCast() { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
137 testTypeProfile("checkCastSnippet", 1); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
138 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
139 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
140 public static Serializable checkCastSnippet(Object obj) { |
9926
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
141 try { |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
142 return (Serializable) obj; |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
143 } catch (ClassCastException e) { |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
144 return null; |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
145 } |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
146 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
147 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
148 @Test |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
149 public void testTypeProfileInstanceOf() { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
150 testTypeProfile("instanceOfSnippet", 1); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
151 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
152 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
153 public static boolean instanceOfSnippet(Object obj) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
154 return obj instanceof Serializable; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
155 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
156 |
9760
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8624
diff
changeset
|
157 private void testTypeProfile(String testSnippet, int bci) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
9926
diff
changeset
|
158 ResolvedJavaType stringType = getMetaAccess().lookupJavaType(String.class); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
9926
diff
changeset
|
159 ResolvedJavaType stringBuilderType = getMetaAccess().lookupJavaType(StringBuilder.class); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
160 |
9760
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8624
diff
changeset
|
161 ProfilingInfo info = profile(testSnippet, "ABC"); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
162 JavaTypeProfile typeProfile = info.getTypeProfile(bci); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
163 Assert.assertEquals(0.0, typeProfile.getNotRecordedProbability(), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
164 Assert.assertEquals(1, typeProfile.getTypes().length); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
165 Assert.assertEquals(stringType, typeProfile.getTypes()[0].getType()); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
166 Assert.assertEquals(1.0, typeProfile.getTypes()[0].getProbability(), DELTA); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
167 |
9760
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8624
diff
changeset
|
168 continueProfiling(testSnippet, new StringBuilder()); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
169 typeProfile = info.getTypeProfile(bci); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
170 Assert.assertEquals(0.0, typeProfile.getNotRecordedProbability(), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
171 Assert.assertEquals(2, typeProfile.getTypes().length); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
172 Assert.assertEquals(stringType, typeProfile.getTypes()[0].getType()); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
173 Assert.assertEquals(stringBuilderType, typeProfile.getTypes()[1].getType()); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
174 Assert.assertEquals(0.5, typeProfile.getTypes()[0].getProbability(), DELTA); |
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
175 Assert.assertEquals(0.5, typeProfile.getTypes()[1].getProbability(), DELTA); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
176 |
9760
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8624
diff
changeset
|
177 resetProfile(testSnippet); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
178 typeProfile = info.getTypeProfile(bci); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
179 Assert.assertNull(typeProfile); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
180 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
181 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
182 @Test |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
183 public void testExceptionSeen() { |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
184 // NullPointerException |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
185 ProfilingInfo info = profile("nullPointerExceptionSnippet", 5); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
186 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
187 |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
188 info = profile("nullPointerExceptionSnippet", (Object) null); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
189 Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
190 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
191 resetProfile("nullPointerExceptionSnippet"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
192 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
193 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
194 // ArrayOutOfBoundsException |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
195 info = profile("arrayIndexOutOfBoundsExceptionSnippet", new int[1]); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
196 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(2)); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
197 |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
198 info = profile("arrayIndexOutOfBoundsExceptionSnippet", new int[0]); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
199 Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(2)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
200 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
201 resetProfile("arrayIndexOutOfBoundsExceptionSnippet"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
202 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(2)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
203 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
204 // CheckCastException |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
205 info = profile("checkCastExceptionSnippet", "ABC"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
206 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
207 |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
208 info = profile("checkCastExceptionSnippet", 5); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
209 Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
210 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
211 resetProfile("checkCastExceptionSnippet"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
212 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
213 |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
214 // Invoke with exception |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
215 info = profile("invokeWithExceptionSnippet", false); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
216 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
217 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
218 info = profile("invokeWithExceptionSnippet", true); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
219 Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
220 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
221 resetProfile("invokeWithExceptionSnippet"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
222 Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
223 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
224 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
225 public static int nullPointerExceptionSnippet(Object obj) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
226 try { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
227 return obj.hashCode(); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
228 } catch (NullPointerException e) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
229 return 1; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
230 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
231 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
232 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
233 public static int arrayIndexOutOfBoundsExceptionSnippet(int[] array) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
234 try { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
235 return array[0]; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
236 } catch (ArrayIndexOutOfBoundsException e) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
237 return 1; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
238 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
239 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
240 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
241 public static int checkCastExceptionSnippet(Object obj) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
242 try { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
243 return ((String) obj).length(); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
244 } catch (ClassCastException e) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
245 return 1; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
246 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
247 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
248 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
249 public static int invokeWithExceptionSnippet(boolean doThrow) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
250 try { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
251 return throwException(doThrow); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
252 } catch (IllegalArgumentException e) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
253 return 1; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
254 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
255 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
256 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
257 private static int throwException(boolean doThrow) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
258 if (doThrow) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
259 throw new IllegalArgumentException(); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
260 } else { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
261 return 1; |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
262 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
263 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
264 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
265 @Test |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
266 public void testNullSeen() { |
9926
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
267 testNullSeen("instanceOfSnippet"); |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
268 testNullSeen("checkCastSnippet"); |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
269 } |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
270 |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
271 private void testNullSeen(String snippet) { |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
272 ProfilingInfo info = profile(snippet, 1); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
273 Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
274 |
9926
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
275 continueProfiling(snippet, "ABC"); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
276 Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
277 |
9926
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
278 continueProfiling(snippet, new Object()); |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
279 Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
280 |
13270
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
281 if (TriState.TRUE == info.getNullSeen(1)) { |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
282 // See the javadoc comment for ProfilingInfoTest. |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
283 continueProfiling(snippet, (Object) null); |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
284 Assert.assertEquals(TriState.TRUE, info.getNullSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
285 |
13270
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
286 continueProfiling(snippet, 0.0); |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
287 Assert.assertEquals(TriState.TRUE, info.getNullSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
288 |
13270
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
289 continueProfiling(snippet, new Object()); |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
290 Assert.assertEquals(TriState.TRUE, info.getNullSeen(1)); |
d86dc1b84973
modified ProfilingInfoTest to better handle variability in profiling info provided by the runtime
Doug Simon <doug.simon@oracle.com>
parents:
11959
diff
changeset
|
291 } |
9926
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
292 |
fe9a97ee352b
Added more profiling information testcases.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9763
diff
changeset
|
293 resetProfile(snippet); |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
294 Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
295 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
296 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
297 private ProfilingInfo profile(String methodName, Object... args) { |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
298 return profile(true, N, methodName, args); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
299 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
300 |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
301 private void continueProfiling(String methodName, Object... args) { |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
302 profile(false, N, methodName, args); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
303 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
304 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
305 private void continueProfiling(int executions, String methodName, Object... args) { |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
306 profile(false, executions, methodName, args); |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
307 } |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
308 |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
309 private ProfilingInfo profile(boolean resetProfile, int executions, String methodName, Object... args) { |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
310 Method method = getMethod(methodName); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
311 Assert.assertTrue(Modifier.isStatic(method.getModifiers())); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
312 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
9926
diff
changeset
|
313 ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
314 if (resetProfile) { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
315 javaMethod.reprofile(); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
316 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
317 |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
318 for (int i = 0; i < executions; ++i) { |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
319 try { |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
320 method.invoke(null, args); |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
321 } catch (Throwable e) { |
8624
7c00d66b81bb
added JUnit 4.11 support to ProfilingInfoTest
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8612
diff
changeset
|
322 Assert.fail("method should not throw an exception: " + e.toString()); |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
323 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
324 } |
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
325 |
13769
af344056124f
Only use mature method datas
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13270
diff
changeset
|
326 ProfilingInfo info = javaMethod.getProfilingInfo(); |
af344056124f
Only use mature method datas
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13270
diff
changeset
|
327 // The execution counts are low so force maturity |
af344056124f
Only use mature method datas
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13270
diff
changeset
|
328 info.setMature(); |
af344056124f
Only use mature method datas
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13270
diff
changeset
|
329 return info; |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
330 } |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
331 |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
332 private void resetProfile(String methodName) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
9926
diff
changeset
|
333 ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(getMethod(methodName)); |
8612
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
334 javaMethod.reprofile(); |
02ef91b94656
finished ProfilingInfo testcases
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8611
diff
changeset
|
335 } |
8611
6c4db417385a
added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents:
diff
changeset
|
336 } |