src/share/vm/opto/bytecodeInfo.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 476
874b2c4f43d1
permissions
-rw-r--r--

Initial load

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

mercurial