Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.code/src/com/oracle/jvmci/code/TypeCheckHints.java @ 21730:b9f9b8af17ff
Simplify interface to reference map
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 19:57:38 -0700 |
parents | 48c1ebd24120 |
children |
rev | line source |
---|---|
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:
diff
changeset
|
1 /* |
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:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
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:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
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:
diff
changeset
|
4 * |
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:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
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:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
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:
diff
changeset
|
7 * published by the Free Software Foundation. |
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:
diff
changeset
|
8 * |
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:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
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:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
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:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
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:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
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:
diff
changeset
|
13 * accompanied this code). |
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:
diff
changeset
|
14 * |
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:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
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:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
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:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
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:
diff
changeset
|
18 * |
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:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
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:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
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:
diff
changeset
|
21 * questions. |
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:
diff
changeset
|
22 */ |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19796
diff
changeset
|
23 package com.oracle.jvmci.code; |
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:
diff
changeset
|
24 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19796
diff
changeset
|
25 import com.oracle.jvmci.meta.JavaTypeProfile; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19796
diff
changeset
|
26 import com.oracle.jvmci.meta.ResolvedJavaType; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19796
diff
changeset
|
27 import com.oracle.jvmci.meta.Assumptions; |
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:
diff
changeset
|
28 import java.util.*; |
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:
diff
changeset
|
29 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19796
diff
changeset
|
30 import com.oracle.jvmci.meta.Assumptions.AssumptionResult; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
19796
diff
changeset
|
31 import com.oracle.jvmci.meta.JavaTypeProfile.ProfiledType; |
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:
diff
changeset
|
32 |
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:
diff
changeset
|
33 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7097
diff
changeset
|
34 * Utility for deriving hint types for a type check instruction (e.g. checkcast or instanceof) based |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7097
diff
changeset
|
35 * on the target type of the check and any profiling information available for the instruction. |
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:
diff
changeset
|
36 */ |
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:
diff
changeset
|
37 public class TypeCheckHints { |
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:
diff
changeset
|
38 |
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:
8660
diff
changeset
|
39 /** |
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:
8660
diff
changeset
|
40 * A receiver type profiled in a type check instruction. |
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:
8660
diff
changeset
|
41 */ |
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:
8660
diff
changeset
|
42 public static class Hint { |
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:
8660
diff
changeset
|
43 |
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:
8660
diff
changeset
|
44 /** |
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:
8660
diff
changeset
|
45 * A type seen while profiling a type check instruction. |
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:
8660
diff
changeset
|
46 */ |
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:
8660
diff
changeset
|
47 public final ResolvedJavaType type; |
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:
8660
diff
changeset
|
48 |
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:
8660
diff
changeset
|
49 /** |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
50 * Specifies if {@link #type} is a sub-type of the checked type. |
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:
8660
diff
changeset
|
51 */ |
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:
8660
diff
changeset
|
52 public final boolean positive; |
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:
8660
diff
changeset
|
53 |
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:
8660
diff
changeset
|
54 Hint(ResolvedJavaType type, boolean positive) { |
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:
8660
diff
changeset
|
55 this.type = type; |
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:
8660
diff
changeset
|
56 this.positive = positive; |
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:
8660
diff
changeset
|
57 } |
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:
8660
diff
changeset
|
58 } |
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:
8660
diff
changeset
|
59 |
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:
8660
diff
changeset
|
60 private static final Hint[] NO_HINTS = {}; |
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:
diff
changeset
|
61 |
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:
diff
changeset
|
62 /** |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
63 * If non-null, then this is the only type that could pass the type check because the target of |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
64 * the type check is a final class or has been speculated to be a final class and this value is |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
65 * the only concrete subclass of the target type. |
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:
diff
changeset
|
66 */ |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
67 public final ResolvedJavaType exact; |
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:
diff
changeset
|
68 |
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:
diff
changeset
|
69 /** |
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:
diff
changeset
|
70 * The most likely types that the type check instruction will see. |
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:
diff
changeset
|
71 */ |
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:
8660
diff
changeset
|
72 public final Hint[] hints; |
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:
diff
changeset
|
73 |
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:
diff
changeset
|
74 /** |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
75 * The profile from which this information was derived. |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
76 */ |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
77 public final JavaTypeProfile profile; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
78 |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
79 /** |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
80 * The total probability that the type check will hit one of the types in {@link #hints}. |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
81 */ |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
82 public final double hintHitProbability; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
83 |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
84 /** |
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:
diff
changeset
|
85 * Derives hint information for use when generating the code for a type check instruction. |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
86 * |
8952
ef450d176a20
fixed bug in transformation of a type check profile into type check hints
Doug Simon <doug.simon@oracle.com>
parents:
8909
diff
changeset
|
87 * @param targetType the target type of the type check |
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:
diff
changeset
|
88 * @param profile the profiling information available for the instruction (if any) |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7097
diff
changeset
|
89 * @param assumptions the object in which speculations are recorded. This is null if |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7097
diff
changeset
|
90 * speculations are not supported. |
8659
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
91 * @param minHintHitProbability if the probability that the type check will hit one of the |
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:
8660
diff
changeset
|
92 * profiled types (up to {@code maxHints}) is below this value, then {@link #hints} |
8659
bc7bb895e359
incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
93 * will be null |
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:
8660
diff
changeset
|
94 * @param maxHints the maximum length of {@link #hints} |
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:
diff
changeset
|
95 */ |
8952
ef450d176a20
fixed bug in transformation of a type check profile into type check hints
Doug Simon <doug.simon@oracle.com>
parents:
8909
diff
changeset
|
96 public TypeCheckHints(ResolvedJavaType targetType, JavaTypeProfile profile, Assumptions assumptions, double minHintHitProbability, int maxHints) { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
97 this.profile = profile; |
8952
ef450d176a20
fixed bug in transformation of a type check profile into type check hints
Doug Simon <doug.simon@oracle.com>
parents:
8909
diff
changeset
|
98 if (targetType != null && !canHaveSubtype(targetType)) { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
99 exact = targetType; |
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:
diff
changeset
|
100 } else { |
19795
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19306
diff
changeset
|
101 if (assumptions != null) { |
19796
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
102 AssumptionResult<ResolvedJavaType> leafConcreteSubtype = targetType == null ? null : targetType.findLeafConcreteSubtype(); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
103 if (leafConcreteSubtype != null) { |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
104 assumptions.record(leafConcreteSubtype); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19795
diff
changeset
|
105 exact = leafConcreteSubtype.getResult(); |
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:
diff
changeset
|
106 } else { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
107 exact = null; |
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:
diff
changeset
|
108 } |
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:
diff
changeset
|
109 } else { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
110 exact = null; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
111 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
112 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
113 Double[] hitProbability = {null}; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
114 this.hints = makeHints(targetType, profile, minHintHitProbability, maxHints, hitProbability); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
115 this.hintHitProbability = hitProbability[0]; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
116 } |
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:
diff
changeset
|
117 |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
118 private static Hint[] makeHints(ResolvedJavaType targetType, JavaTypeProfile profile, double minHintHitProbability, int maxHints, Double[] hitProbability) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
119 double hitProb = 0.0d; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
120 Hint[] hintsBuf = NO_HINTS; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
121 if (profile != null) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
122 double notRecordedTypes = profile.getNotRecordedProbability(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
123 ProfiledType[] ptypes = profile.getTypes(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
124 if (notRecordedTypes < (1D - minHintHitProbability) && ptypes != null && ptypes.length > 0) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
125 hintsBuf = new Hint[ptypes.length]; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
126 int hintCount = 0; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
127 for (ProfiledType ptype : ptypes) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
128 if (targetType != null) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
129 ResolvedJavaType hintType = ptype.getType(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
130 hintsBuf[hintCount++] = new Hint(hintType, targetType.isAssignableFrom(hintType)); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
131 hitProb += ptype.getProbability(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
132 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
133 if (hintCount == maxHints) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
134 break; |
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:
diff
changeset
|
135 } |
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:
diff
changeset
|
136 } |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
137 if (hitProb >= minHintHitProbability) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
138 if (hintsBuf.length != hintCount || hintCount > maxHints) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
139 hintsBuf = Arrays.copyOf(hintsBuf, Math.min(maxHints, hintCount)); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
140 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
141 } else { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
142 hintsBuf = NO_HINTS; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
143 hitProb = 0.0d; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
144 } |
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:
diff
changeset
|
145 } |
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:
diff
changeset
|
146 } |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
147 hitProbability[0] = hitProb; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
8952
diff
changeset
|
148 return hintsBuf; |
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:
diff
changeset
|
149 } |
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:
diff
changeset
|
150 |
6717
5bbe9618118e
clarified the specification of ResolvedJavaType.getModifiers() to indicate the similarity to Class.getModifiers() and fixed the current usages and the HotSpot implementation to accommodate the spec change
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
151 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7097
diff
changeset
|
152 * Determines if a given type can have subtypes other than itself. This analysis is purely |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7097
diff
changeset
|
153 * static; no assumptions are made. |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
154 * |
8660
d47b52b0ff68
fixed discrepancy between a method's name and its semantics
Doug Simon <doug.simon@oracle.com>
parents:
8659
diff
changeset
|
155 * @return true if {@code type} can have subtypes |
6717
5bbe9618118e
clarified the specification of ResolvedJavaType.getModifiers() to indicate the similarity to Class.getModifiers() and fixed the current usages and the HotSpot implementation to accommodate the spec change
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
156 */ |
7087
4c0d132dca4d
made HotSpotResolvedObjectType.findUniqueConcreteSubtype() more conservative for array types to fix issue with frequent invalidation of Graal compiled methods
Doug Simon <doug.simon@oracle.com>
parents:
7081
diff
changeset
|
157 public static boolean canHaveSubtype(ResolvedJavaType type) { |
16476
92f75d104b4b
moved getElementalType() from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
158 return !type.getElementalType().isFinal(); |
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:
diff
changeset
|
159 } |
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:
diff
changeset
|
160 } |