Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/opto/bytecodeInfo.cpp
+++ new/src/share/vm/opto/bytecodeInfo.cpp
1 1 /*
2 2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #include "precompiled.hpp"
26 26 #include "classfile/systemDictionary.hpp"
27 27 #include "classfile/vmSymbols.hpp"
28 +#include "compiler/compileBroker.hpp"
28 29 #include "compiler/compileLog.hpp"
29 30 #include "interpreter/linkResolver.hpp"
30 31 #include "oops/objArrayKlass.hpp"
31 32 #include "opto/callGenerator.hpp"
32 33 #include "opto/parse.hpp"
33 34 #include "runtime/handles.inline.hpp"
34 35
35 36 //=============================================================================
36 37 //------------------------------InlineTree-------------------------------------
37 38 InlineTree::InlineTree( Compile* c,
38 39 const InlineTree *caller_tree, ciMethod* callee,
39 40 JVMState* caller_jvms, int caller_bci,
40 41 float site_invoke_ratio, int site_depth_adjust)
41 42 : C(c), _caller_jvms(caller_jvms),
42 43 _caller_tree((InlineTree*)caller_tree),
43 44 _method(callee), _site_invoke_ratio(site_invoke_ratio),
44 45 _site_depth_adjust(site_depth_adjust),
45 46 _count_inline_bcs(method()->code_size())
46 47 {
47 48 NOT_PRODUCT(_count_inlines = 0;)
48 49 if (_caller_jvms != NULL) {
49 50 // Keep a private copy of the caller_jvms:
50 51 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms());
51 52 _caller_jvms->set_bci(caller_jvms->bci());
52 53 assert(!caller_jvms->should_reexecute(), "there should be no reexecute bytecode with inlining");
53 54 }
54 55 assert(_caller_jvms->same_calls_as(caller_jvms), "consistent JVMS");
55 56 assert((caller_tree == NULL ? 0 : caller_tree->stack_depth() + 1) == stack_depth(), "correct (redundant) depth parameter");
56 57 assert(caller_bci == this->caller_bci(), "correct (redundant) bci parameter");
57 58 if (UseOldInlining) {
58 59 // Update hierarchical counts, count_inline_bcs() and count_inlines()
59 60 InlineTree *caller = (InlineTree *)caller_tree;
60 61 for( ; caller != NULL; caller = ((InlineTree *)(caller->caller_tree())) ) {
61 62 caller->_count_inline_bcs += count_inline_bcs();
62 63 NOT_PRODUCT(caller->_count_inlines++;)
63 64 }
64 65 }
65 66 }
66 67
67 68 InlineTree::InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms,
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
68 69 float site_invoke_ratio, int site_depth_adjust)
69 70 : C(c), _caller_jvms(caller_jvms), _caller_tree(NULL),
70 71 _method(callee_method), _site_invoke_ratio(site_invoke_ratio),
71 72 _site_depth_adjust(site_depth_adjust),
72 73 _count_inline_bcs(method()->code_size())
73 74 {
74 75 NOT_PRODUCT(_count_inlines = 0;)
75 76 assert(!UseOldInlining, "do not use for old stuff");
76 77 }
77 78
78 -
79 -
80 -static void print_indent(int depth) {
81 - tty->print(" ");
82 - for (int i = depth; i != 0; --i) tty->print(" ");
83 -}
84 -
85 79 static bool is_init_with_ea(ciMethod* callee_method,
86 80 ciMethod* caller_method, Compile* C) {
87 81 // True when EA is ON and a java constructor is called or
88 82 // a super constructor is called from an inlined java constructor.
89 83 return C->do_escape_analysis() && EliminateAllocations &&
90 84 ( callee_method->is_initializer() ||
91 85 (caller_method->is_initializer() &&
92 86 caller_method != C->method() &&
93 87 caller_method->holder()->is_subclass_of(callee_method->holder()))
94 88 );
95 89 }
96 90
97 91 // positive filter: should send be inlined? returns NULL, if yes, or rejection msg
98 92 const char* InlineTree::shouldInline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const {
99 93 // Allows targeted inlining
100 94 if(callee_method->should_inline()) {
101 95 *wci_result = *(WarmCallInfo::always_hot());
102 96 if (PrintInlining && Verbose) {
103 - print_indent(inline_depth());
97 + CompileTask::print_inline_indent(inline_depth());
104 98 tty->print_cr("Inlined method is hot: ");
105 99 }
106 100 return NULL;
107 101 }
108 102
109 103 // positive filter: should send be inlined? returns NULL (--> yes)
110 104 // or rejection msg
111 105 int max_size = C->max_inline_size();
112 106 int size = callee_method->code_size();
113 107
114 108 // Check for too many throws (and not too huge)
115 109 if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
116 110 size < InlineThrowMaxSize ) {
117 111 wci_result->set_profit(wci_result->profit() * 100);
118 112 if (PrintInlining && Verbose) {
119 - print_indent(inline_depth());
113 + CompileTask::print_inline_indent(inline_depth());
120 114 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
121 115 }
122 116 return NULL;
123 117 }
124 118
125 119 if (!UseOldInlining) {
126 120 return NULL; // size and frequency are represented in a new way
127 121 }
128 122
129 123 int call_site_count = method()->scale_count(profile.count());
130 124 int invoke_count = method()->interpreter_invocation_count();
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
131 125 assert( invoke_count != 0, "Require invokation count greater than zero");
132 126 int freq = call_site_count/invoke_count;
133 127
134 128 // bump the max size if the call is frequent
135 129 if ((freq >= InlineFrequencyRatio) ||
136 130 (call_site_count >= InlineFrequencyCount) ||
137 131 is_init_with_ea(callee_method, caller_method, C)) {
138 132
139 133 max_size = C->freq_inline_size();
140 134 if (size <= max_size && TraceFrequencyInlining) {
141 - print_indent(inline_depth());
135 + CompileTask::print_inline_indent(inline_depth());
142 136 tty->print_cr("Inlined frequent method (freq=%d count=%d):", freq, call_site_count);
143 - print_indent(inline_depth());
137 + CompileTask::print_inline_indent(inline_depth());
144 138 callee_method->print();
145 139 tty->cr();
146 140 }
147 141 } else {
148 142 // Not hot. Check for medium-sized pre-existing nmethod at cold sites.
149 143 if (callee_method->has_compiled_code() &&
150 144 callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode/4)
151 145 return "already compiled into a medium method";
152 146 }
153 147 if (size > max_size) {
154 148 if (max_size > C->max_inline_size())
155 149 return "hot method too big";
156 150 return "too big";
157 151 }
158 152 return NULL;
159 153 }
160 154
161 155
162 156 // negative filter: should send NOT be inlined? returns NULL, ok to inline, or rejection msg
163 157 const char* InlineTree::shouldNotInline(ciMethod *callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const {
164 158 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg
165 159 if (!UseOldInlining) {
166 160 const char* fail = NULL;
167 161 if (callee_method->is_abstract()) fail = "abstract method";
168 162 // note: we allow ik->is_abstract()
169 163 if (!callee_method->holder()->is_initialized()) fail = "method holder not initialized";
170 164 if (callee_method->is_native()) fail = "native method";
171 165
172 166 if (fail) {
173 167 *wci_result = *(WarmCallInfo::always_cold());
174 168 return fail;
175 169 }
176 170
177 171 if (callee_method->has_unloaded_classes_in_signature()) {
178 172 wci_result->set_profit(wci_result->profit() * 0.1);
179 173 }
180 174
181 175 // don't inline exception code unless the top method belongs to an
182 176 // exception class
183 177 if (callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
184 178 ciMethod* top_method = caller_jvms() ? caller_jvms()->of_depth(1)->method() : method();
185 179 if (!top_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
186 180 wci_result->set_profit(wci_result->profit() * 0.1);
187 181 }
188 182 }
189 183
190 184 if (callee_method->has_compiled_code() && callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode) {
191 185 wci_result->set_profit(wci_result->profit() * 0.1);
192 186 // %%% adjust wci_result->size()?
193 187 }
194 188
195 189 return NULL;
196 190 }
197 191
198 192 // Always inline MethodHandle methods and generated MethodHandle adapters.
199 193 if (callee_method->is_method_handle_invoke() || callee_method->is_method_handle_adapter())
200 194 return NULL;
201 195
202 196 // First check all inlining restrictions which are required for correctness
203 197 if (callee_method->is_abstract()) return "abstract method";
204 198 // note: we allow ik->is_abstract()
205 199 if (!callee_method->holder()->is_initialized()) return "method holder not initialized";
206 200 if (callee_method->is_native()) return "native method";
207 201 if (callee_method->has_unloaded_classes_in_signature()) return "unloaded signature classes";
208 202
209 203 if (callee_method->should_inline()) {
210 204 // ignore heuristic controls on inlining
211 205 return NULL;
212 206 }
213 207
214 208 // Now perform checks which are heuristic
215 209
216 210 if( callee_method->has_compiled_code() && callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode )
217 211 return "already compiled into a big method";
218 212
219 213 // don't inline exception code unless the top method belongs to an
220 214 // exception class
221 215 if (caller_tree() != NULL &&
222 216 callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
223 217 const InlineTree *top = this;
224 218 while (top->caller_tree() != NULL) top = top->caller_tree();
225 219 ciInstanceKlass* k = top->method()->holder();
226 220 if (!k->is_subclass_of(C->env()->Throwable_klass()))
227 221 return "exception method";
228 222 }
229 223
230 224 // use frequency-based objections only for non-trivial methods
231 225 if (callee_method->code_size() <= MaxTrivialSize) return NULL;
232 226
233 227 // don't use counts with -Xcomp or CTW
234 228 if (UseInterpreter && !CompileTheWorld) {
235 229
236 230 if (!callee_method->has_compiled_code() &&
237 231 !callee_method->was_executed_more_than(0)) {
238 232 return "never executed";
239 233 }
240 234
241 235 if (is_init_with_ea(callee_method, caller_method, C)) {
242 236
243 237 // Escape Analysis: inline all executed constructors
244 238
245 239 } else if (!callee_method->was_executed_more_than(MIN2(MinInliningThreshold,
246 240 CompileThreshold >> 1))) {
247 241 return "executed < MinInliningThreshold times";
248 242 }
249 243 }
250 244
251 245 if (callee_method->should_not_inline()) {
252 246 return "disallowed by CompilerOracle";
253 247 }
254 248
255 249 if (UseStringCache) {
256 250 // Do not inline StringCache::profile() method used only at the beginning.
257 251 if (callee_method->name() == ciSymbol::profile_name() &&
258 252 callee_method->holder()->name() == ciSymbol::java_lang_StringCache()) {
259 253 return "profiling method";
260 254 }
261 255 }
262 256
263 257 return NULL;
264 258 }
265 259
266 260 //-----------------------------try_to_inline-----------------------------------
267 261 // return NULL if ok, reason for not inlining otherwise
268 262 // Relocated from "InliningClosure::try_to_inline"
269 263 const char* InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) {
270 264
271 265 // Old algorithm had funny accumulating BC-size counters
272 266 if (UseOldInlining && ClipInlining
273 267 && (int)count_inline_bcs() >= DesiredMethodLimit) {
274 268 return "size > DesiredMethodLimit";
275 269 }
276 270
277 271 const char *msg = NULL;
278 272 if ((msg = shouldInline(callee_method, caller_method, caller_bci,
279 273 profile, wci_result)) != NULL) {
280 274 return msg;
281 275 }
282 276 if ((msg = shouldNotInline(callee_method, caller_method,
283 277 wci_result)) != NULL) {
284 278 return msg;
285 279 }
286 280
287 281 if (InlineAccessors && callee_method->is_accessor()) {
288 282 // accessor methods are not subject to any of the following limits.
289 283 return NULL;
290 284 }
291 285
292 286 // suppress a few checks for accessors and trivial methods
293 287 if (callee_method->code_size() > MaxTrivialSize) {
294 288
295 289 // don't inline into giant methods
296 290 if (C->unique() > (uint)NodeCountInliningCutoff) {
297 291 return "NodeCountInliningCutoff";
298 292 }
299 293
300 294 if ((!UseInterpreter || CompileTheWorld) &&
301 295 is_init_with_ea(callee_method, caller_method, C)) {
302 296
303 297 // Escape Analysis stress testing when running Xcomp or CTW:
304 298 // inline constructors even if they are not reached.
305 299
306 300 } else if (profile.count() == 0) {
307 301 // don't inline unreached call sites
↓ open down ↓ |
154 lines elided |
↑ open up ↑ |
308 302 return "call site not reached";
309 303 }
310 304 }
311 305
312 306 if (!C->do_inlining() && InlineAccessors) {
313 307 return "not an accessor";
314 308 }
315 309 if( inline_depth() > MaxInlineLevel ) {
316 310 return "inlining too deep";
317 311 }
318 - if( method() == callee_method &&
319 - inline_depth() > MaxRecursiveInlineLevel ) {
312 +
313 + // We need to detect recursive inlining of method handle targets: if
314 + // the current method is a method handle adapter and one of the
315 + // callers is the same method as the callee, we bail out if
316 + // MaxRecursiveInlineLevel is hit.
317 + if (method()->is_method_handle_adapter()) {
318 + JVMState* jvms = caller_jvms();
319 + int inline_level = 0;
320 + while (jvms != NULL && jvms->has_method()) {
321 + if (jvms->method() == callee_method) {
322 + inline_level++;
323 + if (inline_level > MaxRecursiveInlineLevel)
324 + return "recursively inlining too deep";
325 + }
326 + jvms = jvms->caller();
327 + }
328 + }
329 +
330 + if (method() == callee_method && inline_depth() > MaxRecursiveInlineLevel) {
320 331 return "recursively inlining too deep";
321 332 }
322 333
323 334 int size = callee_method->code_size();
324 335
325 336 if (UseOldInlining && ClipInlining
326 337 && (int)count_inline_bcs() + size >= DesiredMethodLimit) {
327 338 return "size > DesiredMethodLimit";
328 339 }
329 340
330 341 // ok, inline this method
331 342 return NULL;
332 343 }
333 344
334 345 //------------------------------pass_initial_checks----------------------------
335 346 bool pass_initial_checks(ciMethod* caller_method, int caller_bci, ciMethod* callee_method) {
336 347 ciInstanceKlass *callee_holder = callee_method ? callee_method->holder() : NULL;
337 348 // Check if a callee_method was suggested
338 349 if( callee_method == NULL ) return false;
339 350 // Check if klass of callee_method is loaded
340 351 if( !callee_holder->is_loaded() ) return false;
341 352 if( !callee_holder->is_initialized() ) return false;
342 353 if( !UseInterpreter || CompileTheWorld /* running Xcomp or CTW */ ) {
343 354 // Checks that constant pool's call site has been visited
344 355 // stricter than callee_holder->is_initialized()
345 356 ciBytecodeStream iter(caller_method);
346 357 iter.force_bci(caller_bci);
347 358 Bytecodes::Code call_bc = iter.cur_bc();
348 359 // An invokedynamic instruction does not have a klass.
349 360 if (call_bc != Bytecodes::_invokedynamic) {
350 361 int index = iter.get_index_u2_cpcache();
351 362 if (!caller_method->is_klass_loaded(index, true)) {
352 363 return false;
353 364 }
354 365 // Try to do constant pool resolution if running Xcomp
355 366 if( !caller_method->check_call(index, call_bc == Bytecodes::_invokestatic) ) {
356 367 return false;
357 368 }
358 369 }
359 370 }
360 371 // We will attempt to see if a class/field/etc got properly loaded. If it
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
361 372 // did not, it may attempt to throw an exception during our probing. Catch
362 373 // and ignore such exceptions and do not attempt to compile the method.
363 374 if( callee_method->should_exclude() ) return false;
364 375
365 376 return true;
366 377 }
367 378
368 379 #ifndef PRODUCT
369 380 //------------------------------print_inlining---------------------------------
370 381 // Really, the failure_msg can be a success message also.
371 -void InlineTree::print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const {
372 - print_indent(inline_depth());
373 - tty->print("@ %d ", caller_bci);
374 - if( callee_method ) callee_method->print_short_name();
375 - else tty->print(" callee not monotonic or profiled");
376 - tty->print(" %s", (failure_msg ? failure_msg : "inline"));
377 - if( Verbose && callee_method ) {
382 +void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const {
383 + CompileTask::print_inlining(callee_method, inline_depth(), caller_bci, failure_msg ? failure_msg : "inline");
384 + if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
385 + if (Verbose && callee_method) {
378 386 const InlineTree *top = this;
379 387 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
380 388 tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
381 389 }
382 - tty->cr();
383 390 }
384 391 #endif
385 392
386 393 //------------------------------ok_to_inline-----------------------------------
387 394 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci) {
388 395 assert(callee_method != NULL, "caller checks for optimized virtual!");
389 396 #ifdef ASSERT
390 397 // Make sure the incoming jvms has the same information content as me.
391 398 // This means that we can eventually make this whole class AllStatic.
392 399 if (jvms->caller() == NULL) {
393 400 assert(_caller_jvms == NULL, "redundant instance state");
394 401 } else {
395 402 assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
396 403 }
397 404 assert(_method == jvms->method(), "redundant instance state");
398 405 #endif
399 406 const char *failure_msg = NULL;
400 407 int caller_bci = jvms->bci();
401 408 ciMethod *caller_method = jvms->method();
402 409
403 410 if( !pass_initial_checks(caller_method, caller_bci, callee_method)) {
404 411 if( PrintInlining ) {
405 412 failure_msg = "failed_initial_checks";
406 413 print_inlining( callee_method, caller_bci, failure_msg);
407 414 }
408 415 return NULL;
409 416 }
410 417
411 418 // Check if inlining policy says no.
412 419 WarmCallInfo wci = *(initial_wci);
413 420 failure_msg = try_to_inline(callee_method, caller_method, caller_bci, profile, &wci);
414 421 if (failure_msg != NULL && C->log() != NULL) {
415 422 C->log()->begin_elem("inline_fail reason='");
416 423 C->log()->text("%s", failure_msg);
417 424 C->log()->end_elem("'");
418 425 }
419 426
420 427 #ifndef PRODUCT
421 428 if (UseOldInlining && InlineWarmCalls
422 429 && (PrintOpto || PrintOptoInlining || PrintInlining)) {
423 430 bool cold = wci.is_cold();
424 431 bool hot = !cold && wci.is_hot();
425 432 bool old_cold = (failure_msg != NULL);
426 433 if (old_cold != cold || (Verbose || WizardMode)) {
427 434 tty->print(" OldInlining= %4s : %s\n WCI=",
428 435 old_cold ? "cold" : "hot", failure_msg ? failure_msg : "OK");
429 436 wci.print();
430 437 }
431 438 }
432 439 #endif
433 440 if (UseOldInlining) {
434 441 if (failure_msg == NULL)
435 442 wci = *(WarmCallInfo::always_hot());
436 443 else
437 444 wci = *(WarmCallInfo::always_cold());
438 445 }
439 446 if (!InlineWarmCalls) {
440 447 if (!wci.is_cold() && !wci.is_hot()) {
441 448 // Do not inline the warm calls.
442 449 wci = *(WarmCallInfo::always_cold());
443 450 }
444 451 }
445 452
446 453 if (!wci.is_cold()) {
447 454 // In -UseOldInlining, the failure_msg may also be a success message.
448 455 if (failure_msg == NULL) failure_msg = "inline (hot)";
449 456
450 457 // Inline!
451 458 if( PrintInlining ) print_inlining( callee_method, caller_bci, failure_msg);
452 459 if (UseOldInlining)
453 460 build_inline_tree_for_callee(callee_method, jvms, caller_bci);
454 461 if (InlineWarmCalls && !wci.is_hot())
455 462 return new (C) WarmCallInfo(wci); // copy to heap
456 463 return WarmCallInfo::always_hot();
457 464 }
458 465
459 466 // Do not inline
460 467 if (failure_msg == NULL) failure_msg = "too cold to inline";
461 468 if( PrintInlining ) print_inlining( callee_method, caller_bci, failure_msg);
462 469 return NULL;
463 470 }
464 471
465 472 //------------------------------compute_callee_frequency-----------------------
466 473 float InlineTree::compute_callee_frequency( int caller_bci ) const {
467 474 int count = method()->interpreter_call_site_count(caller_bci);
468 475 int invcnt = method()->interpreter_invocation_count();
469 476 float freq = (float)count/(float)invcnt;
470 477 // Call-site count / interpreter invocation count, scaled recursively.
471 478 // Always between 0.0 and 1.0. Represents the percentage of the method's
472 479 // total execution time used at this call site.
473 480
474 481 return freq;
475 482 }
476 483
477 484 //------------------------------build_inline_tree_for_callee-------------------
478 485 InlineTree *InlineTree::build_inline_tree_for_callee( ciMethod* callee_method, JVMState* caller_jvms, int caller_bci) {
479 486 float recur_frequency = _site_invoke_ratio * compute_callee_frequency(caller_bci);
480 487 // Attempt inlining.
481 488 InlineTree* old_ilt = callee_at(caller_bci, callee_method);
482 489 if (old_ilt != NULL) {
483 490 return old_ilt;
484 491 }
485 492 int new_depth_adjust = 0;
486 493 if (caller_jvms->method() != NULL) {
487 494 if (caller_jvms->method()->is_method_handle_adapter())
488 495 new_depth_adjust -= 1; // don't count actions in MH or indy adapter frames
489 496 else if (callee_method->is_method_handle_invoke()) {
490 497 new_depth_adjust -= 1; // don't count method handle calls from java.lang.invoke implem
491 498 }
492 499 if (new_depth_adjust != 0 && PrintInlining) {
493 500 stringStream nm1; caller_jvms->method()->print_name(&nm1);
494 501 stringStream nm2; callee_method->print_name(&nm2);
495 502 tty->print_cr("discounting inlining depth from %s to %s", nm1.base(), nm2.base());
496 503 }
497 504 if (new_depth_adjust != 0 && C->log()) {
498 505 int id1 = C->log()->identify(caller_jvms->method());
499 506 int id2 = C->log()->identify(callee_method);
500 507 C->log()->elem("inline_depth_discount caller='%d' callee='%d'", id1, id2);
501 508 }
502 509 }
503 510 InlineTree *ilt = new InlineTree(C, this, callee_method, caller_jvms, caller_bci, recur_frequency, _site_depth_adjust + new_depth_adjust);
504 511 _subtrees.append( ilt );
505 512
506 513 NOT_PRODUCT( _count_inlines += 1; )
507 514
508 515 return ilt;
509 516 }
510 517
511 518
512 519 //---------------------------------------callee_at-----------------------------
513 520 InlineTree *InlineTree::callee_at(int bci, ciMethod* callee) const {
514 521 for (int i = 0; i < _subtrees.length(); i++) {
515 522 InlineTree* sub = _subtrees.at(i);
516 523 if (sub->caller_bci() == bci && callee == sub->method()) {
517 524 return sub;
518 525 }
519 526 }
520 527 return NULL;
521 528 }
522 529
523 530
524 531 //------------------------------build_inline_tree_root-------------------------
525 532 InlineTree *InlineTree::build_inline_tree_root() {
526 533 Compile* C = Compile::current();
527 534
528 535 // Root of inline tree
529 536 InlineTree *ilt = new InlineTree(C, NULL, C->method(), NULL, -1, 1.0F, 0);
530 537
531 538 return ilt;
532 539 }
533 540
534 541
535 542 //-------------------------find_subtree_from_root-----------------------------
536 543 // Given a jvms, which determines a call chain from the root method,
537 544 // find the corresponding inline tree.
538 545 // Note: This method will be removed or replaced as InlineTree goes away.
539 546 InlineTree* InlineTree::find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee, bool create_if_not_found) {
540 547 InlineTree* iltp = root;
541 548 uint depth = jvms && jvms->has_method() ? jvms->depth() : 0;
542 549 for (uint d = 1; d <= depth; d++) {
543 550 JVMState* jvmsp = jvms->of_depth(d);
544 551 // Select the corresponding subtree for this bci.
545 552 assert(jvmsp->method() == iltp->method(), "tree still in sync");
546 553 ciMethod* d_callee = (d == depth) ? callee : jvms->of_depth(d+1)->method();
547 554 InlineTree* sub = iltp->callee_at(jvmsp->bci(), d_callee);
548 555 if (!sub) {
549 556 if (create_if_not_found && d == depth) {
550 557 return iltp->build_inline_tree_for_callee(d_callee, jvmsp, jvmsp->bci());
551 558 }
552 559 assert(sub != NULL, "should be a sub-ilt here");
553 560 return NULL;
554 561 }
555 562 iltp = sub;
556 563 }
557 564 return iltp;
558 565 }
↓ open down ↓ |
166 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX