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 }
|
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* method = (nm == NULL) ? NULL : nm->method(); // nm->method() may be uninitialized, i.e. != NULL, but invalid
2140 if ((nm != NULL) && (method != NULL) && (method->signature() != NULL) && !nm->is_zombie() && !nm->is_not_installed() &&
2141 os::is_readable_pointer(method) && os::is_readable_pointer(method->constants()) && os::is_readable_pointer(method->signature())) {
2142 ArgumentCount args(method->signature());
2143 int arity = args.size() + (method->is_static() ? 0 : 1);
2144 int argsize = method->size_of_parameters();
2145 arity = MIN2(arity, MAX_ARITY-1);
2146 argsize = MIN2(argsize, MAX_ARITY-1);
2147 int count = 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 }
|