hotspot/src/share/vm/runtime/compilationPolicy.cpp
author twisti
Thu, 08 Apr 2010 10:55:40 +0200
changeset 5252 58f23871a5b6
parent 4750 71fd601907dc
child 5547 f4b087cbb361
permissions -rw-r--r--
6941529: SharedRuntime::raw_exception_handler_for_return_address must reset thread MethodHandle flag Summary: During testing a bug was hit when an exception returned to the interpreter and the SP was wrong. Reviewed-by: kvn, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
4645
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
     2
 * Copyright 2000-2010 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_compilationPolicy.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
CompilationPolicy* CompilationPolicy::_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
elapsedTimer       CompilationPolicy::_accumulated_time;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
bool               CompilationPolicy::_in_vm_startup;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// Determine compilation policy based on command line argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
void compilationPolicy_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  CompilationPolicy::set_in_vm_startup(DelayCompilationDuringStartup);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  switch(CompilationPolicyChoice) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  case 0:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    CompilationPolicy::set_policy(new SimpleCompPolicy());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  case 1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    CompilationPolicy::set_policy(new StackWalkCompPolicy());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    fatal("CompilationPolicyChoice must be in the range: [0-1]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
void CompilationPolicy::completed_vm_startup() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  if (TraceCompilationPolicy) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    tty->print("CompilationPolicy: completed vm startup.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  _in_vm_startup = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// Returns true if m must be compiled before executing it
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// This is intended to force compiles for methods (usually for
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// debugging) that would otherwise be interpreted for some reason.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
bool CompilationPolicy::mustBeCompiled(methodHandle m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  if (m->has_compiled_code()) return false;       // already compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  if (!canBeCompiled(m))      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  return !UseInterpreter ||                                              // must compile all methods
4750
71fd601907dc 4360113: Evict nmethods when code cache gets full
kvn
parents: 4645
diff changeset
    69
         (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// Returns true if m is allowed to be compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
bool CompilationPolicy::canBeCompiled(methodHandle m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  if (m->is_abstract()) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  if (DontCompileHugeMethods && m->code_size() > HugeMethodLimit) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
4645
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    77
  // Math intrinsics should never be compiled as this can lead to
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    78
  // monotonicity problems because the interpreter will prefer the
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    79
  // compiled code to the intrinsic version.  This can't happen in
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    80
  // production because the invocation counter can't be incremented
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    81
  // but we shouldn't expose the system to this problem in testing
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    82
  // modes.
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    83
  if (!AbstractInterpreter::can_be_compiled(m)) {
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    84
    return false;
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    85
  }
0c5f5b94e93a 6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents: 1
diff changeset
    86
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  return !m->is_not_compilable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
void CompilationPolicy::print_time() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  tty->print_cr ("Accumulated compilationPolicy times:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  tty->print_cr ("---------------------------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  tty->print_cr ("  Total: %3.3f sec.", _accumulated_time.seconds());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
static void trace_osr_completion(nmethod* osr_nm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  if (TraceOnStackReplacement) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    if (osr_nm == NULL) tty->print_cr("compilation failed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    else tty->print_cr("nmethod " INTPTR_FORMAT, osr_nm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
#endif // !PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
void CompilationPolicy::reset_counter_for_invocation_event(methodHandle m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Make sure invocation and backedge counter doesn't overflow again right away
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // as would be the case for native methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // BUT also make sure the method doesn't look like it was never executed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // Set carry bit and reduce counter's value to min(count, CompileThreshold/2).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  m->invocation_counter()->set_carry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  m->backedge_counter()->set_carry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  assert(!m->was_never_executed(), "don't reset to 0 -- could be mistaken for never-executed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
void CompilationPolicy::reset_counter_for_back_branch_event(methodHandle m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // Delay next back-branch event but pump up invocation counter to triger
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // whole method compilation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  InvocationCounter* i = m->invocation_counter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  InvocationCounter* b = m->backedge_counter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // Don't set invocation_counter's value too low otherwise the method will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // look like immature (ic < ~5300) which prevents the inlining based on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // the type profiling.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  i->set(i->state(), CompileThreshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Don't reset counter too low - it is used to check if OSR method is ready.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  b->set(b->state(), CompileThreshold / 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
// SimpleCompPolicy - compile current method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
void SimpleCompPolicy::method_invocation_event( methodHandle m, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  int hot_count = m->invocation_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  reset_counter_for_invocation_event(m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  const char* comment = "count";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
4750
71fd601907dc 4360113: Evict nmethods when code cache gets full
kvn
parents: 4645
diff changeset
   140
  if (!delayCompilationDuringStartup() && canBeCompiled(m) && UseCompiler && CompileBroker::should_compile_new_jobs()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    nmethod* nm = m->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    if (nm == NULL ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      const char* comment = "count";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      CompileBroker::compile_method(m, InvocationEntryBci,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
                                    m, hot_count, comment, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
#ifdef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      if (nm->is_compiled_by_c1()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        const char* comment = "tier1 overflow";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
        CompileBroker::compile_method(m, InvocationEntryBci,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
                                      m, hot_count, comment, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
void SimpleCompPolicy::method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  int hot_count = m->backedge_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  const char* comment = "backedge_count";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
4750
71fd601907dc 4360113: Evict nmethods when code cache gets full
kvn
parents: 4645
diff changeset
   165
  if (!m->is_not_osr_compilable() && !delayCompilationDuringStartup() && canBeCompiled(m) && CompileBroker::should_compile_new_jobs()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    CompileBroker::compile_method(m, loop_top_bci, m, hot_count, comment, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(loop_top_bci));)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
int SimpleCompPolicy::compilation_level(methodHandle m, int branch_bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
#ifdef TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  if (!TieredCompilation) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    return CompLevel_highest_tier;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  if (/* m()->tier1_compile_done() && */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
     // QQQ HACK FIX ME set tier1_compile_done!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
      !m()->is_native()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    // Grab the nmethod so it doesn't go away while it's being queried
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    nmethod* code = m()->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    if (code != NULL && code->is_compiled_by_c1()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
      return CompLevel_highest_tier;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  return CompLevel_fast_compile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  return CompLevel_highest_tier;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
#endif // TIERED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
// StackWalkCompPolicy - walk up stack to find a suitable method to compile
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
const char* StackWalkCompPolicy::_msg = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
// Consider m for compilation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
void StackWalkCompPolicy::method_invocation_event(methodHandle m, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  int hot_count = m->invocation_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  reset_counter_for_invocation_event(m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  const char* comment = "count";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
4750
71fd601907dc 4360113: Evict nmethods when code cache gets full
kvn
parents: 4645
diff changeset
   207
  if (m->code() == NULL && !delayCompilationDuringStartup() && canBeCompiled(m) && UseCompiler && CompileBroker::should_compile_new_jobs()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    ResourceMark rm(THREAD);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    JavaThread *thread = (JavaThread*)THREAD;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    frame       fr     = thread->last_frame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    assert(fr.is_interpreted_frame(), "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    assert(fr.interpreter_frame_method() == m(), "bad method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    if (TraceCompilationPolicy) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      tty->print("method invocation trigger: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      m->print_short_name(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", (address)m(), m->code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    RegisterMap reg_map(thread, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    javaVFrame* triggerVF = thread->last_java_vframe(&reg_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    // triggerVF is the frame that triggered its counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    if (first->top_method()->code() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      // called obsolete method/nmethod -- no need to recompile
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      if (TraceCompilationPolicy) tty->print_cr(" --> " INTPTR_FORMAT, first->top_method()->code());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    } else if (compilation_level(m, InvocationEntryBci) == CompLevel_fast_compile) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      // Tier1 compilation policy avaoids stack walking.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      CompileBroker::compile_method(m, InvocationEntryBci,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
                                    m, hot_count, comment, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      if (TimeCompilationPolicy) accumulated_time()->start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      stack->push(first);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      RFrame* top = findTopInlinableFrame(stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      if (TimeCompilationPolicy) accumulated_time()->stop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      assert(top != NULL, "findTopInlinableFrame returned null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      if (TraceCompilationPolicy) top->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      CompileBroker::compile_method(top->top_method(), InvocationEntryBci,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
                                    m, hot_count, comment, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  int hot_count = m->backedge_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  const char* comment = "backedge_count";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
4750
71fd601907dc 4360113: Evict nmethods when code cache gets full
kvn
parents: 4645
diff changeset
   251
  if (!m->is_not_osr_compilable() && !delayCompilationDuringStartup() && canBeCompiled(m) && CompileBroker::should_compile_new_jobs()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    CompileBroker::compile_method(m, loop_top_bci, m, hot_count, comment, CHECK);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(loop_top_bci));)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
int StackWalkCompPolicy::compilation_level(methodHandle m, int osr_bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  int comp_level = CompLevel_full_optimization;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  if (TieredCompilation && osr_bci == InvocationEntryBci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    if (CompileTheWorld) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
      // Under CTW, the first compile is tier1, the second tier2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
      if (m->highest_tier_compile() == CompLevel_none) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        comp_level = CompLevel_fast_compile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    } else if (!m->has_osr_nmethod()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
      // Before tier1 is done, use invocation_count + backedge_count to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
      // compare against the threshold.  After that, the counters may/will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
      // be reset, so rely on the straight interpreter_invocation_count.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
      if (m->highest_tier_compile() == CompLevel_initial_compile) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
        if (m->interpreter_invocation_count() < Tier2CompileThreshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
          comp_level = CompLevel_fast_compile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      } else if (m->invocation_count() + m->backedge_count() <
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
                 Tier2CompileThreshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        comp_level = CompLevel_fast_compile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  return comp_level;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // go up the stack until finding a frame that (probably) won't be inlined
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // into its caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  RFrame* current = stack->at(0); // current choice for stopping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  assert( current && !current->is_compiled(), "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  const char* msg = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  while (1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    // before going up the stack further, check if doing so would get us into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    // compiled code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    RFrame* next = senderOf(current, stack);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    if( !next )               // No next frame up the stack?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
      break;                  // Then compile with current frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    methodHandle m = current->top_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    methodHandle next_m = next->top_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    if (TraceCompilationPolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      tty->print("[caller: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      next_m->print_short_name(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      tty->print("] ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    if( !Inline ) {           // Inlining turned off
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      msg = "Inlining turned off";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    if (next_m->is_not_compilable()) { // Did fail to compile this before/
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
      msg = "caller not compilable";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    if (next->num() > MaxRecompilationSearchLength) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      // don't go up too high when searching for recompilees
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      msg = "don't go up any further: > MaxRecompilationSearchLength";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    if (next->distance() > MaxInterpretedSearchLength) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      // don't go up too high when searching for recompilees
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      msg = "don't go up any further: next > MaxInterpretedSearchLength";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    // Compiled frame above already decided not to inline;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    // do not recompile him.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    if (next->is_compiled()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
      msg = "not going up into optimized code";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    // Interpreted frame above us was already compiled.  Do not force
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    // a recompile, although if the frame above us runs long enough an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    // OSR might still happen.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    if( current->is_interpreted() && next_m->has_compiled_code() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      msg = "not going up -- already compiled caller";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    // Compute how frequent this call site is.  We have current method 'm'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    // We know next method 'next_m' is interpreted.  Find the call site and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    // check the various invocation counts.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    int invcnt = 0;             // Caller counts
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    if (ProfileInterpreter) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      invcnt = next_m->interpreter_invocation_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    int cnt = 0;                // Call site counts
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    if (ProfileInterpreter && next_m->method_data() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
      int bci = next->top_vframe()->bci();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
      ProfileData* data = next_m->method_data()->bci_to_data(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
      if (data != NULL && data->is_CounterData())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
        cnt = data->as_CounterData()->count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    // Caller counts / call-site counts; i.e. is this call site
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    // a hot call site for method next_m?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    int freq = (invcnt) ? cnt/invcnt : cnt;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    // Check size and frequency limits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    if ((msg = shouldInline(m, freq, cnt)) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    // Check inlining negative tests
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    if ((msg = shouldNotInline(m)) != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    // If the caller method is too big or something then we do not want to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    // compile it just to inline a method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    if (!canBeCompiled(next_m)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      msg = "caller cannot be compiled";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    if( next_m->name() == vmSymbols::class_initializer_name() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      msg = "do not compile class initializer (OSR ok)";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    if (TraceCompilationPolicy && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      tty->print("\n\t     check caller: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
      next_m->print_short_name(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", (address)next_m(), next_m->code_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
    current = next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  assert( !current || !current->is_compiled(), "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  if (TraceCompilationPolicy && msg) tty->print("(%s)\n", msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  return current;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
RFrame* StackWalkCompPolicy::senderOf(RFrame* rf, GrowableArray<RFrame*>* stack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  RFrame* sender = rf->caller();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  if (sender && sender->num() == stack->length()) stack->push(sender);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  return sender;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
const char* StackWalkCompPolicy::shouldInline(methodHandle m, float freq, int cnt) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  // Allows targeted inlining
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // positive filter: should send be inlined?  returns NULL (--> yes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  // or rejection msg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  int max_size = MaxInlineSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  int cost = m->code_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  // Check for too many throws (and not too huge)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  if (m->interpreter_throwout_count() > InlineThrowCount && cost < InlineThrowMaxSize ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // bump the max size if the call is frequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  if ((freq >= InlineFrequencyRatio) || (cnt >= InlineFrequencyCount)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    if (TraceFrequencyInlining) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      tty->print("(Inlined frequent method)\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      m->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    max_size = FreqInlineSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  if (cost > max_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    return (_msg = "too big");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
const char* StackWalkCompPolicy::shouldNotInline(methodHandle m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  // negative filter: should send NOT be inlined?  returns NULL (--> inline) or rejection msg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  if (m->is_abstract()) return (_msg = "abstract method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  // note: we allow ik->is_abstract()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  if (!instanceKlass::cast(m->method_holder())->is_initialized()) return (_msg = "method holder not initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  if (m->is_native()) return (_msg = "native method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  nmethod* m_code = m->code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  if( m_code != NULL && m_code->instructions_size() > InlineSmallCode )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    return (_msg = "already compiled into a big method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  // use frequency-based objections only for non-trivial methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  if (m->code_size() <= MaxTrivialSize) return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  if (UseInterpreter) {     // don't use counts with -Xcomp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    if ((m->code() == NULL) && m->was_never_executed()) return (_msg = "never executed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    if (!m->was_executed_more_than(MIN2(MinInliningThreshold, CompileThreshold >> 1))) return (_msg = "executed < MinInliningThreshold times");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  if (methodOopDesc::has_unloaded_classes_in_signature(m, JavaThread::current())) return (_msg = "unloaded signature classes");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
#endif // COMPILER2