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 "precompiled.hpp"
26 #include "ci/ciEnv.hpp"
27 #include "ci/ciInstance.hpp"
28 #include "ci/ciMetadata.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 (StubRoutines::contains(addr)) {
305 StubCodeDesc* desc = StubCodeDesc::desc_for(addr);
306 if (desc == nullptr) {
307 desc = StubCodeDesc::desc_for(addr + frame::pc_return_offset);
308 }
309 const char* stub_name = (desc != nullptr) ? desc->name() : "<unknown>";
310 tty->print(" stub: %s", stub_name);
311 } else {
312 ResourceMark rm;
313 const int buflen = 1024;
314 char* buf = NEW_RESOURCE_ARRAY(char, buflen);
315 int offset = 0;
316 if (os::dll_address_to_function_name(addr, buf, buflen, &offset)) {
317 tty->print(" extn: %s", buf);
318 if (offset != 0) {
319 tty->print("+%d", offset);
320 }
321 } else {
322 if (CodeCache::contains((void*)addr)) {
323 // Something in CodeCache
324 tty->print(" in CodeCache");
|
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 "precompiled.hpp"
26 #include "ci/ciEnv.hpp"
27 #include "ci/ciInstance.hpp"
28 #include "ci/ciMetadata.hpp"
29 #include "ci/ciUtilities.hpp"
30 #include "code/oopRecorder.inline.hpp"
31 #include "gc/shared/collectedHeap.hpp"
32 #include "memory/allocation.inline.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/jniHandles.inline.hpp"
35 #include "runtime/mutexLocker.hpp"
36 #include "runtime/os.hpp"
37 #include "utilities/copy.hpp"
38
39 #ifdef ASSERT
40 template <class T> int ValueRecorder<T>::_find_index_calls = 0;
41 template <class T> int ValueRecorder<T>::_hit_indexes = 0;
42 template <class T> int ValueRecorder<T>::_missed_indexes = 0;
43 #endif //ASSERT
44
45
46 template <class T> ValueRecorder<T>::ValueRecorder(Arena* arena) {
47 _handles = nullptr;
48 _indexes = nullptr;
49 _arena = arena;
285 int cnt = count();
286 tty->print_cr("External addresses table: %d entries, %d accesses", cnt, total_access_count);
287 { // Print most accessed entries in the table.
288 int* array = NEW_C_HEAP_ARRAY(int, (2 * cnt), mtCode);
289 for (int i = 0; i < cnt; i++) {
290 array[(2 * i) + 0] = extern_hist->at(i);
291 array[(2 * i) + 1] = i;
292 }
293 // Reverse sort to have "hottest" addresses first.
294 qsort(array, cnt, 2*sizeof(int), count_cmp);
295 // Print all entries with Verbose flag otherwise only top 5.
296 int limit = (Verbose || cnt <= 5) ? cnt : 5;
297 int j = 0;
298 for (int i = 0; i < limit; i++) {
299 int index = array[(2 * i) + 1];
300 int n = extern_hist->at(index);
301 if (n > 0) {
302 address addr = at(index);
303 tty->print("%d: %8d " INTPTR_FORMAT " :", j++, n, p2i(addr));
304 if (addr != nullptr) {
305 if (is_card_table_address(addr)) {
306 tty->print(" card_table_base");
307 } else if (StubRoutines::contains(addr)) {
308 StubCodeDesc* desc = StubCodeDesc::desc_for(addr);
309 if (desc == nullptr) {
310 desc = StubCodeDesc::desc_for(addr + frame::pc_return_offset);
311 }
312 const char* stub_name = (desc != nullptr) ? desc->name() : "<unknown>";
313 tty->print(" stub: %s", stub_name);
314 } else {
315 ResourceMark rm;
316 const int buflen = 1024;
317 char* buf = NEW_RESOURCE_ARRAY(char, buflen);
318 int offset = 0;
319 if (os::dll_address_to_function_name(addr, buf, buflen, &offset)) {
320 tty->print(" extn: %s", buf);
321 if (offset != 0) {
322 tty->print("+%d", offset);
323 }
324 } else {
325 if (CodeCache::contains((void*)addr)) {
326 // Something in CodeCache
327 tty->print(" in CodeCache");
|