29 #include "oops/oop.inline.hpp" |
29 #include "oops/oop.inline.hpp" |
30 #include "runtime/thread.hpp" |
30 #include "runtime/thread.hpp" |
31 #include "runtime/unhandledOops.hpp" |
31 #include "runtime/unhandledOops.hpp" |
32 #include "utilities/globalDefinitions.hpp" |
32 #include "utilities/globalDefinitions.hpp" |
33 |
33 |
34 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
|
35 |
|
36 #ifdef CHECK_UNHANDLED_OOPS |
34 #ifdef CHECK_UNHANDLED_OOPS |
37 const int free_list_size = 256; |
35 const int free_list_size = 256; |
38 |
36 |
39 |
37 |
40 UnhandledOops::UnhandledOops(Thread* thread) { |
38 UnhandledOops::UnhandledOops(Thread* thread) { |
50 |
48 |
51 |
49 |
52 void UnhandledOops::dump_oops(UnhandledOops *list) { |
50 void UnhandledOops::dump_oops(UnhandledOops *list) { |
53 for (int k = 0; k < list->_oop_list->length(); k++) { |
51 for (int k = 0; k < list->_oop_list->length(); k++) { |
54 UnhandledOopEntry entry = list->_oop_list->at(k); |
52 UnhandledOopEntry entry = list->_oop_list->at(k); |
55 tty->print(" " INTPTR_FORMAT, entry._oop_ptr); |
53 tty->print(" " INTPTR_FORMAT, p2i(entry._oop_ptr)); |
56 } |
54 } |
57 tty->cr(); |
55 tty->cr(); |
58 } |
56 } |
59 |
57 |
60 // For debugging unhandled oop detector _in the debugger_ |
58 // For debugging unhandled oop detector _in the debugger_ |
66 return; |
64 return; |
67 |
65 |
68 _level ++; |
66 _level ++; |
69 if (unhandled_oop_print) { |
67 if (unhandled_oop_print) { |
70 for (int i=0; i<_level; i++) tty->print(" "); |
68 for (int i=0; i<_level; i++) tty->print(" "); |
71 tty->print_cr("r " INTPTR_FORMAT, op); |
69 tty->print_cr("r " INTPTR_FORMAT, p2i(op)); |
72 } |
70 } |
73 UnhandledOopEntry entry(op, pc); |
71 UnhandledOopEntry entry(op, pc); |
74 _oop_list->push(entry); |
72 _oop_list->push(entry); |
75 } |
73 } |
76 |
74 |
103 if (!_thread->is_in_stack((address)op)) return; |
101 if (!_thread->is_in_stack((address)op)) return; |
104 |
102 |
105 _level --; |
103 _level --; |
106 if (unhandled_oop_print) { |
104 if (unhandled_oop_print) { |
107 for (int i=0; i<_level; i++) tty->print(" "); |
105 for (int i=0; i<_level; i++) tty->print(" "); |
108 tty->print_cr("u " INTPTR_FORMAT, op); |
106 tty->print_cr("u " INTPTR_FORMAT, p2i(op)); |
109 } |
107 } |
110 |
108 |
111 int i = _oop_list->find_from_end(op, match_oop_entry); |
109 int i = _oop_list->find_from_end(op, match_oop_entry); |
112 assert(i!=-1, "oop not in unhandled_oop_list"); |
110 assert(i!=-1, "oop not in unhandled_oop_list"); |
113 _oop_list->remove_at(i); |
111 _oop_list->remove_at(i); |
120 UnhandledOopEntry entry = _oop_list->at(k); |
118 UnhandledOopEntry entry = _oop_list->at(k); |
121 // If an entry is on the unhandled oop list but isn't on the stack |
119 // If an entry is on the unhandled oop list but isn't on the stack |
122 // anymore, it must not have gotten unregistered properly and it's a bug |
120 // anymore, it must not have gotten unregistered properly and it's a bug |
123 // in the unhandled oop generator. |
121 // in the unhandled oop generator. |
124 if(!_thread->is_in_stack((address)entry._oop_ptr)) { |
122 if(!_thread->is_in_stack((address)entry._oop_ptr)) { |
125 tty->print_cr("oop_ptr is " INTPTR_FORMAT, (address)entry._oop_ptr); |
123 tty->print_cr("oop_ptr is " INTPTR_FORMAT, p2i(entry._oop_ptr)); |
126 tty->print_cr("thread is " INTPTR_FORMAT " from pc " INTPTR_FORMAT, |
124 tty->print_cr("thread is " INTPTR_FORMAT " from pc " INTPTR_FORMAT, |
127 (address)_thread, (address)entry._pc); |
125 p2i(_thread), p2i(entry._pc)); |
128 assert(false, "heap is corrupted by the unhandled oop detector"); |
126 assert(false, "heap is corrupted by the unhandled oop detector"); |
129 } |
127 } |
130 // Set unhandled oops to a pattern that will crash distinctively |
128 // Set unhandled oops to a pattern that will crash distinctively |
131 if (!entry._ok_for_gc) *(intptr_t*)(entry._oop_ptr) = BAD_OOP_ADDR; |
129 if (!entry._ok_for_gc) *(intptr_t*)(entry._oop_ptr) = BAD_OOP_ADDR; |
132 } |
130 } |