53
53
/**
54
54
* Substitutions/intrinsics for Espresso.
55
55
* <p>
56
- * Some substitutions are statically defined, others runtime-dependent. The static ones are loaded
57
- * via {@link ServiceLoader}. Iterating over the collection in this class allows to register them
56
+ * Some substitutions are globally defined, others runtime-dependent. The global ones are loaded via
57
+ * {@link ServiceLoader}. Iterating over the collection in this class allows to register them
58
58
* directly, and assign to each of them a node, which will dispatch them directly, without the need
59
59
* for reflection. In practice, this allows inlining.
60
60
* <p>
@@ -136,7 +136,7 @@ default EspressoRootNode createNodeIfValid(Method method) {
136
136
}
137
137
}
138
138
139
- private static final EconomicMap <MethodKey , JavaSubstitution .Factory > STATIC_SUBSTITUTIONS = EconomicMap .create ();
139
+ private static final EconomicMap <MethodKey , JavaSubstitution .Factory > GLOBAL_SUBSTITUTIONS = EconomicMap .create ();
140
140
141
141
private final ConcurrentHashMap <MethodKey , EspressoRootNodeFactory > runtimeSubstitutions = new ConcurrentHashMap <>();
142
142
@@ -176,17 +176,17 @@ private static void registerStaticSubstitution(JavaSubstitution.Factory substitu
176
176
177
177
private static void registerStaticSubstitution (Symbol <Type > type , Symbol <Name > methodName , Symbol <Signature > signature , JavaSubstitution .Factory factory , boolean throwIfPresent ) {
178
178
MethodKey key = new MethodKey (type , methodName , signature , !factory .hasReceiver ());
179
- if (throwIfPresent && STATIC_SUBSTITUTIONS .containsKey (key )) {
179
+ if (throwIfPresent && GLOBAL_SUBSTITUTIONS .containsKey (key )) {
180
180
throw EspressoError .shouldNotReachHere ("substitution already registered" + key );
181
181
}
182
- STATIC_SUBSTITUTIONS .put (key , factory );
182
+ GLOBAL_SUBSTITUTIONS .put (key , factory );
183
183
}
184
184
185
185
public void registerRuntimeSubstitution (Symbol <Type > type , Symbol <Name > methodName , Symbol <Signature > signature , boolean isStatic , EspressoRootNodeFactory factory , boolean throwIfPresent ) {
186
186
MethodKey key = new MethodKey (type , methodName , signature , isStatic );
187
187
188
- if (STATIC_SUBSTITUTIONS .containsKey (key )) {
189
- getLogger ().log (Level .FINE , "Runtime substitution shadowed by static one: " + key );
188
+ if (GLOBAL_SUBSTITUTIONS .containsKey (key )) {
189
+ getLogger ().log (Level .FINE , "Runtime substitution shadowed by global one: " + key );
190
190
}
191
191
192
192
if (throwIfPresent && runtimeSubstitutions .containsKey (key )) {
@@ -201,7 +201,7 @@ public void removeRuntimeSubstitution(Method method) {
201
201
}
202
202
203
203
public static JavaSubstitution .Factory lookupSubstitution (Method m ) {
204
- return STATIC_SUBSTITUTIONS .get (getMethodKey (m ));
204
+ return GLOBAL_SUBSTITUTIONS .get (getMethodKey (m ));
205
205
}
206
206
207
207
/**
@@ -211,7 +211,7 @@ public static JavaSubstitution.Factory lookupSubstitution(Method m) {
211
211
public EspressoRootNode get (Method method ) {
212
212
// Look into the static substitutions.
213
213
MethodKey key = getMethodKey (method );
214
- JavaSubstitution .Factory staticSubstitutionFactory = STATIC_SUBSTITUTIONS .get (key );
214
+ JavaSubstitution .Factory staticSubstitutionFactory = GLOBAL_SUBSTITUTIONS .get (key );
215
215
if (staticSubstitutionFactory != null && staticSubstitutionFactory .isValidFor (method .getLanguage ())) {
216
216
EspressoRootNode root = createRootNodeFromSubstitution (method , staticSubstitutionFactory );
217
217
if (root != null ) {
@@ -250,6 +250,6 @@ public String get() {
250
250
@ TruffleBoundary
251
251
public boolean hasSubstitutionFor (Method method ) {
252
252
MethodKey key = getMethodKey (method );
253
- return STATIC_SUBSTITUTIONS .containsKey (key ) || runtimeSubstitutions .containsKey (key );
253
+ return GLOBAL_SUBSTITUTIONS .containsKey (key ) || runtimeSubstitutions .containsKey (key );
254
254
}
255
255
}
0 commit comments