< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page




2138 
2139   AdapterHandlerLibrary::print_statistics();
2140 
2141   if (xtty != NULL)  xtty->tail("statistics");
2142 }
2143 
2144 inline double percent(int x, int y) {
2145   return 100.0 * x / MAX2(y, 1);
2146 }
2147 
2148 class MethodArityHistogram {
2149  public:
2150   enum { MAX_ARITY = 256 };
2151  private:
2152   static int _arity_histogram[MAX_ARITY];     // histogram of #args
2153   static int _size_histogram[MAX_ARITY];      // histogram of arg size in words
2154   static int _max_arity;                      // max. arity seen
2155   static int _max_size;                       // max. arg size seen
2156 
2157   static void add_method_to_histogram(nmethod* nm) {
2158     if (CompiledMethod::nmethod_access_is_safe(nm)) {
2159       Method* method = nm->method();
2160       ArgumentCount args(method->signature());
2161       int arity   = args.size() + (method->is_static() ? 0 : 1);
2162       int argsize = method->size_of_parameters();
2163       arity   = MIN2(arity, MAX_ARITY-1);
2164       argsize = MIN2(argsize, MAX_ARITY-1);
2165       int count = method->compiled_invocation_count();
2166       _arity_histogram[arity]  += count;
2167       _size_histogram[argsize] += count;
2168       _max_arity = MAX2(_max_arity, arity);
2169       _max_size  = MAX2(_max_size, argsize);
2170     }
2171   }
2172 
2173   void print_histogram_helper(int n, int* histo, const char* name) {
2174     const int N = MIN2(5, n);
2175     tty->print_cr("\nHistogram of call arity (incl. rcvr, calls to compiled methods only):");
2176     double sum = 0;
2177     double weighted_sum = 0;
2178     int i;
2179     for (i = 0; i <= n; i++) { sum += histo[i]; weighted_sum += i*histo[i]; }
2180     double rest = sum;
2181     double percent = sum / 100;
2182     for (i = 0; i <= N; i++) {
2183       rest -= histo[i];
2184       tty->print_cr("%4d: %7d (%5.1f%%)", i, histo[i], histo[i] / percent);
2185     }
2186     tty->print_cr("rest: %7d (%5.1f%%))", (int)rest, rest / percent);
2187     tty->print_cr("(avg. %s = %3.1f, max = %d)", name, weighted_sum / sum, n);
2188   }
2189 
2190   void print_histogram() {
2191     tty->print_cr("\nHistogram of call arity (incl. rcvr, calls to compiled methods only):");
2192     print_histogram_helper(_max_arity, _arity_histogram, "arity");
2193     tty->print_cr("\nSame for parameter size (in words):");
2194     print_histogram_helper(_max_size, _size_histogram, "size");
2195     tty->cr();
2196   }
2197 
2198  public:
2199   MethodArityHistogram() {
2200     MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);



2201     _max_arity = _max_size = 0;
2202     for (int i = 0; i < MAX_ARITY; i++) _arity_histogram[i] = _size_histogram[i] = 0;
2203     CodeCache::nmethods_do(add_method_to_histogram);
2204     print_histogram();
2205   }
2206 };
2207 
2208 int MethodArityHistogram::_arity_histogram[MethodArityHistogram::MAX_ARITY];
2209 int MethodArityHistogram::_size_histogram[MethodArityHistogram::MAX_ARITY];
2210 int MethodArityHistogram::_max_arity;
2211 int MethodArityHistogram::_max_size;
2212 
2213 void SharedRuntime::print_call_statistics(int comp_total) {
2214   tty->print_cr("Calls from compiled code:");
2215   int total  = _nof_normal_calls + _nof_interface_calls + _nof_static_calls;
2216   int mono_c = _nof_normal_calls - _nof_optimized_calls - _nof_megamorphic_calls;
2217   int mono_i = _nof_interface_calls - _nof_optimized_interface_calls - _nof_megamorphic_interface_calls;
2218   tty->print_cr("\t%9d   (%4.1f%%) total non-inlined   ", total, percent(total, total));
2219   tty->print_cr("\t%9d   (%4.1f%%) virtual calls       ", _nof_normal_calls, percent(_nof_normal_calls, total));
2220   tty->print_cr("\t  %9d  (%3.0f%%)   inlined          ", _nof_inlined_calls, percent(_nof_inlined_calls, _nof_normal_calls));




2138 
2139   AdapterHandlerLibrary::print_statistics();
2140 
2141   if (xtty != NULL)  xtty->tail("statistics");
2142 }
2143 
2144 inline double percent(int x, int y) {
2145   return 100.0 * x / MAX2(y, 1);
2146 }
2147 
2148 class MethodArityHistogram {
2149  public:
2150   enum { MAX_ARITY = 256 };
2151  private:
2152   static int _arity_histogram[MAX_ARITY];     // histogram of #args
2153   static int _size_histogram[MAX_ARITY];      // histogram of arg size in words
2154   static int _max_arity;                      // max. arity seen
2155   static int _max_size;                       // max. arg size seen
2156 
2157   static void add_method_to_histogram(nmethod* nm) {
2158     Method* method = (nm == NULL) ? NULL : nm->method();
2159     if ((method != NULL) && nm->is_alive()) {
2160       ArgumentCount args(method->signature());
2161       int arity   = args.size() + (method->is_static() ? 0 : 1);
2162       int argsize = method->size_of_parameters();
2163       arity   = MIN2(arity, MAX_ARITY-1);
2164       argsize = MIN2(argsize, MAX_ARITY-1);
2165       int count = method->compiled_invocation_count();
2166       _arity_histogram[arity]  += count;
2167       _size_histogram[argsize] += count;
2168       _max_arity = MAX2(_max_arity, arity);
2169       _max_size  = MAX2(_max_size, argsize);
2170     }
2171   }
2172 
2173   void print_histogram_helper(int n, int* histo, const char* name) {
2174     const int N = MIN2(5, n);
2175     tty->print_cr("\nHistogram of call arity (incl. rcvr, calls to compiled methods only):");
2176     double sum = 0;
2177     double weighted_sum = 0;
2178     int i;
2179     for (i = 0; i <= n; i++) { sum += histo[i]; weighted_sum += i*histo[i]; }
2180     double rest = sum;
2181     double percent = sum / 100;
2182     for (i = 0; i <= N; i++) {
2183       rest -= histo[i];
2184       tty->print_cr("%4d: %7d (%5.1f%%)", i, histo[i], histo[i] / percent);
2185     }
2186     tty->print_cr("rest: %7d (%5.1f%%))", (int)rest, rest / percent);
2187     tty->print_cr("(avg. %s = %3.1f, max = %d)", name, weighted_sum / sum, n);
2188   }
2189 
2190   void print_histogram() {
2191     tty->print_cr("\nHistogram of call arity (incl. rcvr, calls to compiled methods only):");
2192     print_histogram_helper(_max_arity, _arity_histogram, "arity");
2193     tty->print_cr("\nSame for parameter size (in words):");
2194     print_histogram_helper(_max_size, _size_histogram, "size");
2195     tty->cr();
2196   }
2197 
2198  public:
2199   MethodArityHistogram() {
2200     // Take the Compile_lock to protect against changes in the CodeBlob structures
2201     MutexLockerEx mu1(Compile_lock, Mutex::_no_safepoint_check_flag);
2202     // Take the CodeCache_lock to protect against changes in the CodeHeap structure
2203     MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag);
2204     _max_arity = _max_size = 0;
2205     for (int i = 0; i < MAX_ARITY; i++) _arity_histogram[i] = _size_histogram[i] = 0;
2206     CodeCache::nmethods_do(add_method_to_histogram);
2207     print_histogram();
2208   }
2209 };
2210 
2211 int MethodArityHistogram::_arity_histogram[MethodArityHistogram::MAX_ARITY];
2212 int MethodArityHistogram::_size_histogram[MethodArityHistogram::MAX_ARITY];
2213 int MethodArityHistogram::_max_arity;
2214 int MethodArityHistogram::_max_size;
2215 
2216 void SharedRuntime::print_call_statistics(int comp_total) {
2217   tty->print_cr("Calls from compiled code:");
2218   int total  = _nof_normal_calls + _nof_interface_calls + _nof_static_calls;
2219   int mono_c = _nof_normal_calls - _nof_optimized_calls - _nof_megamorphic_calls;
2220   int mono_i = _nof_interface_calls - _nof_optimized_interface_calls - _nof_megamorphic_interface_calls;
2221   tty->print_cr("\t%9d   (%4.1f%%) total non-inlined   ", total, percent(total, total));
2222   tty->print_cr("\t%9d   (%4.1f%%) virtual calls       ", _nof_normal_calls, percent(_nof_normal_calls, total));
2223   tty->print_cr("\t  %9d  (%3.0f%%)   inlined          ", _nof_inlined_calls, percent(_nof_inlined_calls, _nof_normal_calls));


< prev index next >