215 assert targetMethod.getDeclaringClass().isAssignableFrom(holder) : holder + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod;
216 ResolvedJavaMethod resolvedMethod = holder.resolveConcreteMethod(targetMethod, contextType);
217 if (resolvedMethod != null) {
218 return getExactInlineInfo(invoke, resolvedMethod);
219 }
220 }
221 }
222 }
223
224 if (holder.isArray()) {
225 // arrays can be treated as Objects
226 ResolvedJavaMethod resolvedMethod = holder.resolveConcreteMethod(targetMethod, contextType);
227 if (resolvedMethod != null) {
228 return getExactInlineInfo(invoke, resolvedMethod);
229 }
230 }
231
232 AssumptionResult<ResolvedJavaType> leafConcreteSubtype = holder.findLeafConcreteSubtype();
233 if (leafConcreteSubtype != null) {
234 ResolvedJavaMethod resolvedMethod = leafConcreteSubtype.getResult().resolveConcreteMethod(targetMethod, contextType);
235 if (resolvedMethod != null) {
236 if (leafConcreteSubtype.canRecordTo(callTarget.graph().getAssumptions())) {
237 return getAssumptionInlineInfo(invoke, resolvedMethod, leafConcreteSubtype);
238 } else {
239 return getTypeCheckedAssumptionInfo(invoke, resolvedMethod, leafConcreteSubtype.getResult());
240 }
241 }
242 }
243
244 AssumptionResult<ResolvedJavaMethod> concrete = holder.findUniqueConcreteMethod(targetMethod);
245 if (concrete != null && concrete.canRecordTo(callTarget.graph().getAssumptions())) {
246 return getAssumptionInlineInfo(invoke, concrete.getResult(), concrete);
247 }
248
249 // type check based inlining
250 return getTypeCheckedInlineInfo(invoke, targetMethod);
251 }
252
253 private InlineInfo getTypeCheckedAssumptionInfo(Invoke invoke, ResolvedJavaMethod method, ResolvedJavaType type) {
254 if (!checkTargetConditions(invoke, method)) {
255 return null;
256 }
257 return new TypeGuardInlineInfo(invoke, method, type);
258 }
259
260 private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod targetMethod) {
261 JavaTypeProfile typeProfile = ((MethodCallTargetNode) invoke.callTarget()).getProfile();
262 if (typeProfile == null) {
263 InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "no type profile exists");
264 invoke.asNode().graph().getInliningLog().addDecision(invoke, false, "InliningPhase", null, null, "no type profile exists");
265 return null;
266 }
267
268 JavaTypeProfile.ProfiledType[] ptypes = typeProfile.getTypes();
269 if (ptypes == null || ptypes.length <= 0) {
270 InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "no types in profile");
271 invoke.asNode().graph().getInliningLog().addDecision(invoke, false, "InliningPhase", null, null, "no types in profile");
272 return null;
273 }
274 ResolvedJavaType contextType = invoke.getContextType();
275 double notRecordedTypeProbability = typeProfile.getNotRecordedProbability();
276 final OptimisticOptimizations optimisticOpts = context.getOptimisticOptimizations();
277 OptionValues options = invoke.asNode().getOptions();
|
215 assert targetMethod.getDeclaringClass().isAssignableFrom(holder) : holder + " subtype of " + targetMethod.getDeclaringClass() + " for " + targetMethod;
216 ResolvedJavaMethod resolvedMethod = holder.resolveConcreteMethod(targetMethod, contextType);
217 if (resolvedMethod != null) {
218 return getExactInlineInfo(invoke, resolvedMethod);
219 }
220 }
221 }
222 }
223
224 if (holder.isArray()) {
225 // arrays can be treated as Objects
226 ResolvedJavaMethod resolvedMethod = holder.resolveConcreteMethod(targetMethod, contextType);
227 if (resolvedMethod != null) {
228 return getExactInlineInfo(invoke, resolvedMethod);
229 }
230 }
231
232 AssumptionResult<ResolvedJavaType> leafConcreteSubtype = holder.findLeafConcreteSubtype();
233 if (leafConcreteSubtype != null) {
234 ResolvedJavaMethod resolvedMethod = leafConcreteSubtype.getResult().resolveConcreteMethod(targetMethod, contextType);
235 if (resolvedMethod != null && leafConcreteSubtype.canRecordTo(callTarget.graph().getAssumptions())) {
236 return getAssumptionInlineInfo(invoke, resolvedMethod, leafConcreteSubtype);
237 }
238 }
239
240 AssumptionResult<ResolvedJavaMethod> concrete = holder.findUniqueConcreteMethod(targetMethod);
241 if (concrete != null && concrete.canRecordTo(callTarget.graph().getAssumptions())) {
242 return getAssumptionInlineInfo(invoke, concrete.getResult(), concrete);
243 }
244
245 // type check based inlining
246 return getTypeCheckedInlineInfo(invoke, targetMethod);
247 }
248
249 private InlineInfo getTypeCheckedInlineInfo(Invoke invoke, ResolvedJavaMethod targetMethod) {
250 JavaTypeProfile typeProfile = ((MethodCallTargetNode) invoke.callTarget()).getProfile();
251 if (typeProfile == null) {
252 InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "no type profile exists");
253 invoke.asNode().graph().getInliningLog().addDecision(invoke, false, "InliningPhase", null, null, "no type profile exists");
254 return null;
255 }
256
257 JavaTypeProfile.ProfiledType[] ptypes = typeProfile.getTypes();
258 if (ptypes == null || ptypes.length <= 0) {
259 InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "no types in profile");
260 invoke.asNode().graph().getInliningLog().addDecision(invoke, false, "InliningPhase", null, null, "no types in profile");
261 return null;
262 }
263 ResolvedJavaType contextType = invoke.getContextType();
264 double notRecordedTypeProbability = typeProfile.getNotRecordedProbability();
265 final OptimisticOptimizations optimisticOpts = context.getOptimisticOptimizations();
266 OptionValues options = invoke.asNode().getOptions();
|