annotate src/share/vm/runtime/unhandledOops.cpp @ 18096:ca6d25be853b jdk8u25-b13

8044269: Analysis of archive files. Summary: Add checksum verification. Reviewed-by: iklam, dholmes, mschoene
author jiangli
date Tue, 12 Aug 2014 17:46:16 -0400
parents 78bbf4d43a14
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17876
diff changeset
2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "memory/gcLocker.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/universe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/thread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/unhandledOops.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "utilities/globalDefinitions.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17876
diff changeset
34 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17876
diff changeset
35
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 #ifdef CHECK_UNHANDLED_OOPS
a61af66fc99e Initial load
duke
parents:
diff changeset
37 const int free_list_size = 256;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 UnhandledOops::UnhandledOops(Thread* thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _thread = thread;
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
42 _oop_list = new (ResourceObj::C_HEAP, mtInternal)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43 GrowableArray<UnhandledOopEntry>(free_list_size, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _level = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 UnhandledOops::~UnhandledOops() {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 delete _oop_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 void UnhandledOops::dump_oops(UnhandledOops *list) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 for (int k = 0; k < list->_oop_list->length(); k++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 UnhandledOopEntry entry = list->_oop_list->at(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 tty->print(" " INTPTR_FORMAT, entry._oop_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // For debugging unhandled oop detector _in the debugger_
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // You don't want to turn it on in compiled code here.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 static bool unhandled_oop_print=0;
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void UnhandledOops::register_unhandled_oop(oop* op, address pc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 if (!_thread->is_in_stack((address)op))
a61af66fc99e Initial load
duke
parents:
diff changeset
66 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _level ++;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (unhandled_oop_print) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 for (int i=0; i<_level; i++) tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 tty->print_cr("r " INTPTR_FORMAT, op);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 UnhandledOopEntry entry(op, pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _oop_list->push(entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 bool match_oop_entry(void *op, UnhandledOopEntry e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return (e.oop_ptr() == op);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Mark unhandled oop as okay for GC - the containing struct has an oops_do and
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // for some reason the oop has to be on the stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // May not be called for the current thread, as in the case of
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // VM_GetOrSetLocal in jvmti.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void UnhandledOops::allow_unhandled_oop(oop* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 assert (CheckUnhandledOops, "should only be called with checking option");
a61af66fc99e Initial load
duke
parents:
diff changeset
88
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
89 int i = _oop_list->find_from_end(op, match_oop_entry);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 assert(i!=-1, "safe for gc oop not in unhandled_oop_list");
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 UnhandledOopEntry entry = _oop_list->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(!entry._ok_for_gc, "duplicate entry");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 entry._ok_for_gc = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _oop_list->at_put(i, entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Called by the oop destructor to remove unhandled oop from the thread's
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // oop list. All oops given are assumed to be on the list. If not,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // there's a bug in the unhandled oop detector.
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void UnhandledOops::unregister_unhandled_oop(oop* op) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (!_thread->is_in_stack((address)op)) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _level --;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 if (unhandled_oop_print) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 for (int i=0; i<_level; i++) tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 tty->print_cr("u "INTPTR_FORMAT, op);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
111 int i = _oop_list->find_from_end(op, match_oop_entry);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 assert(i!=-1, "oop not in unhandled_oop_list");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 _oop_list->remove_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void UnhandledOops::clear_unhandled_oops() {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 assert (CheckUnhandledOops, "should only be called with checking option");
17876
9c3dc501b5eb 8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents: 6725
diff changeset
118
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 for (int k = 0; k < _oop_list->length(); k++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 UnhandledOopEntry entry = _oop_list->at(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // If an entry is on the unhandled oop list but isn't on the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // anymore, it must not have gotten unregistered properly and it's a bug
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // in the unhandled oop generator.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if(!_thread->is_in_stack((address)entry._oop_ptr)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 tty->print_cr("oop_ptr is " INTPTR_FORMAT, (address)entry._oop_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 tty->print_cr("thread is " INTPTR_FORMAT " from pc " INTPTR_FORMAT,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 (address)_thread, (address)entry._pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(false, "heap is corrupted by the unhandled oop detector");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Set unhandled oops to a pattern that will crash distinctively
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (!entry._ok_for_gc) *(intptr_t*)(entry._oop_ptr) = BAD_OOP_ADDR;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 #endif // CHECK_UNHANDLED_OOPS