annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java @ 11959:23ccaa863eda

made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
author Doug Simon <doug.simon@oracle.com>
date Thu, 10 Oct 2013 16:14:55 +0200
parents 0e2cceed1caf
children 0fc653a9e019
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
11839
0e2cceed1caf Temporarily move encodeDeoptActionAndReason to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11732
diff changeset
25 import static com.oracle.graal.api.meta.DeoptimizationAction.*;
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
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.*;
10787
388fbd0dd4a4 moved BranchNodeProbabilities to graal.nodes project
Doug Simon <doug.simon@oracle.com>
parents: 10080
diff changeset
30 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9793
diff changeset
31 import static com.oracle.graal.phases.GraalOptions.*;
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,
11344
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
82 @ConstantParameter boolean nullSeen) {
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
83 if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
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
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) {
10080
e04f128d719c cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
Doug Simon <doug.simon@oracle.com>
parents: 10069
diff changeset
86 // See comment below for other deoptimization path; the
e04f128d719c cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
Doug Simon <doug.simon@oracle.com>
parents: 10069
diff changeset
87 // same reasoning applies here.
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 }
11348
d46159285f97 removed Stamp parameter of BeginNode.anchor node intrinsic
Doug Simon <doug.simon@oracle.com>
parents: 11344
diff changeset
92 BeginNode anchorNode = BeginNode.anchor();
11258
56f1aa40e13b made LoadHubNode be floating
Doug Simon <doug.simon@oracle.com>
parents: 10787
diff changeset
93 Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
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
94 // 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 }
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
103 }
10080
e04f128d719c cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
Doug Simon <doug.simon@oracle.com>
parents: 10069
diff changeset
104 // This maybe just be a rare event but it might also indicate a phase change
e04f128d719c cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
Doug Simon <doug.simon@oracle.com>
parents: 10069
diff changeset
105 // in the application. Ideally we want to use DeoptimizationAction.None for
e04f128d719c cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
Doug Simon <doug.simon@oracle.com>
parents: 10069
diff changeset
106 // the former but the cost is too high if indeed it is the latter. As such,
e04f128d719c cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
Doug Simon <doug.simon@oracle.com>
parents: 10069
diff changeset
107 // we defensively opt for InvalidateReprofile.
e04f128d719c cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
Doug Simon <doug.simon@oracle.com>
parents: 10069
diff changeset
108 DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, 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
109 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
110 }
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
111
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
112 /**
6652
efcf6cd16a2f renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents: 6648
diff changeset
113 * 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
114 */
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115 @Snippet
11344
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
116 public static Object instanceofExact(Object object, Word exactHub, Object trueValue, Object falseValue) {
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
117 if (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
118 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
119 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
120 }
11348
d46159285f97 removed Stamp parameter of BeginNode.anchor node intrinsic
Doug Simon <doug.simon@oracle.com>
parents: 11344
diff changeset
121 BeginNode anchorNode = BeginNode.anchor();
11258
56f1aa40e13b made LoadHubNode be floating
Doug Simon <doug.simon@oracle.com>
parents: 10787
diff changeset
122 Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
9316
5e1465ec46d6 Change the way branch probabilities are injected. Update all snippets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9015
diff changeset
123 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
124 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
125 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
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 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
128 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
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
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 /**
6652
efcf6cd16a2f renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents: 6648
diff changeset
132 * 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
133 */
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 @Snippet
11344
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
135 public static Object instanceofPrimary(Word hub, Object object, @ConstantParameter int superCheckOffset, Object trueValue, Object falseValue) {
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
136 if (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
137 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
138 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
139 }
11348
d46159285f97 removed Stamp parameter of BeginNode.anchor node intrinsic
Doug Simon <doug.simon@oracle.com>
parents: 11344
diff changeset
140 BeginNode anchorNode = BeginNode.anchor();
11258
56f1aa40e13b made LoadHubNode be floating
Doug Simon <doug.simon@oracle.com>
parents: 10787
diff changeset
141 Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
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
142 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
143 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
144 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
145 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 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
147 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
148 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 /**
6652
efcf6cd16a2f renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents: 6648
diff changeset
151 * 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
152 */
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 @Snippet
11344
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
154 public static Object instanceofSecondary(Word hub, Object object, @VarargsParameter Word[] hints, @VarargsParameter boolean[] hintIsPositive, Object trueValue, Object falseValue) {
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
155 if (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
156 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
157 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
158 }
11348
d46159285f97 removed Stamp parameter of BeginNode.anchor node intrinsic
Doug Simon <doug.simon@oracle.com>
parents: 11344
diff changeset
159 BeginNode anchorNode = BeginNode.anchor();
11258
56f1aa40e13b made LoadHubNode be floating
Doug Simon <doug.simon@oracle.com>
parents: 10787
diff changeset
160 Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 // 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 }
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 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
172 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
173 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 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
175 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
177 /**
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
178 * 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
179 */
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
180 @Snippet
11344
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
181 public static Object instanceofDynamic(Class mirror, Object object, Object trueValue, Object falseValue) {
4b3a6662deb1 Remove checkNull parameter from snippets. Fixes several instances of unsafe usage of BeginNode.anchor.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11265
diff changeset
182 if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
183 isNull.inc();
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
184 return falseValue;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
185 }
11348
d46159285f97 removed Stamp parameter of BeginNode.anchor node intrinsic
Doug Simon <doug.simon@oracle.com>
parents: 11344
diff changeset
186 BeginNode anchorNode = BeginNode.anchor();
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
187 Word hub = loadWordFromObject(mirror, klassOffset());
11258
56f1aa40e13b made LoadHubNode be floating
Doug Simon <doug.simon@oracle.com>
parents: 10787
diff changeset
188 Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
189 if (!checkUnknownSubType(hub, objectHub)) {
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
190 return falseValue;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
191 }
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
192 return trueValue;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
193 }
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
194
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
195 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
196
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
197 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
198 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
199 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
200 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
201 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
202
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
203 public Templates(MetaAccessProvider metaAccess, GraalCodeCacheProvider codeCache, Replacements replacements, TargetDescription target) {
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
204 super(metaAccess, codeCache, 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
205 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206
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
207 @Override
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
208 protected Arguments makeArguments(InstanceOfUsageReplacer replacer, LoweringTool tool) {
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
209 if (replacer.instanceOf instanceof InstanceOfNode) {
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
210 InstanceOfNode instanceOf = (InstanceOfNode) replacer.instanceOf;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
211 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
212 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
213 final HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) instanceOf.type();
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
214 ConstantNode hub = ConstantNode.forConstant(type.klass(), metaAccess, instanceOf.graph());
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
215
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
216 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
217
11732
03c781923573 made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents: 11348
diff changeset
218 StructuredGraph graph = hub.graph();
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
219 if (hintInfo.hintHitProbability >= hintHitProbabilityThresholdForDeoptimizingSnippet()) {
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
220 Hints hints = createHints(hintInfo, metaAccess, false, graph);
11732
03c781923573 made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents: 11348
diff changeset
221 args = new Arguments(instanceofWithProfile, graph.getGuardsStage());
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("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
223 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
224 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
225 } else if (hintInfo.exact != null) {
11732
03c781923573 made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents: 11348
diff changeset
226 args = new Arguments(instanceofExact, graph.getGuardsStage());
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
227 args.add("object", object);
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
228 args.add("exactHub", ConstantNode.forConstant(((HotSpotResolvedObjectType) hintInfo.exact).klass(), metaAccess, graph));
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
229 } else if (type.isPrimaryType()) {
11732
03c781923573 made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents: 11348
diff changeset
230 args = new Arguments(instanceofPrimary, graph.getGuardsStage());
9015
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);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
233 args.addConst("superCheckOffset", type.superCheckOffset());
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
234 } else {
11959
23ccaa863eda made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
235 Hints hints = createHints(hintInfo, metaAccess, false, graph);
11732
03c781923573 made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents: 11348
diff changeset
236 args = new Arguments(instanceofSecondary, graph.getGuardsStage());
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
237 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
238 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
239 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
240 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
241 }
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
242 args.add("trueValue", replacer.trueValue);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
243 args.add("falseValue", replacer.falseValue);
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
244 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
245 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
246 }
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
247 return args;
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
248
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
249 } else {
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
250 assert replacer.instanceOf instanceof InstanceOfDynamicNode;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
251 InstanceOfDynamicNode instanceOf = (InstanceOfDynamicNode) replacer.instanceOf;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
252 ValueNode object = instanceOf.object();
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
253
11732
03c781923573 made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents: 11348
diff changeset
254 Arguments args = new Arguments(instanceofDynamic, instanceOf.graph().getGuardsStage());
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
255 args.add("mirror", instanceOf.mirror());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
256 args.add("object", object);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
257 args.add("trueValue", replacer.trueValue);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
258 args.add("falseValue", replacer.falseValue);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
259 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
260 }
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
261 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
262 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
263 }