Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java @ 9389:708aea0e5a25
Introduce proxy nodes for propagating profiling information.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 28 Apr 2013 18:38:48 +0200 |
parents | f1170c277b7b |
children | c76b43ed5089 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5369
diff
changeset
|
23 package com.oracle.graal.api.meta; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.io.*; |
9389
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
26 import java.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
8659
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
28 import com.oracle.graal.api.meta.ProfilingInfo.*; |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
29 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
31 * This profile object represents the type profile at a specific BCI. The precision of the supplied |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
32 * values may vary, but a runtime that provides this information should be aware that it will be |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
33 * used to guide performance-critical decisions like speculative inlining, etc. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 */ |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
35 public final class JavaTypeProfile implements Serializable { |
5321
12c63380e7ff
removed empty javadoc for generated serialVersionUID fields
Doug Simon <doug.simon@oracle.com>
parents:
4456
diff
changeset
|
36 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
37 private static final long serialVersionUID = -6877016333706838441L; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
38 |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
39 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
40 * A profiled type that has a probability. Profiled types are naturally sorted in descending |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
41 * order of their probabilities. |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
42 */ |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
43 public static final class ProfiledType implements Comparable<ProfiledType>, Serializable { |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
44 |
5346
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5335
diff
changeset
|
45 private static final long serialVersionUID = 7838575753661305744L; |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
46 |
9389
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
47 public static final ProfiledType[] EMPTY_ARRAY = new ProfiledType[0]; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
48 |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
49 private final ResolvedJavaType type; |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
50 private final double probability; |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4199
diff
changeset
|
51 |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
52 public ProfiledType(ResolvedJavaType type, double probability) { |
5369
2e9a5365dfb0
moved conversion of type profiles into hints for type check instructions from front end to lowering phase
Doug Simon <doug.simon@oracle.com>
parents:
5346
diff
changeset
|
53 assert type != null; |
2e9a5365dfb0
moved conversion of type profiles into hints for type check instructions from front end to lowering phase
Doug Simon <doug.simon@oracle.com>
parents:
5346
diff
changeset
|
54 assert probability >= 0.0D && probability <= 1.0D; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
55 this.type = type; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
56 this.probability = probability; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
57 } |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
58 |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
59 /** |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
60 * Returns the type for this profile entry. |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
61 */ |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
62 public ResolvedJavaType getType() { |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
63 return type; |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
64 } |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
65 |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
66 /** |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
67 * Returns the estimated probability of {@link #getType()}. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
68 * |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
69 * @return double value >= 0.0 and <= 1.0 |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
70 */ |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
71 public double getProbability() { |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
72 return probability; |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
73 } |
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
74 |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
75 @Override |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
76 public int compareTo(ProfiledType o) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
77 if (getProbability() > o.getProbability()) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
78 return -1; |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
79 } else if (getProbability() < o.getProbability()) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
80 return 1; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
81 } |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
82 return 0; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
83 } |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
84 |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
85 @Override |
9389
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
86 public int hashCode() { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
87 final int prime = 31; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
88 int result = 1; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
89 long temp; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
90 temp = Double.doubleToLongBits(probability); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
91 result = prime * result + (int) (temp ^ (temp >>> 32)); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
92 result = prime * result + type.hashCode(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
93 return result; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
94 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
95 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
96 @Override |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
97 public boolean equals(Object obj) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
98 if (this == obj) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
99 return true; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
100 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
101 if (obj == null) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
102 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
103 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
104 if (getClass() != obj.getClass()) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
105 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
106 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
107 ProfiledType other = (ProfiledType) obj; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
108 if (Double.doubleToLongBits(probability) != Double.doubleToLongBits(other.probability)) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
109 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
110 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
111 return type.equals(other.type); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
112 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
113 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
114 @Override |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
115 public String toString() { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
116 return "{" + type.getName() + ", " + probability + "}"; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
117 } |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4199
diff
changeset
|
118 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 |
8659
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
120 private final TriState nullSeen; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
121 private final double notRecordedProbability; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
122 private final ProfiledType[] ptypes; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
123 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
125 * Determines if an array of profiled types are sorted in descending order of their |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
126 * probabilities. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 */ |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
128 private static boolean isSorted(ProfiledType[] ptypes) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
129 for (int i = 1; i < ptypes.length; i++) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5541
diff
changeset
|
130 if (ptypes[i - 1].getProbability() < ptypes[i].getProbability()) { |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
131 return false; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
132 } |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
133 } |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
134 return true; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
135 } |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
136 |
8659
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
137 public JavaTypeProfile(TriState nullSeen, double notRecordedProbability, ProfiledType... ptypes) { |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
138 this.nullSeen = nullSeen; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
139 this.ptypes = ptypes; |
9389
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
140 assert notRecordedProbability != Double.NaN; |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
141 this.notRecordedProbability = notRecordedProbability; |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
142 assert isSorted(ptypes); |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4199
diff
changeset
|
143 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
146 * Returns the estimated probability of all types that could not be recorded due to profiling |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
147 * limitations. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
148 * |
4456
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
149 * @return double value >= 0.0 and <= 1.0 |
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
150 */ |
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
151 public double getNotRecordedProbability() { |
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
152 return notRecordedProbability; |
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
153 } |
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
154 |
f4c82dd4619e
inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4453
diff
changeset
|
155 /** |
8659
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
156 * Returns whether a null value was at the type check. |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
157 */ |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
158 public TriState getNullSeen() { |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
159 return nullSeen; |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
160 } |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
161 |
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
162 /** |
8909
06e08471949e
expanded type check hints to support use of negative hints (i.e., profiled types that failed the corresponding type check)
Doug Simon <doug.simon@oracle.com>
parents:
8659
diff
changeset
|
163 * A list of types for which the runtime has recorded probability information. Note that this |
06e08471949e
expanded type check hints to support use of negative hints (i.e., profiled types that failed the corresponding type check)
Doug Simon <doug.simon@oracle.com>
parents:
8659
diff
changeset
|
164 * includes both positive and negative types where a positive type is a subtype of the checked |
06e08471949e
expanded type check hints to support use of negative hints (i.e., profiled types that failed the corresponding type check)
Doug Simon <doug.simon@oracle.com>
parents:
8659
diff
changeset
|
165 * type and a negative type is not. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 */ |
5335
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
167 public ProfiledType[] getTypes() { |
439ca5ecc7dc
types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
168 return ptypes; |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4199
diff
changeset
|
169 } |
9366
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
170 |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
171 /** |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
172 * Searches for an entry of a given resolved Java type. |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
173 * |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
174 * @param type the type for which an entry should be searched |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
175 * @return the entry or null if no entry for this type can be found |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
176 */ |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
177 public ProfiledType findEntry(ResolvedJavaType type) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
178 if (ptypes != null) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
179 for (ProfiledType pt : ptypes) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
180 if (pt.getType() == type) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
181 return pt; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
182 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
183 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
184 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
185 return null; |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
186 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
187 |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
188 @Override |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
189 public String toString() { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
190 StringBuilder builder = new StringBuilder(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
191 builder.append("JavaTypeProfile["); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
192 builder.append(this.nullSeen); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
193 builder.append(", "); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
194 if (ptypes != null) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
195 for (ProfiledType pt : ptypes) { |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
196 builder.append(pt.toString()); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
197 builder.append(", "); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
198 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
199 } |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
200 builder.append(this.notRecordedProbability); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
201 builder.append("]"); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
202 return builder.toString(); |
f1170c277b7b
Implement instanceof after instanceof swapping.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8909
diff
changeset
|
203 } |
9389
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
204 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
205 public JavaTypeProfile restrict(JavaTypeProfile otherProfile) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
206 if (otherProfile.getNotRecordedProbability() > 0.0) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
207 // Not useful for restricting since there is an unknown set of types occuring. |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
208 return this; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
209 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
210 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
211 if (this.getNotRecordedProbability() > 0.0) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
212 // We are unrestricted, so the other profile is always a better estimate. |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
213 return otherProfile; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
214 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
215 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
216 ArrayList<ProfiledType> result = new ArrayList<>(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
217 for (int i = 0; i < getTypes().length; i++) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
218 ProfiledType ptype = getTypes()[i]; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
219 ResolvedJavaType type = ptype.getType(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
220 if (otherProfile.isIncluded(type)) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
221 result.add(ptype); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
222 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
223 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
224 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
225 TriState newNullSeen = (otherProfile.getNullSeen() == TriState.FALSE) ? TriState.FALSE : this.nullSeen; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
226 double newNotRecorded = this.notRecordedProbability; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
227 return createAdjustedProfile(result, newNullSeen, newNotRecorded); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
228 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
229 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
230 public boolean isIncluded(ResolvedJavaType type) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
231 if (this.getNotRecordedProbability() > 0.0) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
232 return true; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
233 } else { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
234 for (int i = 0; i < getTypes().length; i++) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
235 ProfiledType ptype = getTypes()[i]; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
236 ResolvedJavaType curType = ptype.getType(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
237 if (curType == type) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
238 return true; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
239 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
240 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
241 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
242 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
243 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
244 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
245 public JavaTypeProfile restrict(ResolvedJavaType declaredType, boolean nonNull) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
246 ArrayList<ProfiledType> result = new ArrayList<>(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
247 for (int i = 0; i < getTypes().length; i++) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
248 ProfiledType ptype = getTypes()[i]; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
249 ResolvedJavaType type = ptype.getType(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
250 if (declaredType.isAssignableFrom(type)) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
251 result.add(ptype); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
252 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
253 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
254 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
255 TriState newNullSeen = (nonNull) ? TriState.FALSE : this.nullSeen; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
256 double newNotRecorded = this.getNotRecordedProbability(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
257 // Assume for the types not recorded, the incompatibility rate is the same. |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
258 if (getTypes().length != 0) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
259 newNotRecorded *= ((double) result.size() / (double) getTypes().length); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
260 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
261 return createAdjustedProfile(result, newNullSeen, newNotRecorded); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
262 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
263 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
264 private JavaTypeProfile createAdjustedProfile(ArrayList<ProfiledType> result, TriState newNullSeen, double newNotRecorded) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
265 if (result.size() != this.getTypes().length || newNotRecorded != getNotRecordedProbability() || newNullSeen != this.nullSeen) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
266 if (result.size() == 0) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
267 return new JavaTypeProfile(newNullSeen, 1.0, ProfiledType.EMPTY_ARRAY); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
268 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
269 double probabilitySum = 0.0; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
270 for (int i = 0; i < result.size(); i++) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
271 probabilitySum += result.get(i).getProbability(); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
272 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
273 probabilitySum += newNotRecorded; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
274 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
275 double factor = 1.0 / probabilitySum; // Normalize to 1.0 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
276 assert factor > 1.0; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
277 ProfiledType[] newResult = new ProfiledType[result.size()]; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
278 for (int i = 0; i < newResult.length; ++i) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
279 ProfiledType curType = result.get(i); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
280 newResult[i] = new ProfiledType(curType.getType(), Math.min(1.0, curType.getProbability() * factor)); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
281 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
282 double newNotRecordedTypeProbability = Math.min(1.0, newNotRecorded * factor); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
283 return new JavaTypeProfile(newNullSeen, newNotRecordedTypeProbability, newResult); |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
284 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
285 return this; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
286 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
287 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
288 @Override |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
289 public boolean equals(Object other) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
290 if (other == this) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
291 return true; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
292 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
293 if (other instanceof JavaTypeProfile) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
294 JavaTypeProfile javaTypeProfile = (JavaTypeProfile) other; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
295 if (javaTypeProfile.nullSeen != nullSeen) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
296 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
297 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
298 if (javaTypeProfile.notRecordedProbability != notRecordedProbability) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
299 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
300 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
301 if (javaTypeProfile.ptypes.length != ptypes.length) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
302 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
303 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
304 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
305 for (int i = 0; i < ptypes.length; ++i) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
306 if (!ptypes[i].equals(javaTypeProfile.ptypes[i])) { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
307 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
308 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
309 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
310 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
311 return true; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
312 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
313 return false; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
314 } |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
315 |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
316 @Override |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
317 public int hashCode() { |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
318 return nullSeen.hashCode() + (int) Double.doubleToLongBits(notRecordedProbability) + ptypes.length * 13; |
708aea0e5a25
Introduce proxy nodes for propagating profiling information.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9366
diff
changeset
|
319 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 } |