Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java @ 16841:cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 15 Aug 2014 11:34:38 +0200 |
parents | 5992012d3bca |
children | 06c15e88d383 |
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.*; |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
27 import static com.oracle.graal.compiler.common.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.*; | |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
32 import java.util.concurrent.atomic.*; |
7076 | 33 |
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
|
34 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
|
35 |
7076 | 36 import com.oracle.graal.api.code.*; |
37 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
|
38 import com.oracle.graal.api.replacements.*; |
16772
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
39 import com.oracle.graal.compiler.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15053
diff
changeset
|
40 import com.oracle.graal.compiler.common.*; |
7076 | 41 import com.oracle.graal.debug.*; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
42 import com.oracle.graal.debug.Debug.Scope; |
12714
655c87d8d3c2
added SnippetPreparationTime metric
Doug Simon <doug.simon@oracle.com>
parents:
12706
diff
changeset
|
43 import com.oracle.graal.debug.internal.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16772
diff
changeset
|
44 import com.oracle.graal.graph.Graph.Mark; |
7076 | 45 import com.oracle.graal.graph.*; |
46 import com.oracle.graal.java.*; | |
14739
553527010fc4
Allow subclasses to provide their own graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14636
diff
changeset
|
47 import com.oracle.graal.java.GraphBuilderPhase.Instance; |
7076 | 48 import com.oracle.graal.nodes.*; |
16563
1e63cb55f61d
Move InvokeKind from MethodCallTargetNode to CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16480
diff
changeset
|
49 import com.oracle.graal.nodes.CallTargetNode.InvokeKind; |
7076 | 50 import com.oracle.graal.nodes.java.*; |
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
|
51 import com.oracle.graal.nodes.spi.*; |
7076 | 52 import com.oracle.graal.phases.*; |
53 import com.oracle.graal.phases.common.*; | |
15470
c55f44b3c5e5
remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15311
diff
changeset
|
54 import com.oracle.graal.phases.common.inlining.*; |
11569
2f6734f8126a
Avoid direct usage of CanonicalizerPhase.Instance in replacements processing.
Roland Schatz <roland.schatz@oracle.com>
parents:
11491
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 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
|
59 import com.oracle.graal.word.phases.*; |
7076 | 60 |
8628
77de2f3df379
renames: [HotSpot]ReplacementsInstaller -> [HotSpot]ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8627
diff
changeset
|
61 public class ReplacementsImpl implements Replacements { |
7076 | 62 |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
63 protected final Providers providers; |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
64 protected final SnippetReflectionProvider snippetReflection; |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
65 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
|
66 protected final Assumptions assumptions; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
67 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
68 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
69 * The preprocessed replacement graphs. |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
70 */ |
13146
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
71 protected final ConcurrentMap<ResolvedJavaMethod, StructuredGraph> graphs; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
72 |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
73 /** |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
74 * Encapsulates method and macro substitutions for a single class. |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
75 */ |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
76 protected class ClassReplacements { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
77 protected final Map<ResolvedJavaMethod, ResolvedJavaMethod> methodSubstitutions = new HashMap<>(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
78 private final Map<ResolvedJavaMethod, Class<? extends FixedWithNextNode>> macroSubstitutions = new HashMap<>(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
79 private final Set<ResolvedJavaMethod> forcedSubstitutions = new HashSet<>(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
80 |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
81 public ClassReplacements(Class<?>[] substitutionClasses, AtomicReference<ClassReplacements> ref) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
82 for (Class<?> substitutionClass : substitutionClasses) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
83 ClassSubstitution classSubstitution = substitutionClass.getAnnotation(ClassSubstitution.class); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
84 assert !Snippets.class.isAssignableFrom(substitutionClass); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
85 SubstitutionGuard defaultGuard = getGuard(classSubstitution.defaultGuard()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
86 for (Method substituteMethod : substitutionClass.getDeclaredMethods()) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
87 if (ref.get() != null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
88 // Bail if another thread beat us creating the substitutions |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
89 return; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
90 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
91 MethodSubstitution methodSubstitution = substituteMethod.getAnnotation(MethodSubstitution.class); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
92 MacroSubstitution macroSubstitution = substituteMethod.getAnnotation(MacroSubstitution.class); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
93 if (methodSubstitution == null && macroSubstitution == null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
94 continue; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
95 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
96 |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
97 int modifiers = substituteMethod.getModifiers(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
98 if (!Modifier.isStatic(modifiers)) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
99 throw new GraalInternalError("Substitution methods must be static: " + substituteMethod); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
100 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
101 |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
102 if (methodSubstitution != null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
103 SubstitutionGuard guard = getGuard(methodSubstitution.guard()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
104 if (guard == null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
105 guard = defaultGuard; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
106 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
107 |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
108 if (macroSubstitution != null && macroSubstitution.isStatic() != methodSubstitution.isStatic()) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
109 throw new GraalInternalError("Macro and method substitution must agree on isStatic attribute: " + substituteMethod); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
110 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
111 if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
112 throw new GraalInternalError("Substitution method must not be abstract or native: " + substituteMethod); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
113 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
114 String originalName = originalName(substituteMethod, methodSubstitution.value()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
115 JavaSignature originalSignature = originalSignature(substituteMethod, methodSubstitution.signature(), methodSubstitution.isStatic()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
116 Member originalMethod = originalMethod(classSubstitution, methodSubstitution.optional(), originalName, originalSignature); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
117 if (originalMethod != null && (guard == null || guard.execute())) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
118 ResolvedJavaMethod original = registerMethodSubstitution(this, originalMethod, substituteMethod); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
119 if (original != null && methodSubstitution.forced() && shouldIntrinsify(original)) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
120 forcedSubstitutions.add(original); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
121 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
122 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
123 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
124 // We don't have per method guards for macro substitutions but at |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
125 // least respect the defaultGuard if there is one. |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
126 if (macroSubstitution != null && (defaultGuard == null || defaultGuard.execute())) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
127 String originalName = originalName(substituteMethod, macroSubstitution.value()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
128 JavaSignature originalSignature = originalSignature(substituteMethod, macroSubstitution.signature(), macroSubstitution.isStatic()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
129 Member originalMethod = originalMethod(classSubstitution, macroSubstitution.optional(), originalName, originalSignature); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
130 if (originalMethod != null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
131 ResolvedJavaMethod original = registerMacroSubstitution(this, originalMethod, macroSubstitution.macro()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
132 if (original != null && macroSubstitution.forced() && shouldIntrinsify(original)) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
133 forcedSubstitutions.add(original); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
134 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
135 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
136 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
137 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
138 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
139 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
140 |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
141 private JavaSignature originalSignature(Method substituteMethod, String methodSubstitution, boolean isStatic) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
142 Class<?>[] parameters; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
143 Class<?> returnType; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
144 if (methodSubstitution.isEmpty()) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
145 parameters = substituteMethod.getParameterTypes(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
146 if (!isStatic) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
147 assert parameters.length > 0 : "must be a static method with the 'this' object as its first parameter"; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
148 parameters = Arrays.copyOfRange(parameters, 1, parameters.length); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
149 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
150 returnType = substituteMethod.getReturnType(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
151 } else { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
152 Signature signature = providers.getMetaAccess().parseMethodDescriptor(methodSubstitution); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
153 parameters = new Class[signature.getParameterCount(false)]; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
154 for (int i = 0; i < parameters.length; i++) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
155 parameters[i] = resolveClass(signature.getParameterType(i, null)); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
156 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
157 returnType = resolveClass(signature.getReturnType(null)); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
158 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
159 return new JavaSignature(returnType, parameters); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
160 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
161 |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
162 private Member originalMethod(ClassSubstitution classSubstitution, boolean optional, String name, JavaSignature signature) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
163 Class<?> originalClass = classSubstitution.value(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
164 if (originalClass == ClassSubstitution.class) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
165 originalClass = resolveClass(classSubstitution.className(), classSubstitution.optional()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
166 if (originalClass == null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
167 // optional class was not found |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
168 return null; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
169 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
170 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
171 try { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
172 if (name.equals("<init>")) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
173 assert signature.returnType.equals(void.class) : signature; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
174 Constructor<?> original = originalClass.getDeclaredConstructor(signature.parameters); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
175 return original; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
176 } else { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
177 Method original = originalClass.getDeclaredMethod(name, signature.parameters); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
178 if (!original.getReturnType().equals(signature.returnType)) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
179 throw new NoSuchMethodException(originalClass.getName() + "." + name + signature); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
180 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
181 return original; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
182 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
183 } catch (NoSuchMethodException | SecurityException e) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
184 if (optional) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
185 return null; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
186 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
187 throw new GraalInternalError(e); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
188 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
189 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
190 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
191 |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
192 /** |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
193 * Per-class replacements. The entries in these maps are all fully initialized during |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
194 * single-threaded compiler startup and so do not need to be concurrent. |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
195 */ |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
196 private final Map<String, AtomicReference<ClassReplacements>> classReplacements; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
197 private final Map<String, Class<?>[]> internalNameToSubstitutionClasses; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
198 |
9187
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
199 private final Map<Class<? extends SnippetTemplateCache>, SnippetTemplateCache> snippetTemplateCache; |
7076 | 200 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
201 public ReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, Assumptions assumptions, TargetDescription target) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12408
diff
changeset
|
202 this.providers = providers.copyWith(this); |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
203 this.classReplacements = new HashMap<>(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
204 this.internalNameToSubstitutionClasses = new HashMap<>(); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
205 this.snippetReflection = snippetReflection; |
13132
922dd1415c0a
Commit pass target as a parameter to ReplacementImpl, so that it does not require a CodeCacheProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13128
diff
changeset
|
206 this.target = target; |
7076 | 207 this.assumptions = assumptions; |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
208 this.graphs = new ConcurrentHashMap<>(); |
9187
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
209 this.snippetTemplateCache = new HashMap<>(); |
7076 | 210 } |
211 | |
12706
bb5fa27daa20
added ability to disable snippet graph preparation cache (-Dgraal.useSnippetGraphCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12432
diff
changeset
|
212 private static final boolean UseSnippetGraphCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetGraphCache", "true")); |
12714
655c87d8d3c2
added SnippetPreparationTime metric
Doug Simon <doug.simon@oracle.com>
parents:
12706
diff
changeset
|
213 private static final DebugTimer SnippetPreparationTime = Debug.timer("SnippetPreparationTime"); |
12706
bb5fa27daa20
added ability to disable snippet graph preparation cache (-Dgraal.useSnippetGraphCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12432
diff
changeset
|
214 |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
215 /** |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
216 * Gets the method and macro replacements for a given class. This method will parse the |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
217 * replacements in the substitution classes associated with {@code internalName} the first time |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
218 * this method is called for {@code internalName}. |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
219 */ |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
220 protected ClassReplacements getClassReplacements(String internalName) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
221 Class<?>[] substitutionClasses = internalNameToSubstitutionClasses.get(internalName); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
222 if (substitutionClasses != null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
223 AtomicReference<ClassReplacements> crRef = classReplacements.get(internalName); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
224 if (crRef.get() == null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
225 crRef.compareAndSet(null, new ClassReplacements(substitutionClasses, crRef)); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
226 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
227 return crRef.get(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
228 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
229 return null; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
230 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
231 |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
232 public StructuredGraph getSnippet(ResolvedJavaMethod method) { |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
233 return getSnippet(method, null); |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
234 } |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
235 |
13146
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
236 @Override |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
237 public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry) { |
9015
92d2bedb5dfc
Change of Snippet template and instantiation process
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8981
diff
changeset
|
238 assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName(); |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
239 assert !method.isAbstract() && !method.isNative() : "Snippet must not be abstract or native"; |
7076 | 240 |
12706
bb5fa27daa20
added ability to disable snippet graph preparation cache (-Dgraal.useSnippetGraphCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12432
diff
changeset
|
241 StructuredGraph graph = UseSnippetGraphCache ? graphs.get(method) : null; |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
242 if (graph == null) { |
12714
655c87d8d3c2
added SnippetPreparationTime metric
Doug Simon <doug.simon@oracle.com>
parents:
12706
diff
changeset
|
243 try (TimerCloseable a = SnippetPreparationTime.start()) { |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
244 FrameStateProcessing frameStateProcessing = method.getAnnotation(Snippet.class).removeAllFrameStates() ? FrameStateProcessing.Removal |
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
245 : FrameStateProcessing.CollapseFrameForSingleSideEffect; |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
246 StructuredGraph newGraph = makeGraph(method, recursiveEntry, inliningPolicy(method), frameStateProcessing); |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
14589
diff
changeset
|
247 Debug.metric("SnippetNodeCount[%#s]", method).add(newGraph.getNodeCount()); |
12745
31ed7cd96914
made SnippetGraphNodeCount count the right thing; re-enable prepared snippet graph caching by default
Doug Simon <doug.simon@oracle.com>
parents:
12714
diff
changeset
|
248 if (!UseSnippetGraphCache) { |
12714
655c87d8d3c2
added SnippetPreparationTime metric
Doug Simon <doug.simon@oracle.com>
parents:
12706
diff
changeset
|
249 return newGraph; |
655c87d8d3c2
added SnippetPreparationTime metric
Doug Simon <doug.simon@oracle.com>
parents:
12706
diff
changeset
|
250 } |
655c87d8d3c2
added SnippetPreparationTime metric
Doug Simon <doug.simon@oracle.com>
parents:
12706
diff
changeset
|
251 graphs.putIfAbsent(method, newGraph); |
655c87d8d3c2
added SnippetPreparationTime metric
Doug Simon <doug.simon@oracle.com>
parents:
12706
diff
changeset
|
252 graph = graphs.get(method); |
12706
bb5fa27daa20
added ability to disable snippet graph preparation cache (-Dgraal.useSnippetGraphCache=false)
Doug Simon <doug.simon@oracle.com>
parents:
12432
diff
changeset
|
253 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
254 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
255 return graph; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
256 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
257 |
13146
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
258 @Override |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
259 public void registerSnippet(ResolvedJavaMethod method) { |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
260 // No initialization needed as snippet graphs are created on demand in getSnippet |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
261 } |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
262 |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
263 @Override |
13222
de8f74d49690
rename Replacements.prepareSnippetCopyAfterInstantiation
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13197
diff
changeset
|
264 public void notifyAfterConstantsBound(StructuredGraph specializedSnippet) { |
13146
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
265 |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
266 // Do deferred intrinsification of node intrinsics |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
267 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
268 new NodeIntrinsificationPhase(providers, snippetReflection).apply(specializedSnippet); |
13222
de8f74d49690
rename Replacements.prepareSnippetCopyAfterInstantiation
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13197
diff
changeset
|
269 new CanonicalizerPhase(true).apply(specializedSnippet, new PhaseContext(providers, assumptions)); |
de8f74d49690
rename Replacements.prepareSnippetCopyAfterInstantiation
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13197
diff
changeset
|
270 NodeIntrinsificationVerificationPhase.verify(specializedSnippet); |
13146
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
271 } |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
272 |
ffbfc3e78746
extend replacements API to support svm specific snippet handling
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13132
diff
changeset
|
273 @Override |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
274 public StructuredGraph getMethodSubstitution(ResolvedJavaMethod original) { |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
275 ClassReplacements cr = getClassReplacements(original.getDeclaringClass().getName()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
276 ResolvedJavaMethod substitute = cr == null ? null : cr.methodSubstitutions.get(original); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
277 if (substitute == null) { |
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
278 return null; |
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
279 } |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
280 StructuredGraph graph = graphs.get(substitute); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
281 if (graph == null) { |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
282 graph = makeGraph(substitute, original, inliningPolicy(substitute), FrameStateProcessing.None); |
13980
68ae6fae9d2e
freeze graphs before inserting into table
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13977
diff
changeset
|
283 graph.freeze(); |
68ae6fae9d2e
freeze graphs before inserting into table
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13977
diff
changeset
|
284 graphs.putIfAbsent(substitute, graph); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
285 graph = graphs.get(substitute); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
286 } |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13629
diff
changeset
|
287 assert graph.isFrozen(); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
288 return graph; |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
289 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
290 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
291 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
292 public Class<? extends FixedWithNextNode> getMacroSubstitution(ResolvedJavaMethod method) { |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
293 ClassReplacements cr = getClassReplacements(method.getDeclaringClass().getName()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
294 return cr == null ? null : cr.macroSubstitutions.get(method); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
295 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
296 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
297 public Assumptions getAssumptions() { |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
298 return assumptions; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
299 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
300 |
13629
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
301 private static SubstitutionGuard getGuard(Class<? extends SubstitutionGuard> guardClass) { |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
302 if (guardClass != SubstitutionGuard.class) { |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
303 try { |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
304 return guardClass.newInstance(); |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
305 } catch (Exception e) { |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
306 throw new GraalInternalError(e); |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
307 } |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
308 } |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
309 return null; |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
310 } |
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
311 |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
312 private static String getOriginalInternalName(Class<?> substitutions) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
313 ClassSubstitution cs = substitutions.getAnnotation(ClassSubstitution.class); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
314 assert cs != null : substitutions + " must be annotated by " + ClassSubstitution.class.getSimpleName(); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
315 if (cs.value() == ClassSubstitution.class) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
316 return toInternalName(cs.className()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
317 } |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
318 return toInternalName(cs.value().getName()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
319 } |
13629
5348da19751d
Add locally specified guards to substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13618
diff
changeset
|
320 |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
321 public void registerSubstitutions(Type original, Class<?> substitutionClass) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
322 String internalName = toInternalName(original.getTypeName()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
323 assert getOriginalInternalName(substitutionClass).equals(internalName) : getOriginalInternalName(substitutionClass) + " != " + (internalName); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
324 Class<?>[] classes = internalNameToSubstitutionClasses.get(internalName); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
325 if (classes == null) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
326 classes = new Class<?>[]{substitutionClass}; |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
327 } else { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
328 assert !Arrays.asList(classes).contains(substitutionClass); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
329 classes = Arrays.copyOf(classes, classes.length + 1); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
330 classes[classes.length - 1] = substitutionClass; |
7076 | 331 } |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
332 internalNameToSubstitutionClasses.put(internalName, classes); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
333 AtomicReference<ClassReplacements> existing = classReplacements.put(internalName, new AtomicReference<>()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
334 assert existing == null || existing.get() == null; |
7076 | 335 } |
336 | |
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
|
337 /** |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
338 * Registers a method substitution. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14908
diff
changeset
|
339 * |
8431
be5ce3e9d473
rename: originalMethod -> originalMember
Doug Simon <doug.simon@oracle.com>
parents:
8430
diff
changeset
|
340 * @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
|
341 * @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
|
342 * @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
|
343 */ |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
344 protected ResolvedJavaMethod registerMethodSubstitution(ClassReplacements cr, 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
|
345 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
346 ResolvedJavaMethod substitute = metaAccess.lookupJavaMethod(substituteMethod); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
347 ResolvedJavaMethod original; |
8431
be5ce3e9d473
rename: originalMethod -> originalMember
Doug Simon <doug.simon@oracle.com>
parents:
8430
diff
changeset
|
348 if (originalMember instanceof Method) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
349 original = metaAccess.lookupJavaMethod((Method) originalMember); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
350 } else { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
351 original = metaAccess.lookupJavaConstructor((Constructor<?>) originalMember); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
352 } |
14636
733e50d96f9b
fixed usages of Debug.log()
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
353 if (Debug.isLogEnabled()) { |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16479
diff
changeset
|
354 Debug.log("substitution: %s --> %s", original.format("%H.%n(%p) %r"), substitute.format("%H.%n(%p) %r")); |
14636
733e50d96f9b
fixed usages of Debug.log()
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
355 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
356 |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
357 cr.methodSubstitutions.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
|
358 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
|
359 } |
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
|
360 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
361 /** |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
362 * Registers a macro substitution. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14908
diff
changeset
|
363 * |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
364 * @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
|
365 * @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
|
366 * @return the original method |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
367 */ |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
368 protected ResolvedJavaMethod registerMacroSubstitution(ClassReplacements cr, Member originalMethod, Class<? extends FixedWithNextNode> macro) { |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
369 ResolvedJavaMethod originalJavaMethod; |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
370 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
371 if (originalMethod instanceof Method) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
372 originalJavaMethod = metaAccess.lookupJavaMethod((Method) originalMethod); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
373 } else { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
374 originalJavaMethod = metaAccess.lookupJavaConstructor((Constructor<?>) originalMethod); |
8360
fa5a670a1682
added support for substituting constructors
Doug Simon <doug.simon@oracle.com>
parents:
8199
diff
changeset
|
375 } |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
376 cr.macroSubstitutions.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
|
377 return originalJavaMethod; |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
378 } |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
379 |
13128
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
380 private static SnippetInliningPolicy createPolicyClassInstance(Class<? extends SnippetInliningPolicy> policyClass) { |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
381 try { |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
382 return policyClass.getConstructor().newInstance(); |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
383 } catch (Exception e) { |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
384 throw new GraalInternalError(e); |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
385 } |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
386 } |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
387 |
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
388 protected SnippetInliningPolicy inliningPolicy(ResolvedJavaMethod method) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7510
diff
changeset
|
389 Class<? extends SnippetInliningPolicy> policyClass = SnippetInliningPolicy.class; |
7076 | 390 Snippet snippet = method.getAnnotation(Snippet.class); |
391 if (snippet != null) { | |
392 policyClass = snippet.inlining(); | |
393 } | |
394 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
|
395 return new DefaultSnippetInliningPolicy(providers.getMetaAccess()); |
7076 | 396 } |
13128
c9660efac5f6
Factor out methods that use reflection so that they can be substituted
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12747
diff
changeset
|
397 return createPolicyClassInstance(policyClass); |
7076 | 398 } |
399 | |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
400 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
401 * Creates a preprocessed graph for a snippet or method substitution. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14908
diff
changeset
|
402 * |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
403 * @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
|
404 * @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
|
405 * substitution} otherwise null |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
406 * @param policy the inlining policy to use during preprocessing |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
407 * @param frameStateProcessing controls how {@link FrameState FrameStates} should be handled. |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
408 */ |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
409 public StructuredGraph makeGraph(ResolvedJavaMethod method, ResolvedJavaMethod original, SnippetInliningPolicy policy, FrameStateProcessing frameStateProcessing) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
410 return createGraphMaker(method, original, frameStateProcessing).makeGraph(policy); |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
411 } |
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
412 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
413 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
414 * 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
|
415 */ |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
416 protected GraphMaker createGraphMaker(ResolvedJavaMethod substitute, ResolvedJavaMethod original, FrameStateProcessing frameStateProcessing) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
417 return new GraphMaker(substitute, original, frameStateProcessing); |
7076 | 418 } |
419 | |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
420 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
421 * 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
|
422 */ |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
423 final ConcurrentMap<ResolvedJavaMethod, StructuredGraph> graphCache = new ConcurrentHashMap<>(); |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
424 |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
425 public enum FrameStateProcessing { |
14908
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14756
diff
changeset
|
426 None, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14756
diff
changeset
|
427 CollapseFrameForSingleSideEffect, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14756
diff
changeset
|
428 Removal |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
429 } |
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
430 |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
431 /** |
16772
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
432 * Calls in snippets to methods matching one of these filters are elided. Only void methods are |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
433 * considered for elision. |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
434 */ |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
435 private static final MethodFilter[] MethodsElidedInSnippets = getMethodsElidedInSnippets(); |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
436 |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
437 private static MethodFilter[] getMethodsElidedInSnippets() { |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
438 String commaSeparatedPatterns = System.getProperty("graal.MethodsElidedInSnippets"); |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
439 if (commaSeparatedPatterns != null) { |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
440 return MethodFilter.parse(commaSeparatedPatterns); |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
441 } |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
442 return null; |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
443 } |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
444 |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
445 /** |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
446 * 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
|
447 */ |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
448 protected class GraphMaker { |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
449 /** |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
450 * 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
|
451 */ |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
452 protected final ResolvedJavaMethod method; |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
453 |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
454 /** |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
455 * The original method which {@link #method} is substituting. Calls to {@link #method} or |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
456 * {@link #substitutedMethod} will be replaced with a forced inline of |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
457 * {@link #substitutedMethod}. |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
458 */ |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
459 protected final ResolvedJavaMethod substitutedMethod; |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
460 |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
461 /** |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
462 * Controls how FrameStates are processed. |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
463 */ |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
464 private FrameStateProcessing frameStateProcessing; |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
465 |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
466 protected GraphMaker(ResolvedJavaMethod substitute, ResolvedJavaMethod substitutedMethod, FrameStateProcessing frameStateProcessing) { |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
467 this.method = substitute; |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
468 this.substitutedMethod = substitutedMethod; |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
469 this.frameStateProcessing = frameStateProcessing; |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
470 } |
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
471 |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
472 public StructuredGraph makeGraph(final SnippetInliningPolicy policy) { |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
473 try (Scope s = Debug.scope("BuildSnippetGraph", method)) { |
14756
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
474 StructuredGraph graph = parseGraph(method, policy, 0); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
475 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
476 // Cannot have a finalized version of a graph in the cache |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
477 graph = graph.copy(); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
478 |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
479 finalizeGraph(graph); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
480 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
481 Debug.dump(graph, "%s: Final", method.getName()); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
482 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
483 return graph; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
484 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
485 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
486 } |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
487 } |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
488 |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
489 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
490 * 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
|
491 */ |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
492 protected void finalizeGraph(StructuredGraph graph) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
493 new NodeIntrinsificationPhase(providers, snippetReflection).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
|
494 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
|
495 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
|
496 } |
16126
dbd32c5942e8
complain when deleting side effecting nodes from snippets
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15942
diff
changeset
|
497 int sideEffectCount = 0; |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
498 assert (sideEffectCount = graph.getNodes().filter(e -> hasSideEffect(e)).count()) >= 0; |
9323
712d583d0d21
Perform deopt-to-guard conversion at snippet installation time.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9302
diff
changeset
|
499 new ConvertDeoptimizeToGuardPhase().apply(graph); |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
500 assert sideEffectCount == graph.getNodes().filter(e -> hasSideEffect(e)).count() : "deleted side effecting node"; |
8199
a68310b2b8b8
made GraphBuilderPhase and SnippetInstaller more extensible (inspired by patch from Mick Jordan)
Doug Simon <doug.simon@oracle.com>
parents:
8175
diff
changeset
|
501 |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
502 switch (frameStateProcessing) { |
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
503 case Removal: |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
504 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
|
505 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
|
506 ((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
|
507 } |
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
11717
diff
changeset
|
508 } |
13618
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
509 break; |
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
510 case CollapseFrameForSingleSideEffect: |
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
511 new CollapseFrameForSingleSideEffectPhase().apply(graph); |
b87fcab6624a
Replacements: use enum to describe framestate action
Bernhard Urban <bernhard.urban@jku.at>
parents:
13604
diff
changeset
|
512 break; |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
513 } |
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
|
514 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
|
515 } |
7076 | 516 |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
517 /** |
16418 | 518 * Filter nodes which have side effects and shouldn't be deleted from snippets when |
519 * converting deoptimizations to guards. Currently this only allows exception constructors | |
520 * to be eliminated to cover the case when Java assertions are in the inlined code. | |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
521 * |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
522 * @param node |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
523 * @return true for nodes that have side effects and are unsafe to delete |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
524 */ |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
525 private boolean hasSideEffect(Node node) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
526 if (node instanceof StateSplit) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
527 if (((StateSplit) node).hasSideEffect()) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
528 if (node instanceof Invoke) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
529 CallTargetNode callTarget = ((Invoke) node).callTarget(); |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
530 if (callTarget instanceof MethodCallTargetNode) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
531 ResolvedJavaMethod targetMethod = ((MethodCallTargetNode) callTarget).targetMethod(); |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
532 if (targetMethod.isConstructor()) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
533 ResolvedJavaType throwableType = providers.getMetaAccess().lookupJavaType(Throwable.class); |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
534 return !throwableType.isAssignableFrom(targetMethod.getDeclaringClass()); |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
535 } |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
536 } |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
537 } |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
538 // Not an exception constructor call |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
539 return true; |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
540 } |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
541 } |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
542 // Not a StateSplit |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
543 return false; |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
544 } |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
545 |
14756
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
546 private static final int MAX_GRAPH_INLINING_DEPTH = 100; // more than enough |
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
547 |
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
548 private StructuredGraph parseGraph(final ResolvedJavaMethod methodToParse, final SnippetInliningPolicy policy, int inliningDepth) { |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
549 StructuredGraph graph = graphCache.get(methodToParse); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
550 if (graph == null) { |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
551 StructuredGraph newGraph = null; |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
552 try (Scope s = Debug.scope("ParseGraph", methodToParse)) { |
14756
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
553 newGraph = buildGraph(methodToParse, policy == null ? inliningPolicy(methodToParse) : policy, inliningDepth); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
554 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
555 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
556 } |
9341
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
557 |
26d11d3ca6bc
fixed debug scopes during snippet preparation
Doug Simon <doug.simon@oracle.com>
parents:
9323
diff
changeset
|
558 graphCache.putIfAbsent(methodToParse, newGraph); |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
559 graph = graphCache.get(methodToParse); |
8630
f32fa4cdfbb1
fixed concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8628
diff
changeset
|
560 assert graph != null; |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
561 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
562 return graph; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
563 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
564 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
565 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
566 * 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
|
567 */ |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
568 protected StructuredGraph buildInitialGraph(final ResolvedJavaMethod methodToParse) { |
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
569 final StructuredGraph graph = new StructuredGraph(methodToParse); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
570 try (Scope s = Debug.scope("buildInitialGraph", graph)) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
571 MetaAccessProvider metaAccess = providers.getMetaAccess(); |
16772
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
572 |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
573 if (MethodsElidedInSnippets != null && methodToParse.getSignature().getReturnKind() == Kind.Void && MethodFilter.matches(MethodsElidedInSnippets, methodToParse)) { |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
574 graph.addAfterFixed(graph.start(), graph.add(new ReturnNode(null))); |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
575 } else { |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
576 createGraphBuilder(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph); |
5992012d3bca
support for eliding methods in snippets (e.g., to handle instrumentation agents)
Doug Simon <doug.simon@oracle.com>
parents:
16563
diff
changeset
|
577 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
578 new WordTypeVerificationPhase(metaAccess, snippetReflection, target.wordKind).apply(graph); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
579 new WordTypeRewriterPhase(metaAccess, snippetReflection, target.wordKind).apply(graph); |
10707
a643c88d164f
Add scopes to capture the graphs in ReplacementsImpl
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9908
diff
changeset
|
580 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
581 if (OptCanonicalizer.getValue()) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
582 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
|
583 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
584 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
585 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
586 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
587 return graph; |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
588 } |
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
589 |
14739
553527010fc4
Allow subclasses to provide their own graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14636
diff
changeset
|
590 protected Instance createGraphBuilder(MetaAccessProvider metaAccess, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) { |
553527010fc4
Allow subclasses to provide their own graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14636
diff
changeset
|
591 return new GraphBuilderPhase.Instance(metaAccess, graphBuilderConfig, optimisticOpts); |
553527010fc4
Allow subclasses to provide their own graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14636
diff
changeset
|
592 } |
553527010fc4
Allow subclasses to provide their own graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14636
diff
changeset
|
593 |
11588 | 594 protected Object beforeInline(@SuppressWarnings("unused") MethodCallTargetNode callTarget, @SuppressWarnings("unused") StructuredGraph callee) { |
595 return null; | |
596 } | |
597 | |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
598 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
599 * Called after a graph is inlined. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14908
diff
changeset
|
600 * |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
601 * @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
|
602 * @param callee the graph that was inlined into {@code caller} |
11588 | 603 * @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
|
604 */ |
11588 | 605 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
|
606 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
|
607 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
|
608 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
609 } |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
610 |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
611 /** |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
612 * 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
|
613 */ |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
614 protected void afterInlining(StructuredGraph graph) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15002
diff
changeset
|
615 new NodeIntrinsificationPhase(providers, snippetReflection).apply(graph); |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
616 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
|
617 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
|
618 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
|
619 } |
7271
9c06e8bd8769
added phase to remove unnecessary frame states from substitution snippets
Doug Simon <doug.simon@oracle.com>
parents:
7229
diff
changeset
|
620 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
621 |
14756
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
622 private StructuredGraph buildGraph(final ResolvedJavaMethod methodToParse, final SnippetInliningPolicy policy, int inliningDepth) { |
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
623 assert inliningDepth < MAX_GRAPH_INLINING_DEPTH : "inlining limit exceeded"; |
15050
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
624 assert isInlinable(methodToParse) : methodToParse; |
8631
a5ad23f6f9ca
fixed more concurrency issues in ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8630
diff
changeset
|
625 final StructuredGraph graph = buildInitialGraph(methodToParse); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
626 try (Scope s = Debug.scope("buildGraph", graph)) { |
15050
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
627 Set<MethodCallTargetNode> doNotInline = null; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
628 for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.class)) { |
15050
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
629 if (doNotInline != null && doNotInline.contains(callTarget)) { |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
630 continue; |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
631 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
632 ResolvedJavaMethod callee = callTarget.targetMethod(); |
16383
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
633 if (substitutedMethod != null && (callee.equals(method) || callee.equals(substitutedMethod))) { |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
634 /* |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
635 * Ensure that calls to the original method inside of a substitution ends up |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
636 * calling it instead of the Graal substitution. |
657ff04a7b73
look for original method and substitution when processing snippet graph
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16176
diff
changeset
|
637 */ |
15050
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
638 if (isInlinable(substitutedMethod)) { |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
639 final StructuredGraph originalGraph = buildInitialGraph(substitutedMethod); |
15050
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
640 Mark mark = graph.getMark(); |
16176
5785eca138b0
improve tracking of nodes to canonicalize after inlining
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16126
diff
changeset
|
641 InliningUtil.inline(callTarget.invoke(), originalGraph, true, null); |
15050
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
642 for (MethodCallTargetNode inlinedCallTarget : graph.getNewNodes(mark).filter(MethodCallTargetNode.class)) { |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
643 if (doNotInline == null) { |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
644 doNotInline = new HashSet<>(); |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
645 } |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
646 // We do not want to do further inlining (now) for calls |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
647 // in the original method as this can cause unlimited |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
648 // recursive inlining given an eager inlining policy such |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
649 // as DefaultSnippetInliningPolicy. |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
650 doNotInline.add(inlinedCallTarget); |
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
651 } |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
652 Debug.dump(graph, "after inlining %s", callee); |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
653 afterInline(graph, originalGraph, null); |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
654 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
655 } else { |
13600
32ba70c49d27
Replacements: try to inline MacroNodes first
Bernhard Urban <bernhard.urban@jku.at>
parents:
13585
diff
changeset
|
656 Class<? extends FixedWithNextNode> macroNodeClass = InliningUtil.getMacroNodeClass(ReplacementsImpl.this, callee); |
32ba70c49d27
Replacements: try to inline MacroNodes first
Bernhard Urban <bernhard.urban@jku.at>
parents:
13585
diff
changeset
|
657 if (macroNodeClass != null) { |
13601
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
658 InliningUtil.inlineMacroNode(callTarget.invoke(), callee, macroNodeClass); |
13600
32ba70c49d27
Replacements: try to inline MacroNodes first
Bernhard Urban <bernhard.urban@jku.at>
parents:
13585
diff
changeset
|
659 } else { |
13601
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
660 StructuredGraph intrinsicGraph = InliningUtil.getIntrinsicGraph(ReplacementsImpl.this, callee); |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
661 if ((callTarget.invokeKind() == InvokeKind.Static || callTarget.invokeKind() == InvokeKind.Special) && |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
662 (policy.shouldInline(callee, methodToParse) || (intrinsicGraph != null && policy.shouldUseReplacement(callee, methodToParse)))) { |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
663 StructuredGraph targetGraph; |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
664 if (intrinsicGraph != null && policy.shouldUseReplacement(callee, methodToParse)) { |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
665 targetGraph = intrinsicGraph; |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
666 } else { |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
667 if (callee.getName().startsWith("$jacoco")) { |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16479
diff
changeset
|
668 throw new GraalInternalError("Parsing call to JaCoCo instrumentation method " + callee.format("%H.%n(%p)") + " from " + methodToParse.format("%H.%n(%p)") + |
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16479
diff
changeset
|
669 " while preparing replacement " + method.format("%H.%n(%p)") + ". Placing \"//JaCoCo Exclude\" anywhere in " + |
13601
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
670 methodToParse.getDeclaringClass().getSourceFileName() + " should fix this."); |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
671 } |
14756
3e1e83287128
add assertion to detect infinite recursion in snippet inlining
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14739
diff
changeset
|
672 targetGraph = parseGraph(callee, policy, inliningDepth + 1); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
673 } |
13601
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
674 Object beforeInlineData = beforeInline(callTarget, targetGraph); |
16176
5785eca138b0
improve tracking of nodes to canonicalize after inlining
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16126
diff
changeset
|
675 InliningUtil.inline(callTarget.invoke(), targetGraph, true, null); |
13601
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
676 Debug.dump(graph, "after inlining %s", callee); |
fd522e725ee5
inliningutils: minor refactor
Bernhard Urban <bernhard.urban@jku.at>
parents:
13600
diff
changeset
|
677 afterInline(graph, targetGraph, beforeInlineData); |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
678 } |
8913
653110156f8a
refactored boxing identification and lowering, removed BoxingMethodPool and explicit boxing phases
Lukas Stadler <lukas.stadler@jku.at>
parents:
8912
diff
changeset
|
679 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
680 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
681 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
682 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
683 afterInlining(graph); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
684 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
685 for (LoopEndNode end : graph.getNodes(LoopEndNode.class)) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
686 end.disableSafepoint(); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
687 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
688 |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
689 new DeadCodeEliminationPhase().apply(graph); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
690 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
691 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
13177
diff
changeset
|
692 } |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
693 return graph; |
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
694 } |
7076 | 695 } |
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
|
696 |
15050
90e8e3b90558
prevent recursive inlining when a method substitution calls the original (i.e., substituted) method
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
697 private static boolean isInlinable(final ResolvedJavaMethod method) { |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15259
diff
changeset
|
698 return !method.isAbstract() && !method.isNative(); |
13604
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
699 } |
bd21ee1a874c
fix recursion problem around macro nodes (e.g. array copy)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13603
diff
changeset
|
700 |
7510
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
701 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
|
702 if (methodSubstitution.isEmpty()) { |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
703 return substituteMethod.getName(); |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
704 } else { |
225002aba5a5
added new macro node facility, removed ArrayCopyIntrinsificationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7383
diff
changeset
|
705 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
|
706 } |
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
|
707 } |
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
|
708 |
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
|
709 /** |
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
|
710 * Resolves a name to a class. |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14908
diff
changeset
|
711 * |
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
|
712 * @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
|
713 * @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
|
714 * @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
|
715 */ |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
716 static Class<?> resolveClass(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
|
717 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
|
718 // 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
|
719 // 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
|
720 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
|
721 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
|
722 } 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
|
723 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
|
724 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
|
725 } |
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
|
726 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
|
727 } |
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
|
728 } |
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
|
729 |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
730 private static Class<?> resolveClass(JavaType type) { |
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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 } |
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
|
737 |
16479
558cf39c646b
moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents:
16418
diff
changeset
|
738 Class<?> baseClass = base.getKind() != Kind.Object ? base.getKind().toJavaClass() : resolveClass(base.toJavaName(), 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
|
739 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
|
740 } |
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
|
741 |
13177
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
742 static class JavaSignature { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
743 final Class<?> returnType; |
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
744 final Class<?>[] parameters; |
13177
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
745 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
746 public JavaSignature(Class<?> returnType, Class<?>[] parameters) { |
13177
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
747 this.parameters = parameters; |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
748 this.returnType = returnType; |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
749 } |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
750 |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
751 @Override |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
752 public String toString() { |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
753 StringBuilder sb = new StringBuilder("("); |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
754 for (int i = 0; i < parameters.length; i++) { |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
755 if (i != 0) { |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
756 sb.append(", "); |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
757 } |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
758 sb.append(parameters[i].getName()); |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
759 } |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
760 return sb.append(") ").append(returnType.getName()).toString(); |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
761 } |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
762 } |
74cfcd0fbedf
made method substitution take return types into account (GRAAL-612)
Doug Simon <doug.simon@oracle.com>
parents:
13146
diff
changeset
|
763 |
8912
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
764 @Override |
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
765 public Collection<ResolvedJavaMethod> getAllReplacements() { |
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
766 HashSet<ResolvedJavaMethod> result = new HashSet<>(); |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
767 for (String internalName : classReplacements.keySet()) { |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
768 ClassReplacements cr = getClassReplacements(internalName); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
769 result.addAll(cr.methodSubstitutions.keySet()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
770 result.addAll(cr.macroSubstitutions.keySet()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
771 } |
8912
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
772 return result; |
9631f95971a3
new GraalOption.BootstrapReplacements for debugging purposes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8631
diff
changeset
|
773 } |
8915
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
774 |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
775 @Override |
880619fd6a67
allow MethodSubstitutions and MacroSubstitutions to be forced (instead of depending on inlining)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8913
diff
changeset
|
776 public boolean isForcedSubstitution(ResolvedJavaMethod method) { |
15942
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
777 ClassReplacements cr = getClassReplacements(method.getDeclaringClass().getName()); |
5c73b162eec2
reduced execution time of ReplacementsImple.registerSubstitutions() by deferring parsing of substitution classes until the first request for a substitute method is received
Doug Simon <doug.simon@oracle.com>
parents:
15470
diff
changeset
|
778 return cr != null && cr.forcedSubstitutions.contains(method); |
8627
75db7afee829
implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents:
8484
diff
changeset
|
779 } |
9187
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
780 |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
781 @Override |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
782 public void registerSnippetTemplateCache(SnippetTemplateCache templates) { |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
783 assert snippetTemplateCache.get(templates.getClass()) == null; |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
784 snippetTemplateCache.put(templates.getClass(), templates); |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
785 } |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
786 |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
787 @Override |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
788 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
|
789 SnippetTemplateCache ret = snippetTemplateCache.get(templatesClass); |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
790 return templatesClass.cast(ret); |
cd2600a2336e
Store snippet templates in Replacements object.
Roland Schatz <roland.schatz@oracle.com>
parents:
9147
diff
changeset
|
791 } |
7076 | 792 } |