@@ -128,9 +128,26 @@ class InlineBeforeAnalysisMethodScope extends PEMethodScope {
128128 super (targetGraph , caller , callerLoopScope , encodedGraph , method , invokeData , inliningDepth , arguments );
129129
130130 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+ */
131141 policyScope = policy .createTopScope ();
142+ if (graph .getDebug ().isLogEnabled ()) {
143+ graph .getDebug ().logv (repeat (" " , inliningDepth ) + "createTopScope for " + method .format ("%H.%n(%p)" ) + ": " + policyScope );
144+ }
132145 } else {
146+ /* Nested inlining. */
133147 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+ }
134151 }
135152 }
136153 }
@@ -146,6 +163,10 @@ class InlineBeforeAnalysisMethodScope extends PEMethodScope {
146163 new ConcurrentHashMap <>(), new ConcurrentHashMap <>(), true );
147164 this .bb = bb ;
148165 this .policy = policy ;
166+
167+ if (graph .getDebug ().isLogEnabled ()) {
168+ graph .getDebug ().logv ("InlineBeforeAnalysis: decoding " + graph .method ().format ("%H.%n(%p)" ));
169+ }
149170 }
150171
151172 @ Override
@@ -192,8 +213,16 @@ protected void handleNonInlinedInvoke(MethodScope methodScope, LoopScope loopSco
192213
193214 private void maybeAbortInlining (MethodScope ms , Node node ) {
194215 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+ }
197226 }
198227 }
199228
@@ -221,8 +250,12 @@ protected void finishInlining(MethodScope is) {
221250 InvokeData invokeData = inlineScope .invokeData ;
222251
223252 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+ }
226259 killControlFlowNodes (inlineScope , invokeData .invokePredecessor .next ());
227260 assert invokeData .invokePredecessor .next () == null : "Successor must have been a fixed node created in the aborted scope, which is deleted now" ;
228261 invokeData .invokePredecessor .setNext (invokeData .invoke .asNode ());
@@ -239,12 +272,26 @@ protected void finishInlining(MethodScope is) {
239272 return ;
240273 }
241274
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+ }
243281 ((AnalysisMethod ) invokeData .callTarget .targetMethod ()).registerAsInlined ();
244282
245283 super .finishInlining (inlineScope );
246284 }
247285
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+
248295 /**
249296 * Kill fixed nodes of structured control flow. Not as generic, but faster, than
250297 * {@link GraphUtil#killCFG}.
0 commit comments