annotate src/share/vm/oops/instanceRefKlass.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_instanceRefKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 void instanceRefKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
30 oop referent = *referent_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
32 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
34 }
a61af66fc99e Initial load
duke
parents:
diff changeset
35 )
a61af66fc99e Initial load
duke
parents:
diff changeset
36 if (referent != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 if (!referent->is_gc_marked() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
38 MarkSweep::ref_processor()->
a61af66fc99e Initial load
duke
parents:
diff changeset
39 discover_reference(obj, reference_type())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // reference already enqueued, referent will be traversed later
a61af66fc99e Initial load
duke
parents:
diff changeset
41 instanceKlass::oop_follow_contents(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46 )
a61af66fc99e Initial load
duke
parents:
diff changeset
47 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // treat referent as normal oop
a61af66fc99e Initial load
duke
parents:
diff changeset
50 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 )
a61af66fc99e Initial load
duke
parents:
diff changeset
55 MarkSweep::mark_and_push(referent_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // treat next as normal oop. next is a link in the pending list.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 oop* next_addr = java_lang_ref_Reference::next_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 gclog_or_tty->print_cr(" Process next as normal " INTPTR_FORMAT, next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 )
a61af66fc99e Initial load
duke
parents:
diff changeset
65 MarkSweep::mark_and_push(next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 instanceKlass::oop_follow_contents(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
70 void instanceRefKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
71 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 oop referent = *referent_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
75 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 )
a61af66fc99e Initial load
duke
parents:
diff changeset
79 if (referent != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
81 PSParallelCompact::ref_processor()->
a61af66fc99e Initial load
duke
parents:
diff changeset
82 discover_reference(obj, reference_type())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // reference already enqueued, referent will be traversed later
a61af66fc99e Initial load
duke
parents:
diff changeset
84 instanceKlass::oop_follow_contents(cm, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 )
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // treat referent as normal oop
a61af66fc99e Initial load
duke
parents:
diff changeset
93 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 )
a61af66fc99e Initial load
duke
parents:
diff changeset
98 PSParallelCompact::mark_and_push(cm, referent_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // treat next as normal oop. next is a link in the pending list.
a61af66fc99e Initial load
duke
parents:
diff changeset
102 oop* next_addr = java_lang_ref_Reference::next_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 debug_only(
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 gclog_or_tty->print_cr(" Process next as normal " INTPTR_FORMAT, next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 )
a61af66fc99e Initial load
duke
parents:
diff changeset
108 PSParallelCompact::mark_and_push(cm, next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 instanceKlass::oop_follow_contents(cm, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 int instanceRefKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 int size = size_helper();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 instanceKlass::oop_adjust_pointers(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 MarkSweep::adjust_pointer(referent_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 oop* next_addr = java_lang_ref_Reference::next_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 MarkSweep::adjust_pointer(next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 oop* discovered_addr = java_lang_ref_Reference::discovered_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 MarkSweep::adjust_pointer(discovered_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 gclog_or_tty->print_cr("instanceRefKlass::oop_adjust_pointers obj "
a61af66fc99e Initial load
duke
parents:
diff changeset
128 INTPTR_FORMAT, (address)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 gclog_or_tty->print_cr(" referent_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
130 INTPTR_FORMAT, referent_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
131 referent_addr ? (address)*referent_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 gclog_or_tty->print_cr(" next_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
133 INTPTR_FORMAT, next_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
134 next_addr ? (address)*next_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 gclog_or_tty->print_cr(" discovered_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
136 INTPTR_FORMAT, discovered_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
137 discovered_addr ? (address)*discovered_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
a61af66fc99e Initial load
duke
parents:
diff changeset
145 \
a61af66fc99e Initial load
duke
parents:
diff changeset
146 int instanceRefKlass:: \
a61af66fc99e Initial load
duke
parents:
diff changeset
147 oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
148 /* Get size before changing pointers */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
149 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
a61af66fc99e Initial load
duke
parents:
diff changeset
150 \
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int size = instanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \
a61af66fc99e Initial load
duke
parents:
diff changeset
152 \
a61af66fc99e Initial load
duke
parents:
diff changeset
153 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
154 oop referent = *referent_addr; \
a61af66fc99e Initial load
duke
parents:
diff changeset
155 if (referent != NULL) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
156 ReferenceProcessor* rp = closure->_ref_processor; \
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (!referent->is_gc_marked() && (rp != NULL) && \
a61af66fc99e Initial load
duke
parents:
diff changeset
158 rp->discover_reference(obj, reference_type())) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
160 } else { \
a61af66fc99e Initial load
duke
parents:
diff changeset
161 /* treat referent as normal oop */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
162 SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
a61af66fc99e Initial load
duke
parents:
diff changeset
163 closure->do_oop##nv_suffix(referent_addr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
164 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
165 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
166 \
a61af66fc99e Initial load
duke
parents:
diff changeset
167 /* treat next as normal oop */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
168 oop* next_addr = java_lang_ref_Reference::next_addr(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
169 SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
a61af66fc99e Initial load
duke
parents:
diff changeset
170 closure->do_oop##nv_suffix(next_addr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
171 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \
a61af66fc99e Initial load
duke
parents:
diff changeset
175 \
a61af66fc99e Initial load
duke
parents:
diff changeset
176 int instanceRefKlass:: \
a61af66fc99e Initial load
duke
parents:
diff changeset
177 oop_oop_iterate##nv_suffix##_m(oop obj, \
a61af66fc99e Initial load
duke
parents:
diff changeset
178 OopClosureType* closure, \
a61af66fc99e Initial load
duke
parents:
diff changeset
179 MemRegion mr) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
180 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
a61af66fc99e Initial load
duke
parents:
diff changeset
181 \
a61af66fc99e Initial load
duke
parents:
diff changeset
182 int size = instanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
183 \
a61af66fc99e Initial load
duke
parents:
diff changeset
184 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
185 oop referent = *referent_addr; \
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (referent != NULL && mr.contains(referent_addr)) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
187 ReferenceProcessor* rp = closure->_ref_processor; \
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (!referent->is_gc_marked() && (rp != NULL) && \
a61af66fc99e Initial load
duke
parents:
diff changeset
189 rp->discover_reference(obj, reference_type())) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
191 } else { \
a61af66fc99e Initial load
duke
parents:
diff changeset
192 /* treat referent as normal oop */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
193 SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
a61af66fc99e Initial load
duke
parents:
diff changeset
194 closure->do_oop##nv_suffix(referent_addr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
195 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
196 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
197 \
a61af66fc99e Initial load
duke
parents:
diff changeset
198 /* treat next as normal oop */ \
a61af66fc99e Initial load
duke
parents:
diff changeset
199 oop* next_addr = java_lang_ref_Reference::next_addr(obj); \
a61af66fc99e Initial load
duke
parents:
diff changeset
200 if (mr.contains(next_addr)) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
201 SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
a61af66fc99e Initial load
duke
parents:
diff changeset
202 closure->do_oop##nv_suffix(next_addr); \
a61af66fc99e Initial load
duke
parents:
diff changeset
203 } \
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return size; \
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN)
a61af66fc99e Initial load
duke
parents:
diff changeset
208 ALL_OOP_OOP_ITERATE_CLOSURES_3(InstanceRefKlass_OOP_OOP_ITERATE_DEFN)
a61af66fc99e Initial load
duke
parents:
diff changeset
209 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m)
a61af66fc99e Initial load
duke
parents:
diff changeset
210 ALL_OOP_OOP_ITERATE_CLOSURES_3(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m)
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
214 void instanceRefKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 assert(!pm->depth_first(), "invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
216 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if (PSScavenge::should_scavenge(*referent_addr)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 ReferenceProcessor* rp = PSScavenge::reference_processor();
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if (rp->discover_reference(obj, reference_type())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // reference already enqueued, referent and next will be traversed later
a61af66fc99e Initial load
duke
parents:
diff changeset
221 instanceKlass::oop_copy_contents(pm, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
223 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // treat referent as normal oop
a61af66fc99e Initial load
duke
parents:
diff changeset
225 pm->claim_or_forward_breadth(referent_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // treat next as normal oop
a61af66fc99e Initial load
duke
parents:
diff changeset
229 oop* next_addr = java_lang_ref_Reference::next_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 if (PSScavenge::should_scavenge(*next_addr)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 pm->claim_or_forward_breadth(next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233 instanceKlass::oop_copy_contents(pm, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void instanceRefKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 assert(pm->depth_first(), "invariant");
a61af66fc99e Initial load
duke
parents:
diff changeset
238 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 if (PSScavenge::should_scavenge(*referent_addr)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 ReferenceProcessor* rp = PSScavenge::reference_processor();
a61af66fc99e Initial load
duke
parents:
diff changeset
241 if (rp->discover_reference(obj, reference_type())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // reference already enqueued, referent and next will be traversed later
a61af66fc99e Initial load
duke
parents:
diff changeset
243 instanceKlass::oop_push_contents(pm, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // treat referent as normal oop
a61af66fc99e Initial load
duke
parents:
diff changeset
247 pm->claim_or_forward_depth(referent_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // treat next as normal oop
a61af66fc99e Initial load
duke
parents:
diff changeset
251 oop* next_addr = java_lang_ref_Reference::next_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if (PSScavenge::should_scavenge(*next_addr)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 pm->claim_or_forward_depth(next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 instanceKlass::oop_push_contents(pm, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 int instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 instanceKlass::oop_update_pointers(cm, obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 oop* referent_addr = java_lang_ref_Reference::referent_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 PSParallelCompact::adjust_pointer(referent_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 oop* next_addr = java_lang_ref_Reference::next_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 PSParallelCompact::adjust_pointer(next_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 oop* discovered_addr = java_lang_ref_Reference::discovered_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 PSParallelCompact::adjust_pointer(discovered_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 gclog_or_tty->print_cr("instanceRefKlass::oop_update_pointers obj "
a61af66fc99e Initial load
duke
parents:
diff changeset
271 INTPTR_FORMAT, (oopDesc*) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 gclog_or_tty->print_cr(" referent_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
273 INTPTR_FORMAT, referent_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
274 referent_addr ? (oopDesc*) *referent_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 gclog_or_tty->print_cr(" next_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
276 INTPTR_FORMAT, next_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
277 next_addr ? (oopDesc*) *next_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 gclog_or_tty->print_cr(" discovered_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
279 INTPTR_FORMAT, discovered_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
280 discovered_addr ? (oopDesc*) *discovered_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 return size_helper();
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 int
a61af66fc99e Initial load
duke
parents:
diff changeset
288 instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
289 HeapWord* beg_addr, HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 instanceKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 oop* p;
a61af66fc99e Initial load
duke
parents:
diff changeset
293 oop* referent_addr = p = java_lang_ref_Reference::referent_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 oop* next_addr = p = java_lang_ref_Reference::next_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
297 oop* discovered_addr = p = java_lang_ref_Reference::discovered_addr(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
301 if(TraceReferenceGC && PrintGCDetails) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 gclog_or_tty->print_cr("instanceRefKlass::oop_update_pointers obj "
a61af66fc99e Initial load
duke
parents:
diff changeset
303 INTPTR_FORMAT, (oopDesc*) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 gclog_or_tty->print_cr(" referent_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
305 INTPTR_FORMAT, referent_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
306 referent_addr ? (oopDesc*) *referent_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
307 gclog_or_tty->print_cr(" next_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
308 INTPTR_FORMAT, next_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
309 next_addr ? (oopDesc*) *next_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 gclog_or_tty->print_cr(" discovered_addr/* " INTPTR_FORMAT " / "
a61af66fc99e Initial load
duke
parents:
diff changeset
311 INTPTR_FORMAT, discovered_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
312 discovered_addr ? (oopDesc*) *discovered_addr : NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return size_helper();
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 void instanceRefKlass::update_nonstatic_oop_maps(klassOop k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // Clear the nonstatic oop-map entries corresponding to referent
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // and nextPending field. They are treated specially by the
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // garbage collector.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // The discovered field is used only by the garbage collector
a61af66fc99e Initial load
duke
parents:
diff changeset
325 // and is also treated specially.
a61af66fc99e Initial load
duke
parents:
diff changeset
326 instanceKlass* ik = instanceKlass::cast(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // Check that we have the right class
a61af66fc99e Initial load
duke
parents:
diff changeset
329 debug_only(static bool first_time = true);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 assert(k == SystemDictionary::reference_klass() && first_time,
a61af66fc99e Initial load
duke
parents:
diff changeset
331 "Invalid update of maps");
a61af66fc99e Initial load
duke
parents:
diff changeset
332 debug_only(first_time = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 assert(ik->nonstatic_oop_map_size() == 1, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // Check that the current map is (2,4) - currently points at field with
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // offset 2 (words) and has 4 map entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
339 debug_only(int offset = java_lang_ref_Reference::referent_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
340 debug_only(int length = ((java_lang_ref_Reference::discovered_offset -
a61af66fc99e Initial load
duke
parents:
diff changeset
341 java_lang_ref_Reference::referent_offset)/wordSize) + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (UseSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 assert(map->offset() == java_lang_ref_Reference::queue_offset &&
a61af66fc99e Initial load
duke
parents:
diff changeset
345 map->length() == 1, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
346 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
347 assert(map->offset() == offset && map->length() == length,
a61af66fc99e Initial load
duke
parents:
diff changeset
348 "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // Update map to (3,1) - point to offset of 3 (words) with 1 map entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
351 map->set_offset(java_lang_ref_Reference::queue_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 map->set_length(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 void instanceRefKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 instanceKlass::oop_verify_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // Verify referent field
a61af66fc99e Initial load
duke
parents:
diff changeset
362 oop referent = java_lang_ref_Reference::referent(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // We should make this general to all heaps
a61af66fc99e Initial load
duke
parents:
diff changeset
365 GenCollectedHeap* gch = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
366 if (Universe::heap()->kind() == CollectedHeap::GenCollectedHeap)
a61af66fc99e Initial load
duke
parents:
diff changeset
367 gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 if (referent != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 guarantee(referent->is_oop(), "referent field heap failed");
a61af66fc99e Initial load
duke
parents:
diff changeset
371 if (gch != NULL && !gch->is_in_youngest(obj))
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // We do a specific remembered set check here since the referent
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // field is not part of the oop mask and therefore skipped by the
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // regular verify code.
a61af66fc99e Initial load
duke
parents:
diff changeset
375 obj->verify_old_oop(java_lang_ref_Reference::referent_addr(obj), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // Verify next field
a61af66fc99e Initial load
duke
parents:
diff changeset
378 oop next = java_lang_ref_Reference::next(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
379 if (next != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
380 guarantee(next->is_oop(), "next field verify failed");
a61af66fc99e Initial load
duke
parents:
diff changeset
381 guarantee(next->is_instanceRef(), "next field verify failed");
a61af66fc99e Initial load
duke
parents:
diff changeset
382 if (gch != NULL && !gch->is_in_youngest(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // We do a specific remembered set check here since the next field is
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // not part of the oop mask and therefore skipped by the regular
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // verify code.
a61af66fc99e Initial load
duke
parents:
diff changeset
386 obj->verify_old_oop(java_lang_ref_Reference::next_addr(obj), true);
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388 }
a61af66fc99e Initial load
duke
parents:
diff changeset
389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 void instanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // we may enter this with pending exception set
a61af66fc99e Initial load
duke
parents:
diff changeset
393 PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument
a61af66fc99e Initial load
duke
parents:
diff changeset
394 Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock());
a61af66fc99e Initial load
duke
parents:
diff changeset
395 ObjectSynchronizer::fast_enter(h_lock, pending_list_basic_lock, false, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
396 assert(ObjectSynchronizer::current_thread_holds_lock(
a61af66fc99e Initial load
duke
parents:
diff changeset
397 JavaThread::current(), h_lock),
a61af66fc99e Initial load
duke
parents:
diff changeset
398 "Locking should have succeeded");
a61af66fc99e Initial load
duke
parents:
diff changeset
399 if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 void instanceRefKlass::release_and_notify_pending_list_lock(
a61af66fc99e Initial load
duke
parents:
diff changeset
403 BasicLock *pending_list_basic_lock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // we may enter this with pending exception set
a61af66fc99e Initial load
duke
parents:
diff changeset
405 PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument
a61af66fc99e Initial load
duke
parents:
diff changeset
406 //
a61af66fc99e Initial load
duke
parents:
diff changeset
407 Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock());
a61af66fc99e Initial load
duke
parents:
diff changeset
408 assert(ObjectSynchronizer::current_thread_holds_lock(
a61af66fc99e Initial load
duke
parents:
diff changeset
409 JavaThread::current(), h_lock),
a61af66fc99e Initial load
duke
parents:
diff changeset
410 "Lock should be held");
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // Notify waiters on pending lists lock if there is any reference.
a61af66fc99e Initial load
duke
parents:
diff changeset
412 if (java_lang_ref_Reference::pending_list() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 ObjectSynchronizer::notifyall(h_lock, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415 ObjectSynchronizer::fast_exit(h_lock(), pending_list_basic_lock, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
416 if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
417 }