comparison src/share/vm/opto/bytecodeInfo.cpp @ 8124:5fc51c1ecdeb

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 05 Mar 2013 23:44:54 +0100
parents 989155e2d07a 133bf557ef77
children b8f261ba79c6
comparison
equal deleted inserted replaced
7943:a413bcd552a4 8124:5fc51c1ecdeb
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 _subtrees(c->comp_arena(), 2, 0, NULL),
51 _msg(NULL)
51 { 52 {
52 NOT_PRODUCT(_count_inlines = 0;) 53 NOT_PRODUCT(_count_inlines = 0;)
53 if (_caller_jvms != NULL) { 54 if (_caller_jvms != NULL) {
54 // Keep a private copy of the caller_jvms: 55 // Keep a private copy of the caller_jvms:
55 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms()); 56 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms());
75 _caller_jvms(caller_jvms), 76 _caller_jvms(caller_jvms),
76 _caller_tree(NULL), 77 _caller_tree(NULL),
77 _method(callee_method), 78 _method(callee_method),
78 _site_invoke_ratio(site_invoke_ratio), 79 _site_invoke_ratio(site_invoke_ratio),
79 _max_inline_level(max_inline_level), 80 _max_inline_level(max_inline_level),
80 _count_inline_bcs(method()->code_size()) 81 _count_inline_bcs(method()->code_size()),
82 _msg(NULL)
81 { 83 {
82 NOT_PRODUCT(_count_inlines = 0;) 84 NOT_PRODUCT(_count_inlines = 0;)
83 assert(!UseOldInlining, "do not use for old stuff"); 85 assert(!UseOldInlining, "do not use for old stuff");
84 } 86 }
85 87
93 caller_method != C->method() && 95 caller_method != C->method() &&
94 caller_method->holder()->is_subclass_of(callee_method->holder())) 96 caller_method->holder()->is_subclass_of(callee_method->holder()))
95 ); 97 );
96 } 98 }
97 99
98 // positive filter: should callee be inlined? returns NULL, if yes, or rejection msg 100 // positive filter: should callee be inlined?
99 const char* InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const { 101 bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
102 int caller_bci, ciCallProfile& profile,
103 WarmCallInfo* wci_result) {
100 // Allows targeted inlining 104 // Allows targeted inlining
101 if(callee_method->should_inline()) { 105 if(callee_method->should_inline()) {
102 *wci_result = *(WarmCallInfo::always_hot()); 106 *wci_result = *(WarmCallInfo::always_hot());
103 if (PrintInlining && Verbose) { 107 if (PrintInlining && Verbose) {
104 CompileTask::print_inline_indent(inline_level()); 108 CompileTask::print_inline_indent(inline_level());
105 tty->print_cr("Inlined method is hot: "); 109 tty->print_cr("Inlined method is hot: ");
106 } 110 }
107 return NULL; 111 set_msg("force inline by CompilerOracle");
108 } 112 return true;
109 113 }
110 // positive filter: should send be inlined? returns NULL (--> yes) 114
111 // or rejection msg
112 int size = callee_method->code_size_for_inlining(); 115 int size = callee_method->code_size_for_inlining();
113 116
114 // Check for too many throws (and not too huge) 117 // Check for too many throws (and not too huge)
115 if(callee_method->interpreter_throwout_count() > InlineThrowCount && 118 if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
116 size < InlineThrowMaxSize ) { 119 size < InlineThrowMaxSize ) {
117 wci_result->set_profit(wci_result->profit() * 100); 120 wci_result->set_profit(wci_result->profit() * 100);
118 if (PrintInlining && Verbose) { 121 if (PrintInlining && Verbose) {
119 CompileTask::print_inline_indent(inline_level()); 122 CompileTask::print_inline_indent(inline_level());
120 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count()); 123 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
121 } 124 }
122 return NULL; 125 set_msg("many throws");
126 return true;
123 } 127 }
124 128
125 if (!UseOldInlining) { 129 if (!UseOldInlining) {
126 return NULL; // size and frequency are represented in a new way 130 set_msg("!UseOldInlining");
131 return true; // size and frequency are represented in a new way
127 } 132 }
128 133
129 int default_max_inline_size = C->max_inline_size(); 134 int default_max_inline_size = C->max_inline_size();
130 int inline_small_code_size = InlineSmallCode / 4; 135 int inline_small_code_size = InlineSmallCode / 4;
131 int max_inline_size = default_max_inline_size; 136 int max_inline_size = default_max_inline_size;
151 } 156 }
152 } else { 157 } else {
153 // Not hot. Check for medium-sized pre-existing nmethod at cold sites. 158 // Not hot. Check for medium-sized pre-existing nmethod at cold sites.
154 if (callee_method->has_compiled_code() && 159 if (callee_method->has_compiled_code() &&
155 callee_method->instructions_size() > inline_small_code_size) 160 callee_method->instructions_size() > inline_small_code_size)
156 return "already compiled into a medium method"; 161 set_msg("already compiled into a medium method");
162 return false;
157 } 163 }
158 if (size > max_inline_size) { 164 if (size > max_inline_size) {
159 if (max_inline_size > default_max_inline_size) 165 if (max_inline_size > default_max_inline_size) {
160 return "hot method too big"; 166 set_msg("hot method too big");
161 return "too big"; 167 } else {
162 } 168 set_msg("too big");
163 return NULL; 169 }
164 } 170 return false;
165 171 }
166 172 return true;
167 // negative filter: should callee NOT be inlined? returns NULL, ok to inline, or rejection msg 173 }
168 const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const { 174
169 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg 175
176 // negative filter: should callee NOT be inlined?
177 bool InlineTree::should_not_inline(ciMethod *callee_method,
178 ciMethod* caller_method,
179 WarmCallInfo* wci_result) {
180
181 const char* fail_msg = NULL;
182
183 // First check all inlining restrictions which are required for correctness
184 if ( callee_method->is_abstract()) {
185 fail_msg = "abstract method"; // // note: we allow ik->is_abstract()
186 } else if (!callee_method->holder()->is_initialized()) {
187 fail_msg = "method holder not initialized";
188 } else if ( callee_method->is_native()) {
189 fail_msg = "native method";
190 } else if ( callee_method->dont_inline()) {
191 fail_msg = "don't inline by annotation";
192 }
193
170 if (!UseOldInlining) { 194 if (!UseOldInlining) {
171 const char* fail = NULL; 195 if (fail_msg != NULL) {
172 if ( callee_method->is_abstract()) fail = "abstract method";
173 // note: we allow ik->is_abstract()
174 if (!callee_method->holder()->is_initialized()) fail = "method holder not initialized";
175 if ( callee_method->is_native()) fail = "native method";
176 if ( callee_method->dont_inline()) fail = "don't inline by annotation";
177
178 if (fail) {
179 *wci_result = *(WarmCallInfo::always_cold()); 196 *wci_result = *(WarmCallInfo::always_cold());
180 return fail; 197 set_msg(fail_msg);
198 return true;
181 } 199 }
182 200
183 if (callee_method->has_unloaded_classes_in_signature()) { 201 if (callee_method->has_unloaded_classes_in_signature()) {
184 wci_result->set_profit(wci_result->profit() * 0.1); 202 wci_result->set_profit(wci_result->profit() * 0.1);
185 } 203 }
197 callee_method->instructions_size() > InlineSmallCode) { 215 callee_method->instructions_size() > InlineSmallCode) {
198 wci_result->set_profit(wci_result->profit() * 0.1); 216 wci_result->set_profit(wci_result->profit() * 0.1);
199 // %%% adjust wci_result->size()? 217 // %%% adjust wci_result->size()?
200 } 218 }
201 219
202 return NULL; 220 return false;
203 } 221 }
204 222
205 // First check all inlining restrictions which are required for correctness 223 // one more inlining restriction
206 if ( callee_method->is_abstract()) return "abstract method"; 224 if (fail_msg == NULL && callee_method->has_unloaded_classes_in_signature()) {
207 // note: we allow ik->is_abstract() 225 fail_msg = "unloaded signature classes";
208 if (!callee_method->holder()->is_initialized()) return "method holder not initialized"; 226 }
209 if ( callee_method->is_native()) return "native method"; 227
210 if ( callee_method->dont_inline()) return "don't inline by annotation"; 228 if (fail_msg != NULL) {
211 if ( callee_method->has_unloaded_classes_in_signature()) return "unloaded signature classes"; 229 set_msg(fail_msg);
212 230 return true;
231 }
232
233 // ignore heuristic controls on inlining
213 if (callee_method->should_inline()) { 234 if (callee_method->should_inline()) {
214 // ignore heuristic controls on inlining 235 set_msg("force inline by CompilerOracle");
215 return NULL; 236 return false;
216 } 237 }
217 if (callee_method->should_not_inline()) { 238 if (callee_method->should_not_inline()) {
218 return "disallowed by CompilerOracle"; 239 return "disallowed by CompilerOracle";
219 } 240 }
220 241
221 // Now perform checks which are heuristic 242 // Now perform checks which are heuristic
222 243
223 if (!callee_method->force_inline()) { 244 if (!callee_method->force_inline()) {
224 if (callee_method->has_compiled_code() && 245 if (callee_method->has_compiled_code() &&
225 callee_method->instructions_size() > InlineSmallCode) { 246 callee_method->instructions_size() > InlineSmallCode) {
226 return "already compiled into a big method"; 247 set_msg("already compiled into a big method");
248 return true;
227 } 249 }
228 } 250 }
229 251
230 // don't inline exception code unless the top method belongs to an 252 // don't inline exception code unless the top method belongs to an
231 // exception class 253 // exception class
232 if (caller_tree() != NULL && 254 if (caller_tree() != NULL &&
233 callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) { 255 callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
234 const InlineTree *top = this; 256 const InlineTree *top = this;
235 while (top->caller_tree() != NULL) top = top->caller_tree(); 257 while (top->caller_tree() != NULL) top = top->caller_tree();
236 ciInstanceKlass* k = top->method()->holder(); 258 ciInstanceKlass* k = top->method()->holder();
237 if (!k->is_subclass_of(C->env()->Throwable_klass())) 259 if (!k->is_subclass_of(C->env()->Throwable_klass())) {
238 return "exception method"; 260 set_msg("exception method");
261 return true;
262 }
239 } 263 }
240 264
241 if (callee_method->should_not_inline()) { 265 if (callee_method->should_not_inline()) {
242 return "disallowed by CompilerOracle"; 266 set_msg("disallowed by CompilerOracle");
267 return true;
243 } 268 }
244 269
245 #ifndef PRODUCT 270 #ifndef PRODUCT
246 if (ciReplay::should_not_inline(callee_method)) { 271 if (ciReplay::should_not_inline(callee_method)) {
247 return "disallowed by ciReplay"; 272 set_msg("disallowed by ciReplay");
273 return true;
248 } 274 }
249 #endif 275 #endif
250 276
251 if (UseStringCache) { 277 if (UseStringCache) {
252 // Do not inline StringCache::profile() method used only at the beginning. 278 // Do not inline StringCache::profile() method used only at the beginning.
253 if (callee_method->name() == ciSymbol::profile_name() && 279 if (callee_method->name() == ciSymbol::profile_name() &&
254 callee_method->holder()->name() == ciSymbol::java_lang_StringCache()) { 280 callee_method->holder()->name() == ciSymbol::java_lang_StringCache()) {
255 return "profiling method"; 281 set_msg("profiling method");
282 return true;
256 } 283 }
257 } 284 }
258 285
259 // use frequency-based objections only for non-trivial methods 286 // use frequency-based objections only for non-trivial methods
260 if (callee_method->code_size() <= MaxTrivialSize) return NULL; 287 if (callee_method->code_size() <= MaxTrivialSize) {
288 return false;
289 }
261 290
262 // don't use counts with -Xcomp or CTW 291 // don't use counts with -Xcomp or CTW
263 if (UseInterpreter && !CompileTheWorld) { 292 if (UseInterpreter && !CompileTheWorld) {
264 293
265 if (!callee_method->has_compiled_code() && 294 if (!callee_method->has_compiled_code() &&
266 !callee_method->was_executed_more_than(0)) { 295 !callee_method->was_executed_more_than(0)) {
267 return "never executed"; 296 set_msg("never executed");
297 return true;
268 } 298 }
269 299
270 if (is_init_with_ea(callee_method, caller_method, C)) { 300 if (is_init_with_ea(callee_method, caller_method, C)) {
271 301
272 // Escape Analysis: inline all executed constructors 302 // Escape Analysis: inline all executed constructors
273 303
274 } else if (!callee_method->was_executed_more_than(MIN2(MinInliningThreshold, 304 } else if (!callee_method->was_executed_more_than(MIN2(MinInliningThreshold,
275 CompileThreshold >> 1))) { 305 CompileThreshold >> 1))) {
276 return "executed < MinInliningThreshold times"; 306 set_msg("executed < MinInliningThreshold times");
277 } 307 return true;
278 } 308 }
279 309 }
280 return NULL; 310
311 return false;
281 } 312 }
282 313
283 //-----------------------------try_to_inline----------------------------------- 314 //-----------------------------try_to_inline-----------------------------------
284 // return NULL if ok, reason for not inlining otherwise 315 // return true if ok
285 // Relocated from "InliningClosure::try_to_inline" 316 // Relocated from "InliningClosure::try_to_inline"
286 const char* InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result, bool& should_delay) { 317 bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,
287 // Old algorithm had funny accumulating BC-size counters 318 int caller_bci, ciCallProfile& profile,
319 WarmCallInfo* wci_result, bool& should_delay) {
320
321 // Old algorithm had funny accumulating BC-size counters
288 if (UseOldInlining && ClipInlining 322 if (UseOldInlining && ClipInlining
289 && (int)count_inline_bcs() >= DesiredMethodLimit) { 323 && (int)count_inline_bcs() >= DesiredMethodLimit) {
290 if (!callee_method->force_inline() || !IncrementalInline) { 324 if (!callee_method->force_inline() || !IncrementalInline) {
291 return "size > DesiredMethodLimit"; 325 set_msg("size > DesiredMethodLimit");
326 return false;
292 } else if (!C->inlining_incrementally()) { 327 } else if (!C->inlining_incrementally()) {
293 should_delay = true; 328 should_delay = true;
294 } 329 }
295 } 330 }
296 331
297 const char *msg = NULL; 332 if (!should_inline(callee_method, caller_method, caller_bci, profile,
298 msg = should_inline(callee_method, caller_method, caller_bci, profile, wci_result); 333 wci_result)) {
299 if (msg != NULL) 334 return false;
300 return msg; 335 }
301 336 if (should_not_inline(callee_method, caller_method, wci_result)) {
302 msg = should_not_inline(callee_method, caller_method, wci_result); 337 return false;
303 if (msg != NULL) 338 }
304 return msg;
305 339
306 if (InlineAccessors && callee_method->is_accessor()) { 340 if (InlineAccessors && callee_method->is_accessor()) {
307 // accessor methods are not subject to any of the following limits. 341 // accessor methods are not subject to any of the following limits.
308 return NULL; 342 set_msg("accessor");
343 return true;
309 } 344 }
310 345
311 // suppress a few checks for accessors and trivial methods 346 // suppress a few checks for accessors and trivial methods
312 if (callee_method->code_size() > MaxTrivialSize) { 347 if (callee_method->code_size() > MaxTrivialSize) {
313 348
314 // don't inline into giant methods 349 // don't inline into giant methods
315 if (C->over_inlining_cutoff()) { 350 if (C->over_inlining_cutoff()) {
316 if ((!callee_method->force_inline() && !caller_method->is_compiled_lambda_form()) 351 if ((!callee_method->force_inline() && !caller_method->is_compiled_lambda_form())
317 || !IncrementalInline) { 352 || !IncrementalInline) {
318 return "NodeCountInliningCutoff"; 353 set_msg("NodeCountInliningCutoff");
354 return false;
319 } else { 355 } else {
320 should_delay = true; 356 should_delay = true;
321 } 357 }
322 } 358 }
323 359
327 // Escape Analysis stress testing when running Xcomp or CTW: 363 // Escape Analysis stress testing when running Xcomp or CTW:
328 // inline constructors even if they are not reached. 364 // inline constructors even if they are not reached.
329 365
330 } else if (profile.count() == 0) { 366 } else if (profile.count() == 0) {
331 // don't inline unreached call sites 367 // don't inline unreached call sites
332 return "call site not reached"; 368 set_msg("call site not reached");
369 return false;
333 } 370 }
334 } 371 }
335 372
336 if (!C->do_inlining() && InlineAccessors) { 373 if (!C->do_inlining() && InlineAccessors) {
337 return "not an accessor"; 374 set_msg("not an accessor");
375 return false;
338 } 376 }
339 if (inline_level() > _max_inline_level) { 377 if (inline_level() > _max_inline_level) {
340 if (!callee_method->force_inline() || !IncrementalInline) { 378 if (!callee_method->force_inline() || !IncrementalInline) {
341 return "inlining too deep"; 379 set_msg("inlining too deep");
380 return false;
342 } else if (!C->inlining_incrementally()) { 381 } else if (!C->inlining_incrementally()) {
343 should_delay = true; 382 should_delay = true;
344 } 383 }
345 } 384 }
346 385
347 // detect direct and indirect recursive inlining 386 // detect direct and indirect recursive inlining
348 if (!callee_method->is_compiled_lambda_form()) { 387 if (!callee_method->is_compiled_lambda_form()) {
349 // count the current method and the callee 388 // count the current method and the callee
350 int inline_level = (method() == callee_method) ? 1 : 0; 389 int inline_level = (method() == callee_method) ? 1 : 0;
351 if (inline_level > MaxRecursiveInlineLevel) 390 if (inline_level > MaxRecursiveInlineLevel) {
352 return "recursively inlining too deep"; 391 set_msg("recursively inlining too deep");
392 return false;
393 }
353 // count callers of current method and callee 394 // count callers of current method and callee
354 JVMState* jvms = caller_jvms(); 395 JVMState* jvms = caller_jvms();
355 while (jvms != NULL && jvms->has_method()) { 396 while (jvms != NULL && jvms->has_method()) {
356 if (jvms->method() == callee_method) { 397 if (jvms->method() == callee_method) {
357 inline_level++; 398 inline_level++;
358 if (inline_level > MaxRecursiveInlineLevel) 399 if (inline_level > MaxRecursiveInlineLevel) {
359 return "recursively inlining too deep"; 400 set_msg("recursively inlining too deep");
401 return false;
402 }
360 } 403 }
361 jvms = jvms->caller(); 404 jvms = jvms->caller();
362 } 405 }
363 } 406 }
364 407
365 int size = callee_method->code_size_for_inlining(); 408 int size = callee_method->code_size_for_inlining();
366 409
367 if (UseOldInlining && ClipInlining 410 if (UseOldInlining && ClipInlining
368 && (int)count_inline_bcs() + size >= DesiredMethodLimit) { 411 && (int)count_inline_bcs() + size >= DesiredMethodLimit) {
369 if (!callee_method->force_inline() || !IncrementalInline) { 412 if (!callee_method->force_inline() || !IncrementalInline) {
370 return "size > DesiredMethodLimit"; 413 set_msg("size > DesiredMethodLimit");
414 return false;
371 } else if (!C->inlining_incrementally()) { 415 } else if (!C->inlining_incrementally()) {
372 should_delay = true; 416 should_delay = true;
373 } 417 }
374 } 418 }
375 419
376 // ok, inline this method 420 // ok, inline this method
377 return NULL; 421 return true;
378 } 422 }
379 423
380 //------------------------------pass_initial_checks---------------------------- 424 //------------------------------pass_initial_checks----------------------------
381 bool pass_initial_checks(ciMethod* caller_method, int caller_bci, ciMethod* callee_method) { 425 bool pass_initial_checks(ciMethod* caller_method, int caller_bci, ciMethod* callee_method) {
382 ciInstanceKlass *callee_holder = callee_method ? callee_method->holder() : NULL; 426 ciInstanceKlass *callee_holder = callee_method ? callee_method->holder() : NULL;
421 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)"; 465 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)";
422 return NULL; 466 return NULL;
423 } 467 }
424 468
425 //------------------------------print_inlining--------------------------------- 469 //------------------------------print_inlining---------------------------------
426 // Really, the failure_msg can be a success message also. 470 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
427 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const { 471 bool success) const {
428 C->print_inlining(callee_method, inline_level(), caller_bci, failure_msg ? failure_msg : "inline"); 472 const char* inline_msg = msg();
429 if (callee_method == NULL) tty->print(" callee not monotonic or profiled"); 473 assert(inline_msg != NULL, "just checking");
430 if (Verbose && callee_method) { 474 if (C->log() != NULL) {
431 const InlineTree *top = this; 475 if (success) {
432 while( top->caller_tree() != NULL ) { top = top->caller_tree(); } 476 C->log()->inline_success(inline_msg);
433 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count()); 477 } else {
478 C->log()->inline_fail(inline_msg);
479 }
480 }
481 if (PrintInlining) {
482 C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
483 if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
484 if (Verbose && callee_method) {
485 const InlineTree *top = this;
486 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
487 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
488 }
434 } 489 }
435 } 490 }
436 491
437 //------------------------------ok_to_inline----------------------------------- 492 //------------------------------ok_to_inline-----------------------------------
438 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) { 493 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
446 } else { 501 } else {
447 assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state"); 502 assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
448 } 503 }
449 assert(_method == jvms->method(), "redundant instance state"); 504 assert(_method == jvms->method(), "redundant instance state");
450 #endif 505 #endif
451 const char *failure_msg = NULL;
452 int caller_bci = jvms->bci(); 506 int caller_bci = jvms->bci();
453 ciMethod *caller_method = jvms->method(); 507 ciMethod* caller_method = jvms->method();
454 508
455 // Do some initial checks. 509 // Do some initial checks.
456 if (!pass_initial_checks(caller_method, caller_bci, callee_method)) { 510 if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
457 if (PrintInlining) print_inlining(callee_method, caller_bci, "failed initial checks"); 511 set_msg("failed initial checks");
512 print_inlining(callee_method, caller_bci, false /* !success */);
458 return NULL; 513 return NULL;
459 } 514 }
460 515
461 // Do some parse checks. 516 // Do some parse checks.
462 failure_msg = check_can_parse(callee_method); 517 set_msg(check_can_parse(callee_method));
463 if (failure_msg != NULL) { 518 if (msg() != NULL) {
464 if (PrintInlining) print_inlining(callee_method, caller_bci, failure_msg); 519 print_inlining(callee_method, caller_bci, false /* !success */);
465 return NULL; 520 return NULL;
466 } 521 }
467 522
468 // Check if inlining policy says no. 523 // Check if inlining policy says no.
469 WarmCallInfo wci = *(initial_wci); 524 WarmCallInfo wci = *(initial_wci);
470 failure_msg = try_to_inline(callee_method, caller_method, caller_bci, profile, &wci, should_delay); 525 bool success = try_to_inline(callee_method, caller_method, caller_bci,
471 if (failure_msg != NULL && C->log() != NULL) { 526 profile, &wci, should_delay);
472 C->log()->inline_fail(failure_msg);
473 }
474 527
475 #ifndef PRODUCT 528 #ifndef PRODUCT
476 if (UseOldInlining && InlineWarmCalls 529 if (UseOldInlining && InlineWarmCalls
477 && (PrintOpto || PrintOptoInlining || PrintInlining)) { 530 && (PrintOpto || PrintOptoInlining || PrintInlining)) {
478 bool cold = wci.is_cold(); 531 bool cold = wci.is_cold();
479 bool hot = !cold && wci.is_hot(); 532 bool hot = !cold && wci.is_hot();
480 bool old_cold = (failure_msg != NULL); 533 bool old_cold = !success;
481 if (old_cold != cold || (Verbose || WizardMode)) { 534 if (old_cold != cold || (Verbose || WizardMode)) {
535 if (msg() == NULL) {
536 set_msg("OK");
537 }
482 tty->print(" OldInlining= %4s : %s\n WCI=", 538 tty->print(" OldInlining= %4s : %s\n WCI=",
483 old_cold ? "cold" : "hot", failure_msg ? failure_msg : "OK"); 539 old_cold ? "cold" : "hot", msg());
484 wci.print(); 540 wci.print();
485 } 541 }
486 } 542 }
487 #endif 543 #endif
488 if (UseOldInlining) { 544 if (UseOldInlining) {
489 if (failure_msg == NULL) 545 if (success) {
490 wci = *(WarmCallInfo::always_hot()); 546 wci = *(WarmCallInfo::always_hot());
491 else 547 } else {
492 wci = *(WarmCallInfo::always_cold()); 548 wci = *(WarmCallInfo::always_cold());
549 }
493 } 550 }
494 if (!InlineWarmCalls) { 551 if (!InlineWarmCalls) {
495 if (!wci.is_cold() && !wci.is_hot()) { 552 if (!wci.is_cold() && !wci.is_hot()) {
496 // Do not inline the warm calls. 553 // Do not inline the warm calls.
497 wci = *(WarmCallInfo::always_cold()); 554 wci = *(WarmCallInfo::always_cold());
498 } 555 }
499 } 556 }
500 557
501 if (!wci.is_cold()) { 558 if (!wci.is_cold()) {
502 // In -UseOldInlining, the failure_msg may also be a success message.
503 if (failure_msg == NULL) failure_msg = "inline (hot)";
504
505 // Inline! 559 // Inline!
506 if (PrintInlining) print_inlining(callee_method, caller_bci, failure_msg); 560 if (msg() == NULL) {
561 set_msg("inline (hot)");
562 }
563 print_inlining(callee_method, caller_bci, true /* success */);
507 if (UseOldInlining) 564 if (UseOldInlining)
508 build_inline_tree_for_callee(callee_method, jvms, caller_bci); 565 build_inline_tree_for_callee(callee_method, jvms, caller_bci);
509 if (InlineWarmCalls && !wci.is_hot()) 566 if (InlineWarmCalls && !wci.is_hot())
510 return new (C) WarmCallInfo(wci); // copy to heap 567 return new (C) WarmCallInfo(wci); // copy to heap
511 return WarmCallInfo::always_hot(); 568 return WarmCallInfo::always_hot();
512 } 569 }
513 570
514 // Do not inline 571 // Do not inline
515 if (failure_msg == NULL) failure_msg = "too cold to inline"; 572 if (msg() == NULL) {
516 if (PrintInlining) print_inlining(callee_method, caller_bci, failure_msg); 573 set_msg("too cold to inline");
574 }
575 print_inlining(callee_method, caller_bci, false /* !success */ );
517 return NULL; 576 return NULL;
518 } 577 }
519 578
520 //------------------------------compute_callee_frequency----------------------- 579 //------------------------------compute_callee_frequency-----------------------
521 float InlineTree::compute_callee_frequency( int caller_bci ) const { 580 float InlineTree::compute_callee_frequency( int caller_bci ) const {