src/hotspot/share/runtime/compilationPolicy.cpp
branchstuefe-new-metaspace-branch
changeset 58494 54c1ba464b78
parent 58398 ff559f979c4b
equal deleted inserted replaced
58475:e3aa9f95b85e 58494:54c1ba464b78
    34 #include "oops/oop.inline.hpp"
    34 #include "oops/oop.inline.hpp"
    35 #include "prims/nativeLookup.hpp"
    35 #include "prims/nativeLookup.hpp"
    36 #include "runtime/compilationPolicy.hpp"
    36 #include "runtime/compilationPolicy.hpp"
    37 #include "runtime/frame.hpp"
    37 #include "runtime/frame.hpp"
    38 #include "runtime/handles.inline.hpp"
    38 #include "runtime/handles.inline.hpp"
    39 #include "runtime/rframe.hpp"
       
    40 #include "runtime/stubRoutines.hpp"
    39 #include "runtime/stubRoutines.hpp"
    41 #include "runtime/thread.hpp"
    40 #include "runtime/thread.hpp"
    42 #include "runtime/tieredThresholdPolicy.hpp"
    41 #include "runtime/tieredThresholdPolicy.hpp"
    43 #include "runtime/vframe.hpp"
    42 #include "runtime/vframe.hpp"
    44 #include "runtime/vmOperations.hpp"
    43 #include "runtime/vmOperations.hpp"
    54 
    53 
    55 CompilationPolicy* CompilationPolicy::_policy;
    54 CompilationPolicy* CompilationPolicy::_policy;
    56 
    55 
    57 // Determine compilation policy based on command line argument
    56 // Determine compilation policy based on command line argument
    58 void compilationPolicy_init() {
    57 void compilationPolicy_init() {
    59   switch(CompilationPolicyChoice) {
    58   #ifdef TIERED
    60   case 0:
    59   if (TieredCompilation) {
       
    60     CompilationPolicy::set_policy(new TieredThresholdPolicy());
       
    61   } else {
    61     CompilationPolicy::set_policy(new SimpleCompPolicy());
    62     CompilationPolicy::set_policy(new SimpleCompPolicy());
    62     break;
    63   }
    63 
    64   #else
    64   case 1:
    65   CompilationPolicy::set_policy(new SimpleCompPolicy());
    65 #ifdef COMPILER2
    66   #endif
    66     CompilationPolicy::set_policy(new StackWalkCompPolicy());
    67 
    67 #else
       
    68     Unimplemented();
       
    69 #endif
       
    70     break;
       
    71   case 2:
       
    72 #ifdef TIERED
       
    73     CompilationPolicy::set_policy(new TieredThresholdPolicy());
       
    74 #else
       
    75     Unimplemented();
       
    76 #endif
       
    77     break;
       
    78   default:
       
    79     fatal("CompilationPolicyChoice must be in the range: [0-2]");
       
    80   }
       
    81   CompilationPolicy::policy()->initialize();
    68   CompilationPolicy::policy()->initialize();
    82 }
    69 }
    83 
    70 
    84 // Returns true if m must be compiled before executing it
    71 // Returns true if m must be compiled before executing it
    85 // This is intended to force compiles for methods (usually for
    72 // This is intended to force compiles for methods (usually for
   202 #endif
   189 #endif
   203   return compile_queue->first();
   190   return compile_queue->first();
   204 }
   191 }
   205 
   192 
   206 #ifndef PRODUCT
   193 #ifndef PRODUCT
   207 void NonTieredCompPolicy::trace_osr_completion(nmethod* osr_nm) {
   194 void SimpleCompPolicy::trace_osr_completion(nmethod* osr_nm) {
   208   if (TraceOnStackReplacement) {
   195   if (TraceOnStackReplacement) {
   209     if (osr_nm == NULL) tty->print_cr("compilation failed");
   196     if (osr_nm == NULL) tty->print_cr("compilation failed");
   210     else tty->print_cr("nmethod " INTPTR_FORMAT, p2i(osr_nm));
   197     else tty->print_cr("nmethod " INTPTR_FORMAT, p2i(osr_nm));
   211   }
   198   }
   212 }
   199 }
   213 #endif // !PRODUCT
   200 #endif // !PRODUCT
   214 
   201 
   215 void NonTieredCompPolicy::initialize() {
   202 void SimpleCompPolicy::initialize() {
   216   // Setup the compiler thread numbers
   203   // Setup the compiler thread numbers
   217   if (CICompilerCountPerCPU) {
   204   if (CICompilerCountPerCPU) {
   218     // Example: if CICompilerCountPerCPU is true, then we get
   205     // Example: if CICompilerCountPerCPU is true, then we get
   219     // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine.
   206     // max(log2(8)-1,1) = 2 compiler threads on an 8-way machine.
   220     // May help big-app startup time.
   207     // May help big-app startup time.
   244 //   zero for the c1 compilation levels in server compilation mode runs
   231 //   zero for the c1 compilation levels in server compilation mode runs
   245 //   and c2 compilation levels in client compilation mode runs.
   232 //   and c2 compilation levels in client compilation mode runs.
   246 // - with COMPILER2 not defined it should return zero for c2 compilation levels.
   233 // - with COMPILER2 not defined it should return zero for c2 compilation levels.
   247 // - with COMPILER1 not defined it should return zero for c1 compilation levels.
   234 // - with COMPILER1 not defined it should return zero for c1 compilation levels.
   248 // - if neither is defined - always return zero.
   235 // - if neither is defined - always return zero.
   249 int NonTieredCompPolicy::compiler_count(CompLevel comp_level) {
   236 int SimpleCompPolicy::compiler_count(CompLevel comp_level) {
   250   assert(!TieredCompilation, "This policy should not be used with TieredCompilation");
   237   assert(!TieredCompilation, "This policy should not be used with TieredCompilation");
   251   if (COMPILER2_PRESENT(is_server_compilation_mode_vm() && is_c2_compile(comp_level) ||)
   238   if (COMPILER2_PRESENT(is_server_compilation_mode_vm() && is_c2_compile(comp_level) ||)
   252       is_client_compilation_mode_vm() && is_c1_compile(comp_level)) {
   239       is_client_compilation_mode_vm() && is_c1_compile(comp_level)) {
   253     return _compiler_count;
   240     return _compiler_count;
   254   }
   241   }
   255   return 0;
   242   return 0;
   256 }
   243 }
   257 
   244 
   258 void NonTieredCompPolicy::reset_counter_for_invocation_event(const methodHandle& m) {
   245 void SimpleCompPolicy::reset_counter_for_invocation_event(const methodHandle& m) {
   259   // Make sure invocation and backedge counter doesn't overflow again right away
   246   // Make sure invocation and backedge counter doesn't overflow again right away
   260   // as would be the case for native methods.
   247   // as would be the case for native methods.
   261 
   248 
   262   // BUT also make sure the method doesn't look like it was never executed.
   249   // BUT also make sure the method doesn't look like it was never executed.
   263   // Set carry bit and reduce counter's value to min(count, CompileThreshold/2).
   250   // Set carry bit and reduce counter's value to min(count, CompileThreshold/2).
   267   mcs->backedge_counter()->set_carry();
   254   mcs->backedge_counter()->set_carry();
   268 
   255 
   269   assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed");
   256   assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed");
   270 }
   257 }
   271 
   258 
   272 void NonTieredCompPolicy::reset_counter_for_back_branch_event(const methodHandle& m) {
   259 void SimpleCompPolicy::reset_counter_for_back_branch_event(const methodHandle& m) {
   273   // Delay next back-branch event but pump up invocation counter to trigger
   260   // Delay next back-branch event but pump up invocation counter to trigger
   274   // whole method compilation.
   261   // whole method compilation.
   275   MethodCounters* mcs = m->method_counters();
   262   MethodCounters* mcs = m->method_counters();
   276   assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
   263   assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
   277   InvocationCounter* i = mcs->invocation_counter();
   264   InvocationCounter* i = mcs->invocation_counter();
   325     }
   312     }
   326   }
   313   }
   327 }
   314 }
   328 
   315 
   329 // Called at the end of the safepoint
   316 // Called at the end of the safepoint
   330 void NonTieredCompPolicy::do_safepoint_work() {
   317 void SimpleCompPolicy::do_safepoint_work() {
   331   if(UseCounterDecay && CounterDecay::is_decay_needed()) {
   318   if(UseCounterDecay && CounterDecay::is_decay_needed()) {
   332     CounterDecay::decay();
   319     CounterDecay::decay();
   333   }
   320   }
   334 }
   321 }
   335 
   322 
   336 void NonTieredCompPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
   323 void SimpleCompPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
   337   ScopeDesc* sd = trap_scope;
   324   ScopeDesc* sd = trap_scope;
   338   MethodCounters* mcs;
   325   MethodCounters* mcs;
   339   InvocationCounter* c;
   326   InvocationCounter* c;
   340   for (; !sd->is_top(); sd = sd->sender()) {
   327   for (; !sd->is_top(); sd = sd->sender()) {
   341     mcs = sd->method()->method_counters();
   328     mcs = sd->method()->method_counters();
   357   }
   344   }
   358 }
   345 }
   359 
   346 
   360 // This method can be called by any component of the runtime to notify the policy
   347 // This method can be called by any component of the runtime to notify the policy
   361 // that it's recommended to delay the compilation of this method.
   348 // that it's recommended to delay the compilation of this method.
   362 void NonTieredCompPolicy::delay_compilation(Method* method) {
   349 void SimpleCompPolicy::delay_compilation(Method* method) {
   363   MethodCounters* mcs = method->method_counters();
   350   MethodCounters* mcs = method->method_counters();
   364   if (mcs != NULL) {
   351   if (mcs != NULL) {
   365     mcs->invocation_counter()->decay();
   352     mcs->invocation_counter()->decay();
   366     mcs->backedge_counter()->decay();
   353     mcs->backedge_counter()->decay();
   367   }
   354   }
   368 }
   355 }
   369 
   356 
   370 void NonTieredCompPolicy::disable_compilation(Method* method) {
   357 void SimpleCompPolicy::disable_compilation(Method* method) {
   371   MethodCounters* mcs = method->method_counters();
   358   MethodCounters* mcs = method->method_counters();
   372   if (mcs != NULL) {
   359   if (mcs != NULL) {
   373     mcs->invocation_counter()->set_state(InvocationCounter::wait_for_nothing);
   360     mcs->invocation_counter()->set_state(InvocationCounter::wait_for_nothing);
   374     mcs->backedge_counter()->set_state(InvocationCounter::wait_for_nothing);
   361     mcs->backedge_counter()->set_state(InvocationCounter::wait_for_nothing);
   375   }
   362   }
   376 }
   363 }
   377 
   364 
   378 CompileTask* NonTieredCompPolicy::select_task(CompileQueue* compile_queue) {
   365 CompileTask* SimpleCompPolicy::select_task(CompileQueue* compile_queue) {
   379   return select_task_helper(compile_queue);
   366   return select_task_helper(compile_queue);
   380 }
   367 }
   381 
   368 
   382 bool NonTieredCompPolicy::is_mature(Method* method) {
   369 bool SimpleCompPolicy::is_mature(Method* method) {
   383   MethodData* mdo = method->method_data();
   370   MethodData* mdo = method->method_data();
   384   assert(mdo != NULL, "Should be");
   371   assert(mdo != NULL, "Should be");
   385   uint current = mdo->mileage_of(method);
   372   uint current = mdo->mileage_of(method);
   386   uint initial = mdo->creation_mileage();
   373   uint initial = mdo->creation_mileage();
   387   if (current < initial)
   374   if (current < initial)
   392   else
   379   else
   393     target = (uint)( (ProfileMaturityPercentage * CompileThreshold) / 100 );
   380     target = (uint)( (ProfileMaturityPercentage * CompileThreshold) / 100 );
   394   return (current >= initial + target);
   381   return (current >= initial + target);
   395 }
   382 }
   396 
   383 
   397 nmethod* NonTieredCompPolicy::event(const methodHandle& method, const methodHandle& inlinee, int branch_bci,
   384 nmethod* SimpleCompPolicy::event(const methodHandle& method, const methodHandle& inlinee, int branch_bci,
   398                                     int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) {
   385                                     int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) {
   399   assert(comp_level == CompLevel_none, "This should be only called from the interpreter");
   386   assert(comp_level == CompLevel_none, "This should be only called from the interpreter");
   400   NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci));
   387   NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci));
   401   if (JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) {
   388   if (JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) {
   402     // If certain JVMTI events (e.g. frame pop event) are requested then the
   389     // If certain JVMTI events (e.g. frame pop event) are requested then the
   451   }
   438   }
   452   return NULL;
   439   return NULL;
   453 }
   440 }
   454 
   441 
   455 #ifndef PRODUCT
   442 #ifndef PRODUCT
   456 void NonTieredCompPolicy::trace_frequency_counter_overflow(const methodHandle& m, int branch_bci, int bci) {
   443 void SimpleCompPolicy::trace_frequency_counter_overflow(const methodHandle& m, int branch_bci, int bci) {
   457   if (TraceInvocationCounterOverflow) {
   444   if (TraceInvocationCounterOverflow) {
   458     MethodCounters* mcs = m->method_counters();
   445     MethodCounters* mcs = m->method_counters();
   459     assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
   446     assert(mcs != NULL, "MethodCounters cannot be NULL for profiling");
   460     InvocationCounter* ic = mcs->invocation_counter();
   447     InvocationCounter* ic = mcs->invocation_counter();
   461     InvocationCounter* bc = mcs->backedge_counter();
   448     InvocationCounter* bc = mcs->backedge_counter();
   483       }
   470       }
   484     }
   471     }
   485   }
   472   }
   486 }
   473 }
   487 
   474 
   488 void NonTieredCompPolicy::trace_osr_request(const methodHandle& method, nmethod* osr, int bci) {
   475 void SimpleCompPolicy::trace_osr_request(const methodHandle& method, nmethod* osr, int bci) {
   489   if (TraceOnStackReplacement) {
   476   if (TraceOnStackReplacement) {
   490     ResourceMark rm;
   477     ResourceMark rm;
   491     tty->print(osr != NULL ? "Reused OSR entry for " : "Requesting OSR entry for ");
   478     tty->print(osr != NULL ? "Reused OSR entry for " : "Requesting OSR entry for ");
   492     method->print_short_name(tty);
   479     method->print_short_name(tty);
   493     tty->print_cr(" at bci %d", bci);
   480     tty->print_cr(" at bci %d", bci);
   494   }
   481   }
   495 }
   482 }
   496 #endif // !PRODUCT
   483 #endif // !PRODUCT
   497 
   484 
   498 // SimpleCompPolicy - compile current method
       
   499 
       
   500 void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
   485 void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
   501   const int comp_level = CompLevel_highest_tier;
   486   const int comp_level = CompLevel_highest_tier;
   502   const int hot_count = m->invocation_count();
   487   const int hot_count = m->invocation_count();
   503   reset_counter_for_invocation_event(m);
   488   reset_counter_for_invocation_event(m);
   504 
   489 
   517   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
   502   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
   518     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread);
   503     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread);
   519     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   504     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   520   }
   505   }
   521 }
   506 }
   522 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
       
   523 
       
   524 #ifdef COMPILER2
       
   525 const char* StackWalkCompPolicy::_msg = NULL;
       
   526 
       
   527 
       
   528 // Consider m for compilation
       
   529 void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
       
   530   const int comp_level = CompLevel_highest_tier;
       
   531   const int hot_count = m->invocation_count();
       
   532   reset_counter_for_invocation_event(m);
       
   533 
       
   534   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
       
   535     ResourceMark rm(thread);
       
   536     frame       fr     = thread->last_frame();
       
   537     assert(fr.is_interpreted_frame(), "must be interpreted");
       
   538     assert(fr.interpreter_frame_method() == m(), "bad method");
       
   539 
       
   540     RegisterMap reg_map(thread, false);
       
   541     javaVFrame* triggerVF = thread->last_java_vframe(&reg_map);
       
   542     // triggerVF is the frame that triggered its counter
       
   543     RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m());
       
   544 
       
   545     if (first->top_method()->code() != NULL) {
       
   546       // called obsolete method/nmethod -- no need to recompile
       
   547     } else {
       
   548       GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
       
   549       stack->push(first);
       
   550       RFrame* top = findTopInlinableFrame(stack);
       
   551       assert(top != NULL, "findTopInlinableFrame returned null");
       
   552       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
       
   553                                     m, hot_count, CompileTask::Reason_InvocationCount, thread);
       
   554     }
       
   555   }
       
   556 }
       
   557 
       
   558 void StackWalkCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
       
   559   const int comp_level = CompLevel_highest_tier;
       
   560   const int hot_count = m->backedge_count();
       
   561 
       
   562   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
       
   563     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread);
       
   564     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
       
   565   }
       
   566 }
       
   567 
       
   568 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
       
   569   // go up the stack until finding a frame that (probably) won't be inlined
       
   570   // into its caller
       
   571   RFrame* current = stack->at(0); // current choice for stopping
       
   572   assert( current && !current->is_compiled(), "" );
       
   573   const char* msg = NULL;
       
   574 
       
   575   while (1) {
       
   576 
       
   577     // before going up the stack further, check if doing so would get us into
       
   578     // compiled code
       
   579     RFrame* next = senderOf(current, stack);
       
   580     if( !next )               // No next frame up the stack?
       
   581       break;                  // Then compile with current frame
       
   582 
       
   583     Method* m = current->top_method();
       
   584     Method* next_m = next->top_method();
       
   585 
       
   586     if( !Inline ) {           // Inlining turned off
       
   587       msg = "Inlining turned off";
       
   588       break;
       
   589     }
       
   590     if (next_m->is_not_compilable()) { // Did fail to compile this before/
       
   591       msg = "caller not compilable";
       
   592       break;
       
   593     }
       
   594     if (next->num() > MaxRecompilationSearchLength) {
       
   595       // don't go up too high when searching for recompilees
       
   596       msg = "don't go up any further: > MaxRecompilationSearchLength";
       
   597       break;
       
   598     }
       
   599     if (next->distance() > MaxInterpretedSearchLength) {
       
   600       // don't go up too high when searching for recompilees
       
   601       msg = "don't go up any further: next > MaxInterpretedSearchLength";
       
   602       break;
       
   603     }
       
   604     // Compiled frame above already decided not to inline;
       
   605     // do not recompile him.
       
   606     if (next->is_compiled()) {
       
   607       msg = "not going up into optimized code";
       
   608       break;
       
   609     }
       
   610 
       
   611     // Interpreted frame above us was already compiled.  Do not force
       
   612     // a recompile, although if the frame above us runs long enough an
       
   613     // OSR might still happen.
       
   614     if( current->is_interpreted() && next_m->has_compiled_code() ) {
       
   615       msg = "not going up -- already compiled caller";
       
   616       break;
       
   617     }
       
   618 
       
   619     // Compute how frequent this call site is.  We have current method 'm'.
       
   620     // We know next method 'next_m' is interpreted.  Find the call site and
       
   621     // check the various invocation counts.
       
   622     int invcnt = 0;             // Caller counts
       
   623     if (ProfileInterpreter) {
       
   624       invcnt = next_m->interpreter_invocation_count();
       
   625     }
       
   626     int cnt = 0;                // Call site counts
       
   627     if (ProfileInterpreter && next_m->method_data() != NULL) {
       
   628       ResourceMark rm;
       
   629       int bci = next->top_vframe()->bci();
       
   630       ProfileData* data = next_m->method_data()->bci_to_data(bci);
       
   631       if (data != NULL && data->is_CounterData())
       
   632         cnt = data->as_CounterData()->count();
       
   633     }
       
   634 
       
   635     // Caller counts / call-site counts; i.e. is this call site
       
   636     // a hot call site for method next_m?
       
   637     int freq = (invcnt) ? cnt/invcnt : cnt;
       
   638 
       
   639     // Check size and frequency limits
       
   640     if ((msg = shouldInline(m, freq, cnt)) != NULL) {
       
   641       break;
       
   642     }
       
   643     // Check inlining negative tests
       
   644     if ((msg = shouldNotInline(m)) != NULL) {
       
   645       break;
       
   646     }
       
   647 
       
   648 
       
   649     // If the caller method is too big or something then we do not want to
       
   650     // compile it just to inline a method
       
   651     if (!can_be_compiled(next_m, CompLevel_any)) {
       
   652       msg = "caller cannot be compiled";
       
   653       break;
       
   654     }
       
   655 
       
   656     if( next_m->name() == vmSymbols::class_initializer_name() ) {
       
   657       msg = "do not compile class initializer (OSR ok)";
       
   658       break;
       
   659     }
       
   660 
       
   661     current = next;
       
   662   }
       
   663 
       
   664   assert( !current || !current->is_compiled(), "" );
       
   665 
       
   666   return current;
       
   667 }
       
   668 
       
   669 RFrame* StackWalkCompPolicy::senderOf(RFrame* rf, GrowableArray<RFrame*>* stack) {
       
   670   RFrame* sender = rf->caller();
       
   671   if (sender && sender->num() == stack->length()) stack->push(sender);
       
   672   return sender;
       
   673 }
       
   674 
       
   675 
       
   676 const char* StackWalkCompPolicy::shouldInline(const methodHandle& m, float freq, int cnt) {
       
   677   // Allows targeted inlining
       
   678   // positive filter: should send be inlined?  returns NULL (--> yes)
       
   679   // or rejection msg
       
   680   int max_size = MaxInlineSize;
       
   681   int cost = m->code_size();
       
   682 
       
   683   // Check for too many throws (and not too huge)
       
   684   if (m->interpreter_throwout_count() > InlineThrowCount && cost < InlineThrowMaxSize ) {
       
   685     return NULL;
       
   686   }
       
   687 
       
   688   // bump the max size if the call is frequent
       
   689   if ((freq >= InlineFrequencyRatio) || (cnt >= InlineFrequencyCount)) {
       
   690     if (TraceFrequencyInlining) {
       
   691       tty->print("(Inlined frequent method)\n");
       
   692       m->print();
       
   693     }
       
   694     max_size = FreqInlineSize;
       
   695   }
       
   696   if (cost > max_size) {
       
   697     return (_msg = "too big");
       
   698   }
       
   699   return NULL;
       
   700 }
       
   701 
       
   702 
       
   703 const char* StackWalkCompPolicy::shouldNotInline(const methodHandle& m) {
       
   704   // negative filter: should send NOT be inlined?  returns NULL (--> inline) or rejection msg
       
   705   if (m->is_abstract()) return (_msg = "abstract method");
       
   706   // note: we allow ik->is_abstract()
       
   707   if (!m->method_holder()->is_initialized()) return (_msg = "method holder not initialized");
       
   708   if (m->is_native()) return (_msg = "native method");
       
   709   CompiledMethod* m_code = m->code();
       
   710   if (m_code != NULL && m_code->code_size() > InlineSmallCode)
       
   711     return (_msg = "already compiled into a big method");
       
   712 
       
   713   // use frequency-based objections only for non-trivial methods
       
   714   if (m->code_size() <= MaxTrivialSize) return NULL;
       
   715   if (UseInterpreter) {     // don't use counts with -Xcomp
       
   716     if ((m->code() == NULL) && m->was_never_executed()) return (_msg = "never executed");
       
   717     if (!m->was_executed_more_than(MIN2(MinInliningThreshold, CompileThreshold >> 1))) return (_msg = "executed < MinInliningThreshold times");
       
   718   }
       
   719   if (Method::has_unloaded_classes_in_signature(m, JavaThread::current())) return (_msg = "unloaded signature classes");
       
   720 
       
   721   return NULL;
       
   722 }
       
   723 
       
   724 
       
   725 
       
   726 #endif // COMPILER2