8267396: Avoid recording "pc" in unhandled oops detector for better performance

Reviewed-by: coleenp, dholmes
This commit is contained in:
Aleksey Shipilev 2021-05-20 14:26:18 +00:00
parent 878d1b3f60
commit f67847f52a
3 changed files with 8 additions and 11 deletions

View File

@ -36,8 +36,7 @@ void oop::register_oop() {
// This gets expensive, which is why checking unhandled oops is on a switch. // This gets expensive, which is why checking unhandled oops is on a switch.
Thread* t = Thread::current_or_null(); Thread* t = Thread::current_or_null();
if (t != NULL && t->is_Java_thread()) { if (t != NULL && t->is_Java_thread()) {
frame fr = os::current_frame(); t->unhandled_oops()->register_unhandled_oop(this);
t->unhandled_oops()->register_unhandled_oop(this, fr.pc());
} }
} }

View File

@ -57,7 +57,7 @@ void UnhandledOops::dump_oops(UnhandledOops *list) {
// You don't want to turn it on in compiled code here. // You don't want to turn it on in compiled code here.
static Thread* unhandled_oop_print = NULL; static Thread* unhandled_oop_print = NULL;
void UnhandledOops::register_unhandled_oop(oop* op, address pc) { void UnhandledOops::register_unhandled_oop(oop* op) {
if (!_thread->is_in_live_stack((address)op)) { if (!_thread->is_in_live_stack((address)op)) {
return; return;
} }
@ -67,7 +67,7 @@ void UnhandledOops::register_unhandled_oop(oop* op, address pc) {
for (int i=0; i < _level; i++) tty->print(" "); for (int i=0; i < _level; i++) tty->print(" ");
tty->print_cr("r " INTPTR_FORMAT, p2i(op)); tty->print_cr("r " INTPTR_FORMAT, p2i(op));
} }
UnhandledOopEntry entry(op, pc); UnhandledOopEntry entry(op);
_oop_list->push(entry); _oop_list->push(entry);
} }
@ -120,8 +120,7 @@ void UnhandledOops::clear_unhandled_oops() {
// in the unhandled oop generator. // in the unhandled oop generator.
if (!_thread->is_in_live_stack((address)entry._oop_ptr)) { if (!_thread->is_in_live_stack((address)entry._oop_ptr)) {
tty->print_cr("oop_ptr is " INTPTR_FORMAT, p2i(entry._oop_ptr)); tty->print_cr("oop_ptr is " INTPTR_FORMAT, p2i(entry._oop_ptr));
tty->print_cr("thread is " INTPTR_FORMAT " from pc " INTPTR_FORMAT, tty->print_cr("thread is " INTPTR_FORMAT, p2i(_thread));
p2i(_thread), p2i(entry._pc));
assert(false, "heap is corrupted by the unhandled oop detector"); assert(false, "heap is corrupted by the unhandled oop detector");
} }
// Set unhandled oops to a pattern that will crash distinctively // Set unhandled oops to a pattern that will crash distinctively

View File

@ -53,12 +53,11 @@ class UnhandledOopEntry : public CHeapObj<mtThread> {
private: private:
oop* _oop_ptr; oop* _oop_ptr;
bool _ok_for_gc; bool _ok_for_gc;
address _pc;
public: public:
oop* oop_ptr() { return _oop_ptr; } oop* oop_ptr() { return _oop_ptr; }
UnhandledOopEntry() : _oop_ptr(NULL), _ok_for_gc(false), _pc(NULL) {} UnhandledOopEntry() : _oop_ptr(NULL), _ok_for_gc(false) {}
UnhandledOopEntry(oop* op, address pc) : UnhandledOopEntry(oop* op) :
_oop_ptr(op), _ok_for_gc(false), _pc(pc) {} _oop_ptr(op), _ok_for_gc(false) {}
}; };
@ -75,7 +74,7 @@ class UnhandledOops : public CHeapObj<mtThread> {
public: public:
static void dump_oops(UnhandledOops* list); static void dump_oops(UnhandledOops* list);
void register_unhandled_oop(oop* op, address pc); void register_unhandled_oop(oop* op);
void unregister_unhandled_oop(oop* op); void unregister_unhandled_oop(oop* op);
}; };