Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/unhandledOops.hpp @ 1640:bfc89697cccb
6964164: MonitorInUseLists leak of contended objects
Summary: fix MonitorInUseLists memory leak and MonitorBound now works
Reviewed-by: chrisphi, dice
author | acorn |
---|---|
date | Fri, 02 Jul 2010 17:23:43 -0400 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
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 | 22 * |
23 */ | |
24 #ifdef CHECK_UNHANDLED_OOPS | |
25 | |
26 // Detect unhanded oops in VM code | |
27 | |
28 // The design is that when an oop is declared on the stack as a local | |
29 // variable, the oop is actually a C++ struct with constructor and | |
30 // destructor. The constructor adds the oop address on a list | |
31 // off each thread and the destructor removes the oop. At a potential | |
32 // safepoint, the stack addresses of the local variable oops are trashed | |
33 // with a recognizeable value. If the local variable is used again, it | |
34 // will segfault, indicating an unsafe use of that oop. | |
35 // eg: | |
36 // oop o; //register &o on list | |
37 // funct(); // if potential safepoint - causes clear_naked_oops() | |
38 // // which trashes o above. | |
39 // o->do_something(); // Crashes because o is unsafe. | |
40 // | |
41 // This code implements the details of the unhandled oop list on the thread. | |
42 // | |
43 | |
44 class oop; | |
45 class Thread; | |
46 | |
47 class UnhandledOopEntry { | |
48 friend class UnhandledOops; | |
49 private: | |
50 oop* _oop_ptr; | |
51 bool _ok_for_gc; | |
52 address _pc; | |
53 public: | |
54 oop* oop_ptr() { return _oop_ptr; } | |
55 UnhandledOopEntry() : _oop_ptr(NULL), _ok_for_gc(false), _pc(NULL) {} | |
56 UnhandledOopEntry(oop* op, address pc) : | |
57 _oop_ptr(op), _ok_for_gc(false), _pc(pc) {} | |
58 }; | |
59 | |
60 | |
61 class UnhandledOops { | |
62 friend class Thread; | |
63 private: | |
64 Thread* _thread; | |
65 int _level; | |
66 GrowableArray<UnhandledOopEntry> *_oop_list; | |
67 void allow_unhandled_oop(oop* op); | |
68 void clear_unhandled_oops(); | |
69 UnhandledOops(Thread* thread); | |
70 ~UnhandledOops(); | |
71 | |
72 public: | |
73 static void dump_oops(UnhandledOops* list); | |
74 void register_unhandled_oop(oop* op, address pc); | |
75 void unregister_unhandled_oop(oop* op); | |
76 }; | |
77 | |
78 #ifdef _LP64 | |
79 const intptr_t BAD_OOP_ADDR = 0xfffffffffffffff1; | |
80 #else | |
81 const intptr_t BAD_OOP_ADDR = 0xfffffff1; | |
82 #endif // _LP64 | |
83 #endif // CHECK_UNHANDLED_OOPS |