Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java @ 10069:abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 17 Jun 2013 17:55:19 +0200 |
parents | 0b30da13d86b |
children | e04f128d719c |
rev | line source |
---|---|
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
23 package com.oracle.graal.hotspot.replacements; |
7034
89df4e71940a
More flexible handling of stamp for word type: Define a singleton Stamp instance for words that is then re-written to the target-specific primitive word stamp by the WordTypeRewriterPhase. This allows nodes to have a word stamp without any dependency on global or static state.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6954
diff
changeset
|
24 |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
25 import static com.oracle.graal.api.code.DeoptimizationAction.*; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
9513
659bb6cf930c
rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents:
9318
diff
changeset
|
28 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
29 import static com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9793
diff
changeset
|
30 import static com.oracle.graal.phases.GraalOptions.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
31 import static com.oracle.graal.replacements.nodes.BranchProbabilityNode.*; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.api.code.*; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.api.meta.*; |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
35 import com.oracle.graal.api.meta.ProfilingInfo.TriState; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.hotspot.meta.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
37 import com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.Hints; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.*; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.graal.nodes.java.*; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.graal.nodes.spi.*; |
7034
89df4e71940a
More flexible handling of stamp for word type: Define a singleton Stamp instance for words that is then re-written to the target-specific primitive word stamp by the WordTypeRewriterPhase. This allows nodes to have a word stamp without any dependency on global or static state.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6954
diff
changeset
|
41 import com.oracle.graal.nodes.type.*; |
10016
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
42 import com.oracle.graal.phases.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
43 import com.oracle.graal.replacements.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
44 import com.oracle.graal.replacements.Snippet.ConstantParameter; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
45 import com.oracle.graal.replacements.Snippet.VarargsParameter; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
46 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
47 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
48 import com.oracle.graal.replacements.nodes.*; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7278
diff
changeset
|
49 import com.oracle.graal.word.*; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
52 * Snippets used for implementing the type test of an instanceof instruction. Since instanceof is a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
53 * floating node, it is lowered separately for each of its usages. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
54 * |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
55 * The type tests implemented are described in the paper <a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
56 * href="http://dl.acm.org/citation.cfm?id=583821"> Fast subtype checking in the HotSpot JVM</a> by |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
57 * Cliff Click and John Rose. |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 */ |
8413
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
7868
diff
changeset
|
59 public class InstanceOfSnippets implements Snippets { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 /** |
10069
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
62 * Gets the minimum required probability of a profiled instanceof hitting one the profiled types |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
63 * for use of the {@linkplain #instanceofWithProfile deoptimizing} snippet. The value is |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
64 * computed to be an order of magnitude greater than the configured compilation threshold. For |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
65 * example, if a method is compiled after being interpreted 10000 times, the deoptimizing |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
66 * snippet will only be used for an instanceof if its profile indicates that less than 1 in |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
67 * 100000 executions are for an object whose type is not one of the top N profiled types (where |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
68 * {@code N == } {@link GraalOptions#InstanceOfMaxHints}). |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
69 */ |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
70 public static double hintHitProbabilityThresholdForDeoptimizingSnippet() { |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
71 return 1.0D - (1.0D / (graalRuntime().getConfig().compileThreshold * 10)); |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
72 } |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
73 |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
74 /** |
10016
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
75 * A test against a set of hints derived from a profile with very close to 100% precise coverage |
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
76 * of seen types. This snippet deoptimizes on hint miss paths. |
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
77 * |
10069
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
78 * @see #hintHitProbabilityThresholdForDeoptimizingSnippet() |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
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:
9864
diff
changeset
|
80 @Snippet |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
81 public static Object instanceofWithProfile(Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue, |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
82 @ConstantParameter boolean checkNull, @ConstantParameter boolean nullSeen) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
83 if (probability(NOT_FREQUENT_PROBABILITY, checkNull && object == null)) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
84 isNull.inc(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
85 if (!nullSeen) { |
10016
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
86 // In this case, the execution is contradicting the profile |
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
87 // so invalidating and re-profiling is justified. |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
88 DeoptimizeNode.deopt(InvalidateReprofile, OptimizedTypeCheckViolated); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
89 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
90 return falseValue; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
91 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
92 Word objectHub = loadHub(object); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
93 // if we get an exact match: succeed immediately |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
94 ExplodeLoopNode.explodeLoop(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
95 for (int i = 0; i < hints.length; i++) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
96 Word hintHub = hints[i]; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
97 boolean positive = hintIsPositive[i]; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
98 if (probability(NOT_FREQUENT_PROBABILITY, hintHub.equal(objectHub))) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
99 hintsHit.inc(); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
100 return positive ? trueValue : falseValue; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
101 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
102 } |
10016
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
103 // Don't throw away the code as we assume this is a rare event |
7709bb831916
adjusted threshold at which the deoptimizing instanceof snippet is used and change the deoptimization action to None to reflect that fact it is a rare event but does not warrant reprofiling
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
104 // that will periodically occur. |
10042
0b30da13d86b
fixed bug in InstanceOfSnippets - deoptimization action should be None for instanceofWithProfile snippet
Doug Simon <doug.simon@oracle.com>
parents:
10016
diff
changeset
|
105 DeoptimizeNode.deopt(DeoptimizationAction.None, OptimizedTypeCheckViolated); |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
106 return falseValue; |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
107 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
108 |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
109 /** |
6652
efcf6cd16a2f
renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents:
6648
diff
changeset
|
110 * A test against a final type. |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 */ |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
113 public static Object instanceofExact(Object object, Word exactHub, Object trueValue, Object falseValue, @ConstantParameter boolean checkNull) { |
9318
dc04c7e8f714
Add javadoc to BranchProbabilityNode.probability node intrinsic. Avoid combined conditions in connection with the probability.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9316
diff
changeset
|
114 if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 isNull.inc(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 return falseValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 } |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6670
diff
changeset
|
118 Word objectHub = loadHub(object); |
9316
5e1465ec46d6
Change the way branch probabilities are injected. Update all snippets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9015
diff
changeset
|
119 if (probability(LIKELY_PROBABILITY, objectHub.notEqual(exactHub))) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 exactMiss.inc(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 return falseValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 exactHit.inc(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 return trueValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 /** |
6652
efcf6cd16a2f
renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents:
6648
diff
changeset
|
128 * A test against a primary type. |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 */ |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
131 public static Object instanceofPrimary(Word hub, Object object, @ConstantParameter int superCheckOffset, Object trueValue, Object falseValue, @ConstantParameter boolean checkNull) { |
9318
dc04c7e8f714
Add javadoc to BranchProbabilityNode.probability node intrinsic. Avoid combined conditions in connection with the probability.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9316
diff
changeset
|
132 if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 isNull.inc(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 return falseValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 } |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6670
diff
changeset
|
136 Word objectHub = loadHub(object); |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9513
diff
changeset
|
137 if (probability(NOT_LIKELY_PROBABILITY, objectHub.readWord(superCheckOffset, LocationIdentity.FINAL_LOCATION).notEqual(hub))) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 displayMiss.inc(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 return falseValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 displayHit.inc(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 return trueValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 /** |
6652
efcf6cd16a2f
renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents:
6648
diff
changeset
|
146 * A test against a restricted secondary type type. |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 */ |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
149 public static Object instanceofSecondary(Word hub, Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue, |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
150 @ConstantParameter boolean checkNull) { |
9318
dc04c7e8f714
Add javadoc to BranchProbabilityNode.probability node intrinsic. Avoid combined conditions in connection with the probability.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9316
diff
changeset
|
151 if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 isNull.inc(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 return falseValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 } |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6670
diff
changeset
|
155 Word objectHub = loadHub(object); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 // if we get an exact match: succeed immediately |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 ExplodeLoopNode.explodeLoop(); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 for (int i = 0; i < hints.length; i++) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6670
diff
changeset
|
159 Word hintHub = hints[i]; |
8953
b47759136478
making use of negative types in the type check profile associated with an instanceof
Doug Simon <doug.simon@oracle.com>
parents:
8909
diff
changeset
|
160 boolean positive = hintIsPositive[i]; |
9316
5e1465ec46d6
Change the way branch probabilities are injected. Update all snippets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9015
diff
changeset
|
161 if (probability(NOT_FREQUENT_PROBABILITY, hintHub.equal(objectHub))) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 hintsHit.inc(); |
8953
b47759136478
making use of negative types in the type check profile associated with an instanceof
Doug Simon <doug.simon@oracle.com>
parents:
8909
diff
changeset
|
163 return positive ? trueValue : falseValue; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 if (!checkSecondarySubType(hub, objectHub)) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 return falseValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 return trueValue; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
172 /** |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
173 * Type test used when the type being tested against is not known at compile time. |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
174 */ |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
175 @Snippet |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
176 public static Object instanceofDynamic(Class mirror, Object object, Object trueValue, Object falseValue, @ConstantParameter boolean checkNull) { |
9318
dc04c7e8f714
Add javadoc to BranchProbabilityNode.probability node intrinsic. Avoid combined conditions in connection with the probability.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9316
diff
changeset
|
177 if (checkNull && probability(NOT_FREQUENT_PROBABILITY, object == null)) { |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
178 isNull.inc(); |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
179 return falseValue; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
180 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
181 |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
182 Word hub = loadWordFromObject(mirror, klassOffset()); |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
183 Word objectHub = loadHub(object); |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
184 if (!checkUnknownSubType(hub, objectHub)) { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
185 return falseValue; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
186 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
187 return trueValue; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
188 } |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
189 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
190 public static class Templates extends InstanceOfSnippetsTemplates { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
192 private final SnippetInfo instanceofWithProfile = snippet(InstanceOfSnippets.class, "instanceofWithProfile"); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
193 private final SnippetInfo instanceofExact = snippet(InstanceOfSnippets.class, "instanceofExact"); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
194 private final SnippetInfo instanceofPrimary = snippet(InstanceOfSnippets.class, "instanceofPrimary"); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
195 private final SnippetInfo instanceofSecondary = snippet(InstanceOfSnippets.class, "instanceofSecondary"); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
196 private final SnippetInfo instanceofDynamic = snippet(InstanceOfSnippets.class, "instanceofDynamic"); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8415
diff
changeset
|
198 public Templates(CodeCacheProvider runtime, Replacements replacements, TargetDescription target) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
199 super(runtime, replacements, target); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
6662
diff
changeset
|
202 @Override |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
203 protected Arguments makeArguments(InstanceOfUsageReplacer replacer, LoweringTool tool) { |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
204 if (replacer.instanceOf instanceof InstanceOfNode) { |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
205 InstanceOfNode instanceOf = (InstanceOfNode) replacer.instanceOf; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
206 ValueNode object = instanceOf.object(); |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9793
diff
changeset
|
207 TypeCheckHints hintInfo = new TypeCheckHints(instanceOf.type(), instanceOf.profile(), tool.assumptions(), InstanceOfMinHintHitProbability.getValue(), InstanceOfMaxHints.getValue()); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
208 final HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) instanceOf.type(); |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
209 ConstantNode hub = ConstantNode.forConstant(type.klass(), runtime, instanceOf.graph()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
210 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
211 Arguments args; |
10069
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
212 |
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
213 if (hintInfo.hintHitProbability >= hintHitProbabilityThresholdForDeoptimizingSnippet()) { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
214 Hints hints = createHints(hintInfo, runtime, false, hub.graph()); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
215 args = new Arguments(instanceofWithProfile); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
216 args.add("object", object); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
217 args.addVarargs("hints", Word.class, StampFactory.forKind(wordKind()), hints.hubs); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
218 args.addVarargs("hintIsPositive", boolean.class, StampFactory.forKind(Kind.Boolean), hints.isPositive); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
219 } else if (hintInfo.exact != null) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
220 args = new Arguments(instanceofExact); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
221 args.add("object", object); |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
222 args.add("exactHub", ConstantNode.forConstant(((HotSpotResolvedObjectType) hintInfo.exact).klass(), runtime, hub.graph())); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
223 } else if (type.isPrimaryType()) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
224 args = new Arguments(instanceofPrimary); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
225 args.add("hub", hub); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
226 args.add("object", object); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
227 args.addConst("superCheckOffset", type.superCheckOffset()); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
228 } else { |
8953
b47759136478
making use of negative types in the type check profile associated with an instanceof
Doug Simon <doug.simon@oracle.com>
parents:
8909
diff
changeset
|
229 Hints hints = createHints(hintInfo, runtime, false, hub.graph()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
230 args = new Arguments(instanceofSecondary); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
231 args.add("hub", hub); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
232 args.add("object", object); |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9513
diff
changeset
|
233 args.addVarargs("hints", Word.class, StampFactory.forKind(getWordKind()), hints.hubs); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
234 args.addVarargs("hintIsPositive", boolean.class, StampFactory.forKind(Kind.Boolean), hints.isPositive); |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
235 } |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
236 args.add("trueValue", replacer.trueValue); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
237 args.add("falseValue", replacer.falseValue); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
238 args.addConst("checkNull", !object.stamp().nonNull()); |
10069
abb9d3a26025
an instanceof instruction lowers to a deoptimize-on-hint-miss snippet only if its profile indicates a miss (of a hint type) occurs an order of magnitude less than the compilation threshold
Doug Simon <doug.simon@oracle.com>
parents:
10042
diff
changeset
|
239 if (hintInfo.hintHitProbability >= hintHitProbabilityThresholdForDeoptimizingSnippet()) { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
240 args.addConst("nullSeen", hintInfo.profile.getNullSeen() != TriState.FALSE); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
241 } |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
242 return args; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
243 |
6663
04944369f982
refactored complex snippet-based lowering mechanism for InstanceOfNodes into non-HotSpot specific project
Doug Simon <doug.simon@oracle.com>
parents:
6662
diff
changeset
|
244 } else { |
7278
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
245 assert replacer.instanceOf instanceof InstanceOfDynamicNode; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
246 InstanceOfDynamicNode instanceOf = (InstanceOfDynamicNode) replacer.instanceOf; |
346336325337
added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents:
7275
diff
changeset
|
247 ValueNode object = instanceOf.object(); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
248 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
249 Arguments args = new Arguments(instanceofDynamic); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
250 args.add("mirror", instanceOf.mirror()); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
251 args.add("object", object); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
252 args.add("trueValue", replacer.trueValue); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
253 args.add("falseValue", replacer.falseValue); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
254 args.addConst("checkNull", !object.stamp().nonNull()); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8953
diff
changeset
|
255 return args; |
6653
2d5407ae1ac4
intermediate materialization is now removed during lowering of an InstanceOfNode that has a single usage which is an IfNode in the same block
Doug Simon <doug.simon@oracle.com>
parents:
6652
diff
changeset
|
256 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
258 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
259 } |