author | tschatzl |
Thu, 11 Jan 2018 10:40:01 +0100 | |
changeset 48631 | 862c41cf1c7f |
parent 47216 | 71c04702a3d5 |
child 49594 | 898ef81cbc0e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/shared/collectedHeap.hpp" |
27 |
#include "gc/shared/gcLocker.inline.hpp" |
|
7397 | 28 |
#include "memory/universe.hpp" |
29 |
#include "oops/oop.inline.hpp" |
|
30 |
#include "runtime/thread.hpp" |
|
31 |
#include "runtime/unhandledOops.hpp" |
|
32 |
#include "utilities/globalDefinitions.hpp" |
|
1 | 33 |
|
34 |
#ifdef CHECK_UNHANDLED_OOPS |
|
35 |
const int free_list_size = 256; |
|
36 |
||
37 |
||
38 |
UnhandledOops::UnhandledOops(Thread* thread) { |
|
39 |
_thread = thread; |
|
13195 | 40 |
_oop_list = new (ResourceObj::C_HEAP, mtInternal) |
1 | 41 |
GrowableArray<UnhandledOopEntry>(free_list_size, true); |
42 |
_level = 0; |
|
43 |
} |
|
44 |
||
45 |
UnhandledOops::~UnhandledOops() { |
|
46 |
delete _oop_list; |
|
47 |
} |
|
48 |
||
49 |
||
50 |
void UnhandledOops::dump_oops(UnhandledOops *list) { |
|
51 |
for (int k = 0; k < list->_oop_list->length(); k++) { |
|
52 |
UnhandledOopEntry entry = list->_oop_list->at(k); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
31592
diff
changeset
|
53 |
tty->print(" " INTPTR_FORMAT, p2i(entry._oop_ptr)); |
1 | 54 |
} |
55 |
tty->cr(); |
|
56 |
} |
|
57 |
||
58 |
// For debugging unhandled oop detector _in the debugger_ |
|
59 |
// You don't want to turn it on in compiled code here. |
|
60 |
static bool unhandled_oop_print=0; |
|
61 |
||
62 |
void UnhandledOops::register_unhandled_oop(oop* op, address pc) { |
|
63 |
if (!_thread->is_in_stack((address)op)) |
|
64 |
return; |
|
65 |
||
66 |
_level ++; |
|
67 |
if (unhandled_oop_print) { |
|
68 |
for (int i=0; i<_level; i++) tty->print(" "); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
31592
diff
changeset
|
69 |
tty->print_cr("r " INTPTR_FORMAT, p2i(op)); |
1 | 70 |
} |
71 |
UnhandledOopEntry entry(op, pc); |
|
72 |
_oop_list->push(entry); |
|
73 |
} |
|
74 |
||
75 |
||
76 |
bool match_oop_entry(void *op, UnhandledOopEntry e) { |
|
77 |
return (e.oop_ptr() == op); |
|
78 |
} |
|
79 |
||
80 |
// Mark unhandled oop as okay for GC - the containing struct has an oops_do and |
|
81 |
// for some reason the oop has to be on the stack. |
|
82 |
// May not be called for the current thread, as in the case of |
|
83 |
// VM_GetOrSetLocal in jvmti. |
|
84 |
void UnhandledOops::allow_unhandled_oop(oop* op) { |
|
85 |
assert (CheckUnhandledOops, "should only be called with checking option"); |
|
86 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
87 |
int i = _oop_list->find_from_end(op, match_oop_entry); |
1 | 88 |
assert(i!=-1, "safe for gc oop not in unhandled_oop_list"); |
89 |
||
90 |
UnhandledOopEntry entry = _oop_list->at(i); |
|
91 |
assert(!entry._ok_for_gc, "duplicate entry"); |
|
92 |
entry._ok_for_gc = true; |
|
93 |
_oop_list->at_put(i, entry); |
|
94 |
} |
|
95 |
||
96 |
||
97 |
// Called by the oop destructor to remove unhandled oop from the thread's |
|
98 |
// oop list. All oops given are assumed to be on the list. If not, |
|
99 |
// there's a bug in the unhandled oop detector. |
|
100 |
void UnhandledOops::unregister_unhandled_oop(oop* op) { |
|
101 |
if (!_thread->is_in_stack((address)op)) return; |
|
102 |
||
103 |
_level --; |
|
104 |
if (unhandled_oop_print) { |
|
105 |
for (int i=0; i<_level; i++) tty->print(" "); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
31592
diff
changeset
|
106 |
tty->print_cr("u " INTPTR_FORMAT, p2i(op)); |
1 | 107 |
} |
108 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
109 |
int i = _oop_list->find_from_end(op, match_oop_entry); |
1 | 110 |
assert(i!=-1, "oop not in unhandled_oop_list"); |
111 |
_oop_list->remove_at(i); |
|
112 |
} |
|
113 |
||
114 |
void UnhandledOops::clear_unhandled_oops() { |
|
115 |
assert (CheckUnhandledOops, "should only be called with checking option"); |
|
23540
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
13728
diff
changeset
|
116 |
|
1 | 117 |
for (int k = 0; k < _oop_list->length(); k++) { |
118 |
UnhandledOopEntry entry = _oop_list->at(k); |
|
119 |
// If an entry is on the unhandled oop list but isn't on the stack |
|
120 |
// anymore, it must not have gotten unregistered properly and it's a bug |
|
121 |
// in the unhandled oop generator. |
|
122 |
if(!_thread->is_in_stack((address)entry._oop_ptr)) { |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
31592
diff
changeset
|
123 |
tty->print_cr("oop_ptr is " INTPTR_FORMAT, p2i(entry._oop_ptr)); |
1 | 124 |
tty->print_cr("thread is " INTPTR_FORMAT " from pc " INTPTR_FORMAT, |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
31592
diff
changeset
|
125 |
p2i(_thread), p2i(entry._pc)); |
1 | 126 |
assert(false, "heap is corrupted by the unhandled oop detector"); |
127 |
} |
|
128 |
// Set unhandled oops to a pattern that will crash distinctively |
|
129 |
if (!entry._ok_for_gc) *(intptr_t*)(entry._oop_ptr) = BAD_OOP_ADDR; |
|
130 |
} |
|
131 |
} |
|
132 |
#endif // CHECK_UNHANDLED_OOPS |