8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "ci/ciEnv.hpp"
26 #include "ci/ciInstance.hpp"
27 #include "ci/ciMetadata.hpp"
28 #include "code/oopRecorder.inline.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "memory/allocation.inline.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "runtime/jniHandles.inline.hpp"
33 #include "runtime/mutexLocker.hpp"
34 #include "runtime/os.hpp"
35 #include "utilities/copy.hpp"
36
37 #ifdef ASSERT
38 template <class T> int ValueRecorder<T>::_find_index_calls = 0;
39 template <class T> int ValueRecorder<T>::_hit_indexes = 0;
40 template <class T> int ValueRecorder<T>::_missed_indexes = 0;
41 #endif //ASSERT
42
43
44 template <class T> ValueRecorder<T>::ValueRecorder(Arena* arena) {
45 _handles = nullptr;
46 _indexes = nullptr;
47 _arena = arena;
283 int cnt = count();
284 tty->print_cr("External addresses table: %d entries, %d accesses", cnt, total_access_count);
285 { // Print most accessed entries in the table.
286 int* array = NEW_C_HEAP_ARRAY(int, (2 * cnt), mtCode);
287 for (int i = 0; i < cnt; i++) {
288 array[(2 * i) + 0] = extern_hist->at(i);
289 array[(2 * i) + 1] = i;
290 }
291 // Reverse sort to have "hottest" addresses first.
292 qsort(array, cnt, 2*sizeof(int), count_cmp);
293 // Print all entries with Verbose flag otherwise only top 5.
294 int limit = (Verbose || cnt <= 5) ? cnt : 5;
295 int j = 0;
296 for (int i = 0; i < limit; i++) {
297 int index = array[(2 * i) + 1];
298 int n = extern_hist->at(index);
299 if (n > 0) {
300 address addr = at(index);
301 tty->print("%d: %8d " INTPTR_FORMAT " :", j++, n, p2i(addr));
302 if (addr != nullptr) {
303 if (StubRoutines::contains(addr)) {
304 StubCodeDesc* desc = StubCodeDesc::desc_for(addr);
305 if (desc == nullptr) {
306 desc = StubCodeDesc::desc_for(addr + frame::pc_return_offset);
307 }
308 const char* stub_name = (desc != nullptr) ? desc->name() : "<unknown>";
309 tty->print(" stub: %s", stub_name);
310 } else {
311 ResourceMark rm;
312 const int buflen = 1024;
313 char* buf = NEW_RESOURCE_ARRAY(char, buflen);
314 int offset = 0;
315 if (os::dll_address_to_function_name(addr, buf, buflen, &offset)) {
316 tty->print(" extn: %s", buf);
317 if (offset != 0) {
318 tty->print("+%d", offset);
319 }
320 } else {
321 if (CodeCache::contains((void*)addr)) {
322 // Something in CodeCache
323 tty->print(" in CodeCache");
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "ci/ciEnv.hpp"
26 #include "ci/ciInstance.hpp"
27 #include "ci/ciMetadata.hpp"
28 #include "ci/ciUtilities.hpp"
29 #include "code/oopRecorder.inline.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/jniHandles.inline.hpp"
34 #include "runtime/mutexLocker.hpp"
35 #include "runtime/os.hpp"
36 #include "utilities/copy.hpp"
37
38 #ifdef ASSERT
39 template <class T> int ValueRecorder<T>::_find_index_calls = 0;
40 template <class T> int ValueRecorder<T>::_hit_indexes = 0;
41 template <class T> int ValueRecorder<T>::_missed_indexes = 0;
42 #endif //ASSERT
43
44
45 template <class T> ValueRecorder<T>::ValueRecorder(Arena* arena) {
46 _handles = nullptr;
47 _indexes = nullptr;
48 _arena = arena;
284 int cnt = count();
285 tty->print_cr("External addresses table: %d entries, %d accesses", cnt, total_access_count);
286 { // Print most accessed entries in the table.
287 int* array = NEW_C_HEAP_ARRAY(int, (2 * cnt), mtCode);
288 for (int i = 0; i < cnt; i++) {
289 array[(2 * i) + 0] = extern_hist->at(i);
290 array[(2 * i) + 1] = i;
291 }
292 // Reverse sort to have "hottest" addresses first.
293 qsort(array, cnt, 2*sizeof(int), count_cmp);
294 // Print all entries with Verbose flag otherwise only top 5.
295 int limit = (Verbose || cnt <= 5) ? cnt : 5;
296 int j = 0;
297 for (int i = 0; i < limit; i++) {
298 int index = array[(2 * i) + 1];
299 int n = extern_hist->at(index);
300 if (n > 0) {
301 address addr = at(index);
302 tty->print("%d: %8d " INTPTR_FORMAT " :", j++, n, p2i(addr));
303 if (addr != nullptr) {
304 if (is_card_table_address(addr)) {
305 tty->print(" card_table_base");
306 } else if (StubRoutines::contains(addr)) {
307 StubCodeDesc* desc = StubCodeDesc::desc_for(addr);
308 if (desc == nullptr) {
309 desc = StubCodeDesc::desc_for(addr + frame::pc_return_offset);
310 }
311 const char* stub_name = (desc != nullptr) ? desc->name() : "<unknown>";
312 tty->print(" stub: %s", stub_name);
313 } else {
314 ResourceMark rm;
315 const int buflen = 1024;
316 char* buf = NEW_RESOURCE_ARRAY(char, buflen);
317 int offset = 0;
318 if (os::dll_address_to_function_name(addr, buf, buflen, &offset)) {
319 tty->print(" extn: %s", buf);
320 if (offset != 0) {
321 tty->print("+%d", offset);
322 }
323 } else {
324 if (CodeCache::contains((void*)addr)) {
325 // Something in CodeCache
326 tty->print(" in CodeCache");
|