@@ -128,9 +128,26 @@ class InlineBeforeAnalysisMethodScope extends PEMethodScope {
128
128
super (targetGraph , caller , callerLoopScope , encodedGraph , method , invokeData , inliningDepth , arguments );
129
129
130
130
if (caller == null ) {
131
+ /*
132
+ * The root method that we are decoding, i.e., inlining into. No policy, because the
133
+ * whole method must of course be decoded.
134
+ */
135
+ policyScope = null ;
136
+ } else if (caller .caller == null ) {
137
+ /*
138
+ * The first level of method inlining, i.e., the top scope from the inlining policy
139
+ * point of view.
140
+ */
131
141
policyScope = policy .createTopScope ();
142
+ if (graph .getDebug ().isLogEnabled ()) {
143
+ graph .getDebug ().logv (repeat (" " , inliningDepth ) + "createTopScope for " + method .format ("%H.%n(%p)" ) + ": " + policyScope );
144
+ }
132
145
} else {
146
+ /* Nested inlining. */
133
147
policyScope = policy .openCalleeScope ((cast (caller )).policyScope );
148
+ if (graph .getDebug ().isLogEnabled ()) {
149
+ graph .getDebug ().logv (repeat (" " , inliningDepth ) + "openCalleeScope for " + method .format ("%H.%n(%p)" ) + ": " + policyScope );
150
+ }
134
151
}
135
152
}
136
153
}
@@ -146,6 +163,10 @@ class InlineBeforeAnalysisMethodScope extends PEMethodScope {
146
163
new ConcurrentHashMap <>(), new ConcurrentHashMap <>(), true );
147
164
this .bb = bb ;
148
165
this .policy = policy ;
166
+
167
+ if (graph .getDebug ().isLogEnabled ()) {
168
+ graph .getDebug ().logv ("InlineBeforeAnalysis: decoding " + graph .method ().format ("%H.%n(%p)" ));
169
+ }
149
170
}
150
171
151
172
@ Override
@@ -192,8 +213,16 @@ protected void handleNonInlinedInvoke(MethodScope methodScope, LoopScope loopSco
192
213
193
214
private void maybeAbortInlining (MethodScope ms , Node node ) {
194
215
InlineBeforeAnalysisMethodScope methodScope = cast (ms );
195
- if (!methodScope .inliningAborted && methodScope .isInlinedMethod () && !policy .processNode (methodScope .policyScope , node )) {
196
- methodScope .inliningAborted = true ;
216
+ if (!methodScope .inliningAborted && methodScope .isInlinedMethod ()) {
217
+ if (graph .getDebug ().isLogEnabled ()) {
218
+ graph .getDebug ().logv (repeat (" " , methodScope .inliningDepth ) + " node " + node + ": " + methodScope .policyScope );
219
+ }
220
+ if (!policy .processNode (methodScope .policyScope , node )) {
221
+ if (graph .getDebug ().isLogEnabled ()) {
222
+ graph .getDebug ().logv (repeat (" " , methodScope .inliningDepth ) + " abort!" );
223
+ }
224
+ methodScope .inliningAborted = true ;
225
+ }
197
226
}
198
227
}
199
228
@@ -221,8 +250,12 @@ protected void finishInlining(MethodScope is) {
221
250
InvokeData invokeData = inlineScope .invokeData ;
222
251
223
252
if (inlineScope .inliningAborted ) {
224
- policy .abortCalleeScope (callerScope .policyScope , inlineScope .policyScope );
225
-
253
+ if (graph .getDebug ().isLogEnabled ()) {
254
+ graph .getDebug ().logv (repeat (" " , callerScope .inliningDepth ) + " aborted " + invokeData .callTarget .targetMethod ().format ("%H.%n(%p)" ) + ": " + inlineScope .policyScope );
255
+ }
256
+ if (callerScope .policyScope != null ) {
257
+ policy .abortCalleeScope (callerScope .policyScope , inlineScope .policyScope );
258
+ }
226
259
killControlFlowNodes (inlineScope , invokeData .invokePredecessor .next ());
227
260
assert invokeData .invokePredecessor .next () == null : "Successor must have been a fixed node created in the aborted scope, which is deleted now" ;
228
261
invokeData .invokePredecessor .setNext (invokeData .invoke .asNode ());
@@ -239,12 +272,26 @@ protected void finishInlining(MethodScope is) {
239
272
return ;
240
273
}
241
274
242
- policy .commitCalleeScope (callerScope .policyScope , inlineScope .policyScope );
275
+ if (graph .getDebug ().isLogEnabled ()) {
276
+ graph .getDebug ().logv (repeat (" " , callerScope .inliningDepth ) + " committed " + invokeData .callTarget .targetMethod ().format ("%H.%n(%p)" ) + ": " + inlineScope .policyScope );
277
+ }
278
+ if (callerScope .policyScope != null ) {
279
+ policy .commitCalleeScope (callerScope .policyScope , inlineScope .policyScope );
280
+ }
243
281
((AnalysisMethod ) invokeData .callTarget .targetMethod ()).registerAsInlined ();
244
282
245
283
super .finishInlining (inlineScope );
246
284
}
247
285
286
+ /* String.repeat is only available in JDK 11 and later, so need to do our own. */
287
+ private static String repeat (String s , int count ) {
288
+ StringBuilder result = new StringBuilder ();
289
+ for (int i = 0 ; i < count ; i ++) {
290
+ result .append (s );
291
+ }
292
+ return result .toString ();
293
+ }
294
+
248
295
/**
249
296
* Kill fixed nodes of structured control flow. Not as generic, but faster, than
250
297
* {@link GraphUtil#killCFG}.
0 commit comments