Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java @ 21554:b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 May 2015 23:21:15 +0200 |
parents | 7ba8fb19d56d |
children | 48c1ebd24120 |
rev | line source |
---|---|
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
20178
7ba8fb19d56d
Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents:
18502
diff
changeset
|
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
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:
11752
diff
changeset
|
25 import static com.oracle.graal.api.meta.DeoptimizationAction.*; |
7542
a0298e142ea8
factored out common code shared by InstanceOfSnippets and CheckCastSnippets
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*; |
9513
659bb6cf930c
rename: HotSpotSnippetUtils -> HotSpotReplacementsUtil
Doug Simon <doug.simon@oracle.com>
parents:
9318
diff
changeset
|
27 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
28 import static com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.*; |
11752
7e7edb86fb43
Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11732
diff
changeset
|
29 import static com.oracle.graal.nodes.PiNode.*; |
10787
388fbd0dd4a4
moved BranchNodeProbabilities to graal.nodes project
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
30 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
31 import static com.oracle.graal.replacements.SnippetTemplate.*; |
5400
028c9ce0fc0f
added support for -G:+CheckcastCounters in checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5398
diff
changeset
|
32 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
33 import com.oracle.graal.api.code.*; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
34 import com.oracle.graal.compiler.common.type.*; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15005
diff
changeset
|
35 import com.oracle.graal.hotspot.meta.*; |
15005
9fa900dd3f96
create special-purpose SnippetAnchorNode to replace usages of BeginNode in snippets
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13505
diff
changeset
|
36 import com.oracle.graal.hotspot.nodes.*; |
18502
f38677340519
Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18401
diff
changeset
|
37 import com.oracle.graal.hotspot.word.*; |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.*; |
15005
9fa900dd3f96
create special-purpose SnippetAnchorNode to replace usages of BeginNode in snippets
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13505
diff
changeset
|
39 import com.oracle.graal.nodes.extended.*; |
5400
028c9ce0fc0f
added support for -G:+CheckcastCounters in checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5398
diff
changeset
|
40 import com.oracle.graal.nodes.java.*; |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12054
diff
changeset
|
41 import com.oracle.graal.nodes.spi.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8413
diff
changeset
|
42 import com.oracle.graal.replacements.*; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8909
diff
changeset
|
43 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8909
diff
changeset
|
44 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8909
diff
changeset
|
45 import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo; |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20178
diff
changeset
|
46 import com.oracle.jvmci.debug.*; |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 |
5400
028c9ce0fc0f
added support for -G:+CheckcastCounters in checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5398
diff
changeset
|
48 /** |
11226
422b0e9b9aed
removed obsolete checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
10787
diff
changeset
|
49 * Snippet used for lowering {@link CheckCastDynamicNode}. |
5400
028c9ce0fc0f
added support for -G:+CheckcastCounters in checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5398
diff
changeset
|
50 */ |
11226
422b0e9b9aed
removed obsolete checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
10787
diff
changeset
|
51 public class CheckCastDynamicSnippets implements Snippets { |
5469
7a0d58000ae0
checkcasts against restricted primary types no longer use hints
Doug Simon <doug.simon@oracle.com>
parents:
5466
diff
changeset
|
52 |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5439
diff
changeset
|
53 @Snippet |
18502
f38677340519
Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18401
diff
changeset
|
54 public static Object checkcastDynamic(KlassPointer hub, Object object) { |
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
|
55 if (probability(NOT_FREQUENT_PROBABILITY, object == null)) { |
5482
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
56 isNull.inc(); |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7542
diff
changeset
|
57 } else { |
15005
9fa900dd3f96
create special-purpose SnippetAnchorNode to replace usages of BeginNode in snippets
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13505
diff
changeset
|
58 GuardingNode anchorNode = SnippetAnchorNode.anchor(); |
18502
f38677340519
Add memory operations to MetaspacePointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18401
diff
changeset
|
59 KlassPointer objectHub = loadHubIntrinsic(object, anchorNode); |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7542
diff
changeset
|
60 if (!checkUnknownSubType(hub, objectHub)) { |
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7542
diff
changeset
|
61 DeoptimizeNode.deopt(InvalidateReprofile, ClassCastException); |
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7542
diff
changeset
|
62 } |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5439
diff
changeset
|
63 } |
15005
9fa900dd3f96
create special-purpose SnippetAnchorNode to replace usages of BeginNode in snippets
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13505
diff
changeset
|
64 GuardingNode anchorNode = SnippetAnchorNode.anchor(); |
11752
7e7edb86fb43
Refactor the handling of unsafe casts to distinguish between word-object-conversions, PiNode-like type information, and real unsafe casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11732
diff
changeset
|
65 return piCast(verifyOop(object), StampFactory.forNodeIntrinsic(), anchorNode); |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 } |
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8909
diff
changeset
|
68 public static class Templates extends AbstractTemplates { |
5428
6ec0857cdf46
added support for snippet templates which are snippet graphs specialized by binding a constant to at least one of the snippet's parameters
Doug Simon <doug.simon@oracle.com>
parents:
5400
diff
changeset
|
69 |
20178
7ba8fb19d56d
Check that snippets only access locations that are either accessed by the replacee, or are private to the snippet.
Roland Schatz <roland.schatz@oracle.com>
parents:
18502
diff
changeset
|
70 private final SnippetInfo dynamic = snippet(CheckCastDynamicSnippets.class, "checkcastDynamic", SECONDARY_SUPER_CACHE_LOCATION); |
5428
6ec0857cdf46
added support for snippet templates which are snippet graphs specialized by binding a constant to at least one of the snippet's parameters
Doug Simon <doug.simon@oracle.com>
parents:
5400
diff
changeset
|
71 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15005
diff
changeset
|
72 public Templates(HotSpotProviders providers, TargetDescription target) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15005
diff
changeset
|
73 super(providers, providers.getSnippetReflection(), target); |
5428
6ec0857cdf46
added support for snippet templates which are snippet graphs specialized by binding a constant to at least one of the snippet's parameters
Doug Simon <doug.simon@oracle.com>
parents:
5400
diff
changeset
|
74 } |
6ec0857cdf46
added support for snippet templates which are snippet graphs specialized by binding a constant to at least one of the snippet's parameters
Doug Simon <doug.simon@oracle.com>
parents:
5400
diff
changeset
|
75 |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12054
diff
changeset
|
76 public void lower(CheckCastDynamicNode checkcast, LoweringTool tool) { |
9602
19c5a07c7843
Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9513
diff
changeset
|
77 StructuredGraph graph = checkcast.graph(); |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6568
diff
changeset
|
78 ValueNode object = checkcast.object(); |
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6568
diff
changeset
|
79 |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12054
diff
changeset
|
80 Arguments args = new Arguments(dynamic, graph.getGuardsStage(), tool.getLoweringStage()); |
11226
422b0e9b9aed
removed obsolete checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
10787
diff
changeset
|
81 args.add("hub", checkcast.hub()); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8909
diff
changeset
|
82 args.add("object", object); |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6568
diff
changeset
|
83 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8909
diff
changeset
|
84 SnippetTemplate template = template(args); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8909
diff
changeset
|
85 Debug.log("Lowering dynamic checkcast in %s: node=%s, template=%s, arguments=%s", graph, checkcast, template, args); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
86 template.instantiate(providers.getMetaAccess(), checkcast, DEFAULT_REPLACER, args); |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6568
diff
changeset
|
87 } |
5428
6ec0857cdf46
added support for snippet templates which are snippet graphs specialized by binding a constant to at least one of the snippet's parameters
Doug Simon <doug.simon@oracle.com>
parents:
5400
diff
changeset
|
88 } |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 } |