Mercurial > hg > truffle
comparison src/share/vm/opto/bytecodeInfo.cpp @ 7482:989155e2d07a
Merge with hs25-b15.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Jan 2013 01:34:24 +0100 |
parents | 2cb439954abf d092d1b31229 |
children | 5fc51c1ecdeb |
comparison
equal
deleted
inserted
replaced
7381:6761a8f854a4 | 7482:989155e2d07a |
---|---|
44 _caller_jvms(caller_jvms), | 44 _caller_jvms(caller_jvms), |
45 _caller_tree((InlineTree*) caller_tree), | 45 _caller_tree((InlineTree*) caller_tree), |
46 _method(callee), | 46 _method(callee), |
47 _site_invoke_ratio(site_invoke_ratio), | 47 _site_invoke_ratio(site_invoke_ratio), |
48 _max_inline_level(max_inline_level), | 48 _max_inline_level(max_inline_level), |
49 _count_inline_bcs(method()->code_size_for_inlining()) | 49 _count_inline_bcs(method()->code_size_for_inlining()), |
50 _subtrees(c->comp_arena(), 2, 0, NULL) | |
50 { | 51 { |
51 NOT_PRODUCT(_count_inlines = 0;) | 52 NOT_PRODUCT(_count_inlines = 0;) |
52 if (_caller_jvms != NULL) { | 53 if (_caller_jvms != NULL) { |
53 // Keep a private copy of the caller_jvms: | 54 // Keep a private copy of the caller_jvms: |
54 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms()); | 55 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms()); |
207 if (!callee_method->holder()->is_initialized()) return "method holder not initialized"; | 208 if (!callee_method->holder()->is_initialized()) return "method holder not initialized"; |
208 if ( callee_method->is_native()) return "native method"; | 209 if ( callee_method->is_native()) return "native method"; |
209 if ( callee_method->dont_inline()) return "don't inline by annotation"; | 210 if ( callee_method->dont_inline()) return "don't inline by annotation"; |
210 if ( callee_method->has_unloaded_classes_in_signature()) return "unloaded signature classes"; | 211 if ( callee_method->has_unloaded_classes_in_signature()) return "unloaded signature classes"; |
211 | 212 |
212 if (callee_method->force_inline() || callee_method->should_inline()) { | 213 if (callee_method->should_inline()) { |
213 // ignore heuristic controls on inlining | 214 // ignore heuristic controls on inlining |
214 return NULL; | 215 return NULL; |
215 } | 216 } |
216 if (callee_method->should_not_inline()) { | 217 if (callee_method->should_not_inline()) { |
217 return "disallowed by CompilerOracle"; | 218 return "disallowed by CompilerOracle"; |
218 } | 219 } |
219 | 220 |
220 // Now perform checks which are heuristic | 221 // Now perform checks which are heuristic |
221 | 222 |
222 if (callee_method->has_compiled_code() && | 223 if (!callee_method->force_inline()) { |
223 callee_method->instructions_size() > InlineSmallCode) { | 224 if (callee_method->has_compiled_code() && |
225 callee_method->instructions_size() > InlineSmallCode) { | |
224 return "already compiled into a big method"; | 226 return "already compiled into a big method"; |
227 } | |
225 } | 228 } |
226 | 229 |
227 // don't inline exception code unless the top method belongs to an | 230 // don't inline exception code unless the top method belongs to an |
228 // exception class | 231 // exception class |
229 if (caller_tree() != NULL && | 232 if (caller_tree() != NULL && |
278 } | 281 } |
279 | 282 |
280 //-----------------------------try_to_inline----------------------------------- | 283 //-----------------------------try_to_inline----------------------------------- |
281 // return NULL if ok, reason for not inlining otherwise | 284 // return NULL if ok, reason for not inlining otherwise |
282 // Relocated from "InliningClosure::try_to_inline" | 285 // Relocated from "InliningClosure::try_to_inline" |
283 const char* InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) { | 286 const char* InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result, bool& should_delay) { |
284 | |
285 // Old algorithm had funny accumulating BC-size counters | 287 // Old algorithm had funny accumulating BC-size counters |
286 if (UseOldInlining && ClipInlining | 288 if (UseOldInlining && ClipInlining |
287 && (int)count_inline_bcs() >= DesiredMethodLimit) { | 289 && (int)count_inline_bcs() >= DesiredMethodLimit) { |
288 return "size > DesiredMethodLimit"; | 290 if (!callee_method->force_inline() || !IncrementalInline) { |
291 return "size > DesiredMethodLimit"; | |
292 } else if (!C->inlining_incrementally()) { | |
293 should_delay = true; | |
294 } | |
289 } | 295 } |
290 | 296 |
291 const char *msg = NULL; | 297 const char *msg = NULL; |
292 msg = should_inline(callee_method, caller_method, caller_bci, profile, wci_result); | 298 msg = should_inline(callee_method, caller_method, caller_bci, profile, wci_result); |
293 if (msg != NULL) | 299 if (msg != NULL) |
304 | 310 |
305 // suppress a few checks for accessors and trivial methods | 311 // suppress a few checks for accessors and trivial methods |
306 if (callee_method->code_size() > MaxTrivialSize) { | 312 if (callee_method->code_size() > MaxTrivialSize) { |
307 | 313 |
308 // don't inline into giant methods | 314 // don't inline into giant methods |
309 if (C->unique() > (uint)NodeCountInliningCutoff) { | 315 if (C->over_inlining_cutoff()) { |
310 return "NodeCountInliningCutoff"; | 316 if ((!callee_method->force_inline() && !caller_method->is_compiled_lambda_form()) |
317 || !IncrementalInline) { | |
318 return "NodeCountInliningCutoff"; | |
319 } else { | |
320 should_delay = true; | |
321 } | |
311 } | 322 } |
312 | 323 |
313 if ((!UseInterpreter || CompileTheWorld) && | 324 if ((!UseInterpreter || CompileTheWorld) && |
314 is_init_with_ea(callee_method, caller_method, C)) { | 325 is_init_with_ea(callee_method, caller_method, C)) { |
315 | 326 |
324 | 335 |
325 if (!C->do_inlining() && InlineAccessors) { | 336 if (!C->do_inlining() && InlineAccessors) { |
326 return "not an accessor"; | 337 return "not an accessor"; |
327 } | 338 } |
328 if (inline_level() > _max_inline_level) { | 339 if (inline_level() > _max_inline_level) { |
329 return "inlining too deep"; | 340 if (!callee_method->force_inline() || !IncrementalInline) { |
341 return "inlining too deep"; | |
342 } else if (!C->inlining_incrementally()) { | |
343 should_delay = true; | |
344 } | |
330 } | 345 } |
331 | 346 |
332 // detect direct and indirect recursive inlining | 347 // detect direct and indirect recursive inlining |
333 if (!callee_method->is_compiled_lambda_form()) { | 348 if (!callee_method->is_compiled_lambda_form()) { |
334 // count the current method and the callee | 349 // count the current method and the callee |
349 | 364 |
350 int size = callee_method->code_size_for_inlining(); | 365 int size = callee_method->code_size_for_inlining(); |
351 | 366 |
352 if (UseOldInlining && ClipInlining | 367 if (UseOldInlining && ClipInlining |
353 && (int)count_inline_bcs() + size >= DesiredMethodLimit) { | 368 && (int)count_inline_bcs() + size >= DesiredMethodLimit) { |
354 return "size > DesiredMethodLimit"; | 369 if (!callee_method->force_inline() || !IncrementalInline) { |
370 return "size > DesiredMethodLimit"; | |
371 } else if (!C->inlining_incrementally()) { | |
372 should_delay = true; | |
373 } | |
355 } | 374 } |
356 | 375 |
357 // ok, inline this method | 376 // ok, inline this method |
358 return NULL; | 377 return NULL; |
359 } | 378 } |
404 } | 423 } |
405 | 424 |
406 //------------------------------print_inlining--------------------------------- | 425 //------------------------------print_inlining--------------------------------- |
407 // Really, the failure_msg can be a success message also. | 426 // Really, the failure_msg can be a success message also. |
408 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const { | 427 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const { |
409 CompileTask::print_inlining(callee_method, inline_level(), caller_bci, failure_msg ? failure_msg : "inline"); | 428 C->print_inlining(callee_method, inline_level(), caller_bci, failure_msg ? failure_msg : "inline"); |
410 if (callee_method == NULL) tty->print(" callee not monotonic or profiled"); | 429 if (callee_method == NULL) tty->print(" callee not monotonic or profiled"); |
411 if (Verbose && callee_method) { | 430 if (Verbose && callee_method) { |
412 const InlineTree *top = this; | 431 const InlineTree *top = this; |
413 while( top->caller_tree() != NULL ) { top = top->caller_tree(); } | 432 while( top->caller_tree() != NULL ) { top = top->caller_tree(); } |
414 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count()); | 433 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count()); |
415 } | 434 } |
416 } | 435 } |
417 | 436 |
418 //------------------------------ok_to_inline----------------------------------- | 437 //------------------------------ok_to_inline----------------------------------- |
419 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci) { | 438 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) { |
420 assert(callee_method != NULL, "caller checks for optimized virtual!"); | 439 assert(callee_method != NULL, "caller checks for optimized virtual!"); |
440 assert(!should_delay, "should be initialized to false"); | |
421 #ifdef ASSERT | 441 #ifdef ASSERT |
422 // Make sure the incoming jvms has the same information content as me. | 442 // Make sure the incoming jvms has the same information content as me. |
423 // This means that we can eventually make this whole class AllStatic. | 443 // This means that we can eventually make this whole class AllStatic. |
424 if (jvms->caller() == NULL) { | 444 if (jvms->caller() == NULL) { |
425 assert(_caller_jvms == NULL, "redundant instance state"); | 445 assert(_caller_jvms == NULL, "redundant instance state"); |
445 return NULL; | 465 return NULL; |
446 } | 466 } |
447 | 467 |
448 // Check if inlining policy says no. | 468 // Check if inlining policy says no. |
449 WarmCallInfo wci = *(initial_wci); | 469 WarmCallInfo wci = *(initial_wci); |
450 failure_msg = try_to_inline(callee_method, caller_method, caller_bci, profile, &wci); | 470 failure_msg = try_to_inline(callee_method, caller_method, caller_bci, profile, &wci, should_delay); |
451 if (failure_msg != NULL && C->log() != NULL) { | 471 if (failure_msg != NULL && C->log() != NULL) { |
452 C->log()->inline_fail(failure_msg); | 472 C->log()->inline_fail(failure_msg); |
453 } | 473 } |
454 | 474 |
455 #ifndef PRODUCT | 475 #ifndef PRODUCT |