Mercurial > hg > truffle
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java @ 12054:bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 11 Oct 2013 16:11:21 +0200 |
parents | 0afe7370260c |
children | f53dc8bbb88c |
rev | line source |
---|---|
7076 | 1 /* |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8981
diff
changeset
|
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
7076 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
8414
diff
changeset
|
23 package com.oracle.graal.replacements; |
7076 | 24 |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
25 import static com.oracle.graal.api.meta.MetaUtil.*; |
11491
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11402
diff
changeset
|
26 import static com.oracle.graal.compiler.GraalCompiler.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9601
diff
changeset
|
27 import static com.oracle.graal.phases.GraalOptions.*; |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
28 |
7076 | 29 import java.lang.reflect.*; |
30 import java.util.*; | |
31 import java.util.concurrent.*; | |
32 | |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
33 import sun.misc.*; |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
34 |
7076 | 35 import com.oracle.graal.api.code.*; |
36 import com.oracle.graal.api.meta.*; | |
8420
5d3fa6f949fb
created com.oracle.graal.api.replacements project and moved ClassSubstitution and MethodSubstitution there
Doug Simon <doug.simon@oracle.com>
parents:
8419
diff
changeset
|
37 import com.oracle.graal.api.replacements.*; |
7076 | 38 import com.oracle.graal.debug.*; |
39 import com.oracle.graal.graph.*; | |
40 import com.oracle.graal.java.*; | |
41 import com.oracle.graal.nodes.*; | |
42 import com.oracle.graal.nodes.java.*; | |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7295
diff
changeset
|
43 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
8637
ce5750014c3d
moved Replacements and MacroSubstitution from the graal.api.replacements project to graal.nodes project and reversed the dependency between these two projects (the latter now/again depends on the former)
Doug Simon <doug.simon@oracle.com>
parents:
8631
diff
changeset
|
44 import com.oracle.graal.nodes.spi.*; |
7076 | 45 import com.oracle.graal.phases.*; |
46 import com.oracle.graal.phases.common.*; | |
11569
2f6734f8126a
Avoid direct usage of CanonicalizerPhase.Instance in replacements processing.
Roland Schatz <roland.schatz@oracle.com>
parents:
11491
diff
changeset
|
47 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
|
48 import com.oracle.graal.phases.util.*; |
8419
11bada5f81a6
refactored MethodSubstitution and MacroSubstitution into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
8416
diff
changeset
|
49 import com.oracle.graal.replacements.Snippet.DefaultSnippetInliningPolicy; |
11bada5f81a6
refactored MethodSubstitution and MacroSubstitution into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
8416
diff
changeset
|
50 import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7295
diff
changeset
|
51 import com.oracle.graal.word.phases.*; |
7076 | 52 |
8628
77de2f3df379
renames: [HotSpot]ReplacementsInstaller -> [HotSpot]ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8627
diff
changeset
|
53 public class ReplacementsImpl implements Replacements { |
7076 | 54 |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
55 protected final Providers providers; |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
56 protected final TargetDescription target; |
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
57 protected final Assumptions assumptions; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
58 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
59 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
60 * The preprocessed replacement graphs. |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
61 */ |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
62 private final ConcurrentMap<ResolvedJavaMethod, StructuredGraph> graphs; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
63 |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
64 // These data structures are all fully initialized during single-threaded |
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
65 // compiler startup and so do not need to be concurrent. |
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
66 private final Map<ResolvedJavaMethod, ResolvedJavaMethod> registeredMethodSubstitutions; |
11402 | 67 private final Map<ResolvedJavaMethod, Class<? extends FixedWithNextNode>> registeredMacroSubstitutions; |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
68 private final Set<ResolvedJavaMethod> forcedSubstitutions; |
9187
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
69 private final Map<Class<? extends SnippetTemplateCache>, SnippetTemplateCache> snippetTemplateCache; |
7076 | 70 |
12052
0afe7370260c
refactored constantEquals(), lookupArrayLength() and readUnsafeConstant() out of MetaAccessProvider into ConstantReflectionProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12045
diff
changeset
|
71 public ReplacementsImpl(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, CodeCacheProvider codeCache, LoweringProvider lowerer, Assumptions assumptions, |
0afe7370260c
refactored constantEquals(), lookupArrayLength() and readUnsafeConstant() out of MetaAccessProvider into ConstantReflectionProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12045
diff
changeset
|
72 TargetDescription target) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
73 this.providers = new Providers(metaAccess, codeCache, constantReflection, lowerer, this); |
7076 | 74 this.target = target; |
75 this.assumptions = assumptions; | |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
76 this.graphs = new ConcurrentHashMap<>(); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
77 this.registeredMethodSubstitutions = new HashMap<>(); |
11402 | 78 this.registeredMacroSubstitutions = new HashMap<>(); |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
79 this.forcedSubstitutions = new HashSet<>(); |
9187
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
80 this.snippetTemplateCache = new HashMap<>(); |
7076 | 81 } |
82 | |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8981
diff
changeset
|
83 public StructuredGraph getSnippet(ResolvedJavaMethod method) { |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8981
diff
changeset
|
84 assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName(); |
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8981
diff
changeset
|
85 assert !Modifier.isAbstract(method.getModifiers()) && !Modifier.isNative(method.getModifiers()) : "Snippet must not be abstract or native"; |
7076 | 86 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
87 StructuredGraph graph = graphs.get(method); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
88 if (graph == null) { |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
89 graphs.putIfAbsent(method, makeGraph(method, null, inliningPolicy(method), method.getAnnotation(Snippet.class).removeAllFrameStates())); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
90 graph = graphs.get(method); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
91 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
92 return graph; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
93 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
94 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
95 public StructuredGraph getMethodSubstitution(ResolvedJavaMethod original) { |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
96 ResolvedJavaMethod substitute = registeredMethodSubstitutions.get(original); |
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
97 if (substitute == null) { |
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
98 return null; |
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
99 } |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
100 StructuredGraph graph = graphs.get(substitute); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
101 if (graph == null) { |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
102 graphs.putIfAbsent(substitute, makeGraph(substitute, original, inliningPolicy(substitute), false)); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
103 graph = graphs.get(substitute); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
104 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
105 return graph; |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
106 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
107 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
108 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
109 public Class<? extends FixedWithNextNode> getMacroSubstitution(ResolvedJavaMethod method) { |
11402 | 110 return registeredMacroSubstitutions.get(method); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
111 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
112 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
113 public Assumptions getAssumptions() { |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
114 return assumptions; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
115 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
116 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
117 public void registerSubstitutions(Class<?> substitutions) { |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
118 ClassSubstitution classSubstitution = substitutions.getAnnotation(ClassSubstitution.class); |
7545
b30b33d9da80
sanity checks for SnippetInstaller.installSubstitutions()
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
119 assert classSubstitution != null; |
8413
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
8410
diff
changeset
|
120 assert !Snippets.class.isAssignableFrom(substitutions); |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
121 for (Method substituteMethod : substitutions.getDeclaredMethods()) { |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
122 MethodSubstitution methodSubstitution = substituteMethod.getAnnotation(MethodSubstitution.class); |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
123 MacroSubstitution macroSubstitution = substituteMethod.getAnnotation(MacroSubstitution.class); |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
124 if (methodSubstitution == null && macroSubstitution == null) { |
7076 | 125 continue; |
126 } | |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
127 |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
128 int modifiers = substituteMethod.getModifiers(); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
129 if (!Modifier.isStatic(modifiers)) { |
10903
d518ea24c82b
added ClassIsInterfaceNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
10707
diff
changeset
|
130 throw new GraalInternalError("Substitution methods must be static: " + substituteMethod); |
7076 | 131 } |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
132 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
133 if (methodSubstitution != null) { |
10903
d518ea24c82b
added ClassIsInterfaceNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
10707
diff
changeset
|
134 if (macroSubstitution != null && macroSubstitution.isStatic() != methodSubstitution.isStatic()) { |
d518ea24c82b
added ClassIsInterfaceNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
10707
diff
changeset
|
135 throw new GraalInternalError("Macro and method substitution must agree on isStatic attribute: " + substituteMethod); |
d518ea24c82b
added ClassIsInterfaceNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
10707
diff
changeset
|
136 } |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
137 if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { |
10903
d518ea24c82b
added ClassIsInterfaceNode macro node
Doug Simon <doug.simon@oracle.com>
parents:
10707
diff
changeset
|
138 throw new GraalInternalError("Substitution method must not be abstract or native: " + substituteMethod); |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
139 } |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
140 String originalName = originalName(substituteMethod, methodSubstitution.value()); |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
141 Class[] originalParameters = originalParameters(substituteMethod, methodSubstitution.signature(), methodSubstitution.isStatic()); |
8902
59e751e68bea
made method (and macro) substitution optional to support different JDK versions
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
142 Member originalMethod = originalMethod(classSubstitution, methodSubstitution.optional(), originalName, originalParameters); |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
143 if (originalMethod != null) { |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
144 ResolvedJavaMethod original = registerMethodSubstitution(originalMethod, substituteMethod); |
11491
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11402
diff
changeset
|
145 if (original != null && methodSubstitution.forced() && shouldIntrinsify(original)) { |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
146 forcedSubstitutions.add(original); |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
147 } |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
148 } |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
149 } |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
150 if (macroSubstitution != null) { |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
151 String originalName = originalName(substituteMethod, macroSubstitution.value()); |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
152 Class[] originalParameters = originalParameters(substituteMethod, macroSubstitution.signature(), macroSubstitution.isStatic()); |
8902
59e751e68bea
made method (and macro) substitution optional to support different JDK versions
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
153 Member originalMethod = originalMethod(classSubstitution, macroSubstitution.optional(), originalName, originalParameters); |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
154 if (originalMethod != null) { |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
155 ResolvedJavaMethod original = registerMacroSubstitution(originalMethod, macroSubstitution.macro()); |
11491
a03452edfc4d
made enabling/disabling of intrinsifications extensible (GRAAL-111)
Doug Simon <doug.simon@oracle.com>
parents:
11402
diff
changeset
|
156 if (original != null && macroSubstitution.forced() && shouldIntrinsify(original)) { |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
157 forcedSubstitutions.add(original); |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
158 } |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
159 } |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
160 } |
7076 | 161 } |
162 } | |
163 | |
7373
6b2c55fc9ba8
reworked mechanism for omitting intrinsics if the underlying hardware support is not available and used it to make intrinsification of Integer.bitCount() dependent on whether the POPCNT instruction is available
Doug Simon <doug.simon@oracle.com>
parents:
7360
diff
changeset
|
164 /** |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
165 * Registers a method substitution. |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11593
diff
changeset
|
166 * |
8431
be5ce3e9d473
rename: originalMethod -> originalMember
Doug Simon <doug.simon@oracle.com>
parents:
8430
diff
changeset
|
167 * @param originalMember a method or constructor being substituted |
7373
6b2c55fc9ba8
reworked mechanism for omitting intrinsics if the underlying hardware support is not available and used it to make intrinsification of Integer.bitCount() dependent on whether the POPCNT instruction is available
Doug Simon <doug.simon@oracle.com>
parents:
7360
diff
changeset
|
168 * @param substituteMethod the substitute method |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
169 * @return the original method |
7373
6b2c55fc9ba8
reworked mechanism for omitting intrinsics if the underlying hardware support is not available and used it to make intrinsification of Integer.bitCount() dependent on whether the POPCNT instruction is available
Doug Simon <doug.simon@oracle.com>
parents:
7360
diff
changeset
|
170 */ |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
171 protected ResolvedJavaMethod registerMethodSubstitution(Member originalMember, Method substituteMethod) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
172 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
173 ResolvedJavaMethod substitute = metaAccess.lookupJavaMethod(substituteMethod); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
174 ResolvedJavaMethod original; |
8431
be5ce3e9d473
rename: originalMethod -> originalMember
Doug Simon <doug.simon@oracle.com>
parents:
8430
diff
changeset
|
175 if (originalMember instanceof Method) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
176 original = metaAccess.lookupJavaMethod((Method) originalMember); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
177 } else { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
178 original = metaAccess.lookupJavaConstructor((Constructor) originalMember); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
179 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
180 Debug.log("substitution: " + MetaUtil.format("%H.%n(%p)", original) + " --> " + MetaUtil.format("%H.%n(%p)", substitute)); |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
181 |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
182 registeredMethodSubstitutions.put(original, substitute); |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
183 return original; |
7373
6b2c55fc9ba8
reworked mechanism for omitting intrinsics if the underlying hardware support is not available and used it to make intrinsification of Integer.bitCount() dependent on whether the POPCNT instruction is available
Doug Simon <doug.simon@oracle.com>
parents:
7360
diff
changeset
|
184 } |
6b2c55fc9ba8
reworked mechanism for omitting intrinsics if the underlying hardware support is not available and used it to make intrinsification of Integer.bitCount() dependent on whether the POPCNT instruction is available
Doug Simon <doug.simon@oracle.com>
parents:
7360
diff
changeset
|
185 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
186 /** |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
187 * Registers a macro substitution. |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11593
diff
changeset
|
188 * |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
189 * @param originalMethod a method or constructor being substituted |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
190 * @param macro the substitute macro node class |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
191 * @return the original method |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
192 */ |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
193 protected ResolvedJavaMethod registerMacroSubstitution(Member originalMethod, Class<? extends FixedWithNextNode> macro) { |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
194 ResolvedJavaMethod originalJavaMethod; |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
195 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
196 if (originalMethod instanceof Method) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
197 originalJavaMethod = metaAccess.lookupJavaMethod((Method) originalMethod); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
198 } else { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
199 originalJavaMethod = metaAccess.lookupJavaConstructor((Constructor) originalMethod); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
200 } |
11402 | 201 registeredMacroSubstitutions.put(originalJavaMethod, macro); |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
202 return originalJavaMethod; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
203 } |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
204 |
7096
585fc9f79ebc
Remove ResolvedJavaType.isClass()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7076
diff
changeset
|
205 private SnippetInliningPolicy inliningPolicy(ResolvedJavaMethod method) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7510
diff
changeset
|
206 Class<? extends SnippetInliningPolicy> policyClass = SnippetInliningPolicy.class; |
7076 | 207 Snippet snippet = method.getAnnotation(Snippet.class); |
208 if (snippet != null) { | |
209 policyClass = snippet.inlining(); | |
210 } | |
211 if (policyClass == SnippetInliningPolicy.class) { | |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
212 return new DefaultSnippetInliningPolicy(providers.getMetaAccess()); |
7076 | 213 } |
214 try { | |
215 return policyClass.getConstructor().newInstance(); | |
216 } catch (Exception e) { | |
217 throw new GraalInternalError(e); | |
218 } | |
219 } | |
220 | |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
221 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
222 * Creates a preprocessed graph for a snippet or method substitution. |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11593
diff
changeset
|
223 * |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
224 * @param method the snippet or method substitution for which a graph will be created |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
225 * @param original the original method if {@code method} is a {@linkplain MethodSubstitution |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
226 * substitution} otherwise null |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
227 * @param policy the inlining policy to use during preprocessing |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
228 * @param removeAllFrameStates removes all frame states from side effecting instructions |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
229 */ |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
230 public StructuredGraph makeGraph(ResolvedJavaMethod method, ResolvedJavaMethod original, SnippetInliningPolicy policy, boolean removeAllFrameStates) { |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
231 return createGraphMaker(method, original).makeGraph(policy, removeAllFrameStates); |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
232 } |
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
233 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
234 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
235 * Can be overridden to return an object that specializes various parts of graph preprocessing. |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
236 */ |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
237 protected GraphMaker createGraphMaker(ResolvedJavaMethod substitute, ResolvedJavaMethod original) { |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
238 return new GraphMaker(substitute, original); |
7076 | 239 } |
240 | |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
241 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
242 * Cache to speed up preprocessing of replacement graphs. |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
243 */ |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
244 final ConcurrentMap<ResolvedJavaMethod, StructuredGraph> graphCache = new ConcurrentHashMap<>(); |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
245 |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
246 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
247 * Creates and preprocesses a graph for a replacement. |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
248 */ |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
249 protected class GraphMaker { |
7076 | 250 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
251 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
252 * The method for which a graph is being created. |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
253 */ |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
254 protected final ResolvedJavaMethod method; |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
255 |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
256 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
257 * The original method if {@link #method} is a {@linkplain MethodSubstitution substitution} |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
258 * otherwise null. |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
259 */ |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
260 protected final ResolvedJavaMethod original; |
7076 | 261 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
262 boolean substituteCallsOriginal; |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
263 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
264 protected GraphMaker(ResolvedJavaMethod substitute, ResolvedJavaMethod original) { |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
265 this.method = substitute; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
266 this.original = original; |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
267 } |
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
268 |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
269 public StructuredGraph makeGraph(final SnippetInliningPolicy policy, final boolean removeAllFrameStates) { |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
270 return Debug.scope("BuildSnippetGraph", new Object[]{method}, new Callable<StructuredGraph>() { |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
271 |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
272 @Override |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
273 public StructuredGraph call() throws Exception { |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
274 StructuredGraph graph = parseGraph(method, policy); |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
275 |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
276 // Cannot have a finalized version of a graph in the cache |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
277 graph = graph.copy(); |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
278 |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
279 finalizeGraph(graph, removeAllFrameStates); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
280 |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
281 Debug.dump(graph, "%s: Final", method.getName()); |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
282 |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
283 return graph; |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
284 } |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
285 }); |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
286 } |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
287 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
288 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
289 * Does final processing of a snippet graph. |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
290 */ |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
291 protected void finalizeGraph(StructuredGraph graph, boolean removeAllFrameStates) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
292 new NodeIntrinsificationPhase(providers.getMetaAccess()).apply(graph); |
9302
c78ef1df7b06
made verification of node intrinsification always be run, independent of whether assertions are enabled
Doug Simon <doug.simon@oracle.com>
parents:
9234
diff
changeset
|
293 if (!SnippetTemplate.hasConstantParameter(method)) { |
c78ef1df7b06
made verification of node intrinsification always be run, independent of whether assertions are enabled
Doug Simon <doug.simon@oracle.com>
parents:
9234
diff
changeset
|
294 NodeIntrinsificationVerificationPhase.verify(graph); |
c78ef1df7b06
made verification of node intrinsification always be run, independent of whether assertions are enabled
Doug Simon <doug.simon@oracle.com>
parents:
9234
diff
changeset
|
295 } |
9323
712d583d0d21
Perform deopt-to-guard conversion at snippet installation time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9302
diff
changeset
|
296 new ConvertDeoptimizeToGuardPhase().apply(graph); |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
297 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
298 if (original == null) { |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
299 if (removeAllFrameStates) { |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
300 for (Node node : graph.getNodes()) { |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
301 if (node instanceof StateSplit) { |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
302 ((StateSplit) node).setStateAfter(null); |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
303 } |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
304 } |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
305 } else { |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
306 new SnippetFrameStateCleanupPhase().apply(graph); |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
307 } |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
308 } |
11717
8a3b59397044
The SnippetFrameStateCleanupPhase now sets invalid framestates on the paths of side effecting instruction except for the last one where an AFTER_BCI is used.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11698
diff
changeset
|
309 new DeadCodeEliminationPhase().apply(graph); |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
310 } |
7076 | 311 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
312 private StructuredGraph parseGraph(final ResolvedJavaMethod methodToParse, final SnippetInliningPolicy policy) { |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
313 StructuredGraph graph = graphCache.get(methodToParse); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
314 if (graph == null) { |
9341
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
315 StructuredGraph newGraph = Debug.scope("ParseGraph", new Object[]{methodToParse}, new Callable<StructuredGraph>() { |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
316 |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
317 public StructuredGraph call() throws Exception { |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
318 return buildGraph(methodToParse, policy == null ? inliningPolicy(methodToParse) : policy); |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
319 } |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
320 }); |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
321 |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
322 graphCache.putIfAbsent(methodToParse, newGraph); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
323 graph = graphCache.get(methodToParse); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
324 assert graph != null; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
325 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
326 return graph; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
327 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
328 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
329 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
330 * Builds the initial graph for a snippet. |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
331 */ |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
332 protected StructuredGraph buildInitialGraph(final ResolvedJavaMethod methodToParse) { |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
333 final StructuredGraph graph = new StructuredGraph(methodToParse); |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
334 Debug.scope("buildInitialGraph", graph, new Runnable() { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
335 |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
336 @Override |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
337 public void run() { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
338 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
339 new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
340 new WordTypeVerificationPhase(metaAccess, target.wordKind).apply(graph); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
341 new WordTypeRewriterPhase(metaAccess, target.wordKind).apply(graph); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
342 |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
343 if (OptCanonicalizer.getValue()) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
344 new CanonicalizerPhase(true).apply(graph, new PhaseContext(providers, assumptions)); |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
345 } |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
346 } |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
347 }); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
348 return graph; |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
349 } |
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
350 |
11588 | 351 protected Object beforeInline(@SuppressWarnings("unused") MethodCallTargetNode callTarget, @SuppressWarnings("unused") StructuredGraph callee) { |
352 return null; | |
353 } | |
354 | |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
355 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
356 * Called after a graph is inlined. |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11593
diff
changeset
|
357 * |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
358 * @param caller the graph into which {@code callee} was inlined |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
359 * @param callee the graph that was inlined into {@code caller} |
11588 | 360 * @param beforeInlineData value returned by {@link #beforeInline}. |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
361 */ |
11588 | 362 protected void afterInline(StructuredGraph caller, StructuredGraph callee, Object beforeInlineData) { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9601
diff
changeset
|
363 if (OptCanonicalizer.getValue()) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
364 new CanonicalizerPhase(true).apply(caller, new PhaseContext(providers, assumptions)); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
365 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
366 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
367 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
368 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
369 * Called after all inlining for a given graph is complete. |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
370 */ |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
371 protected void afterInlining(StructuredGraph graph) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
372 new NodeIntrinsificationPhase(providers.getMetaAccess()).apply(graph); |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
373 new DeadCodeEliminationPhase().apply(graph); |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9601
diff
changeset
|
374 if (OptCanonicalizer.getValue()) { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
375 new CanonicalizerPhase(true).apply(graph, new PhaseContext(providers, assumptions)); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
376 } |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
377 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
378 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
379 private StructuredGraph buildGraph(final ResolvedJavaMethod methodToParse, final SnippetInliningPolicy policy) { |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
380 assert !Modifier.isAbstract(methodToParse.getModifiers()) && !Modifier.isNative(methodToParse.getModifiers()) : methodToParse; |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
381 final StructuredGraph graph = buildInitialGraph(methodToParse); |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
382 Debug.scope("buildGraph", graph, new Runnable() { |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
383 |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
384 @Override |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
385 public void run() { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
386 for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.class)) { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
387 ResolvedJavaMethod callee = callTarget.targetMethod(); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
388 if (callee == method) { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
389 final StructuredGraph originalGraph = new StructuredGraph(original); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
390 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
391 new GraphBuilderPhase(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(originalGraph); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
392 new WordTypeVerificationPhase(metaAccess, target.wordKind).apply(graph); |
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
393 new WordTypeRewriterPhase(metaAccess, target.wordKind).apply(graph); |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11593
diff
changeset
|
394 |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
395 InliningUtil.inline(callTarget.invoke(), originalGraph, true); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
396 |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
397 Debug.dump(graph, "after inlining %s", callee); |
11588 | 398 afterInline(graph, originalGraph, null); |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
399 substituteCallsOriginal = true; |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8912
diff
changeset
|
400 } else { |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
401 StructuredGraph intrinsicGraph = InliningUtil.getIntrinsicGraph(ReplacementsImpl.this, callee); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
402 if ((callTarget.invokeKind() == InvokeKind.Static || callTarget.invokeKind() == InvokeKind.Special) && |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
403 (policy.shouldInline(callee, methodToParse) || (intrinsicGraph != null && policy.shouldUseReplacement(callee, methodToParse)))) { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
404 StructuredGraph targetGraph; |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
405 if (intrinsicGraph != null && policy.shouldUseReplacement(callee, methodToParse)) { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
406 targetGraph = intrinsicGraph; |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
407 } else { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
408 if (callee.getName().startsWith("$jacoco")) { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
409 throw new GraalInternalError("Parsing call to JaCoCo instrumentation method " + format("%H.%n(%p)", callee) + " from " + format("%H.%n(%p)", methodToParse) + |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
410 " while preparing replacement " + format("%H.%n(%p)", method) + ". Placing \"//JaCoCo Exclude\" anywhere in " + |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
411 methodToParse.getDeclaringClass().getSourceFileName() + " should fix this."); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
412 } |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
413 targetGraph = parseGraph(callee, policy); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
414 } |
11588 | 415 Object beforeInlineData = beforeInline(callTarget, targetGraph); |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
416 InliningUtil.inline(callTarget.invoke(), targetGraph, true); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
417 Debug.dump(graph, "after inlining %s", callee); |
11588 | 418 afterInline(graph, targetGraph, beforeInlineData); |
9342
e8dc8748f415
added check for JaCoCo methods being inserted into replacement methods
Doug Simon <doug.simon@oracle.com>
parents:
9341
diff
changeset
|
419 } |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8912
diff
changeset
|
420 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
421 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
422 |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
423 afterInlining(graph); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
424 |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
425 for (LoopEndNode end : graph.getNodes(LoopEndNode.class)) { |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
426 end.disableSafepoint(); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
427 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
428 |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
429 new DeadCodeEliminationPhase().apply(graph); |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
430 } |
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
431 }); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
432 return graph; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
433 } |
7076 | 434 } |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
435 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
436 private static String originalName(Method substituteMethod, String methodSubstitution) { |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
437 if (methodSubstitution.isEmpty()) { |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
438 return substituteMethod.getName(); |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
439 } else { |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
440 return methodSubstitution; |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
441 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
442 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
443 |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
444 /** |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
445 * Resolves a name to a class. |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11593
diff
changeset
|
446 * |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
447 * @param className the name of the class to resolve |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
448 * @param optional if true, resolution failure returns null |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
449 * @return the resolved class or null if resolution fails and {@code optional} is true |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
450 */ |
8466
c7a2a937233f
added @Alias annotation for accessing fields and methods otherwise inaccessible due to Java access rules
Doug Simon <doug.simon@oracle.com>
parents:
8450
diff
changeset
|
451 static Class resolveType(String className, boolean optional) { |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
452 try { |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
453 // Need to use launcher class path to handle classes |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
454 // that are not on the boot class path |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
455 ClassLoader cl = Launcher.getLauncher().getClassLoader(); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
456 return Class.forName(className, false, cl); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
457 } catch (ClassNotFoundException e) { |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
458 if (optional) { |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
459 return null; |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
460 } |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
461 throw new GraalInternalError("Could not resolve type " + className); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
462 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
463 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
464 |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
465 private static Class resolveType(JavaType type) { |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
466 JavaType base = type; |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
467 int dimensions = 0; |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
468 while (base.getComponentType() != null) { |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
469 base = base.getComponentType(); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
470 dimensions++; |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
471 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
472 |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
473 Class baseClass = base.getKind() != Kind.Object ? base.getKind().toJavaClass() : resolveType(toJavaName(base), false); |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
474 return dimensions == 0 ? baseClass : Array.newInstance(baseClass, new int[dimensions]).getClass(); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
475 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
476 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
477 private Class[] originalParameters(Method substituteMethod, String methodSubstitution, boolean isStatic) { |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
478 Class[] parameters; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
479 if (methodSubstitution.isEmpty()) { |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
480 parameters = substituteMethod.getParameterTypes(); |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
481 if (!isStatic) { |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
482 assert parameters.length > 0 : "must be a static method with the 'this' object as its first parameter"; |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
483 parameters = Arrays.copyOfRange(parameters, 1, parameters.length); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
484 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
485 } else { |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
486 Signature signature = providers.getMetaAccess().parseMethodDescriptor(methodSubstitution); |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
487 parameters = new Class[signature.getParameterCount(false)]; |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
488 for (int i = 0; i < parameters.length; i++) { |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
489 parameters[i] = resolveType(signature.getParameterType(i, null)); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
490 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
491 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
492 return parameters; |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
493 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
494 |
8902
59e751e68bea
made method (and macro) substitution optional to support different JDK versions
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
495 private static Member originalMethod(ClassSubstitution classSubstitution, boolean optional, String name, Class[] parameters) { |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
496 Class<?> originalClass = classSubstitution.value(); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
497 if (originalClass == ClassSubstitution.class) { |
8373
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
498 originalClass = resolveType(classSubstitution.className(), classSubstitution.optional()); |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
499 if (originalClass == null) { |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
500 // optional class was not found |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
501 return null; |
86a9e3ea8fe9
support substitutions for classes that made not be part of the runtime (GRAAL-123)
Doug Simon <doug.simon@oracle.com>
parents:
8360
diff
changeset
|
502 } |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
503 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
504 try { |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
505 if (name.equals("<init>")) { |
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
506 return originalClass.getDeclaredConstructor(parameters); |
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
507 } else { |
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
508 return originalClass.getDeclaredMethod(name, parameters); |
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
509 } |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
510 } catch (NoSuchMethodException | SecurityException e) { |
8902
59e751e68bea
made method (and macro) substitution optional to support different JDK versions
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
511 if (optional) { |
59e751e68bea
made method (and macro) substitution optional to support different JDK versions
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
512 return null; |
59e751e68bea
made method (and macro) substitution optional to support different JDK versions
Doug Simon <doug.simon@oracle.com>
parents:
8637
diff
changeset
|
513 } |
7360
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
514 throw new GraalInternalError(e); |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
515 } |
12bd634440d0
support substitution of methods that are not in the bootstrap class path and/or whose signature contains non-accessible types
Doug Simon <doug.simon@oracle.com>
parents:
7356
diff
changeset
|
516 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
517 |
8912
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
518 @Override |
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
519 public Collection<ResolvedJavaMethod> getAllReplacements() { |
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
520 HashSet<ResolvedJavaMethod> result = new HashSet<>(); |
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
521 result.addAll(registeredMethodSubstitutions.keySet()); |
11402 | 522 result.addAll(registeredMacroSubstitutions.keySet()); |
8912
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
523 return result; |
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
524 } |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
525 |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
526 @Override |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
527 public boolean isForcedSubstitution(ResolvedJavaMethod method) { |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
528 return forcedSubstitutions.contains(method); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
529 } |
9187
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
530 |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
531 @Override |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
532 public void registerSnippetTemplateCache(SnippetTemplateCache templates) { |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
533 assert snippetTemplateCache.get(templates.getClass()) == null; |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
534 snippetTemplateCache.put(templates.getClass(), templates); |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
535 } |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
536 |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
537 @Override |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
538 public <T extends SnippetTemplateCache> T getSnippetTemplateCache(Class<T> templatesClass) { |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
539 SnippetTemplateCache ret = snippetTemplateCache.get(templatesClass); |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
540 return templatesClass.cast(ret); |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
541 } |
7076 | 542 } |