annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java @ 10080:e04f128d719c

cannot use DeoptimizationAction.None for deoptimizing instanceof snippet since it will miss application phase changes, causing repeated and expensive deoptimization
author Doug Simon <doug.simon@oracle.com>
date Tue, 18 Jun 2013 12:46:06 +0200
parents abb9d3a26025
children 388fbd0dd4a4
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
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) {
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 }
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 }
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
103 // 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
104 // 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
105 // 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
106 // 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
107 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
108 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
109 }
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 /**
6652
efcf6cd16a2f renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents: 6648
diff changeset
112 * 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
113 */
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
115 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
116 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
117 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
118 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
119 }
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6670
diff changeset
120 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
121 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
122 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
123 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
124 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 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
126 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
127 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 /**
6652
efcf6cd16a2f renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents: 6648
diff changeset
130 * 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
131 */
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
133 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
134 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
135 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
136 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
137 }
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6670
diff changeset
138 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
139 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
140 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
141 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
142 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 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
144 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
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
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147 /**
6652
efcf6cd16a2f renamed snippet methods in InstanceOfSnippets
Doug Simon <doug.simon@oracle.com>
parents: 6648
diff changeset
148 * 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
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 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
151 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
152 @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
153 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
154 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
155 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
156 }
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6670
diff changeset
157 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
158 // 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 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
169 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
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 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
172 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173
7278
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 * 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
176 */
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
177 @Snippet
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
178 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
179 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
180 isNull.inc();
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
181 return falseValue;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
182 }
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
183
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
184 Word hub = loadWordFromObject(mirror, klassOffset());
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
185 Word objectHub = loadHub(object);
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
186 if (!checkUnknownSubType(hub, objectHub)) {
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
187 return falseValue;
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 return trueValue;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
190 }
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
191
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
192 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
193
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
194 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
195 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
196 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
197 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
198 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
199
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8415
diff changeset
200 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
201 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
202 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203
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
204 @Override
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
205 protected Arguments makeArguments(InstanceOfUsageReplacer replacer, LoweringTool tool) {
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
206 if (replacer.instanceOf instanceof InstanceOfNode) {
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
207 InstanceOfNode instanceOf = (InstanceOfNode) replacer.instanceOf;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
208 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
209 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
210 final HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) instanceOf.type();
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
211 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
212
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
213 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
214
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
215 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
216 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
217 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
218 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
219 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
220 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
221 } else if (hintInfo.exact != null) {
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
222 args = new Arguments(instanceofExact);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
223 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
224 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
225 } else if (type.isPrimaryType()) {
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
226 args = new Arguments(instanceofPrimary);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
227 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
228 args.add("object", object);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
229 args.addConst("superCheckOffset", type.superCheckOffset());
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
230 } 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
231 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
232 args = new Arguments(instanceofSecondary);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
233 args.add("hub", hub);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
234 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
235 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
236 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
237 }
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
238 args.add("trueValue", replacer.trueValue);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
239 args.add("falseValue", replacer.falseValue);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
240 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
241 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
242 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
243 }
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
244 return args;
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
245
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
246 } else {
7278
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
247 assert replacer.instanceOf instanceof InstanceOfDynamicNode;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
248 InstanceOfDynamicNode instanceOf = (InstanceOfDynamicNode) replacer.instanceOf;
346336325337 added intrinsification of Class.isInstance()
Doug Simon <doug.simon@oracle.com>
parents: 7275
diff changeset
249 ValueNode object = instanceOf.object();
9015
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
250
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
251 Arguments args = new Arguments(instanceofDynamic);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
252 args.add("mirror", instanceOf.mirror());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
253 args.add("object", object);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
254 args.add("trueValue", replacer.trueValue);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
255 args.add("falseValue", replacer.falseValue);
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
256 args.addConst("checkNull", !object.stamp().nonNull());
92d2bedb5dfc Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8953
diff changeset
257 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
258 }
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
259 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
260 }
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
261 }