< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page
rev 51433 : 8209588: SIGSEGV in MethodArityHistogram() with -XX:+CountCompiledCalls
Reviewed-by:


2118 
2119   AdapterHandlerLibrary::print_statistics();
2120 
2121   if (xtty != NULL)  xtty->tail("statistics");
2122 }
2123 
2124 inline double percent(int x, int y) {
2125   return 100.0 * x / MAX2(y, 1);
2126 }
2127 
2128 class MethodArityHistogram {
2129  public:
2130   enum { MAX_ARITY = 256 };
2131  private:
2132   static int _arity_histogram[MAX_ARITY];     // histogram of #args
2133   static int _size_histogram[MAX_ARITY];      // histogram of arg size in words
2134   static int _max_arity;                      // max. arity seen
2135   static int _max_size;                       // max. arg size seen
2136 
2137   static void add_method_to_histogram(nmethod* nm) {
2138     Method* m = nm->method();



2139     ArgumentCount args(m->signature());
2140     int arity   = args.size() + (m->is_static() ? 0 : 1);
2141     int argsize = m->size_of_parameters();
2142     arity   = MIN2(arity, MAX_ARITY-1);
2143     argsize = MIN2(argsize, MAX_ARITY-1);
2144     int count = nm->method()->compiled_invocation_count();
2145     _arity_histogram[arity]  += count;
2146     _size_histogram[argsize] += count;
2147     _max_arity = MAX2(_max_arity, arity);
2148     _max_size  = MAX2(_max_size, argsize);

2149   }
2150 
2151   void print_histogram_helper(int n, int* histo, const char* name) {
2152     const int N = MIN2(5, n);
2153     tty->print_cr("\nHistogram of call arity (incl. rcvr, calls to compiled methods only):");
2154     double sum = 0;
2155     double weighted_sum = 0;
2156     int i;
2157     for (i = 0; i <= n; i++) { sum += histo[i]; weighted_sum += i*histo[i]; }
2158     double rest = sum;
2159     double percent = sum / 100;
2160     for (i = 0; i <= N; i++) {
2161       rest -= histo[i];
2162       tty->print_cr("%4d: %7d (%5.1f%%)", i, histo[i], histo[i] / percent);
2163     }
2164     tty->print_cr("rest: %7d (%5.1f%%))", (int)rest, rest / percent);
2165     tty->print_cr("(avg. %s = %3.1f, max = %d)", name, weighted_sum / sum, n);
2166   }
2167 
2168   void print_histogram() {




2118 
2119   AdapterHandlerLibrary::print_statistics();
2120 
2121   if (xtty != NULL)  xtty->tail("statistics");
2122 }
2123 
2124 inline double percent(int x, int y) {
2125   return 100.0 * x / MAX2(y, 1);
2126 }
2127 
2128 class MethodArityHistogram {
2129  public:
2130   enum { MAX_ARITY = 256 };
2131  private:
2132   static int _arity_histogram[MAX_ARITY];     // histogram of #args
2133   static int _size_histogram[MAX_ARITY];      // histogram of arg size in words
2134   static int _max_arity;                      // max. arity seen
2135   static int _max_size;                       // max. arg size seen
2136 
2137   static void add_method_to_histogram(nmethod* nm) {
2138     // These checks are taken from CodeHeapState::print_names()
2139     Method* m = (nm == NULL) ? NULL : nm->method();  // nm->method() may be uninitialized, i.e. != NULL, but invalid
2140     if ((nm != NULL) && (m != NULL) && !nm->is_zombie() && !nm->is_not_installed() &&
2141         os::is_readable_pointer(m) && os::is_readable_pointer(m->constants())) {
2142       ArgumentCount args(m->signature());
2143       int arity   = args.size() + (m->is_static() ? 0 : 1);
2144       int argsize = m->size_of_parameters();
2145       arity   = MIN2(arity, MAX_ARITY-1);
2146       argsize = MIN2(argsize, MAX_ARITY-1);
2147       int count = nm->method()->compiled_invocation_count();
2148       _arity_histogram[arity]  += count;
2149       _size_histogram[argsize] += count;
2150       _max_arity = MAX2(_max_arity, arity);
2151       _max_size  = MAX2(_max_size, argsize);
2152     }
2153   }
2154 
2155   void print_histogram_helper(int n, int* histo, const char* name) {
2156     const int N = MIN2(5, n);
2157     tty->print_cr("\nHistogram of call arity (incl. rcvr, calls to compiled methods only):");
2158     double sum = 0;
2159     double weighted_sum = 0;
2160     int i;
2161     for (i = 0; i <= n; i++) { sum += histo[i]; weighted_sum += i*histo[i]; }
2162     double rest = sum;
2163     double percent = sum / 100;
2164     for (i = 0; i <= N; i++) {
2165       rest -= histo[i];
2166       tty->print_cr("%4d: %7d (%5.1f%%)", i, histo[i], histo[i] / percent);
2167     }
2168     tty->print_cr("rest: %7d (%5.1f%%))", (int)rest, rest / percent);
2169     tty->print_cr("(avg. %s = %3.1f, max = %d)", name, weighted_sum / sum, n);
2170   }
2171 
2172   void print_histogram() {


< prev index next >