Wed, 01 May 2013 08:07:59 -0700
8013418: assert(i == total_args_passed) in AdapterHandlerLibrary::get_adapter since 8-b87
Summary: Do not treat static methods as miranda methods.
Reviewed-by: dholmes, acorn
duke@435 | 1 | /* |
brutisso@3711 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "classfile/javaClasses.hpp" |
stefank@2314 | 27 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 28 | #include "gc_implementation/shared/markSweep.inline.hpp" |
stefank@2314 | 29 | #include "gc_interface/collectedHeap.hpp" |
stefank@2314 | 30 | #include "gc_interface/collectedHeap.inline.hpp" |
stefank@2314 | 31 | #include "memory/genCollectedHeap.hpp" |
stefank@2314 | 32 | #include "memory/genOopClosures.inline.hpp" |
stefank@2314 | 33 | #include "oops/instanceRefKlass.hpp" |
stefank@2314 | 34 | #include "oops/oop.inline.hpp" |
stefank@2314 | 35 | #include "utilities/preserveException.hpp" |
jprovino@4542 | 36 | #include "utilities/macros.hpp" |
jprovino@4542 | 37 | #if INCLUDE_ALL_GCS |
stefank@2314 | 38 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
stefank@2314 | 39 | #include "gc_implementation/g1/g1OopClosures.inline.hpp" |
stefank@2314 | 40 | #include "gc_implementation/g1/g1RemSet.inline.hpp" |
stefank@2314 | 41 | #include "gc_implementation/g1/heapRegionSeq.inline.hpp" |
stefank@2314 | 42 | #include "gc_implementation/parNew/parOopClosures.inline.hpp" |
stefank@2314 | 43 | #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" |
stefank@2314 | 44 | #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" |
stefank@2314 | 45 | #include "oops/oop.pcgc.inline.hpp" |
jprovino@4542 | 46 | #endif // INCLUDE_ALL_GCS |
duke@435 | 47 | |
coleenp@548 | 48 | template <class T> |
coleenp@4047 | 49 | void specialized_oop_follow_contents(InstanceRefKlass* ref, oop obj) { |
coleenp@548 | 50 | T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); |
ysr@1280 | 51 | T heap_oop = oopDesc::load_heap_oop(referent_addr); |
duke@435 | 52 | debug_only( |
duke@435 | 53 | if(TraceReferenceGC && PrintGCDetails) { |
coleenp@4047 | 54 | gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj); |
duke@435 | 55 | } |
duke@435 | 56 | ) |
ysr@1280 | 57 | if (!oopDesc::is_null(heap_oop)) { |
ysr@1280 | 58 | oop referent = oopDesc::decode_heap_oop_not_null(heap_oop); |
duke@435 | 59 | if (!referent->is_gc_marked() && |
ysr@3117 | 60 | MarkSweep::ref_processor()->discover_reference(obj, ref->reference_type())) { |
ysr@3117 | 61 | // reference was discovered, referent will be traversed later |
coleenp@4037 | 62 | ref->InstanceKlass::oop_follow_contents(obj); |
duke@435 | 63 | debug_only( |
duke@435 | 64 | if(TraceReferenceGC && PrintGCDetails) { |
coleenp@548 | 65 | gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, obj); |
duke@435 | 66 | } |
duke@435 | 67 | ) |
duke@435 | 68 | return; |
duke@435 | 69 | } else { |
duke@435 | 70 | // treat referent as normal oop |
duke@435 | 71 | debug_only( |
duke@435 | 72 | if(TraceReferenceGC && PrintGCDetails) { |
coleenp@548 | 73 | gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, obj); |
duke@435 | 74 | } |
duke@435 | 75 | ) |
duke@435 | 76 | MarkSweep::mark_and_push(referent_addr); |
duke@435 | 77 | } |
duke@435 | 78 | } |
coleenp@548 | 79 | T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj); |
ysr@3117 | 80 | if (ReferenceProcessor::pending_list_uses_discovered_field()) { |
ysr@3117 | 81 | // Treat discovered as normal oop, if ref is not "active", |
ysr@3117 | 82 | // i.e. if next is non-NULL. |
ysr@3117 | 83 | T next_oop = oopDesc::load_heap_oop(next_addr); |
ysr@3117 | 84 | if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active" |
ysr@3117 | 85 | T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj); |
ysr@3117 | 86 | debug_only( |
ysr@3117 | 87 | if(TraceReferenceGC && PrintGCDetails) { |
ysr@3117 | 88 | gclog_or_tty->print_cr(" Process discovered as normal " |
ysr@3117 | 89 | INTPTR_FORMAT, discovered_addr); |
ysr@3117 | 90 | } |
ysr@3117 | 91 | ) |
ysr@3117 | 92 | MarkSweep::mark_and_push(discovered_addr); |
ysr@3117 | 93 | } |
ysr@3117 | 94 | } else { |
ysr@3117 | 95 | #ifdef ASSERT |
ysr@3117 | 96 | // In the case of older JDKs which do not use the discovered |
ysr@3117 | 97 | // field for the pending list, an inactive ref (next != NULL) |
ysr@3117 | 98 | // must always have a NULL discovered field. |
ysr@3117 | 99 | oop next = oopDesc::load_decode_heap_oop(next_addr); |
ysr@3117 | 100 | oop discovered = java_lang_ref_Reference::discovered(obj); |
ysr@3117 | 101 | assert(oopDesc::is_null(next) || oopDesc::is_null(discovered), |
ysr@3117 | 102 | err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field", |
kvn@3128 | 103 | (oopDesc*)obj)); |
ysr@3117 | 104 | #endif |
ysr@3117 | 105 | } |
ysr@3117 | 106 | // treat next as normal oop. next is a link in the reference queue. |
duke@435 | 107 | debug_only( |
duke@435 | 108 | if(TraceReferenceGC && PrintGCDetails) { |
duke@435 | 109 | gclog_or_tty->print_cr(" Process next as normal " INTPTR_FORMAT, next_addr); |
duke@435 | 110 | } |
duke@435 | 111 | ) |
duke@435 | 112 | MarkSweep::mark_and_push(next_addr); |
coleenp@4037 | 113 | ref->InstanceKlass::oop_follow_contents(obj); |
coleenp@548 | 114 | } |
coleenp@548 | 115 | |
coleenp@4047 | 116 | void InstanceRefKlass::oop_follow_contents(oop obj) { |
coleenp@548 | 117 | if (UseCompressedOops) { |
coleenp@548 | 118 | specialized_oop_follow_contents<narrowOop>(this, obj); |
coleenp@548 | 119 | } else { |
coleenp@548 | 120 | specialized_oop_follow_contents<oop>(this, obj); |
coleenp@548 | 121 | } |
duke@435 | 122 | } |
duke@435 | 123 | |
jprovino@4542 | 124 | #if INCLUDE_ALL_GCS |
coleenp@548 | 125 | template <class T> |
coleenp@4047 | 126 | void specialized_oop_follow_contents(InstanceRefKlass* ref, |
phh@1558 | 127 | ParCompactionManager* cm, |
phh@1558 | 128 | oop obj) { |
coleenp@548 | 129 | T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); |
ysr@1280 | 130 | T heap_oop = oopDesc::load_heap_oop(referent_addr); |
duke@435 | 131 | debug_only( |
duke@435 | 132 | if(TraceReferenceGC && PrintGCDetails) { |
coleenp@4047 | 133 | gclog_or_tty->print_cr("InstanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj); |
duke@435 | 134 | } |
duke@435 | 135 | ) |
ysr@1280 | 136 | if (!oopDesc::is_null(heap_oop)) { |
ysr@1280 | 137 | oop referent = oopDesc::decode_heap_oop_not_null(heap_oop); |
duke@435 | 138 | if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) && |
duke@435 | 139 | PSParallelCompact::ref_processor()-> |
coleenp@548 | 140 | discover_reference(obj, ref->reference_type())) { |
duke@435 | 141 | // reference already enqueued, referent will be traversed later |
coleenp@4037 | 142 | ref->InstanceKlass::oop_follow_contents(cm, obj); |
duke@435 | 143 | debug_only( |
duke@435 | 144 | if(TraceReferenceGC && PrintGCDetails) { |
coleenp@548 | 145 | gclog_or_tty->print_cr(" Non NULL enqueued " INTPTR_FORMAT, obj); |
duke@435 | 146 | } |
duke@435 | 147 | ) |
duke@435 | 148 | return; |
duke@435 | 149 | } else { |
duke@435 | 150 | // treat referent as normal oop |
duke@435 | 151 | debug_only( |
duke@435 | 152 | if(TraceReferenceGC && PrintGCDetails) { |
coleenp@548 | 153 | gclog_or_tty->print_cr(" Non NULL normal " INTPTR_FORMAT, obj); |
duke@435 | 154 | } |
duke@435 | 155 | ) |
duke@435 | 156 | PSParallelCompact::mark_and_push(cm, referent_addr); |
duke@435 | 157 | } |
duke@435 | 158 | } |
coleenp@548 | 159 | T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj); |
ysr@3117 | 160 | if (ReferenceProcessor::pending_list_uses_discovered_field()) { |
ysr@3117 | 161 | // Treat discovered as normal oop, if ref is not "active", |
ysr@3117 | 162 | // i.e. if next is non-NULL. |
ysr@3117 | 163 | T next_oop = oopDesc::load_heap_oop(next_addr); |
ysr@3117 | 164 | if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active" |
ysr@3117 | 165 | T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj); |
ysr@3117 | 166 | debug_only( |
ysr@3117 | 167 | if(TraceReferenceGC && PrintGCDetails) { |
ysr@3117 | 168 | gclog_or_tty->print_cr(" Process discovered as normal " |
ysr@3117 | 169 | INTPTR_FORMAT, discovered_addr); |
ysr@3117 | 170 | } |
ysr@3117 | 171 | ) |
ysr@3117 | 172 | PSParallelCompact::mark_and_push(cm, discovered_addr); |
duke@435 | 173 | } |
ysr@3117 | 174 | } else { |
ysr@3117 | 175 | #ifdef ASSERT |
ysr@3117 | 176 | // In the case of older JDKs which do not use the discovered |
ysr@3117 | 177 | // field for the pending list, an inactive ref (next != NULL) |
ysr@3117 | 178 | // must always have a NULL discovered field. |
ysr@3117 | 179 | T next = oopDesc::load_heap_oop(next_addr); |
ysr@3117 | 180 | oop discovered = java_lang_ref_Reference::discovered(obj); |
ysr@3117 | 181 | assert(oopDesc::is_null(next) || oopDesc::is_null(discovered), |
ysr@3117 | 182 | err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field", |
kvn@3128 | 183 | (oopDesc*)obj)); |
ysr@3117 | 184 | #endif |
ysr@3117 | 185 | } |
duke@435 | 186 | PSParallelCompact::mark_and_push(cm, next_addr); |
coleenp@4037 | 187 | ref->InstanceKlass::oop_follow_contents(cm, obj); |
coleenp@548 | 188 | } |
coleenp@548 | 189 | |
coleenp@4047 | 190 | void InstanceRefKlass::oop_follow_contents(ParCompactionManager* cm, |
coleenp@548 | 191 | oop obj) { |
coleenp@548 | 192 | if (UseCompressedOops) { |
coleenp@548 | 193 | specialized_oop_follow_contents<narrowOop>(this, cm, obj); |
coleenp@548 | 194 | } else { |
coleenp@548 | 195 | specialized_oop_follow_contents<oop>(this, cm, obj); |
coleenp@548 | 196 | } |
duke@435 | 197 | } |
jprovino@4542 | 198 | #endif // INCLUDE_ALL_GCS |
duke@435 | 199 | |
coleenp@548 | 200 | #ifdef ASSERT |
coleenp@548 | 201 | template <class T> void trace_reference_gc(const char *s, oop obj, |
coleenp@548 | 202 | T* referent_addr, |
coleenp@548 | 203 | T* next_addr, |
coleenp@548 | 204 | T* discovered_addr) { |
coleenp@548 | 205 | if(TraceReferenceGC && PrintGCDetails) { |
coleenp@548 | 206 | gclog_or_tty->print_cr("%s obj " INTPTR_FORMAT, s, (address)obj); |
coleenp@548 | 207 | gclog_or_tty->print_cr(" referent_addr/* " INTPTR_FORMAT " / " |
coleenp@548 | 208 | INTPTR_FORMAT, referent_addr, |
coleenp@548 | 209 | referent_addr ? |
coleenp@548 | 210 | (address)oopDesc::load_decode_heap_oop(referent_addr) : NULL); |
coleenp@548 | 211 | gclog_or_tty->print_cr(" next_addr/* " INTPTR_FORMAT " / " |
coleenp@548 | 212 | INTPTR_FORMAT, next_addr, |
coleenp@548 | 213 | next_addr ? (address)oopDesc::load_decode_heap_oop(next_addr) : NULL); |
coleenp@548 | 214 | gclog_or_tty->print_cr(" discovered_addr/* " INTPTR_FORMAT " / " |
coleenp@548 | 215 | INTPTR_FORMAT, discovered_addr, |
coleenp@548 | 216 | discovered_addr ? |
coleenp@548 | 217 | (address)oopDesc::load_decode_heap_oop(discovered_addr) : NULL); |
coleenp@548 | 218 | } |
coleenp@548 | 219 | } |
coleenp@548 | 220 | #endif |
coleenp@548 | 221 | |
coleenp@4047 | 222 | template <class T> void specialized_oop_adjust_pointers(InstanceRefKlass *ref, oop obj) { |
coleenp@548 | 223 | T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); |
coleenp@548 | 224 | MarkSweep::adjust_pointer(referent_addr); |
coleenp@548 | 225 | T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj); |
coleenp@548 | 226 | MarkSweep::adjust_pointer(next_addr); |
coleenp@548 | 227 | T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj); |
coleenp@548 | 228 | MarkSweep::adjust_pointer(discovered_addr); |
coleenp@4047 | 229 | debug_only(trace_reference_gc("InstanceRefKlass::oop_adjust_pointers", obj, |
coleenp@548 | 230 | referent_addr, next_addr, discovered_addr);) |
coleenp@548 | 231 | } |
duke@435 | 232 | |
coleenp@4047 | 233 | int InstanceRefKlass::oop_adjust_pointers(oop obj) { |
duke@435 | 234 | int size = size_helper(); |
coleenp@4037 | 235 | InstanceKlass::oop_adjust_pointers(obj); |
duke@435 | 236 | |
coleenp@548 | 237 | if (UseCompressedOops) { |
coleenp@548 | 238 | specialized_oop_adjust_pointers<narrowOop>(this, obj); |
coleenp@548 | 239 | } else { |
coleenp@548 | 240 | specialized_oop_adjust_pointers<oop>(this, obj); |
duke@435 | 241 | } |
duke@435 | 242 | return size; |
duke@435 | 243 | } |
duke@435 | 244 | |
coleenp@548 | 245 | #define InstanceRefKlass_SPECIALIZED_OOP_ITERATE(T, nv_suffix, contains) \ |
ysr@3117 | 246 | T* disc_addr = (T*)java_lang_ref_Reference::discovered_addr(obj); \ |
ysr@777 | 247 | if (closure->apply_to_weak_ref_discovered_field()) { \ |
ysr@777 | 248 | closure->do_oop##nv_suffix(disc_addr); \ |
ysr@777 | 249 | } \ |
ysr@777 | 250 | \ |
coleenp@548 | 251 | T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); \ |
ysr@1280 | 252 | T heap_oop = oopDesc::load_heap_oop(referent_addr); \ |
ysr@3117 | 253 | ReferenceProcessor* rp = closure->_ref_processor; \ |
ysr@3117 | 254 | if (!oopDesc::is_null(heap_oop)) { \ |
ysr@1280 | 255 | oop referent = oopDesc::decode_heap_oop_not_null(heap_oop); \ |
coleenp@548 | 256 | if (!referent->is_gc_marked() && (rp != NULL) && \ |
coleenp@548 | 257 | rp->discover_reference(obj, reference_type())) { \ |
coleenp@548 | 258 | return size; \ |
ysr@3117 | 259 | } else if (contains(referent_addr)) { \ |
coleenp@548 | 260 | /* treat referent as normal oop */ \ |
coleenp@548 | 261 | SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\ |
coleenp@548 | 262 | closure->do_oop##nv_suffix(referent_addr); \ |
coleenp@548 | 263 | } \ |
coleenp@548 | 264 | } \ |
ysr@3117 | 265 | T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj); \ |
ysr@3117 | 266 | if (ReferenceProcessor::pending_list_uses_discovered_field()) { \ |
ysr@3117 | 267 | T next_oop = oopDesc::load_heap_oop(next_addr); \ |
ysr@3117 | 268 | /* Treat discovered as normal oop, if ref is not "active" (next non-NULL) */\ |
ysr@3117 | 269 | if (!oopDesc::is_null(next_oop) && contains(disc_addr)) { \ |
ysr@3117 | 270 | /* i.e. ref is not "active" */ \ |
ysr@3117 | 271 | debug_only( \ |
ysr@3117 | 272 | if(TraceReferenceGC && PrintGCDetails) { \ |
ysr@3117 | 273 | gclog_or_tty->print_cr(" Process discovered as normal " \ |
ysr@3117 | 274 | INTPTR_FORMAT, disc_addr); \ |
ysr@3117 | 275 | } \ |
ysr@3117 | 276 | ) \ |
ysr@3117 | 277 | SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\ |
ysr@3117 | 278 | closure->do_oop##nv_suffix(disc_addr); \ |
ysr@3117 | 279 | } \ |
ysr@3117 | 280 | } else { \ |
ysr@3117 | 281 | /* In the case of older JDKs which do not use the discovered field for */ \ |
ysr@3117 | 282 | /* the pending list, an inactive ref (next != NULL) must always have a */ \ |
ysr@3117 | 283 | /* NULL discovered field. */ \ |
ysr@3117 | 284 | debug_only( \ |
ysr@3117 | 285 | T next_oop = oopDesc::load_heap_oop(next_addr); \ |
ysr@3117 | 286 | T disc_oop = oopDesc::load_heap_oop(disc_addr); \ |
ysr@3117 | 287 | assert(oopDesc::is_null(next_oop) || oopDesc::is_null(disc_oop), \ |
ysr@3117 | 288 | err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL" \ |
kvn@3128 | 289 | "discovered field", (oopDesc*)obj)); \ |
ysr@3117 | 290 | ) \ |
ysr@3117 | 291 | } \ |
coleenp@548 | 292 | /* treat next as normal oop */ \ |
coleenp@548 | 293 | if (contains(next_addr)) { \ |
coleenp@548 | 294 | SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \ |
coleenp@548 | 295 | closure->do_oop##nv_suffix(next_addr); \ |
coleenp@548 | 296 | } \ |
coleenp@548 | 297 | return size; \ |
coleenp@548 | 298 | |
coleenp@548 | 299 | |
coleenp@548 | 300 | template <class T> bool contains(T *t) { return true; } |
coleenp@548 | 301 | |
coleenp@4047 | 302 | // Macro to define InstanceRefKlass::oop_oop_iterate for virtual/nonvirtual for |
coleenp@548 | 303 | // all closures. Macros calling macros above for each oop size. |
coleenp@548 | 304 | |
duke@435 | 305 | #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
duke@435 | 306 | \ |
coleenp@4047 | 307 | int InstanceRefKlass:: \ |
duke@435 | 308 | oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ |
duke@435 | 309 | /* Get size before changing pointers */ \ |
duke@435 | 310 | SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ |
duke@435 | 311 | \ |
coleenp@4037 | 312 | int size = InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \ |
duke@435 | 313 | \ |
coleenp@548 | 314 | if (UseCompressedOops) { \ |
coleenp@548 | 315 | InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, contains); \ |
coleenp@548 | 316 | } else { \ |
coleenp@548 | 317 | InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, contains); \ |
duke@435 | 318 | } \ |
duke@435 | 319 | } |
duke@435 | 320 | |
jprovino@4542 | 321 | #if INCLUDE_ALL_GCS |
ysr@777 | 322 | #define InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ |
ysr@777 | 323 | \ |
coleenp@4047 | 324 | int InstanceRefKlass:: \ |
ysr@777 | 325 | oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ |
ysr@777 | 326 | /* Get size before changing pointers */ \ |
ysr@777 | 327 | SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ |
ysr@777 | 328 | \ |
coleenp@4037 | 329 | int size = InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \ |
ysr@777 | 330 | \ |
ysr@777 | 331 | if (UseCompressedOops) { \ |
ysr@777 | 332 | InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, contains); \ |
ysr@777 | 333 | } else { \ |
ysr@777 | 334 | InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, contains); \ |
ysr@777 | 335 | } \ |
ysr@777 | 336 | } |
jprovino@4542 | 337 | #endif // INCLUDE_ALL_GCS |
ysr@777 | 338 | |
ysr@777 | 339 | |
duke@435 | 340 | #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ |
duke@435 | 341 | \ |
coleenp@4047 | 342 | int InstanceRefKlass:: \ |
duke@435 | 343 | oop_oop_iterate##nv_suffix##_m(oop obj, \ |
duke@435 | 344 | OopClosureType* closure, \ |
duke@435 | 345 | MemRegion mr) { \ |
duke@435 | 346 | SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ |
duke@435 | 347 | \ |
coleenp@4037 | 348 | int size = InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \ |
coleenp@548 | 349 | if (UseCompressedOops) { \ |
coleenp@548 | 350 | InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr.contains); \ |
coleenp@548 | 351 | } else { \ |
coleenp@548 | 352 | InstanceRefKlass_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, mr.contains); \ |
duke@435 | 353 | } \ |
duke@435 | 354 | } |
duke@435 | 355 | |
duke@435 | 356 | ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN) |
ysr@777 | 357 | ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_DEFN) |
jprovino@4542 | 358 | #if INCLUDE_ALL_GCS |
ysr@777 | 359 | ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
ysr@777 | 360 | ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
jprovino@4542 | 361 | #endif // INCLUDE_ALL_GCS |
duke@435 | 362 | ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m) |
ysr@777 | 363 | ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceRefKlass_OOP_OOP_ITERATE_DEFN_m) |
duke@435 | 364 | |
jprovino@4542 | 365 | #if INCLUDE_ALL_GCS |
coleenp@548 | 366 | template <class T> |
coleenp@4047 | 367 | void specialized_oop_push_contents(InstanceRefKlass *ref, |
coleenp@548 | 368 | PSPromotionManager* pm, oop obj) { |
coleenp@548 | 369 | T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); |
coleenp@548 | 370 | if (PSScavenge::should_scavenge(referent_addr)) { |
duke@435 | 371 | ReferenceProcessor* rp = PSScavenge::reference_processor(); |
coleenp@548 | 372 | if (rp->discover_reference(obj, ref->reference_type())) { |
duke@435 | 373 | // reference already enqueued, referent and next will be traversed later |
coleenp@4037 | 374 | ref->InstanceKlass::oop_push_contents(pm, obj); |
duke@435 | 375 | return; |
duke@435 | 376 | } else { |
duke@435 | 377 | // treat referent as normal oop |
duke@435 | 378 | pm->claim_or_forward_depth(referent_addr); |
duke@435 | 379 | } |
duke@435 | 380 | } |
ysr@3117 | 381 | // Treat discovered as normal oop, if ref is not "active", |
ysr@3117 | 382 | // i.e. if next is non-NULL. |
coleenp@548 | 383 | T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj); |
ysr@3117 | 384 | if (ReferenceProcessor::pending_list_uses_discovered_field()) { |
ysr@3117 | 385 | T next_oop = oopDesc::load_heap_oop(next_addr); |
ysr@3117 | 386 | if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active" |
ysr@3117 | 387 | T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj); |
ysr@3117 | 388 | debug_only( |
ysr@3117 | 389 | if(TraceReferenceGC && PrintGCDetails) { |
ysr@3117 | 390 | gclog_or_tty->print_cr(" Process discovered as normal " |
ysr@3117 | 391 | INTPTR_FORMAT, discovered_addr); |
ysr@3117 | 392 | } |
ysr@3117 | 393 | ) |
ysr@3117 | 394 | if (PSScavenge::should_scavenge(discovered_addr)) { |
ysr@3117 | 395 | pm->claim_or_forward_depth(discovered_addr); |
ysr@3117 | 396 | } |
ysr@3117 | 397 | } |
ysr@3117 | 398 | } else { |
ysr@3117 | 399 | #ifdef ASSERT |
ysr@3117 | 400 | // In the case of older JDKs which do not use the discovered |
ysr@3117 | 401 | // field for the pending list, an inactive ref (next != NULL) |
ysr@3117 | 402 | // must always have a NULL discovered field. |
ysr@3117 | 403 | oop next = oopDesc::load_decode_heap_oop(next_addr); |
ysr@3117 | 404 | oop discovered = java_lang_ref_Reference::discovered(obj); |
ysr@3117 | 405 | assert(oopDesc::is_null(next) || oopDesc::is_null(discovered), |
ysr@3117 | 406 | err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field", |
kvn@3128 | 407 | (oopDesc*)obj)); |
ysr@3117 | 408 | #endif |
ysr@3117 | 409 | } |
ysr@3117 | 410 | |
ysr@3117 | 411 | // Treat next as normal oop; next is a link in the reference queue. |
coleenp@548 | 412 | if (PSScavenge::should_scavenge(next_addr)) { |
duke@435 | 413 | pm->claim_or_forward_depth(next_addr); |
duke@435 | 414 | } |
coleenp@4037 | 415 | ref->InstanceKlass::oop_push_contents(pm, obj); |
coleenp@548 | 416 | } |
coleenp@548 | 417 | |
coleenp@4047 | 418 | void InstanceRefKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
coleenp@548 | 419 | if (UseCompressedOops) { |
coleenp@548 | 420 | specialized_oop_push_contents<narrowOop>(this, pm, obj); |
coleenp@548 | 421 | } else { |
coleenp@548 | 422 | specialized_oop_push_contents<oop>(this, pm, obj); |
coleenp@548 | 423 | } |
coleenp@548 | 424 | } |
coleenp@548 | 425 | |
coleenp@548 | 426 | template <class T> |
coleenp@4047 | 427 | void specialized_oop_update_pointers(InstanceRefKlass *ref, |
coleenp@548 | 428 | ParCompactionManager* cm, oop obj) { |
coleenp@548 | 429 | T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); |
coleenp@548 | 430 | PSParallelCompact::adjust_pointer(referent_addr); |
coleenp@548 | 431 | T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj); |
coleenp@548 | 432 | PSParallelCompact::adjust_pointer(next_addr); |
coleenp@548 | 433 | T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj); |
coleenp@548 | 434 | PSParallelCompact::adjust_pointer(discovered_addr); |
coleenp@4047 | 435 | debug_only(trace_reference_gc("InstanceRefKlass::oop_update_ptrs", obj, |
coleenp@548 | 436 | referent_addr, next_addr, discovered_addr);) |
duke@435 | 437 | } |
duke@435 | 438 | |
coleenp@4047 | 439 | int InstanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { |
coleenp@4037 | 440 | InstanceKlass::oop_update_pointers(cm, obj); |
coleenp@548 | 441 | if (UseCompressedOops) { |
coleenp@548 | 442 | specialized_oop_update_pointers<narrowOop>(this, cm, obj); |
coleenp@548 | 443 | } else { |
coleenp@548 | 444 | specialized_oop_update_pointers<oop>(this, cm, obj); |
coleenp@548 | 445 | } |
coleenp@548 | 446 | return size_helper(); |
coleenp@548 | 447 | } |
jprovino@4542 | 448 | #endif // INCLUDE_ALL_GCS |
duke@435 | 449 | |
coleenp@4047 | 450 | void InstanceRefKlass::update_nonstatic_oop_maps(Klass* k) { |
duke@435 | 451 | // Clear the nonstatic oop-map entries corresponding to referent |
duke@435 | 452 | // and nextPending field. They are treated specially by the |
duke@435 | 453 | // garbage collector. |
duke@435 | 454 | // The discovered field is used only by the garbage collector |
duke@435 | 455 | // and is also treated specially. |
coleenp@4037 | 456 | InstanceKlass* ik = InstanceKlass::cast(k); |
duke@435 | 457 | |
duke@435 | 458 | // Check that we have the right class |
duke@435 | 459 | debug_only(static bool first_time = true); |
never@1577 | 460 | assert(k == SystemDictionary::Reference_klass() && first_time, |
duke@435 | 461 | "Invalid update of maps"); |
duke@435 | 462 | debug_only(first_time = false); |
jcoomes@1373 | 463 | assert(ik->nonstatic_oop_map_count() == 1, "just checking"); |
duke@435 | 464 | |
duke@435 | 465 | OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); |
duke@435 | 466 | |
duke@435 | 467 | // Check that the current map is (2,4) - currently points at field with |
duke@435 | 468 | // offset 2 (words) and has 4 map entries. |
duke@435 | 469 | debug_only(int offset = java_lang_ref_Reference::referent_offset); |
jcoomes@1374 | 470 | debug_only(unsigned int count = ((java_lang_ref_Reference::discovered_offset - |
coleenp@548 | 471 | java_lang_ref_Reference::referent_offset)/heapOopSize) + 1); |
duke@435 | 472 | |
duke@435 | 473 | if (UseSharedSpaces) { |
duke@435 | 474 | assert(map->offset() == java_lang_ref_Reference::queue_offset && |
jcoomes@1373 | 475 | map->count() == 1, "just checking"); |
duke@435 | 476 | } else { |
jcoomes@1373 | 477 | assert(map->offset() == offset && map->count() == count, |
duke@435 | 478 | "just checking"); |
duke@435 | 479 | |
duke@435 | 480 | // Update map to (3,1) - point to offset of 3 (words) with 1 map entry. |
duke@435 | 481 | map->set_offset(java_lang_ref_Reference::queue_offset); |
jcoomes@1373 | 482 | map->set_count(1); |
duke@435 | 483 | } |
duke@435 | 484 | } |
duke@435 | 485 | |
duke@435 | 486 | |
duke@435 | 487 | // Verification |
duke@435 | 488 | |
coleenp@4047 | 489 | void InstanceRefKlass::oop_verify_on(oop obj, outputStream* st) { |
coleenp@4037 | 490 | InstanceKlass::oop_verify_on(obj, st); |
duke@435 | 491 | // Verify referent field |
duke@435 | 492 | oop referent = java_lang_ref_Reference::referent(obj); |
duke@435 | 493 | |
duke@435 | 494 | // We should make this general to all heaps |
duke@435 | 495 | GenCollectedHeap* gch = NULL; |
duke@435 | 496 | if (Universe::heap()->kind() == CollectedHeap::GenCollectedHeap) |
duke@435 | 497 | gch = GenCollectedHeap::heap(); |
duke@435 | 498 | |
duke@435 | 499 | if (referent != NULL) { |
duke@435 | 500 | guarantee(referent->is_oop(), "referent field heap failed"); |
duke@435 | 501 | } |
duke@435 | 502 | // Verify next field |
duke@435 | 503 | oop next = java_lang_ref_Reference::next(obj); |
duke@435 | 504 | if (next != NULL) { |
ysr@777 | 505 | guarantee(next->is_oop(), "next field verify failed"); |
duke@435 | 506 | guarantee(next->is_instanceRef(), "next field verify failed"); |
duke@435 | 507 | } |
duke@435 | 508 | } |
duke@435 | 509 | |
coleenp@4047 | 510 | bool InstanceRefKlass::owns_pending_list_lock(JavaThread* thread) { |
coleenp@2367 | 511 | if (java_lang_ref_Reference::pending_list_lock() == NULL) return false; |
coleenp@2363 | 512 | Handle h_lock(thread, java_lang_ref_Reference::pending_list_lock()); |
coleenp@2363 | 513 | return ObjectSynchronizer::current_thread_holds_lock(thread, h_lock); |
coleenp@2363 | 514 | } |
coleenp@2363 | 515 | |
coleenp@4047 | 516 | void InstanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) { |
duke@435 | 517 | // we may enter this with pending exception set |
duke@435 | 518 | PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument |
johnc@3811 | 519 | |
johnc@3811 | 520 | // Create a HandleMark in case we retry a GC multiple times. |
johnc@3811 | 521 | // Each time we attempt the GC, we allocate the handle below |
johnc@3811 | 522 | // to hold the pending list lock. We want to free this handle. |
johnc@3811 | 523 | HandleMark hm; |
johnc@3811 | 524 | |
duke@435 | 525 | Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock()); |
duke@435 | 526 | ObjectSynchronizer::fast_enter(h_lock, pending_list_basic_lock, false, THREAD); |
duke@435 | 527 | assert(ObjectSynchronizer::current_thread_holds_lock( |
duke@435 | 528 | JavaThread::current(), h_lock), |
duke@435 | 529 | "Locking should have succeeded"); |
duke@435 | 530 | if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION; |
duke@435 | 531 | } |
duke@435 | 532 | |
coleenp@4047 | 533 | void InstanceRefKlass::release_and_notify_pending_list_lock( |
duke@435 | 534 | BasicLock *pending_list_basic_lock) { |
duke@435 | 535 | // we may enter this with pending exception set |
duke@435 | 536 | PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument |
johnc@3811 | 537 | |
johnc@3811 | 538 | // Create a HandleMark in case we retry a GC multiple times. |
johnc@3811 | 539 | // Each time we attempt the GC, we allocate the handle below |
johnc@3811 | 540 | // to hold the pending list lock. We want to free this handle. |
johnc@3811 | 541 | HandleMark hm; |
johnc@3811 | 542 | |
duke@435 | 543 | Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock()); |
duke@435 | 544 | assert(ObjectSynchronizer::current_thread_holds_lock( |
duke@435 | 545 | JavaThread::current(), h_lock), |
duke@435 | 546 | "Lock should be held"); |
duke@435 | 547 | // Notify waiters on pending lists lock if there is any reference. |
duke@435 | 548 | if (java_lang_ref_Reference::pending_list() != NULL) { |
duke@435 | 549 | ObjectSynchronizer::notifyall(h_lock, THREAD); |
duke@435 | 550 | } |
duke@435 | 551 | ObjectSynchronizer::fast_exit(h_lock(), pending_list_basic_lock, THREAD); |
duke@435 | 552 | if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION; |
duke@435 | 553 | } |