@@ -133,13 +133,20 @@ private boolean shouldInlineInvoke0(GraphBuilderContext b, SVMHost hostVM, Accum
133
133
return true ;
134
134
}
135
135
136
- boolean inMethodHandleIntrinsification = policyScope != null ? policyScope .accumulativeCounters .inMethodHandleIntrinsification : false ;
136
+ boolean inMethodHandleIntrinsification = policyScope != null && policyScope .accumulativeCounters .inMethodHandleIntrinsification ;
137
137
int allowedInlinings = inMethodHandleIntrinsification ? optionMethodHandleAllowedInlinings : optionAllowedInlinings ;
138
138
if (policyScope != null && policyScope .accumulativeCounters .totalInlinedMethods >= allowedInlinings ) {
139
139
return false ;
140
140
}
141
141
int allowedDepth = inMethodHandleIntrinsification ? optionMethodHandleAllowedDepth : optionAllowedDepth ;
142
- if (b .getDepth () >= allowedDepth ) {
142
+ /*
143
+ * Note that we do not use the inlining depth from the GraphBuilderContext: If we are in a
144
+ * regular inlining scope, but nested into a deep method handle intrinsification, then the
145
+ * total inlining depth is high but our local depth for the scope can still be low enough to
146
+ * do inlining.
147
+ */
148
+ int actualDepth = policyScope == null ? 0 : policyScope .inliningDepth ;
149
+ if (actualDepth >= allowedDepth ) {
143
150
return false ;
144
151
}
145
152
if (!inMethodHandleIntrinsification && b .recursiveInliningDepth (method ) > 0 ) {
@@ -284,8 +291,11 @@ public AccumulativeInlineScope createAccumulativeInlineScope(AccumulativeInlineS
284
291
* This assumes that the regular limits are strict enough to prevent excessive inlining
285
292
* triggered by method handles. We could also use alternative fixed values or the option
286
293
* defaults instead of any set option values.
294
+ *
295
+ * We start again with an inlining depth of 1, i.e., we behave as if that method is the
296
+ * inlining root.
287
297
*/
288
- depth = outer . inliningDepth + 1 ;
298
+ depth = 1 ;
289
299
accumulativeCounters = new AccumulativeCounters (optionAllowedNodes , optionAllowedInvokes , false );
290
300
291
301
} else {
0 commit comments