Mercurial > hg > truffle
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java @ 18913:51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 20 Jan 2015 16:40:45 +0100 |
parents | 441cc8350b96 |
children | ff232ff8d028 |
rev | line source |
---|---|
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:
diff
changeset
|
1 /* |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
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:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
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:
diff
changeset
|
4 * |
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:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
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:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
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:
diff
changeset
|
7 * published by the Free Software Foundation. |
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:
diff
changeset
|
8 * |
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:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
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:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
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:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
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:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
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:
diff
changeset
|
13 * accompanied this code). |
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:
diff
changeset
|
14 * |
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:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
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:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
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:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
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:
diff
changeset
|
18 * |
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:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
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:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
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:
diff
changeset
|
21 * questions. |
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:
diff
changeset
|
22 */ |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8414
diff
changeset
|
23 package com.oracle.graal.replacements; |
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:
diff
changeset
|
24 |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
25 import static com.oracle.graal.api.meta.LocationIdentity.*; |
15551
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
26 import static com.oracle.graal.compiler.common.GraalOptions.*; |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
27 import static com.oracle.graal.debug.Debug.*; |
17065
37d6d174bc40
denote certain applications of DeadCodeEliminationPhase as optional and only run them if -G:-ReduceDCE
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
28 import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*; |
15968
42eaa579e134
more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents:
15926
diff
changeset
|
29 import static com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates.*; |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
30 import static java.util.FormattableFlags.*; |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
31 |
12733
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
32 import java.io.*; |
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:
diff
changeset
|
33 import java.lang.reflect.*; |
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:
diff
changeset
|
34 import java.util.*; |
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:
diff
changeset
|
35 import java.util.concurrent.*; |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
36 import java.util.concurrent.atomic.*; |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
37 import java.util.stream.*; |
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:
diff
changeset
|
38 |
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:
7015
diff
changeset
|
39 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5503
diff
changeset
|
40 import com.oracle.graal.api.meta.*; |
9187
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9099
diff
changeset
|
41 import com.oracle.graal.api.replacements.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15040
diff
changeset
|
42 import com.oracle.graal.compiler.common.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
43 import com.oracle.graal.compiler.common.type.*; |
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:
diff
changeset
|
44 import com.oracle.graal.debug.*; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
45 import com.oracle.graal.debug.Debug.Scope; |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
46 import com.oracle.graal.debug.internal.*; |
15363
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
47 import com.oracle.graal.graph.Graph.Mark; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16822
diff
changeset
|
48 import com.oracle.graal.graph.Node; |
6523
c8763a2deb0c
rename packages in graal.loop to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6521
diff
changeset
|
49 import com.oracle.graal.loop.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16822
diff
changeset
|
50 import com.oracle.graal.nodeinfo.*; |
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:
diff
changeset
|
51 import com.oracle.graal.nodes.*; |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
52 import com.oracle.graal.nodes.StructuredGraph.GuardsStage; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
53 import com.oracle.graal.nodes.calc.*; |
9879
bf6943c12840
allow for late lowering of MemoryCheckpoints (handle usages by FloatingReads in SnippetTemplate)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
54 import com.oracle.graal.nodes.extended.*; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
55 import com.oracle.graal.nodes.java.*; |
8178
67ee3325c285
added support for node lowering to set the fixed node for the next node to be lowered
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
56 import com.oracle.graal.nodes.spi.*; |
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:
diff
changeset
|
57 import com.oracle.graal.nodes.util.*; |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
58 import com.oracle.graal.phases.common.*; |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
59 import com.oracle.graal.phases.common.FloatingReadPhase.MemoryMapImpl; |
15470
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15363
diff
changeset
|
60 import com.oracle.graal.phases.common.inlining.*; |
11569
2f6734f8126a
Avoid direct usage of CanonicalizerPhase.Instance in replacements processing.
Roland Schatz <roland.schatz@oracle.com>
parents:
11550
diff
changeset
|
61 import com.oracle.graal.phases.tiers.*; |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
62 import com.oracle.graal.phases.util.*; |
8642
1093255fd0d4
simplified registration of snippets
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
63 import com.oracle.graal.replacements.Snippet.ConstantParameter; |
1093255fd0d4
simplified registration of snippets
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
64 import com.oracle.graal.replacements.Snippet.VarargsParameter; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8414
diff
changeset
|
65 import com.oracle.graal.replacements.nodes.*; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
66 import com.oracle.graal.word.*; |
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:
diff
changeset
|
67 |
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:
diff
changeset
|
68 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
69 * A snippet template is a graph created by parsing a snippet method and then specialized by binding |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
70 * constants to the snippet's {@link ConstantParameter} parameters. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
71 * |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
72 * Snippet templates can be managed in a cache maintained by {@link 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:
diff
changeset
|
73 */ |
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:
diff
changeset
|
74 public class SnippetTemplate { |
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:
diff
changeset
|
75 |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
76 // Checkstyle: stop |
17140
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
77 public static boolean LAZY_SNIPPETS = true; |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
78 |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
79 // Checkstyle: resume |
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
80 |
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:
diff
changeset
|
81 /** |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
82 * Holds the {@link ResolvedJavaMethod} of the snippet, together with some information about the |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
83 * method that needs to be computed only once. The {@link SnippetInfo} should be created once |
11732
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
84 * per snippet and then cached. |
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:
diff
changeset
|
85 */ |
17140
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
86 public abstract static class SnippetInfo { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
87 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
88 protected final ResolvedJavaMethod method; |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
89 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
90 /** |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
91 * Lazily constructed parts of {@link SnippetInfo}. |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
92 */ |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
93 static class Lazy { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
94 public Lazy(ResolvedJavaMethod method) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
95 int count = method.getSignature().getParameterCount(false); |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
96 constantParameters = new boolean[count]; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
97 varargsParameters = new boolean[count]; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
98 for (int i = 0; i < count; i++) { |
16477
46397dc87086
moved getParameterAnnotation() from MetaUtil to be a default method in ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16460
diff
changeset
|
99 constantParameters[i] = method.getParameterAnnotation(ConstantParameter.class, i) != null; |
46397dc87086
moved getParameterAnnotation() from MetaUtil to be a default method in ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16460
diff
changeset
|
100 varargsParameters[i] = method.getParameterAnnotation(VarargsParameter.class, i) != null; |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
101 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
102 assert !constantParameters[i] || !varargsParameters[i] : "Parameter cannot be annotated with both @" + ConstantParameter.class.getSimpleName() + " and @" + |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
103 VarargsParameter.class.getSimpleName(); |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
104 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
105 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
106 // Retrieve the names only when assertions are turned on. |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
107 assert initNames(method, count); |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
108 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
109 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
110 final boolean[] constantParameters; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
111 final boolean[] varargsParameters; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
112 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
113 /** |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
114 * The parameter names, taken from the local variables table. Only used for assertion |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
115 * checking, so use only within an assert statement. |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
116 */ |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
117 String[] names; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
118 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
119 private boolean initNames(ResolvedJavaMethod method, int parameterCount) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
120 names = new String[parameterCount]; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
121 int slotIdx = 0; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
122 for (int i = 0; i < names.length; i++) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
123 names[i] = method.getLocalVariableTable().getLocal(slotIdx, 0).getName(); |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
124 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
125 Kind kind = method.getSignature().getParameterKind(i); |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18860
diff
changeset
|
126 slotIdx += kind.getSlotCount(); |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
127 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
128 return true; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
129 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
130 |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
131 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
132 |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
133 /** |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
134 * Times instantiations of all templates derived form this snippet. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
135 * |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
136 * @see SnippetTemplate#instantiationTimer |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
137 */ |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
138 private final DebugTimer instantiationTimer; |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
139 |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
140 /** |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
141 * Counts instantiations of all templates derived from this snippet. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
142 * |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
143 * @see SnippetTemplate#instantiationCounter |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
144 */ |
12507
d72864a2886e
moved snippet timers/metrics from SnippetTemplate to SnippetInfo and added new metric for number of snippet specializations (i.e. number of SnippetTemplate objects created)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
145 private final DebugMetric instantiationCounter; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
146 |
17140
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
147 protected abstract Lazy lazy(); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
148 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
149 protected SnippetInfo(ResolvedJavaMethod method) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
150 this.method = method; |
14740
470e1e6664e2
Fix format string
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
151 instantiationCounter = Debug.metric("SnippetInstantiationCount[%s]", method); |
470e1e6664e2
Fix format string
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14633
diff
changeset
|
152 instantiationTimer = Debug.timer("SnippetInstantiationTime[%s]", method); |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16479
diff
changeset
|
153 assert method.isStatic() : "snippet method must be static: " + method.format("%H.%n"); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
154 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
155 |
12733
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
156 private int templateCount; |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
157 |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
158 void notifyNewTemplate() { |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
159 templateCount++; |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
160 if (UseSnippetTemplateCache && templateCount > MaxTemplatesPerSnippet) { |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
161 PrintStream err = System.err; |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16479
diff
changeset
|
162 err.printf("WARNING: Exceeded %d templates for snippet %s%n" + " Adjust maximum with %s system property%n", MaxTemplatesPerSnippet, method.format("%h.%n(%p)"), |
12733
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
163 MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME); |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
164 } |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
165 } |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
166 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
167 public ResolvedJavaMethod getMethod() { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
168 return method; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
169 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
170 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
171 public int getParameterCount() { |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
172 return lazy().constantParameters.length; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
173 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
174 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
175 public boolean isConstantParameter(int paramIdx) { |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
176 return lazy().constantParameters[paramIdx]; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
177 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
178 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
179 public boolean isVarargsParameter(int paramIdx) { |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
180 return lazy().varargsParameters[paramIdx]; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
181 } |
9417
ffa27c3058e9
minor simplifications for writing compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9302
diff
changeset
|
182 |
ffa27c3058e9
minor simplifications for writing compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9302
diff
changeset
|
183 public String getParameterName(int paramIdx) { |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
184 String[] names = lazy().names; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
185 if (names != null) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
186 return names[paramIdx]; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
187 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
188 return null; |
9417
ffa27c3058e9
minor simplifications for writing compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9302
diff
changeset
|
189 } |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
190 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
191 |
17140
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
192 protected static class LazySnippetInfo extends SnippetInfo { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
193 protected final AtomicReference<Lazy> lazy = new AtomicReference<>(null); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
194 |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
195 protected LazySnippetInfo(ResolvedJavaMethod method) { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
196 super(method); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
197 } |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
198 |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
199 @Override |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
200 protected Lazy lazy() { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
201 if (lazy.get() == null) { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
202 lazy.compareAndSet(null, new Lazy(method)); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
203 } |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
204 return lazy.get(); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
205 } |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
206 } |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
207 |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
208 protected static class EagerSnippetInfo extends SnippetInfo { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
209 protected final Lazy lazy; |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
210 |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
211 protected EagerSnippetInfo(ResolvedJavaMethod method) { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
212 super(method); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
213 lazy = new Lazy(method); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
214 } |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
215 |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
216 @Override |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
217 protected Lazy lazy() { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
218 return lazy; |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
219 } |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
220 } |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
221 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
222 /** |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
223 * Values that are bound to the snippet method parameters. The methods {@link #add}, |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
224 * {@link #addConst}, and {@link #addVarargs} must be called in the same order as in the |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
225 * signature of the snippet method. The parameter name is passed to the add methods for |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
226 * assertion checking, i.e., to enforce that the order matches. Which method needs to be called |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
227 * depends on the annotation of the snippet method parameter: |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
228 * <ul> |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
229 * <li>Use {@link #add} for a parameter without an annotation. The value is bound when the |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
230 * {@link SnippetTemplate} is {@link SnippetTemplate#instantiate instantiated}. |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
231 * <li>Use {@link #addConst} for a parameter annotated with {@link ConstantParameter}. The value |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
232 * is bound when the {@link SnippetTemplate} is {@link SnippetTemplate#SnippetTemplate created}. |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
233 * <li>Use {@link #addVarargs} for an array parameter annotated with {@link VarargsParameter}. A |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
234 * separate {@link SnippetTemplate} is {@link SnippetTemplate#SnippetTemplate created} for every |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
235 * distinct array length. The actual values are bound when the {@link SnippetTemplate} is |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
236 * {@link SnippetTemplate#instantiate instantiated} |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
237 * </ul> |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
238 */ |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
239 public static class Arguments implements Formattable { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
240 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
241 protected final SnippetInfo info; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
242 protected final CacheKey cacheKey; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
243 protected final Object[] values; |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
244 protected final Stamp[] constStamps; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
245 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
246 protected int nextParamIdx; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
247 |
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:
13287
diff
changeset
|
248 public Arguments(SnippetInfo info, GuardsStage guardsStage, LoweringTool.LoweringStage loweringStage) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
249 this.info = info; |
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:
13287
diff
changeset
|
250 this.cacheKey = new CacheKey(info, guardsStage, loweringStage); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
251 this.values = new Object[info.getParameterCount()]; |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
252 this.constStamps = new Stamp[info.getParameterCount()]; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
253 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
254 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
255 public Arguments add(String name, Object value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
256 assert check(name, false, false); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
257 values[nextParamIdx] = value; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
258 nextParamIdx++; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
259 return this; |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
260 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
261 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
262 public Arguments addConst(String name, Object value) { |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
263 return addConst(name, value, null); |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
264 } |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
265 |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
266 public Arguments addConst(String name, Object value, Stamp stamp) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
267 assert check(name, true, false); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
268 values[nextParamIdx] = value; |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
269 constStamps[nextParamIdx] = stamp; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
270 cacheKey.setParam(nextParamIdx, value); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
271 nextParamIdx++; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
272 return this; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
273 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
274 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
275 public Arguments addVarargs(String name, Class<?> componentType, Stamp argStamp, Object value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
276 assert check(name, false, true); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
277 Varargs varargs = new Varargs(componentType, argStamp, value); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
278 values[nextParamIdx] = varargs; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
279 // A separate template is necessary for every distinct array length |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
280 cacheKey.setParam(nextParamIdx, varargs.length); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
281 nextParamIdx++; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
282 return this; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
283 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
284 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
285 private boolean check(String name, boolean constParam, boolean varargsParam) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
286 assert nextParamIdx < info.getParameterCount() : "too many parameters: " + name + " " + this; |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
287 assert info.getParameterName(nextParamIdx) == null || info.getParameterName(nextParamIdx).equals(name) : "wrong parameter name: " + name + " " + this; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
288 assert constParam == info.isConstantParameter(nextParamIdx) : "Parameter " + (constParam ? "not " : "") + "annotated with @" + ConstantParameter.class.getSimpleName() + ": " + name + |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
289 " " + this; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
290 assert varargsParam == info.isVarargsParameter(nextParamIdx) : "Parameter " + (varargsParam ? "not " : "") + "annotated with @" + VarargsParameter.class.getSimpleName() + ": " + name + |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
291 " " + this; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
292 return true; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
293 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
294 |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
295 @Override |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
296 public String toString() { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
297 StringBuilder result = new StringBuilder(); |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16479
diff
changeset
|
298 result.append("Parameters<").append(info.method.format("%h.%n")).append(" ["); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
299 String sep = ""; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
300 for (int i = 0; i < info.getParameterCount(); i++) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
301 result.append(sep); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
302 if (info.isConstantParameter(i)) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
303 result.append("const "); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
304 } else if (info.isVarargsParameter(i)) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
305 result.append("varargs "); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
306 } |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
307 result.append(info.getParameterName(i)).append(" = ").append(values[i]); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
308 sep = ", "; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
309 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
310 result.append(">"); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
311 return result.toString(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
312 } |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
313 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
314 public void formatTo(Formatter formatter, int flags, int width, int precision) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
315 if ((flags & ALTERNATE) == 0) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
316 formatter.format(applyFormattingFlagsAndWidth(toString(), flags, width)); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
317 } else { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
318 StringBuilder sb = new StringBuilder(); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
319 sb.append(info.method.getName()).append('('); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
320 String sep = ""; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
321 for (int i = 0; i < info.getParameterCount(); i++) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
322 if (info.isConstantParameter(i)) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
323 sb.append(sep); |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
324 if (info.getParameterName(i) != null) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
325 sb.append(info.getParameterName(i)); |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
326 } else { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
327 sb.append(i); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
328 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
329 sb.append('=').append(values[i]); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
330 sep = ", "; |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
331 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
332 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
333 sb.append(")"); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
334 formatter.format(applyFormattingFlagsAndWidth(sb.toString(), flags & ~ALTERNATE, width)); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
335 } |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
336 } |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
337 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
338 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
339 /** |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
340 * Wrapper for the prototype value of a {@linkplain VarargsParameter varargs} parameter. |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
341 */ |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
342 static class Varargs { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
343 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
344 protected final Class<?> componentType; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
345 protected final Stamp stamp; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
346 protected final Object value; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
347 protected final int length; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
348 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
349 protected Varargs(Class<?> componentType, Stamp stamp, Object value) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
350 this.componentType = componentType; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
351 this.stamp = stamp; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
352 this.value = value; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
353 if (value instanceof List) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
354 this.length = ((List<?>) value).size(); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
355 } else { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
356 this.length = Array.getLength(value); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
357 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
358 } |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
359 |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
360 @Override |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
361 public String toString() { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
362 if (value instanceof boolean[]) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
363 return Arrays.toString((boolean[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
364 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
365 if (value instanceof byte[]) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
366 return Arrays.toString((byte[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
367 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
368 if (value instanceof char[]) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
369 return Arrays.toString((char[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
370 } |
10007
10b8973ac372
fixed copy-and-paste errors
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
371 if (value instanceof short[]) { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
372 return Arrays.toString((short[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
373 } |
10007
10b8973ac372
fixed copy-and-paste errors
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
374 if (value instanceof int[]) { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
375 return Arrays.toString((int[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
376 } |
10007
10b8973ac372
fixed copy-and-paste errors
Doug Simon <doug.simon@oracle.com>
parents:
10001
diff
changeset
|
377 if (value instanceof long[]) { |
10001
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
378 return Arrays.toString((long[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
379 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
380 if (value instanceof float[]) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
381 return Arrays.toString((float[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
382 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
383 if (value instanceof double[]) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
384 return Arrays.toString((double[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
385 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
386 if (value instanceof Object[]) { |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
387 return Arrays.toString((Object[]) value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
388 } |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
389 return String.valueOf(value); |
38d7b55f87b0
added instanceof snippets that for a profile with 100% precise coverage of seen types.
Doug Simon <doug.simon@oracle.com>
parents:
9917
diff
changeset
|
390 } |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
391 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
392 |
16822
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16488
diff
changeset
|
393 @NodeInfo |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
394 static class VarargsPlaceholderNode extends FloatingNode implements ArrayLengthProvider { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
395 |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
396 protected final Varargs varargs; |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
397 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
398 public VarargsPlaceholderNode(Varargs varargs, MetaAccessProvider metaAccess) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
399 super(StampFactory.exactNonNull(metaAccess.lookupJavaType(varargs.componentType).getArrayClass())); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
400 this.varargs = varargs; |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
401 } |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
402 |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
403 public ValueNode length() { |
16238
db5b41891078
let ArrayLengthNode implement Canonicalizable.Binary
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16230
diff
changeset
|
404 return ConstantNode.forInt(varargs.length); |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
405 } |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
406 } |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
407 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
408 static class CacheKey { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
409 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
410 private final ResolvedJavaMethod method; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
411 private final Object[] values; |
11732
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
412 private final GuardsStage guardsStage; |
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:
13287
diff
changeset
|
413 private final LoweringTool.LoweringStage loweringStage; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
414 private int hash; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
415 |
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:
13287
diff
changeset
|
416 protected CacheKey(SnippetInfo info, GuardsStage guardsStage, LoweringTool.LoweringStage loweringStage) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
417 this.method = info.method; |
11732
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
418 this.guardsStage = guardsStage; |
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:
13287
diff
changeset
|
419 this.loweringStage = loweringStage; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
420 this.values = new Object[info.getParameterCount()]; |
18860
441cc8350b96
make hash code for SnippetTemplate.CacheKey more deterministic
Doug Simon <doug.simon@oracle.com>
parents:
18845
diff
changeset
|
421 this.hash = info.method.hashCode() + 31 * guardsStage.ordinal(); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
422 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
423 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
424 protected void setParam(int paramIdx, Object value) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
425 values[paramIdx] = value; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
426 hash = (hash * 31) ^ (value == null ? 0 : value.hashCode()); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
427 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
428 |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
429 @Override |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
430 public boolean equals(Object obj) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
431 if (!(obj instanceof CacheKey)) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
432 return false; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
433 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
434 CacheKey other = (CacheKey) obj; |
14160
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
13932
diff
changeset
|
435 if (!method.equals(other.method)) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
436 return false; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
437 } |
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:
13287
diff
changeset
|
438 if (guardsStage != other.guardsStage || loweringStage != other.loweringStage) { |
11732
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
439 return false; |
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
440 } |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
441 for (int i = 0; i < values.length; i++) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
442 if (values[i] != null && !values[i].equals(other.values[i])) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
443 return false; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
444 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
445 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
446 return true; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
447 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
448 |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
449 @Override |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
450 public int hashCode() { |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
451 return hash; |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
452 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
453 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
454 |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
455 private static final DebugTimer SnippetTemplateCreationTime = Debug.timer("SnippetTemplateCreationTime"); |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
456 private static final DebugMetric SnippetTemplates = Debug.metric("SnippetTemplateCount"); |
12707
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
457 |
12733
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
458 private static final String MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME = "graal.maxTemplatesPerSnippet"; |
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
459 private static final int MaxTemplatesPerSnippet = Integer.getInteger(MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME, 50); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
460 |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
461 /** |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
462 * Base class for snippet classes. It provides a cache for {@link SnippetTemplate}s. |
5484
f70b1547c7bf
small refactoring of snippet API
Doug Simon <doug.simon@oracle.com>
parents:
5482
diff
changeset
|
463 */ |
15970
af95e5727fdc
workaround for javac compiler error
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
464 public abstract static class AbstractTemplates implements com.oracle.graal.api.replacements.SnippetTemplateCache { |
5484
f70b1547c7bf
small refactoring of snippet API
Doug Simon <doug.simon@oracle.com>
parents:
5482
diff
changeset
|
465 |
15968
42eaa579e134
more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents:
15926
diff
changeset
|
466 static final boolean UseSnippetTemplateCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetTemplateCache", "true")); |
42eaa579e134
more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents:
15926
diff
changeset
|
467 |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
468 protected final Providers providers; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
469 protected final SnippetReflectionProvider snippetReflection; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
470 protected final TargetDescription target; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
471 private final ConcurrentHashMap<CacheKey, SnippetTemplate> templates; |
5484
f70b1547c7bf
small refactoring of snippet API
Doug Simon <doug.simon@oracle.com>
parents:
5482
diff
changeset
|
472 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
473 protected AbstractTemplates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
474 this.providers = providers; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
475 this.snippetReflection = snippetReflection; |
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:
7015
diff
changeset
|
476 this.target = target; |
12707
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
477 if (UseSnippetTemplateCache) { |
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
478 this.templates = new ConcurrentHashMap<>(); |
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
479 } else { |
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
480 this.templates = null; |
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
481 } |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
482 } |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
483 |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
484 private static Method findMethod(Class<? extends Snippets> declaringClass, String methodName, Method except) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
485 for (Method m : declaringClass.getDeclaredMethods()) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
486 if (m.getName().equals(methodName) && !m.equals(except)) { |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
487 return m; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
488 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
489 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
490 return null; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
491 } |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
492 |
9417
ffa27c3058e9
minor simplifications for writing compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9302
diff
changeset
|
493 /** |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
494 * Finds the unique method in {@code declaringClass} named {@code methodName} annotated by |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
495 * {@link Snippet} and returns a {@link SnippetInfo} value describing it. There must be |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
496 * exactly one snippet method in {@code declaringClass}. |
9417
ffa27c3058e9
minor simplifications for writing compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9302
diff
changeset
|
497 */ |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
498 protected SnippetInfo snippet(Class<? extends Snippets> declaringClass, String methodName) { |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
499 assert methodName != null; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
500 Method method = findMethod(declaringClass, methodName, null); |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
501 assert method != null : "did not find @" + Snippet.class.getSimpleName() + " method in " + declaringClass + " named " + methodName; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
502 assert method.getAnnotation(Snippet.class) != null : method + " must be annotated with @" + Snippet.class.getSimpleName(); |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
503 assert findMethod(declaringClass, methodName, method) == null : "found more than one method named " + methodName + " in " + declaringClass; |
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
504 ResolvedJavaMethod javaMethod = providers.getMetaAccess().lookupJavaMethod(method); |
13146
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13131
diff
changeset
|
505 providers.getReplacements().registerSnippet(javaMethod); |
17140
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
506 if (LAZY_SNIPPETS) { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
507 return new LazySnippetInfo(javaMethod); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
508 } else { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
509 return new EagerSnippetInfo(javaMethod); |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
510 } |
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:
diff
changeset
|
511 } |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
512 |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
513 /** |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
514 * Gets a template for a given key, creating it first if necessary. |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
515 */ |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
516 protected SnippetTemplate template(final Arguments args) { |
12707
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
517 SnippetTemplate template = UseSnippetTemplateCache ? templates.get(args.cacheKey) : null; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
518 if (template == null) { |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
519 SnippetTemplates.increment(); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
520 try (TimerCloseable a = SnippetTemplateCreationTime.start(); Scope s = Debug.scope("SnippetSpecialization", args.info.method)) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
521 template = new SnippetTemplate(providers, snippetReflection, args); |
12707
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
522 if (UseSnippetTemplateCache) { |
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
523 templates.put(args.cacheKey, template); |
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
524 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
525 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
526 throw Debug.handle(e); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
527 } |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
528 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
529 return template; |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
530 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
531 } |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
532 |
18643
3e71078c2efe
converted use of '==' to .equals() to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18583
diff
changeset
|
533 // These values must be compared with equals() not '==' to support replay compilation. |
3e71078c2efe
converted use of '==' to .equals() to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18583
diff
changeset
|
534 private static final Object UNUSED_PARAMETER = "UNUSED_PARAMETER"; |
3e71078c2efe
converted use of '==' to .equals() to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18583
diff
changeset
|
535 private static final Object CONSTANT_PARAMETER = "CONSTANT_PARAMETER"; |
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:
diff
changeset
|
536 |
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:
diff
changeset
|
537 /** |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
538 * Determines if any parameter of a given method is annotated with {@link ConstantParameter}. |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
539 */ |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
540 public static boolean hasConstantParameter(ResolvedJavaMethod method) { |
16488
890d25ac05c3
moved getParameterAnnotations(Class<T> annotationClass, ResolvedJavaMethod method) from MetaUtil to be a default method in ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16480
diff
changeset
|
541 for (ConstantParameter p : method.getParameterAnnotations(ConstantParameter.class)) { |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
542 if (p != null) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
543 return true; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
544 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
545 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
546 return false; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
547 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
548 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
549 private final SnippetReflectionProvider snippetReflection; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
550 |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
551 /** |
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:
diff
changeset
|
552 * Creates a snippet template. |
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:
diff
changeset
|
553 */ |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
554 protected SnippetTemplate(final Providers providers, SnippetReflectionProvider snippetReflection, Arguments args) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
555 this.snippetReflection = snippetReflection; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
556 |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
557 StructuredGraph snippetGraph = providers.getReplacements().getSnippet(args.info.method); |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
558 instantiationTimer = Debug.timer("SnippetTemplateInstantiationTime[%#s]", args); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
559 instantiationCounter = Debug.metric("SnippetTemplateInstantiationCount[%#s]", args); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
560 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
561 ResolvedJavaMethod method = snippetGraph.method(); |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6534
diff
changeset
|
562 Signature signature = method.getSignature(); |
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:
diff
changeset
|
563 |
13286
a3c559c0e460
SnippetTemplates does not use assumptions any more
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13282
diff
changeset
|
564 PhaseContext phaseContext = new PhaseContext(providers, new Assumptions(false)); |
11572
a63b63822183
Pass canonicalizer into loop transformations.
Roland Schatz <roland.schatz@oracle.com>
parents:
11569
diff
changeset
|
565 |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5719
diff
changeset
|
566 // Copy snippet graph, replacing constant parameters with given arguments |
11798
2fbb9fd55dde
made lowering recursive instead of iterative
Doug Simon <doug.simon@oracle.com>
parents:
11768
diff
changeset
|
567 final StructuredGraph snippetCopy = new StructuredGraph(snippetGraph.name, snippetGraph.method()); |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18362
diff
changeset
|
568 Map<Node, Node> nodeReplacements = Node.newIdentityMap(); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8606
diff
changeset
|
569 nodeReplacements.put(snippetGraph.start(), snippetCopy.start()); |
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:
diff
changeset
|
570 |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
571 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
572 assert checkTemplate(metaAccess, args, method, signature); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
573 |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
574 int parameterCount = args.info.getParameterCount(); |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
575 VarargsPlaceholderNode[] placeholders = new VarargsPlaceholderNode[parameterCount]; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
576 |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
577 for (int i = 0; i < parameterCount; i++) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
578 if (args.info.isConstantParameter(i)) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
579 Object arg = args.values[i]; |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6534
diff
changeset
|
580 Kind kind = signature.getParameterKind(i); |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
581 ConstantNode constantNode; |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
582 if (arg instanceof Constant) { |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
583 Stamp stamp = args.constStamps[i]; |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
584 if (stamp == null) { |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
585 assert arg instanceof JavaConstant : "could not determine type of constant " + arg; |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
586 constantNode = ConstantNode.forConstant((JavaConstant) arg, metaAccess, snippetCopy); |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
587 } else { |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
588 constantNode = ConstantNode.forConstant(stamp, (Constant) arg, metaAccess, snippetCopy); |
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
589 } |
7141
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
590 } else { |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
591 constantNode = ConstantNode.forConstant(snippetReflection.forBoxed(kind, arg), metaAccess, snippetCopy); |
7141
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
592 } |
18362
ea0fbb571466
Use pointer stamps in LoadHub and LoadMethod.
Roland Schatz <roland.schatz@oracle.com>
parents:
18231
diff
changeset
|
593 nodeReplacements.put(snippetGraph.getParameter(i), constantNode); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
594 } else if (args.info.isVarargsParameter(i)) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
595 Varargs varargs = (Varargs) args.values[i]; |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
596 VarargsPlaceholderNode placeholder = snippetCopy.unique(new VarargsPlaceholderNode(varargs, providers.getMetaAccess())); |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
597 nodeReplacements.put(snippetGraph.getParameter(i), placeholder); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
598 placeholders[i] = placeholder; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
599 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
600 } |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11572
diff
changeset
|
601 snippetCopy.addDuplicates(snippetGraph.getNodes(), snippetGraph, snippetGraph.getNodeCount(), nodeReplacements); |
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:
diff
changeset
|
602 |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
603 Debug.dump(snippetCopy, "Before specialization"); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8606
diff
changeset
|
604 if (!nodeReplacements.isEmpty()) { |
13222
de8f74d49690
rename Replacements.prepareSnippetCopyAfterInstantiation
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13197
diff
changeset
|
605 providers.getReplacements().notifyAfterConstantsBound(snippetCopy); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
606 } |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5428
diff
changeset
|
607 |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
608 // Gather the template parameters |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
609 parameters = new Object[parameterCount]; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
610 for (int i = 0; i < parameterCount; i++) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
611 if (args.info.isConstantParameter(i)) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
612 parameters[i] = CONSTANT_PARAMETER; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
613 } else if (args.info.isVarargsParameter(i)) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
614 assert snippetCopy.getParameter(i) == null; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
615 Varargs varargs = (Varargs) args.values[i]; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
616 int length = varargs.length; |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
617 ParameterNode[] params = new ParameterNode[length]; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
618 Stamp stamp = varargs.stamp; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
619 for (int j = 0; j < length; j++) { |
13932
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
620 // Use a decimal friendly numbering make it more obvious how values map |
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
621 assert parameterCount < 10000; |
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
622 int idx = (i + 1) * 10000 + j; |
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
623 assert idx >= parameterCount : "collision in parameter numbering"; |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
624 ParameterNode local = snippetCopy.unique(new ParameterNode(idx, stamp)); |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
625 params[j] = local; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
626 } |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
627 parameters[i] = params; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
628 |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
629 VarargsPlaceholderNode placeholder = placeholders[i]; |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
630 assert placeholder != null; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
631 for (Node usage : placeholder.usages().snapshot()) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
632 if (usage instanceof LoadIndexedNode) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
633 LoadIndexedNode loadIndexed = (LoadIndexedNode) usage; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
634 Debug.dump(snippetCopy, "Before replacing %s", loadIndexed); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
635 LoadSnippetVarargParameterNode loadSnippetParameter = snippetCopy.add(new LoadSnippetVarargParameterNode(params, loadIndexed.index(), loadIndexed.stamp())); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
636 snippetCopy.replaceFixedWithFixed(loadIndexed, loadSnippetParameter); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
637 Debug.dump(snippetCopy, "After replacing %s", loadIndexed); |
13932
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
638 } else if (usage instanceof StoreIndexedNode) { |
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
639 // The template lowering doesn't really treat this as an array so you can't |
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
640 // store back into the varargs. Allocate your own array if you really need |
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
641 // this and EA should eliminate it. |
0e7841cf749c
a few stronger asserts in snipppet expansion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13794
diff
changeset
|
642 throw new GraalInternalError("Can't store into VarargsParameter array"); |
5482
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
643 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
644 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
645 } else { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
646 ParameterNode local = snippetCopy.getParameter(i); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
647 if (local == null) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
648 // Parameter value was eliminated |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
649 parameters[i] = UNUSED_PARAMETER; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
650 } else { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
651 parameters[i] = local; |
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:
diff
changeset
|
652 } |
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:
diff
changeset
|
653 } |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
654 } |
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:
diff
changeset
|
655 |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
656 // Do any required loop explosion |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
657 boolean exploded = false; |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
658 do { |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
659 exploded = false; |
5490 | 660 ExplodeLoopNode explodeLoop = snippetCopy.getNodes().filter(ExplodeLoopNode.class).first(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
661 if (explodeLoop != null) { // Earlier canonicalization may have removed the loop |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
662 // altogether |
5490 | 663 LoopBeginNode loopBegin = explodeLoop.findLoopBegin(); |
664 if (loopBegin != null) { | |
665 LoopEx loop = new LoopsData(snippetCopy).loop(loopBegin); | |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
666 Mark mark = snippetCopy.getMark(); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
667 LoopTransformations.fullUnroll(loop, phaseContext, new CanonicalizerPhase(true)); |
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
668 new CanonicalizerPhase(true).applyIncremental(snippetCopy, phaseContext, mark); |
16194
7fb828b4c32b
made LoopsData clients clean up dead nodes created during loop analysis
Doug Simon <doug.simon@oracle.com>
parents:
16097
diff
changeset
|
669 loop.deleteUnusedNodes(); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
670 } |
13794
2eb56f87b01e
add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents:
13692
diff
changeset
|
671 GraphUtil.removeFixedWithUnusedInputs(explodeLoop); |
5490 | 672 exploded = true; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
673 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
674 } while (exploded); |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
675 |
13287
9b053d478a4e
Use the appropriate phases in order to change the guards stage
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13286
diff
changeset
|
676 GuardsStage guardsStage = args.cacheKey.guardsStage; |
11732
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
677 // Perform lowering on the snippet |
13287
9b053d478a4e
Use the appropriate phases in order to change the guards stage
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13286
diff
changeset
|
678 if (guardsStage.ordinal() >= GuardsStage.FIXED_DEOPTS.ordinal()) { |
9b053d478a4e
Use the appropriate phases in order to change the guards stage
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13286
diff
changeset
|
679 new GuardLoweringPhase().apply(snippetCopy, null); |
9b053d478a4e
Use the appropriate phases in order to change the guards stage
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13286
diff
changeset
|
680 } |
9b053d478a4e
Use the appropriate phases in order to change the guards stage
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13286
diff
changeset
|
681 snippetCopy.setGuardsStage(guardsStage); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
682 try (Scope s = Debug.scope("LoweringSnippetTemplate", snippetCopy)) { |
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:
13287
diff
changeset
|
683 new LoweringPhase(new CanonicalizerPhase(true), args.cacheKey.loweringStage).apply(snippetCopy, phaseContext); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
684 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
685 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
686 } |
11732
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
687 |
03c781923573
made snippet and substitution graphs lower themselves before being inlined
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
688 // Remove all frame states from snippet graph. Snippets must be atomic (i.e. free |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
689 // of side-effects that prevent deoptimizing to a point before the snippet). |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
690 ArrayList<StateSplit> curSideEffectNodes = new ArrayList<>(); |
10667
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
691 ArrayList<DeoptimizingNode> curDeoptNodes = new ArrayList<>(); |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
692 ArrayList<ValueNode> curStampNodes = new ArrayList<>(); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
693 for (Node node : snippetCopy.getNodes()) { |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
694 if (node instanceof ValueNode && ((ValueNode) node).stamp() == StampFactory.forNodeIntrinsic()) { |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
695 curStampNodes.add((ValueNode) node); |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
696 } |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
697 if (node instanceof StateSplit) { |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
698 StateSplit stateSplit = (StateSplit) node; |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
699 FrameState frameState = stateSplit.stateAfter(); |
6534
feb579677b58
SnippetTemplate must not depend on CodeCacheProvider (only on MetaAccessProvider). This means that the hasSideEffect flag of a RuntimeCall must be already fixed in the RuntimeCall.Descriptor to avoid a lookup of the actual RuntimeCall using the CodeCacheProvider.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
700 if (stateSplit.hasSideEffect()) { |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
701 curSideEffectNodes.add((StateSplit) node); |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
702 } |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
703 if (frameState != null) { |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
704 stateSplit.setStateAfter(null); |
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:
diff
changeset
|
705 } |
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:
diff
changeset
|
706 } |
10667
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
707 if (node instanceof DeoptimizingNode) { |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
708 DeoptimizingNode deoptNode = (DeoptimizingNode) node; |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
709 if (deoptNode.canDeoptimize()) { |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
710 curDeoptNodes.add(deoptNode); |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
711 } |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
712 } |
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:
diff
changeset
|
713 } |
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:
diff
changeset
|
714 |
17094
86888df288ec
fixed case of Optionality constants
Doug Simon <doug.simon@oracle.com>
parents:
17065
diff
changeset
|
715 new DeadCodeEliminationPhase(Required).apply(snippetCopy); |
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:
diff
changeset
|
716 |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
717 assert checkAllVarargPlaceholdersAreDeleted(parameterCount, placeholders); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
718 |
16460
1da834bdfda2
let FloatingReadPhase deal with existing MemoryPhiNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16299
diff
changeset
|
719 new FloatingReadPhase(false, true, false).apply(snippetCopy); |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
720 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
721 MemoryAnchorNode memoryAnchor = snippetCopy.add(new MemoryAnchorNode()); |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
722 snippetCopy.start().replaceAtUsages(InputType.Memory, memoryAnchor); |
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
723 |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
724 this.snippet = snippetCopy; |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
725 |
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
726 Debug.dump(snippet, "SnippetTemplate after fixing memory anchoring"); |
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
727 |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
728 StartNode entryPointNode = snippet.start(); |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
729 if (memoryAnchor.usages().isEmpty()) { |
15595
804326a882f0
don't delete snippet MemoryAnchorNodes if they are used in the memory map
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15551
diff
changeset
|
730 memoryAnchor.safeDelete(); |
804326a882f0
don't delete snippet MemoryAnchorNodes if they are used in the memory map
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15551
diff
changeset
|
731 } else { |
804326a882f0
don't delete snippet MemoryAnchorNodes if they are used in the memory map
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15551
diff
changeset
|
732 snippetCopy.addAfterFixed(snippetCopy.start(), memoryAnchor); |
804326a882f0
don't delete snippet MemoryAnchorNodes if they are used in the memory map
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15551
diff
changeset
|
733 } |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
734 List<ReturnNode> returnNodes = snippet.getNodes(ReturnNode.class).snapshot(); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
735 if (returnNodes.isEmpty()) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
736 this.returnNode = null; |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
737 } else if (returnNodes.size() == 1) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
738 this.returnNode = returnNodes.get(0); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
739 } else { |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
740 MergeNode merge = snippet.add(new MergeNode()); |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
741 List<MemoryMapNode> memMaps = returnNodes.stream().map(n -> n.getMemoryMap()).collect(Collectors.toList()); |
16176
5785eca138b0
improve tracking of nodes to canonicalize after inlining
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16097
diff
changeset
|
742 ValueNode returnValue = InliningUtil.mergeReturns(merge, returnNodes, null); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
743 this.returnNode = snippet.add(new ReturnNode(returnValue)); |
16460
1da834bdfda2
let FloatingReadPhase deal with existing MemoryPhiNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16299
diff
changeset
|
744 MemoryMapImpl mmap = FloatingReadPhase.mergeMemoryMaps(merge, memMaps, false); |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18813
diff
changeset
|
745 MemoryMapNode memoryMap = snippet.unique(new MemoryMapNode(mmap.getMap())); |
16299
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
746 this.returnNode.setMemoryMap(memoryMap); |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
747 for (MemoryMapNode mm : memMaps) { |
16299
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
748 if (mm != memoryMap && mm.isAlive()) { |
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
749 assert mm.usages().isEmpty(); |
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
750 GraphUtil.killWithUnusedFloatingInputs(mm); |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
751 } |
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
752 } |
16299
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
753 merge.setNext(this.returnNode); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
754 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
755 |
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:
7015
diff
changeset
|
756 this.sideEffectNodes = curSideEffectNodes; |
10667
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
757 this.deoptNodes = curDeoptNodes; |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
758 this.stampNodes = curStampNodes; |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
759 |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
760 nodes = new ArrayList<>(snippet.getNodeCount()); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
761 for (Node node : snippet.getNodes()) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
762 if (node != entryPointNode && node != entryPointNode.stateAfter()) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
763 nodes.add(node); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
764 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
765 } |
12707
3b2b8a71d10d
added ability to disable snippet template cache (-Dgraal.useSnippetTemplateCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12703
diff
changeset
|
766 |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
767 Debug.metric("SnippetTemplateNodeCount[%#s]", args).add(nodes.size()); |
12733
8d8d9d0b04bb
added check (with warning on System.err) if number of templates for a snippet exceeds a threshold (default is 50)
Doug Simon <doug.simon@oracle.com>
parents:
12731
diff
changeset
|
768 args.info.notifyNewTemplate(); |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
769 Debug.dump(snippet, "SnippetTemplate final state"); |
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:
diff
changeset
|
770 } |
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:
diff
changeset
|
771 |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12549
diff
changeset
|
772 private static boolean checkAllVarargPlaceholdersAreDeleted(int parameterCount, VarargsPlaceholderNode[] placeholders) { |
5482
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
773 for (int i = 0; i < parameterCount; i++) { |
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
774 if (placeholders[i] != null) { |
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
775 assert placeholders[i].isDeleted() : placeholders[i]; |
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
776 } |
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
777 } |
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
778 return true; |
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
779 } |
9f4783c0269e
folded -G:+CheckcastCounters functionality into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5481
diff
changeset
|
780 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
781 private static boolean checkConstantArgument(MetaAccessProvider metaAccess, final ResolvedJavaMethod method, Signature signature, int i, String name, Object arg, Kind kind) { |
7141
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
782 ResolvedJavaType type = signature.getParameterType(i, method.getDeclaringClass()).resolve(method.getDeclaringClass()); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
783 if (metaAccess.lookupJavaType(WordBase.class).isAssignableFrom(type)) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
784 assert arg instanceof JavaConstant : method + ": word constant parameters must be passed boxed in a Constant value: " + arg; |
7141
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
785 return true; |
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
786 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
787 if (kind != Kind.Object) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
788 assert arg != null && kind.toBoxedJavaClass() == arg.getClass() : method + ": wrong value kind for " + name + ": expected " + kind + ", got " + |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
789 (arg == null ? "null" : arg.getClass().getSimpleName()); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
790 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
791 return true; |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
792 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
793 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
794 private static boolean checkVarargs(MetaAccessProvider metaAccess, final ResolvedJavaMethod method, Signature signature, int i, String name, Varargs varargs) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6534
diff
changeset
|
795 ResolvedJavaType type = (ResolvedJavaType) signature.getParameterType(i, method.getDeclaringClass()); |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7034
diff
changeset
|
796 assert type.isArray() : "varargs parameter must be an array type"; |
16479
558cf39c646b
moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents:
16477
diff
changeset
|
797 assert type.getComponentType().isAssignableFrom(metaAccess.lookupJavaType(varargs.componentType)) : "componentType for " + name + " not matching " + type.toJavaName() + " instance: " + |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
798 varargs.componentType; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
799 return true; |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
800 } |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
801 |
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:
diff
changeset
|
802 /** |
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:
diff
changeset
|
803 * The graph built from the snippet method. |
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:
diff
changeset
|
804 */ |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
805 private final StructuredGraph snippet; |
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:
diff
changeset
|
806 |
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:
diff
changeset
|
807 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
808 * The named parameters of this template that must be bound to values during instantiation. For |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
809 * a parameter that is still live after specialization, the value in this map is either a |
13616 | 810 * {@link ParameterNode} instance or a {@link ParameterNode} array. For an eliminated parameter, |
811 * the value is identical to the key. | |
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:
diff
changeset
|
812 */ |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
813 private final Object[] parameters; |
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:
diff
changeset
|
814 |
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:
diff
changeset
|
815 /** |
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:
diff
changeset
|
816 * The return node (if any) of the snippet. |
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:
diff
changeset
|
817 */ |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
818 private final ReturnNode returnNode; |
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:
diff
changeset
|
819 |
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:
diff
changeset
|
820 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
821 * Nodes that inherit the {@link StateSplit#stateAfter()} from the replacee during |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
822 * instantiation. |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
823 */ |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
824 private final ArrayList<StateSplit> sideEffectNodes; |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
825 |
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
826 /** |
14734
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
827 * Nodes that inherit a deoptimization {@link FrameState} from the replacee during |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
828 * instantiation. |
10667
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
829 */ |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
830 private final ArrayList<DeoptimizingNode> deoptNodes; |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
831 |
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
832 /** |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
833 * The nodes that inherit the {@link ValueNode#stamp()} from the replacee during instantiation. |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
834 */ |
7546
727e869891fc
let CheckCastSnippets insert UnsafeCastNodes (so that type stays visible during lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
835 private final ArrayList<ValueNode> stampNodes; |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
836 |
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
837 /** |
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:
diff
changeset
|
838 * The nodes to be inlined when this specialization is instantiated. |
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:
diff
changeset
|
839 */ |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
840 private final ArrayList<Node> nodes; |
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:
diff
changeset
|
841 |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
842 /** |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
843 * Times instantiations of this template. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
844 * |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
845 * @see SnippetInfo#instantiationTimer |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
846 */ |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
847 private final DebugTimer instantiationTimer; |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
848 |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
849 /** |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
850 * Counts instantiations of this template. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
851 * |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
852 * @see SnippetInfo#instantiationCounter |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
853 */ |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
854 private final DebugMetric instantiationCounter; |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
855 |
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
856 /** |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
857 * Gets the instantiation-time bindings to this template's parameters. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
858 * |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
859 * @return the map that will be used to bind arguments to parameters when inlining this template |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
860 */ |
15551
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
861 private Map<Node, Node> bind(StructuredGraph replaceeGraph, MetaAccessProvider metaAccess, Arguments args) { |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18362
diff
changeset
|
862 Map<Node, Node> replacements = Node.newIdentityMap(); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
863 assert args.info.getParameterCount() == parameters.length : "number of args (" + args.info.getParameterCount() + ") != number of parameters (" + parameters.length + ")"; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
864 for (int i = 0; i < parameters.length; i++) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
865 Object parameter = parameters[i]; |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
866 assert parameter != null : this + " has no parameter named " + args.info.getParameterName(i); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
867 Object argument = args.values[i]; |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
868 if (parameter instanceof ParameterNode) { |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
869 if (argument instanceof ValueNode) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
870 replacements.put((ParameterNode) parameter, (ValueNode) argument); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
871 } else { |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14616
diff
changeset
|
872 Kind kind = ((ParameterNode) parameter).getKind(); |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
873 assert argument != null || kind == Kind.Object : this + " cannot accept null for non-object parameter named " + args.info.getParameterName(i); |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
874 JavaConstant constant = forBoxed(argument, kind); |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
875 replacements.put((ParameterNode) parameter, ConstantNode.forConstant(constant, metaAccess, replaceeGraph)); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
876 } |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
877 } else if (parameter instanceof ParameterNode[]) { |
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
878 ParameterNode[] params = (ParameterNode[]) parameter; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
879 Varargs varargs = (Varargs) argument; |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
880 int length = params.length; |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
881 List<?> list = null; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
882 Object array = null; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
883 if (varargs.value instanceof List) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
884 list = (List<?>) varargs.value; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
885 assert list.size() == length : length + " != " + list.size(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
886 } else { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
887 array = varargs.value; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
888 assert array != null && array.getClass().isArray(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
889 assert Array.getLength(array) == length : length + " != " + Array.getLength(array); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
890 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
891 |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
892 for (int j = 0; j < length; j++) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
893 ParameterNode param = params[j]; |
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
894 assert param != null; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
895 Object value = list != null ? list.get(j) : Array.get(array, j); |
6431
2e376f8ea4e2
added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents:
6408
diff
changeset
|
896 if (value instanceof ValueNode) { |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
897 replacements.put(param, (ValueNode) value); |
6431
2e376f8ea4e2
added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents:
6408
diff
changeset
|
898 } else { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
899 JavaConstant constant = forBoxed(value, param.getKind()); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
900 ConstantNode element = ConstantNode.forConstant(constant, metaAccess, replaceeGraph); |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
901 replacements.put(param, element); |
6431
2e376f8ea4e2
added snippet for lowering NewMultiArrayNodes
Doug Simon <doug.simon@oracle.com>
parents:
6408
diff
changeset
|
902 } |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
903 } |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7141
diff
changeset
|
904 } else { |
18643
3e71078c2efe
converted use of '==' to .equals() to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18583
diff
changeset
|
905 assert parameter.equals(CONSTANT_PARAMETER) || parameter.equals(UNUSED_PARAMETER) : "unexpected entry for parameter: " + args.info.getParameterName(i) + " -> " + parameter; |
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:
diff
changeset
|
906 } |
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:
diff
changeset
|
907 } |
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:
diff
changeset
|
908 return replacements; |
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:
diff
changeset
|
909 } |
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:
diff
changeset
|
910 |
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:
diff
changeset
|
911 /** |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
912 * Converts a Java boxed value to a {@link JavaConstant} of the right kind. This adjusts for the |
8908
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
913 * limitation that a {@link Local}'s kind is a {@linkplain Kind#getStackKind() stack kind} and |
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
914 * so cannot be used for re-boxing primitives smaller than an int. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
915 * |
8908
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
916 * @param argument a Java boxed value |
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
917 * @param localKind the kind of the {@link Local} to which {@code argument} will be bound |
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
918 */ |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
919 protected JavaConstant forBoxed(Object argument, Kind localKind) { |
8908
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
920 assert localKind == localKind.getStackKind(); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
921 if (localKind == Kind.Int) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18163
diff
changeset
|
922 return JavaConstant.forBoxedPrimitive(argument); |
8908
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
923 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
924 return snippetReflection.forBoxed(localKind, argument); |
8908
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
925 } |
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
926 |
b9fb1ecaad92
convert non-int boxed primitives whose stack kind is int to Constants of the right kind
Doug Simon <doug.simon@oracle.com>
parents:
8642
diff
changeset
|
927 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
928 * Logic for replacing a snippet-lowered node at its usages with the return value of the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
929 * snippet. An alternative to the {@linkplain SnippetTemplate#DEFAULT_REPLACER default} |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
930 * replacement logic can be used to handle mismatches between the stamp of the node being |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
931 * lowered and the stamp of the snippet's return value. |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
932 */ |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
933 public interface UsageReplacer { |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
934 /** |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
935 * Replaces all usages of {@code oldNode} with direct or indirect usages of {@code newNode}. |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
936 */ |
16227
ec17c588abf9
rename: MemoryMapNode -> MemoryMap
Doug Simon <doug.simon@oracle.com>
parents:
16201
diff
changeset
|
937 void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap); |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
938 } |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
939 |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
940 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
941 * Represents the default {@link UsageReplacer usage replacer} logic which simply delegates to |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
942 * {@link Node#replaceAtUsages(Node)}. |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
943 */ |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
944 public static final UsageReplacer DEFAULT_REPLACER = new UsageReplacer() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7313
diff
changeset
|
945 |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
946 private LocationIdentity getLocationIdentity(Node node) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
947 if (node instanceof MemoryAccess) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
948 return ((MemoryAccess) node).getLocationIdentity(); |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
949 } else if (node instanceof MemoryProxy) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
950 return ((MemoryProxy) node).getLocationIdentity(); |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
951 } else if (node instanceof MemoryPhiNode) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
952 return ((MemoryPhiNode) node).getLocationIdentity(); |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
953 } else { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
954 return null; |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
955 } |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
956 } |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
957 |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
958 @Override |
16227
ec17c588abf9
rename: MemoryMapNode -> MemoryMap
Doug Simon <doug.simon@oracle.com>
parents:
16201
diff
changeset
|
959 public void replace(ValueNode oldNode, ValueNode newNode, MemoryMap mmap) { |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
960 if (mmap != null) { |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
961 for (Node usage : oldNode.usages().snapshot()) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
962 LocationIdentity identity = getLocationIdentity(usage); |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
963 boolean usageReplaced = false; |
18231
70df63b02309
Use LocationIdentity.isImmutable instead of testing against FINAL_LOCATION
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18187
diff
changeset
|
964 if (identity != null && !identity.isImmutable()) { |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
965 // lastLocationAccess points into the snippet graph. find a proper |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
966 // MemoryCheckPoint inside the snippet graph |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
967 MemoryNode lastAccess = mmap.getLastLocationAccess(identity); |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
968 |
13691
056d9d7dc061
expose memory map merging functionality in FloatingReadPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
13623
diff
changeset
|
969 assert lastAccess != null : "no mapping found for lowerable node " + oldNode + ". (No node in the snippet kills the same location as the lowerable node?)"; |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
970 if (usage instanceof MemoryAccess) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
971 MemoryAccess access = (MemoryAccess) usage; |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
972 if (access.getLastLocationAccess() == oldNode) { |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
973 assert oldNode.graph().isAfterFloatingReadPhase(); |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
974 access.setLastLocationAccess(lastAccess); |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
975 usageReplaced = true; |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
976 } |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
977 } else { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
978 assert usage instanceof MemoryProxy || usage instanceof MemoryPhiNode; |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
979 usage.replaceFirstInput(oldNode, lastAccess.asNode()); |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
980 usageReplaced = true; |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
981 } |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
982 } |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
983 if (!usageReplaced) { |
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
984 assert newNode != null : "this branch is only valid if we have a newNode for replacement"; |
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
985 } |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
986 } |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
987 } |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
988 if (newNode == null) { |
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
989 assert oldNode.usages().isEmpty(); |
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
990 } else { |
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
991 oldNode.replaceAtUsages(newNode); |
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
992 } |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
993 } |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
994 }; |
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
995 |
18813
498a56d8bb9b
Remove IterableNodeType from FloatingReadNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18643
diff
changeset
|
996 private boolean assertSnippetKills(ScheduledNode replacee) { |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
997 if (!replacee.graph().isAfterFloatingReadPhase()) { |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
998 // no floating reads yet, ignore locations created while lowering |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
999 return true; |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1000 } |
17140
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
1001 if (returnNode == null) { |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
1002 // The snippet terminates control flow |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
1003 return true; |
f95ddcd3e08a
Allow customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents:
17094
diff
changeset
|
1004 } |
16299
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
1005 MemoryMapNode memoryMap = returnNode.getMemoryMap(); |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
1006 if (memoryMap == null || memoryMap.isEmpty()) { |
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
1007 // there are no kills in the snippet graph |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1008 return true; |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1009 } |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1010 |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
1011 Set<LocationIdentity> kills = new HashSet<>(memoryMap.getLocations()); |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1012 |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1013 if (replacee instanceof MemoryCheckpoint.Single) { |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1014 // check if some node in snippet graph also kills the same location |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1015 LocationIdentity locationIdentity = ((MemoryCheckpoint.Single) replacee).getLocationIdentity(); |
18583
12bd2b344b08
replace usages of == with .equals()
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
1016 if (locationIdentity.equals(ANY_LOCATION)) { |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
1017 assert !(memoryMap.getLastLocationAccess(ANY_LOCATION) instanceof MemoryAnchorNode) : replacee + " kills ANY_LOCATION, but snippet does not"; |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1018 } |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1019 assert kills.contains(locationIdentity) : replacee + " kills " + locationIdentity + ", but snippet doesn't contain a kill to this location"; |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1020 return true; |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1021 } |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1022 assert !(replacee instanceof MemoryCheckpoint.Multi) : replacee + " multi not supported (yet)"; |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1023 |
11802
82c4106741f7
SnippetTemplate: avoid two getNodes() in assertions. comment fix and renames
Bernhard Urban <bernhard.urban@jku.at>
parents:
11798
diff
changeset
|
1024 Debug.log("WARNING: %s is not a MemoryCheckpoint, but the snippet graph contains kills (%s). You might want %s to be a MemoryCheckpoint", replacee, kills, replacee); |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1025 |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1026 // remove ANY_LOCATION if it's just a kill by the start node |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
1027 if (memoryMap.getLastLocationAccess(ANY_LOCATION) instanceof MemoryAnchorNode) { |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1028 kills.remove(ANY_LOCATION); |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1029 } |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1030 |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1031 // node can only lower to a ANY_LOCATION kill if the replacee also kills ANY_LOCATION |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1032 assert !kills.contains(ANY_LOCATION) : "snippet graph contains a kill to ANY_LOCATION, but replacee (" + replacee + ") doesn't kill ANY_LOCATION. kills: " + kills; |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1033 |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1034 /* |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1035 * kills to other locations than ANY_LOCATION can be still inserted if there aren't any |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1036 * floating reads accessing this locations. Example: In HotSpot, InstanceOfNode is lowered |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1037 * to a snippet containing a write to SECONDARY_SUPER_CACHE_LOCATION. This is runtime |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1038 * specific, so the runtime independent InstanceOfNode can not kill this location. However, |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1039 * if no FloatingReadNode is reading from this location, the kill to this location is fine. |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1040 */ |
18813
498a56d8bb9b
Remove IterableNodeType from FloatingReadNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18643
diff
changeset
|
1041 for (FloatingReadNode frn : replacee.graph().getNodes().filter(FloatingReadNode.class)) { |
15363
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1042 LocationIdentity locationIdentity = frn.location().getLocationIdentity(); |
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1043 if (SnippetCounters.getValue()) { |
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1044 // accesses to snippet counters are artificially introduced and violate the memory |
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1045 // semantics. |
18583
12bd2b344b08
replace usages of == with .equals()
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
1046 if (locationIdentity.equals(SnippetCounter.SNIPPET_COUNTER_LOCATION)) { |
15363
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1047 continue; |
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1048 } |
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1049 } |
c279c6773799
snippet counter: fix location for counter access
Bernhard Urban <bernhard.urban@jku.at>
parents:
15311
diff
changeset
|
1050 assert !kills.contains(locationIdentity) : frn + " reads from location \"" + locationIdentity + "\" but " + replacee + " does not kill this location"; |
11768
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1051 } |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1052 return true; |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1053 } |
e53399f1b2cd
SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents:
11767
diff
changeset
|
1054 |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
1055 private class DuplicateMapper implements MemoryMap { |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1056 |
13131
5d4b75c35f59
Support lowering of control sink nodes; annotate parameters to make node class invariant checker happy
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
1057 private final Map<Node, Node> duplicates; |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
1058 private StartNode replaceeStart; |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1059 |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1060 public DuplicateMapper(Map<Node, Node> duplicates, StartNode replaceeStart) { |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1061 this.duplicates = duplicates; |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1062 this.replaceeStart = replaceeStart; |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1063 } |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1064 |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1065 @Override |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
1066 public MemoryNode getLastLocationAccess(LocationIdentity locationIdentity) { |
16299
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
1067 MemoryMapNode memoryMap = returnNode.getMemoryMap(); |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1068 assert memoryMap != null : "no memory map stored for this snippet graph (snippet doesn't have a ReturnNode?)"; |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
1069 MemoryNode lastLocationAccess = memoryMap.getLastLocationAccess(locationIdentity); |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1070 assert lastLocationAccess != null; |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1071 if (lastLocationAccess instanceof StartNode) { |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1072 return replaceeStart; |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1073 } else { |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13146
diff
changeset
|
1074 return (MemoryNode) duplicates.get(ValueNodeUtil.asNode(lastLocationAccess)); |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1075 } |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1076 } |
13691
056d9d7dc061
expose memory map merging functionality in FloatingReadPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
13623
diff
changeset
|
1077 |
056d9d7dc061
expose memory map merging functionality in FloatingReadPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
13623
diff
changeset
|
1078 @Override |
16230
5f72421928e0
converted MemoryMap to an interface and provided new MemoryMapNode implementation that is also a Node allowing the map and it's node entries to survive DeadCodeElimination by normal graph reachability rules
Doug Simon <doug.simon@oracle.com>
parents:
16227
diff
changeset
|
1079 public Collection<LocationIdentity> getLocations() { |
16299
732a9e80e8dc
ensure memory map (if any) for a snippet template is attached to the returnNode
Doug Simon <doug.simon@oracle.com>
parents:
16238
diff
changeset
|
1080 return returnNode.getMemoryMap().getLocations(); |
13691
056d9d7dc061
expose memory map merging functionality in FloatingReadPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
13623
diff
changeset
|
1081 } |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1082 } |
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1083 |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
1084 /** |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1085 * Replaces a given fixed node with this specialized snippet. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
1086 * |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
1087 * @param metaAccess |
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:
diff
changeset
|
1088 * @param replacee the node that will be replaced |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
1089 * @param replacer object that replaces the usages of {@code replacee} |
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:
diff
changeset
|
1090 * @param args the arguments to be bound to the flattened positional parameters of the snippet |
14906 | 1091 * @return the map of duplicated nodes (original -> duplicate) |
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:
diff
changeset
|
1092 */ |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
1093 public Map<Node, Node> instantiate(MetaAccessProvider metaAccess, FixedNode replacee, UsageReplacer replacer, Arguments args) { |
18813
498a56d8bb9b
Remove IterableNodeType from FloatingReadNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18643
diff
changeset
|
1094 assert assertSnippetKills(replacee); |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
1095 try (TimerCloseable a = args.info.instantiationTimer.start(); TimerCloseable b = instantiationTimer.start()) { |
12507
d72864a2886e
moved snippet timers/metrics from SnippetTemplate to SnippetInfo and added new metric for number of snippet specializations (i.e. number of SnippetTemplate objects created)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
1096 args.info.instantiationCounter.increment(); |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
1097 instantiationCounter.increment(); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1098 // Inline the snippet nodes, replacing parameters with the given args in the process |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1099 StartNode entryPointNode = snippet.start(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1100 FixedNode firstCFGNode = entryPointNode.next(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1101 StructuredGraph replaceeGraph = replacee.graph(); |
15551
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
1102 Map<Node, Node> replacements = bind(replaceeGraph, metaAccess, args); |
12703
b6f66fb9f106
SnippetTemplate instantiation should replace snippet's start node with a valid anchor point not the caller's start node
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12686
diff
changeset
|
1103 replacements.put(entryPointNode, BeginNode.prevBegin(replacee)); |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11572
diff
changeset
|
1104 Map<Node, Node> duplicates = replaceeGraph.addDuplicates(nodes, snippet, snippet.getNodeCount(), replacements); |
11692
8b3a2258b368
Remove unused allocated graph in snippet instantiation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11675
diff
changeset
|
1105 Debug.dump(replaceeGraph, "After inlining snippet %s", snippet.method()); |
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:
diff
changeset
|
1106 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1107 // Re-wire the control flow graph around the replacee |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1108 FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1109 replacee.replaceAtPredecessor(firstCFGNodeDuplicate); |
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:
diff
changeset
|
1110 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1111 if (replacee instanceof StateSplit) { |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1112 for (StateSplit sideEffectNode : sideEffectNodes) { |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1113 assert ((StateSplit) replacee).hasSideEffect(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1114 Node sideEffectDup = duplicates.get(sideEffectNode); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1115 ((StateSplit) sideEffectDup).setStateAfter(((StateSplit) replacee).stateAfter()); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1116 } |
10667
5348b49b2a76
Assign framestates in snippet lowering after framestate assignment.
Roland Schatz <roland.schatz@oracle.com>
parents:
10422
diff
changeset
|
1117 } |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
1118 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1119 if (replacee instanceof DeoptimizingNode) { |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1120 DeoptimizingNode replaceeDeopt = (DeoptimizingNode) replacee; |
14734
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1121 |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1122 FrameState stateBefore = null; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1123 FrameState stateDuring = null; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1124 FrameState stateAfter = null; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1125 if (replaceeDeopt.canDeoptimize()) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1126 if (replaceeDeopt instanceof DeoptimizingNode.DeoptBefore) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1127 stateBefore = ((DeoptimizingNode.DeoptBefore) replaceeDeopt).stateBefore(); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1128 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1129 if (replaceeDeopt instanceof DeoptimizingNode.DeoptDuring) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1130 stateDuring = ((DeoptimizingNode.DeoptDuring) replaceeDeopt).stateDuring(); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1131 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1132 if (replaceeDeopt instanceof DeoptimizingNode.DeoptAfter) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1133 stateAfter = ((DeoptimizingNode.DeoptAfter) replaceeDeopt).stateAfter(); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1134 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1135 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1136 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1137 for (DeoptimizingNode deoptNode : deoptNodes) { |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1138 DeoptimizingNode deoptDup = (DeoptimizingNode) duplicates.get(deoptNode); |
14734
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1139 if (deoptDup.canDeoptimize()) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1140 if (deoptDup instanceof DeoptimizingNode.DeoptBefore) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1141 ((DeoptimizingNode.DeoptBefore) deoptDup).setStateBefore(stateBefore); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1142 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1143 if (deoptDup instanceof DeoptimizingNode.DeoptDuring) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1144 DeoptimizingNode.DeoptDuring deoptDupDuring = (DeoptimizingNode.DeoptDuring) deoptDup; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1145 if (stateDuring != null) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1146 deoptDupDuring.setStateDuring(stateDuring); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1147 } else if (stateAfter != null) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1148 deoptDupDuring.computeStateDuring(stateAfter); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1149 } else if (stateBefore != null) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1150 assert !deoptDupDuring.hasSideEffect() : "can't use stateBefore as stateDuring for state split " + deoptDupDuring; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1151 deoptDupDuring.setStateDuring(stateBefore); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1152 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1153 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1154 if (deoptDup instanceof DeoptimizingNode.DeoptAfter) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1155 DeoptimizingNode.DeoptAfter deoptDupAfter = (DeoptimizingNode.DeoptAfter) deoptDup; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1156 if (stateAfter != null) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1157 deoptDupAfter.setStateAfter(stateAfter); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1158 } else { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1159 assert !deoptDupAfter.hasSideEffect() : "can't use stateBefore as stateAfter for state split " + deoptDupAfter; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1160 deoptDupAfter.setStateAfter(stateBefore); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1161 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1162 |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1163 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14633
diff
changeset
|
1164 } |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1165 } |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1166 } |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1167 |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1168 updateStamps(replacee, duplicates); |
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:
diff
changeset
|
1169 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1170 // Replace all usages of the replacee with the value returned by the snippet |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1171 ValueNode returnValue = null; |
13131
5d4b75c35f59
Support lowering of control sink nodes; annotate parameters to make node class invariant checker happy
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
1172 if (returnNode != null && !(replacee instanceof ControlSinkNode)) { |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1173 ReturnNode returnDuplicate = (ReturnNode) duplicates.get(returnNode); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1174 returnValue = returnDuplicate.result(); |
16227
ec17c588abf9
rename: MemoryMapNode -> MemoryMap
Doug Simon <doug.simon@oracle.com>
parents:
16201
diff
changeset
|
1175 MemoryMap mmap = new DuplicateMapper(duplicates, replaceeGraph.start()); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1176 if (returnValue == null && replacee.usages().isNotEmpty() && replacee instanceof MemoryCheckpoint) { |
14541
145b31ba9a57
SnippetTemplate: don't use dummy node for replace
Bernhard Urban <bernhard.urban@jku.at>
parents:
14160
diff
changeset
|
1177 replacer.replace(replacee, null, mmap); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1178 } else { |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1179 assert returnValue != null || replacee.usages().isEmpty(); |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1180 replacer.replace(replacee, returnValue, mmap); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1181 } |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1182 if (returnDuplicate.isAlive()) { |
14548
e1a2302a42bc
Improve cleanup during snippet lowering where the snippet never returns normally (unwind, deopt...)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14541
diff
changeset
|
1183 FixedNode next = null; |
e1a2302a42bc
Improve cleanup during snippet lowering where the snippet never returns normally (unwind, deopt...)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14541
diff
changeset
|
1184 if (replacee instanceof FixedWithNextNode) { |
e1a2302a42bc
Improve cleanup during snippet lowering where the snippet never returns normally (unwind, deopt...)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14541
diff
changeset
|
1185 FixedWithNextNode fwn = (FixedWithNextNode) replacee; |
e1a2302a42bc
Improve cleanup during snippet lowering where the snippet never returns normally (unwind, deopt...)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14541
diff
changeset
|
1186 next = fwn.next(); |
e1a2302a42bc
Improve cleanup during snippet lowering where the snippet never returns normally (unwind, deopt...)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14541
diff
changeset
|
1187 fwn.setNext(null); |
e1a2302a42bc
Improve cleanup during snippet lowering where the snippet never returns normally (unwind, deopt...)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14541
diff
changeset
|
1188 } |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1189 returnDuplicate.replaceAndDelete(next); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1190 } |
9879
bf6943c12840
allow for late lowering of MemoryCheckpoints (handle usages by FloatingReads in SnippetTemplate)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9602
diff
changeset
|
1191 } |
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:
diff
changeset
|
1192 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1193 // Remove the replacee from its graph |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1194 GraphUtil.killCFG(replacee); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1195 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1196 Debug.dump(replaceeGraph, "After lowering %s with %s", replacee, this); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1197 return duplicates; |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1198 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1199 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1200 |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1201 private void propagateStamp(Node node) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1202 if (node instanceof PhiNode) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1203 PhiNode phi = (PhiNode) node; |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14906
diff
changeset
|
1204 if (phi.inferStamp()) { |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1205 for (Node usage : node.usages()) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1206 propagateStamp(usage); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1207 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1208 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1209 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1210 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1211 |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1212 private void updateStamps(ValueNode replacee, Map<Node, Node> duplicates) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1213 for (ValueNode stampNode : stampNodes) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1214 Node stampDup = duplicates.get(stampNode); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1215 ((ValueNode) stampDup).setStamp(replacee.stamp()); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1216 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1217 for (ParameterNode paramNode : snippet.getNodes(ParameterNode.class)) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1218 for (Node usage : paramNode.usages()) { |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1219 Node usageDup = duplicates.get(usage); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1220 propagateStamp(usageDup); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1221 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1222 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1223 } |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1224 |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1225 /** |
7141
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
1226 * Gets a copy of the specialized graph. |
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
1227 */ |
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
1228 public StructuredGraph copySpecializedGraph() { |
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
1229 return snippet.copy(); |
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
1230 } |
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
1231 |
c85aecfee9e4
made snippet template specialization support ConstantParameters of type Word
Doug Simon <doug.simon@oracle.com>
parents:
7099
diff
changeset
|
1232 /** |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1233 * Replaces a given floating node with this specialized snippet. |
15003
4b1f128a3d45
create memory anchor for snippet StartNodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14978
diff
changeset
|
1234 * |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
1235 * @param metaAccess |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1236 * @param replacee the node that will be replaced |
6568
d8408e5563e5
added indirection for the replacement of a snippet-lowered node with the snippet's return value
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
1237 * @param replacer object that replaces the usages of {@code replacee} |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1238 * @param args the arguments to be bound to the flattened positional parameters of the snippet |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1239 */ |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
1240 public void instantiate(MetaAccessProvider metaAccess, FloatingNode replacee, UsageReplacer replacer, LoweringTool tool, Arguments args) { |
18813
498a56d8bb9b
Remove IterableNodeType from FloatingReadNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18643
diff
changeset
|
1241 assert assertSnippetKills(replacee); |
12507
d72864a2886e
moved snippet timers/metrics from SnippetTemplate to SnippetInfo and added new metric for number of snippet specializations (i.e. number of SnippetTemplate objects created)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
1242 try (TimerCloseable a = args.info.instantiationTimer.start()) { |
d72864a2886e
moved snippet timers/metrics from SnippetTemplate to SnippetInfo and added new metric for number of snippet specializations (i.e. number of SnippetTemplate objects created)
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
1243 args.info.instantiationCounter.increment(); |
12716
c6b7f982e949
added per SnippetTemplate instantiation timer and counter
Doug Simon <doug.simon@oracle.com>
parents:
12707
diff
changeset
|
1244 instantiationCounter.increment(); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1245 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1246 // Inline the snippet nodes, replacing parameters with the given args in the process |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1247 String name = snippet.name == null ? "{copy}" : snippet.name + "{copy}"; |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1248 StructuredGraph snippetCopy = new StructuredGraph(name, snippet.method()); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1249 StartNode entryPointNode = snippet.start(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1250 FixedNode firstCFGNode = entryPointNode.next(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1251 StructuredGraph replaceeGraph = replacee.graph(); |
15551
33cedbce5b23
added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
1252 Map<Node, Node> replacements = bind(replaceeGraph, metaAccess, args); |
12703
b6f66fb9f106
SnippetTemplate instantiation should replace snippet's start node with a valid anchor point not the caller's start node
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12686
diff
changeset
|
1253 replacements.put(entryPointNode, tool.getCurrentGuardAnchor().asNode()); |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11572
diff
changeset
|
1254 Map<Node, Node> duplicates = replaceeGraph.addDuplicates(nodes, snippet, snippet.getNodeCount(), replacements); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1255 Debug.dump(replaceeGraph, "After inlining snippet %s", snippetCopy.method()); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1256 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1257 FixedWithNextNode lastFixedNode = tool.lastFixedNode(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1258 assert lastFixedNode != null && lastFixedNode.isAlive() : replaceeGraph + " lastFixed=" + lastFixedNode; |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1259 FixedNode next = lastFixedNode.next(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1260 lastFixedNode.setNext(null); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1261 FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1262 replaceeGraph.addAfterFixed(lastFixedNode, firstCFGNodeDuplicate); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1263 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1264 if (replacee instanceof StateSplit) { |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1265 for (StateSplit sideEffectNode : sideEffectNodes) { |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1266 assert ((StateSplit) replacee).hasSideEffect(); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1267 Node sideEffectDup = duplicates.get(sideEffectNode); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1268 ((StateSplit) sideEffectDup).setStateAfter(((StateSplit) replacee).stateAfter()); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1269 } |
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:
7015
diff
changeset
|
1270 } |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1271 updateStamps(replacee, duplicates); |
6408
e5768e936147
Allow snippets to inherit the stateAfter and stamp from the replacee
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6407
diff
changeset
|
1272 |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1273 // Replace all usages of the replacee with the value returned by the snippet |
13692
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1274 ReturnNode returnDuplicate = (ReturnNode) duplicates.get(returnNode); |
c215dec9d3cf
allow multiple ReturnNodes per graph
Lukas Stadler <lukas.stadler@jku.at>
parents:
13691
diff
changeset
|
1275 ValueNode returnValue = returnDuplicate.result(); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1276 assert returnValue != null || replacee.usages().isEmpty(); |
11749
a27fcd670725
SnippetTemplate: use FloatingReadPhase to store MemoryMap at ReturnNodes in order to connect the snippet graph properly when inlining it
Bernhard Urban <bernhard.urban@jku.at>
parents:
11732
diff
changeset
|
1277 replacer.replace(replacee, returnValue, new DuplicateMapper(duplicates, replaceeGraph.start())); |
11388
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1278 |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1279 if (returnDuplicate.isAlive()) { |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1280 returnDuplicate.replaceAndDelete(next); |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1281 } |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1282 |
f88427168d19
added counters and timers for snippet instantiation
Doug Simon <doug.simon@oracle.com>
parents:
10667
diff
changeset
|
1283 Debug.dump(replaceeGraph, "After lowering %s with %s", replacee, this); |
5670
29684ae5a194
Make sure snippet instentiation doesn't produce dead nodes and remove redundant DCE
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5574
diff
changeset
|
1284 } |
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:
diff
changeset
|
1285 } |
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:
diff
changeset
|
1286 |
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:
diff
changeset
|
1287 @Override |
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:
diff
changeset
|
1288 public String toString() { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1289 StringBuilder buf = new StringBuilder(snippet.toString()).append('('); |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
1290 String sep = ""; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1291 for (int i = 0; i < parameters.length; i++) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1292 String name = "[" + i + "]"; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1293 Object value = parameters[i]; |
5481
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
1294 buf.append(sep); |
e26e6dca0bcf
added @Parameter and @Constant annotations which simplify creation and instantiation of snippets
Doug Simon <doug.simon@oracle.com>
parents:
5467
diff
changeset
|
1295 sep = ", "; |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1296 if (value == null) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1297 buf.append("<null> ").append(name); |
18643
3e71078c2efe
converted use of '==' to .equals() to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18583
diff
changeset
|
1298 } else if (value.equals(UNUSED_PARAMETER)) { |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7141
diff
changeset
|
1299 buf.append("<unused> ").append(name); |
18643
3e71078c2efe
converted use of '==' to .equals() to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18583
diff
changeset
|
1300 } else if (value.equals(CONSTANT_PARAMETER)) { |
9038
8802f66cba62
Fix bug in graph dumping.
Roland Schatz <roland.schatz@oracle.com>
parents:
9015
diff
changeset
|
1301 buf.append("<constant> ").append(name); |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
1302 } else if (value instanceof ParameterNode) { |
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
1303 ParameterNode param = (ParameterNode) value; |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14616
diff
changeset
|
1304 buf.append(param.getKind().getJavaName()).append(' ').append(name); |
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:
diff
changeset
|
1305 } else { |
13623 | 1306 ParameterNode[] params = (ParameterNode[]) value; |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14616
diff
changeset
|
1307 String kind = params.length == 0 ? "?" : params[0].getKind().getJavaName(); |
13623 | 1308 buf.append(kind).append('[').append(params.length).append("] ").append(name); |
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:
diff
changeset
|
1309 } |
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:
diff
changeset
|
1310 } |
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:
diff
changeset
|
1311 return buf.append(')').toString(); |
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:
diff
changeset
|
1312 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1313 |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11847
diff
changeset
|
1314 private static boolean checkTemplate(MetaAccessProvider metaAccess, Arguments args, ResolvedJavaMethod method, Signature signature) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1315 for (int i = 0; i < args.info.getParameterCount(); i++) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1316 if (args.info.isConstantParameter(i)) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6534
diff
changeset
|
1317 Kind kind = signature.getParameterKind(i); |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
1318 assert checkConstantArgument(metaAccess, method, signature, i, args.info.getParameterName(i), args.values[i], kind); |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1319 |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1320 } else if (args.info.isVarargsParameter(i)) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1321 assert args.values[i] instanceof Varargs; |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
1322 Varargs varargs = (Varargs) args.values[i]; |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15833
diff
changeset
|
1323 assert checkVarargs(metaAccess, method, signature, i, args.info.getParameterName(i), varargs); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1324 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1325 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1326 return true; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
1327 } |
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:
diff
changeset
|
1328 } |