annotate src/share/vm/opto/bytecodeInfo.cpp @ 0:a61af66fc99e

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children 874b2c4f43d1
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 #include "incls/_precompiled.incl"
duke@0 26 #include "incls/_bytecodeInfo.cpp.incl"
duke@0 27
duke@0 28 // These variables are declared in parse1.cpp
duke@0 29 extern int explicit_null_checks_inserted;
duke@0 30 extern int explicit_null_checks_elided;
duke@0 31 extern int explicit_null_checks_inserted_old;
duke@0 32 extern int explicit_null_checks_elided_old;
duke@0 33 extern int nodes_created_old;
duke@0 34 extern int nodes_created;
duke@0 35 extern int methods_parsed_old;
duke@0 36 extern int methods_parsed;
duke@0 37 extern int methods_seen;
duke@0 38 extern int methods_seen_old;
duke@0 39
duke@0 40
duke@0 41 //=============================================================================
duke@0 42 //------------------------------InlineTree-------------------------------------
duke@0 43 InlineTree::InlineTree( Compile* c, const InlineTree *caller_tree, ciMethod* callee, JVMState* caller_jvms, int caller_bci, float site_invoke_ratio )
duke@0 44 : C(c), _caller_jvms(caller_jvms),
duke@0 45 _caller_tree((InlineTree*)caller_tree),
duke@0 46 _method(callee), _site_invoke_ratio(site_invoke_ratio),
duke@0 47 _count_inline_bcs(method()->code_size()) {
duke@0 48 NOT_PRODUCT(_count_inlines = 0;)
duke@0 49 if (_caller_jvms != NULL) {
duke@0 50 // Keep a private copy of the caller_jvms:
duke@0 51 _caller_jvms = new (C) JVMState(caller_jvms->method(), caller_tree->caller_jvms());
duke@0 52 _caller_jvms->set_bci(caller_jvms->bci());
duke@0 53 }
duke@0 54 assert(_caller_jvms->same_calls_as(caller_jvms), "consistent JVMS");
duke@0 55 assert((caller_tree == NULL ? 0 : caller_tree->inline_depth() + 1) == inline_depth(), "correct (redundant) depth parameter");
duke@0 56 assert(caller_bci == this->caller_bci(), "correct (redundant) bci parameter");
duke@0 57 if (UseOldInlining) {
duke@0 58 // Update hierarchical counts, count_inline_bcs() and count_inlines()
duke@0 59 InlineTree *caller = (InlineTree *)caller_tree;
duke@0 60 for( ; caller != NULL; caller = ((InlineTree *)(caller->caller_tree())) ) {
duke@0 61 caller->_count_inline_bcs += count_inline_bcs();
duke@0 62 NOT_PRODUCT(caller->_count_inlines++;)
duke@0 63 }
duke@0 64 }
duke@0 65 }
duke@0 66
duke@0 67 InlineTree::InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio)
duke@0 68 : C(c), _caller_jvms(caller_jvms), _caller_tree(NULL),
duke@0 69 _method(callee_method), _site_invoke_ratio(site_invoke_ratio),
duke@0 70 _count_inline_bcs(method()->code_size()) {
duke@0 71 NOT_PRODUCT(_count_inlines = 0;)
duke@0 72 assert(!UseOldInlining, "do not use for old stuff");
duke@0 73 }
duke@0 74
duke@0 75
duke@0 76
duke@0 77 static void print_indent(int depth) {
duke@0 78 tty->print(" ");
duke@0 79 for (int i = depth; i != 0; --i) tty->print(" ");
duke@0 80 }
duke@0 81
duke@0 82 // positive filter: should send be inlined? returns NULL, if yes, or rejection msg
duke@0 83 const char* InlineTree::shouldInline(ciMethod* callee_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const {
duke@0 84 // Allows targeted inlining
duke@0 85 if(callee_method->should_inline()) {
duke@0 86 *wci_result = *(WarmCallInfo::always_hot());
duke@0 87 if (PrintInlining && Verbose) {
duke@0 88 print_indent(inline_depth());
duke@0 89 tty->print_cr("Inlined method is hot: ");
duke@0 90 }
duke@0 91 return NULL;
duke@0 92 }
duke@0 93
duke@0 94 // positive filter: should send be inlined? returns NULL (--> yes)
duke@0 95 // or rejection msg
duke@0 96 int max_size = C->max_inline_size();
duke@0 97 int size = callee_method->code_size();
duke@0 98
duke@0 99 // Check for too many throws (and not too huge)
duke@0 100 if(callee_method->interpreter_throwout_count() > InlineThrowCount && size < InlineThrowMaxSize ) {
duke@0 101 wci_result->set_profit(wci_result->profit() * 100);
duke@0 102 if (PrintInlining && Verbose) {
duke@0 103 print_indent(inline_depth());
duke@0 104 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
duke@0 105 }
duke@0 106 return NULL;
duke@0 107 }
duke@0 108
duke@0 109 if (!UseOldInlining) {
duke@0 110 return NULL; // size and frequency are represented in a new way
duke@0 111 }
duke@0 112
duke@0 113 int call_site_count = method()->scale_count(profile.count());
duke@0 114 int invoke_count = method()->interpreter_invocation_count();
duke@0 115 assert( invoke_count != 0, "Require invokation count greater than zero");
duke@0 116 int freq = call_site_count/invoke_count;
duke@0 117 // bump the max size if the call is frequent
duke@0 118 if ((freq >= InlineFrequencyRatio) || (call_site_count >= InlineFrequencyCount)) {
duke@0 119 max_size = C->freq_inline_size();
duke@0 120 if (size <= max_size && TraceFrequencyInlining) {
duke@0 121 print_indent(inline_depth());
duke@0 122 tty->print_cr("Inlined frequent method (freq=%d count=%d):", freq, call_site_count);
duke@0 123 print_indent(inline_depth());
duke@0 124 callee_method->print();
duke@0 125 tty->cr();
duke@0 126 }
duke@0 127 } else {
duke@0 128 // Not hot. Check for medium-sized pre-existing nmethod at cold sites.
duke@0 129 if (callee_method->has_compiled_code() && callee_method->instructions_size() > InlineSmallCode/4)
duke@0 130 return "already compiled into a medium method";
duke@0 131 }
duke@0 132 if (size > max_size) {
duke@0 133 if (max_size > C->max_inline_size())
duke@0 134 return "hot method too big";
duke@0 135 return "too big";
duke@0 136 }
duke@0 137 return NULL;
duke@0 138 }
duke@0 139
duke@0 140
duke@0 141 // negative filter: should send NOT be inlined? returns NULL, ok to inline, or rejection msg
duke@0 142 const char* InlineTree::shouldNotInline(ciMethod *callee_method, WarmCallInfo* wci_result) const {
duke@0 143 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg
duke@0 144 if (!UseOldInlining) {
duke@0 145 const char* fail = NULL;
duke@0 146 if (callee_method->is_abstract()) fail = "abstract method";
duke@0 147 // note: we allow ik->is_abstract()
duke@0 148 if (!callee_method->holder()->is_initialized()) fail = "method holder not initialized";
duke@0 149 if (callee_method->is_native()) fail = "native method";
duke@0 150
duke@0 151 if (fail) {
duke@0 152 *wci_result = *(WarmCallInfo::always_cold());
duke@0 153 return fail;
duke@0 154 }
duke@0 155
duke@0 156 if (callee_method->has_unloaded_classes_in_signature()) {
duke@0 157 wci_result->set_profit(wci_result->profit() * 0.1);
duke@0 158 }
duke@0 159
duke@0 160 // don't inline exception code unless the top method belongs to an
duke@0 161 // exception class
duke@0 162 if (callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
duke@0 163 ciMethod* top_method = caller_jvms() ? caller_jvms()->of_depth(1)->method() : method();
duke@0 164 if (!top_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
duke@0 165 wci_result->set_profit(wci_result->profit() * 0.1);
duke@0 166 }
duke@0 167 }
duke@0 168
duke@0 169 if (callee_method->has_compiled_code() && callee_method->instructions_size() > InlineSmallCode) {
duke@0 170 wci_result->set_profit(wci_result->profit() * 0.1);
duke@0 171 // %%% adjust wci_result->size()?
duke@0 172 }
duke@0 173
duke@0 174 return NULL;
duke@0 175 }
duke@0 176
duke@0 177 // First check all inlining restrictions which are required for correctness
duke@0 178 if (callee_method->is_abstract()) return "abstract method";
duke@0 179 // note: we allow ik->is_abstract()
duke@0 180 if (!callee_method->holder()->is_initialized()) return "method holder not initialized";
duke@0 181 if (callee_method->is_native()) return "native method";
duke@0 182 if (callee_method->has_unloaded_classes_in_signature()) return "unloaded signature classes";
duke@0 183
duke@0 184 if (callee_method->should_inline()) {
duke@0 185 // ignore heuristic controls on inlining
duke@0 186 return NULL;
duke@0 187 }
duke@0 188
duke@0 189 // Now perform checks which are heuristic
duke@0 190
duke@0 191 if( callee_method->has_compiled_code() && callee_method->instructions_size() > InlineSmallCode )
duke@0 192 return "already compiled into a big method";
duke@0 193
duke@0 194 // don't inline exception code unless the top method belongs to an
duke@0 195 // exception class
duke@0 196 if (caller_tree() != NULL &&
duke@0 197 callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
duke@0 198 const InlineTree *top = this;
duke@0 199 while (top->caller_tree() != NULL) top = top->caller_tree();
duke@0 200 ciInstanceKlass* k = top->method()->holder();
duke@0 201 if (!k->is_subclass_of(C->env()->Throwable_klass()))
duke@0 202 return "exception method";
duke@0 203 }
duke@0 204
duke@0 205 // use frequency-based objections only for non-trivial methods
duke@0 206 if (callee_method->code_size() <= MaxTrivialSize) return NULL;
duke@0 207 if (UseInterpreter && !CompileTheWorld) { // don't use counts with -Xcomp or CTW
duke@0 208 if (!callee_method->has_compiled_code() && !callee_method->was_executed_more_than(0)) return "never executed";
duke@0 209 if (!callee_method->was_executed_more_than(MIN2(MinInliningThreshold, CompileThreshold >> 1))) return "executed < MinInliningThreshold times";
duke@0 210 }
duke@0 211
duke@0 212 if (callee_method->should_not_inline()) {
duke@0 213 return "disallowed by CompilerOracle";
duke@0 214 }
duke@0 215
duke@0 216 return NULL;
duke@0 217 }
duke@0 218
duke@0 219 //-----------------------------try_to_inline-----------------------------------
duke@0 220 // return NULL if ok, reason for not inlining otherwise
duke@0 221 // Relocated from "InliningClosure::try_to_inline"
duke@0 222 const char* InlineTree::try_to_inline(ciMethod* callee_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) {
duke@0 223 ciMethod* caller_method = method();
duke@0 224
duke@0 225 // Old algorithm had funny accumulating BC-size counters
duke@0 226 if (UseOldInlining && ClipInlining
duke@0 227 && (int)count_inline_bcs() >= DesiredMethodLimit) {
duke@0 228 return "size > DesiredMethodLimit";
duke@0 229 }
duke@0 230
duke@0 231 const char *msg = NULL;
duke@0 232 if ((msg = shouldInline(callee_method, caller_bci, profile, wci_result)) != NULL) return msg;
duke@0 233 if ((msg = shouldNotInline(callee_method, wci_result)) != NULL) return msg;
duke@0 234
duke@0 235 bool is_accessor = InlineAccessors && callee_method->is_accessor();
duke@0 236
duke@0 237 // suppress a few checks for accessors and trivial methods
duke@0 238 if (!is_accessor && callee_method->code_size() > MaxTrivialSize) {
duke@0 239 // don't inline into giant methods
duke@0 240 if (C->unique() > (uint)NodeCountInliningCutoff) return "NodeCountInliningCutoff";
duke@0 241
duke@0 242 // don't inline unreached call sites
duke@0 243 if (profile.count() == 0) return "call site not reached";
duke@0 244 }
duke@0 245
duke@0 246 if (!C->do_inlining() && InlineAccessors && !is_accessor) return "not an accessor";
duke@0 247
duke@0 248 if( inline_depth() > MaxInlineLevel ) return "inlining too deep";
duke@0 249 if( method() == callee_method &&
duke@0 250 inline_depth() > MaxRecursiveInlineLevel ) return "recursively inlining too deep";
duke@0 251
duke@0 252 int size = callee_method->code_size();
duke@0 253
duke@0 254 if (UseOldInlining && ClipInlining
duke@0 255 && (int)count_inline_bcs() + size >= DesiredMethodLimit) {
duke@0 256 return "size > DesiredMethodLimit";
duke@0 257 }
duke@0 258
duke@0 259 // ok, inline this method
duke@0 260 return NULL;
duke@0 261 }
duke@0 262
duke@0 263 //------------------------------pass_initial_checks----------------------------
duke@0 264 bool pass_initial_checks(ciMethod* caller_method, int caller_bci, ciMethod* callee_method) {
duke@0 265 ciInstanceKlass *callee_holder = callee_method ? callee_method->holder() : NULL;
duke@0 266 // Check if a callee_method was suggested
duke@0 267 if( callee_method == NULL ) return false;
duke@0 268 // Check if klass of callee_method is loaded
duke@0 269 if( !callee_holder->is_loaded() ) return false;
duke@0 270 if( !callee_holder->is_initialized() ) return false;
duke@0 271 if( !UseInterpreter || CompileTheWorld /* running Xcomp or CTW */ ) {
duke@0 272 // Checks that constant pool's call site has been visited
duke@0 273 // stricter than callee_holder->is_initialized()
duke@0 274 ciBytecodeStream iter(caller_method);
duke@0 275 iter.force_bci(caller_bci);
duke@0 276 int index = iter.get_index_big();
duke@0 277 if( !caller_method->is_klass_loaded(index, true) ) {
duke@0 278 return false;
duke@0 279 }
duke@0 280 // Try to do constant pool resolution if running Xcomp
duke@0 281 Bytecodes::Code call_bc = iter.cur_bc();
duke@0 282 if( !caller_method->check_call(index, call_bc == Bytecodes::_invokestatic) ) {
duke@0 283 return false;
duke@0 284 }
duke@0 285 }
duke@0 286 // We will attempt to see if a class/field/etc got properly loaded. If it
duke@0 287 // did not, it may attempt to throw an exception during our probing. Catch
duke@0 288 // and ignore such exceptions and do not attempt to compile the method.
duke@0 289 if( callee_method->should_exclude() ) return false;
duke@0 290
duke@0 291 return true;
duke@0 292 }
duke@0 293
duke@0 294 #ifndef PRODUCT
duke@0 295 //------------------------------print_inlining---------------------------------
duke@0 296 // Really, the failure_msg can be a success message also.
duke@0 297 void InlineTree::print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const {
duke@0 298 print_indent(inline_depth());
duke@0 299 tty->print("@ %d ", caller_bci);
duke@0 300 if( callee_method ) callee_method->print_short_name();
duke@0 301 else tty->print(" callee not monotonic or profiled");
duke@0 302 tty->print(" %s", (failure_msg ? failure_msg : "inline"));
duke@0 303 if( Verbose && callee_method ) {
duke@0 304 const InlineTree *top = this;
duke@0 305 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
duke@0 306 tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
duke@0 307 }
duke@0 308 tty->cr();
duke@0 309 }
duke@0 310 #endif
duke@0 311
duke@0 312 //------------------------------ok_to_inline-----------------------------------
duke@0 313 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci) {
duke@0 314 assert(callee_method != NULL, "caller checks for optimized virtual!");
duke@0 315 #ifdef ASSERT
duke@0 316 // Make sure the incoming jvms has the same information content as me.
duke@0 317 // This means that we can eventually make this whole class AllStatic.
duke@0 318 if (jvms->caller() == NULL) {
duke@0 319 assert(_caller_jvms == NULL, "redundant instance state");
duke@0 320 } else {
duke@0 321 assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
duke@0 322 }
duke@0 323 assert(_method == jvms->method(), "redundant instance state");
duke@0 324 #endif
duke@0 325 const char *failure_msg = NULL;
duke@0 326 int caller_bci = jvms->bci();
duke@0 327 ciMethod *caller_method = jvms->method();
duke@0 328
duke@0 329 if( !pass_initial_checks(caller_method, caller_bci, callee_method)) {
duke@0 330 if( PrintInlining ) {
duke@0 331 failure_msg = "failed_initial_checks";
duke@0 332 print_inlining( callee_method, caller_bci, failure_msg);
duke@0 333 }
duke@0 334 return NULL;
duke@0 335 }
duke@0 336
duke@0 337 // Check if inlining policy says no.
duke@0 338 WarmCallInfo wci = *(initial_wci);
duke@0 339 failure_msg = try_to_inline(callee_method, caller_bci, profile, &wci);
duke@0 340 if (failure_msg != NULL && C->log() != NULL) {
duke@0 341 C->log()->begin_elem("inline_fail reason='");
duke@0 342 C->log()->text("%s", failure_msg);
duke@0 343 C->log()->end_elem("'");
duke@0 344 }
duke@0 345
duke@0 346 #ifndef PRODUCT
duke@0 347 if (UseOldInlining && InlineWarmCalls
duke@0 348 && (PrintOpto || PrintOptoInlining || PrintInlining)) {
duke@0 349 bool cold = wci.is_cold();
duke@0 350 bool hot = !cold && wci.is_hot();
duke@0 351 bool old_cold = (failure_msg != NULL);
duke@0 352 if (old_cold != cold || (Verbose || WizardMode)) {
duke@0 353 tty->print(" OldInlining= %4s : %s\n WCI=",
duke@0 354 old_cold ? "cold" : "hot", failure_msg ? failure_msg : "OK");
duke@0 355 wci.print();
duke@0 356 }
duke@0 357 }
duke@0 358 #endif
duke@0 359 if (UseOldInlining) {
duke@0 360 if (failure_msg == NULL)
duke@0 361 wci = *(WarmCallInfo::always_hot());
duke@0 362 else
duke@0 363 wci = *(WarmCallInfo::always_cold());
duke@0 364 }
duke@0 365 if (!InlineWarmCalls) {
duke@0 366 if (!wci.is_cold() && !wci.is_hot()) {
duke@0 367 // Do not inline the warm calls.
duke@0 368 wci = *(WarmCallInfo::always_cold());
duke@0 369 }
duke@0 370 }
duke@0 371
duke@0 372 if (!wci.is_cold()) {
duke@0 373 // In -UseOldInlining, the failure_msg may also be a success message.
duke@0 374 if (failure_msg == NULL) failure_msg = "inline (hot)";
duke@0 375
duke@0 376 // Inline!
duke@0 377 if( PrintInlining ) print_inlining( callee_method, caller_bci, failure_msg);
duke@0 378 if (UseOldInlining)
duke@0 379 build_inline_tree_for_callee(callee_method, jvms, caller_bci);
duke@0 380 if (InlineWarmCalls && !wci.is_hot())
duke@0 381 return new (C) WarmCallInfo(wci); // copy to heap
duke@0 382 return WarmCallInfo::always_hot();
duke@0 383 }
duke@0 384
duke@0 385 // Do not inline
duke@0 386 if (failure_msg == NULL) failure_msg = "too cold to inline";
duke@0 387 if( PrintInlining ) print_inlining( callee_method, caller_bci, failure_msg);
duke@0 388 return NULL;
duke@0 389 }
duke@0 390
duke@0 391 //------------------------------compute_callee_frequency-----------------------
duke@0 392 float InlineTree::compute_callee_frequency( int caller_bci ) const {
duke@0 393 int count = method()->interpreter_call_site_count(caller_bci);
duke@0 394 int invcnt = method()->interpreter_invocation_count();
duke@0 395 float freq = (float)count/(float)invcnt;
duke@0 396 // Call-site count / interpreter invocation count, scaled recursively.
duke@0 397 // Always between 0.0 and 1.0. Represents the percentage of the method's
duke@0 398 // total execution time used at this call site.
duke@0 399
duke@0 400 return freq;
duke@0 401 }
duke@0 402
duke@0 403 //------------------------------build_inline_tree_for_callee-------------------
duke@0 404 InlineTree *InlineTree::build_inline_tree_for_callee( ciMethod* callee_method, JVMState* caller_jvms, int caller_bci) {
duke@0 405 float recur_frequency = _site_invoke_ratio * compute_callee_frequency(caller_bci);
duke@0 406 // Attempt inlining.
duke@0 407 InlineTree* old_ilt = callee_at(caller_bci, callee_method);
duke@0 408 if (old_ilt != NULL) {
duke@0 409 return old_ilt;
duke@0 410 }
duke@0 411 InlineTree *ilt = new InlineTree( C, this, callee_method, caller_jvms, caller_bci, recur_frequency );
duke@0 412 _subtrees.append( ilt );
duke@0 413
duke@0 414 NOT_PRODUCT( _count_inlines += 1; )
duke@0 415
duke@0 416 return ilt;
duke@0 417 }
duke@0 418
duke@0 419
duke@0 420 //---------------------------------------callee_at-----------------------------
duke@0 421 InlineTree *InlineTree::callee_at(int bci, ciMethod* callee) const {
duke@0 422 for (int i = 0; i < _subtrees.length(); i++) {
duke@0 423 InlineTree* sub = _subtrees.at(i);
duke@0 424 if (sub->caller_bci() == bci && callee == sub->method()) {
duke@0 425 return sub;
duke@0 426 }
duke@0 427 }
duke@0 428 return NULL;
duke@0 429 }
duke@0 430
duke@0 431
duke@0 432 //------------------------------build_inline_tree_root-------------------------
duke@0 433 InlineTree *InlineTree::build_inline_tree_root() {
duke@0 434 Compile* C = Compile::current();
duke@0 435
duke@0 436 // Root of inline tree
duke@0 437 InlineTree *ilt = new InlineTree(C, NULL, C->method(), NULL, -1, 1.0F);
duke@0 438
duke@0 439 return ilt;
duke@0 440 }
duke@0 441
duke@0 442
duke@0 443 //-------------------------find_subtree_from_root-----------------------------
duke@0 444 // Given a jvms, which determines a call chain from the root method,
duke@0 445 // find the corresponding inline tree.
duke@0 446 // Note: This method will be removed or replaced as InlineTree goes away.
duke@0 447 InlineTree* InlineTree::find_subtree_from_root(InlineTree* root, JVMState* jvms, ciMethod* callee, bool create_if_not_found) {
duke@0 448 InlineTree* iltp = root;
duke@0 449 uint depth = jvms && jvms->has_method() ? jvms->depth() : 0;
duke@0 450 for (uint d = 1; d <= depth; d++) {
duke@0 451 JVMState* jvmsp = jvms->of_depth(d);
duke@0 452 // Select the corresponding subtree for this bci.
duke@0 453 assert(jvmsp->method() == iltp->method(), "tree still in sync");
duke@0 454 ciMethod* d_callee = (d == depth) ? callee : jvms->of_depth(d+1)->method();
duke@0 455 InlineTree* sub = iltp->callee_at(jvmsp->bci(), d_callee);
duke@0 456 if (!sub) {
duke@0 457 if (create_if_not_found && d == depth) {
duke@0 458 return iltp->build_inline_tree_for_callee(d_callee, jvmsp, jvmsp->bci());
duke@0 459 }
duke@0 460 assert(sub != NULL, "should be a sub-ilt here");
duke@0 461 return NULL;
duke@0 462 }
duke@0 463 iltp = sub;
duke@0 464 }
duke@0 465 return iltp;
duke@0 466 }
duke@0 467
duke@0 468 // ----------------------------------------------------------------------------
duke@0 469 #ifndef PRODUCT
duke@0 470
duke@0 471 static void per_method_stats() {
duke@0 472 // Compute difference between this method's cumulative totals and old totals
duke@0 473 int explicit_null_checks_cur = explicit_null_checks_inserted - explicit_null_checks_inserted_old;
duke@0 474 int elided_null_checks_cur = explicit_null_checks_elided - explicit_null_checks_elided_old;
duke@0 475
duke@0 476 // Print differences
duke@0 477 if( explicit_null_checks_cur )
duke@0 478 tty->print_cr("XXX Explicit NULL checks inserted: %d", explicit_null_checks_cur);
duke@0 479 if( elided_null_checks_cur )
duke@0 480 tty->print_cr("XXX Explicit NULL checks removed at parse time: %d", elided_null_checks_cur);
duke@0 481
duke@0 482 // Store the current cumulative totals
duke@0 483 nodes_created_old = nodes_created;
duke@0 484 methods_parsed_old = methods_parsed;
duke@0 485 methods_seen_old = methods_seen;
duke@0 486 explicit_null_checks_inserted_old = explicit_null_checks_inserted;
duke@0 487 explicit_null_checks_elided_old = explicit_null_checks_elided;
duke@0 488 }
duke@0 489
duke@0 490 #endif