author | mgerdin |
Tue, 01 Dec 2015 10:35:49 +0100 | |
changeset 35899 | 0dbc821628fc |
parent 33611 | 9abd65805e19 |
child 37129 | af29e306e50b |
permissions | -rw-r--r-- |
1 | 1 |
/* |
29792
8c6fa07f0869
8075957: Reduce calls to the GC specific object visitors in oopDesc
stefank
parents:
29688
diff
changeset
|
2 |
* Copyright (c) 1997, 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:
4573
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4573
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:
4573
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "classfile/systemDictionary.hpp" |
|
30764 | 28 |
#include "gc/shared/collectedHeap.inline.hpp" |
29 |
#include "gc/shared/genCollectedHeap.hpp" |
|
30 |
#include "gc/shared/specialized_oop_closures.hpp" |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
29792
diff
changeset
|
31 |
#include "oops/instanceRefKlass.inline.hpp" |
7397 | 32 |
#include "oops/oop.inline.hpp" |
30764 | 33 |
#include "utilities/macros.hpp" |
7397 | 34 |
#include "utilities/preserveException.hpp" |
1 | 35 |
|
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
36 |
void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) { |
1 | 37 |
// Clear the nonstatic oop-map entries corresponding to referent |
38 |
// and nextPending field. They are treated specially by the |
|
39 |
// garbage collector. |
|
40 |
// The discovered field is used only by the garbage collector |
|
41 |
// and is also treated specially. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12780
diff
changeset
|
42 |
InstanceKlass* ik = InstanceKlass::cast(k); |
1 | 43 |
|
44 |
// Check that we have the right class |
|
45 |
debug_only(static bool first_time = true); |
|
4571 | 46 |
assert(k == SystemDictionary::Reference_klass() && first_time, |
1 | 47 |
"Invalid update of maps"); |
48 |
debug_only(first_time = false); |
|
3693 | 49 |
assert(ik->nonstatic_oop_map_count() == 1, "just checking"); |
1 | 50 |
|
51 |
OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); |
|
52 |
||
53 |
// Check that the current map is (2,4) - currently points at field with |
|
54 |
// offset 2 (words) and has 4 map entries. |
|
55 |
debug_only(int offset = java_lang_ref_Reference::referent_offset); |
|
3694
942b7bc7f28c
6845368: large objects cause a crash or unexpected exception
jcoomes
parents:
3693
diff
changeset
|
56 |
debug_only(unsigned int count = ((java_lang_ref_Reference::discovered_offset - |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
57 |
java_lang_ref_Reference::referent_offset)/heapOopSize) + 1); |
1 | 58 |
|
59 |
if (UseSharedSpaces) { |
|
60 |
assert(map->offset() == java_lang_ref_Reference::queue_offset && |
|
3693 | 61 |
map->count() == 1, "just checking"); |
1 | 62 |
} else { |
3693 | 63 |
assert(map->offset() == offset && map->count() == count, |
1 | 64 |
"just checking"); |
65 |
||
66 |
// Update map to (3,1) - point to offset of 3 (words) with 1 map entry. |
|
67 |
map->set_offset(java_lang_ref_Reference::queue_offset); |
|
3693 | 68 |
map->set_count(1); |
1 | 69 |
} |
70 |
} |
|
71 |
||
72 |
||
73 |
// Verification |
|
74 |
||
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
75 |
void InstanceRefKlass::oop_verify_on(oop obj, outputStream* st) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12780
diff
changeset
|
76 |
InstanceKlass::oop_verify_on(obj, st); |
1 | 77 |
// Verify referent field |
78 |
oop referent = java_lang_ref_Reference::referent(obj); |
|
79 |
if (referent != NULL) { |
|
80 |
guarantee(referent->is_oop(), "referent field heap failed"); |
|
81 |
} |
|
82 |
// Verify next field |
|
83 |
oop next = java_lang_ref_Reference::next(obj); |
|
84 |
if (next != NULL) { |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33148
diff
changeset
|
85 |
guarantee(next->is_oop(), "next field should be an oop"); |
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33148
diff
changeset
|
86 |
guarantee(next->is_instance(), "next field should be an instance"); |
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33148
diff
changeset
|
87 |
guarantee(InstanceKlass::cast(next->klass())->is_reference_instance_klass(), "next field verify failed"); |
1 | 88 |
} |
89 |
} |
|
90 |
||
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
91 |
bool InstanceRefKlass::owns_pending_list_lock(JavaThread* thread) { |
7450
e44c68293be8
7006471: fix for 6988439 crashes when pending list lock is null
coleenp
parents:
7446
diff
changeset
|
92 |
if (java_lang_ref_Reference::pending_list_lock() == NULL) return false; |
7446
9193aa209467
6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents:
7397
diff
changeset
|
93 |
Handle h_lock(thread, java_lang_ref_Reference::pending_list_lock()); |
9193aa209467
6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents:
7397
diff
changeset
|
94 |
return ObjectSynchronizer::current_thread_holds_lock(thread, h_lock); |
9193aa209467
6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents:
7397
diff
changeset
|
95 |
} |
9193aa209467
6988439: Parallel Class Loading test deadlock involving MethodData_lock and Pending List Lock
coleenp
parents:
7397
diff
changeset
|
96 |
|
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
97 |
void InstanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) { |
1 | 98 |
// we may enter this with pending exception set |
99 |
PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument |
|
12780
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
100 |
|
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
101 |
// Create a HandleMark in case we retry a GC multiple times. |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
102 |
// Each time we attempt the GC, we allocate the handle below |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
103 |
// to hold the pending list lock. We want to free this handle. |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
104 |
HandleMark hm; |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
105 |
|
1 | 106 |
Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock()); |
107 |
ObjectSynchronizer::fast_enter(h_lock, pending_list_basic_lock, false, THREAD); |
|
108 |
assert(ObjectSynchronizer::current_thread_holds_lock( |
|
109 |
JavaThread::current(), h_lock), |
|
110 |
"Locking should have succeeded"); |
|
111 |
if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION; |
|
112 |
} |
|
113 |
||
13738
d67be49a5beb
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
13728
diff
changeset
|
114 |
void InstanceRefKlass::release_and_notify_pending_list_lock( |
1 | 115 |
BasicLock *pending_list_basic_lock) { |
116 |
// we may enter this with pending exception set |
|
117 |
PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument |
|
12780
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
118 |
|
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
119 |
// Create a HandleMark in case we retry a GC multiple times. |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
120 |
// Each time we attempt the GC, we allocate the handle below |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
121 |
// to hold the pending list lock. We want to free this handle. |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
122 |
HandleMark hm; |
689210d5dd05
7158682: G1: Handle leak when running nsk.sysdict tests
johnc
parents:
12379
diff
changeset
|
123 |
|
1 | 124 |
Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock()); |
125 |
assert(ObjectSynchronizer::current_thread_holds_lock( |
|
126 |
JavaThread::current(), h_lock), |
|
127 |
"Lock should be held"); |
|
128 |
// Notify waiters on pending lists lock if there is any reference. |
|
129 |
if (java_lang_ref_Reference::pending_list() != NULL) { |
|
130 |
ObjectSynchronizer::notifyall(h_lock, THREAD); |
|
131 |
} |
|
132 |
ObjectSynchronizer::fast_exit(h_lock(), pending_list_basic_lock, THREAD); |
|
133 |
if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION; |
|
134 |
} |