Thu, 12 Oct 2017 21:27:07 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "classfile/javaClasses.hpp" |
aoqi@0 | 27 | #include "classfile/systemDictionary.hpp" |
aoqi@0 | 28 | #include "gc_implementation/shared/markSweep.inline.hpp" |
aoqi@0 | 29 | #include "gc_interface/collectedHeap.inline.hpp" |
aoqi@0 | 30 | #include "memory/genOopClosures.inline.hpp" |
stefank@6982 | 31 | #include "memory/iterator.inline.hpp" |
aoqi@0 | 32 | #include "memory/oopFactory.hpp" |
aoqi@0 | 33 | #include "oops/instanceKlass.hpp" |
aoqi@0 | 34 | #include "oops/instanceMirrorKlass.hpp" |
aoqi@0 | 35 | #include "oops/instanceOop.hpp" |
aoqi@0 | 36 | #include "oops/oop.inline.hpp" |
aoqi@0 | 37 | #include "oops/symbol.hpp" |
aoqi@0 | 38 | #include "runtime/handles.inline.hpp" |
aoqi@0 | 39 | #include "utilities/macros.hpp" |
aoqi@0 | 40 | #if INCLUDE_ALL_GCS |
aoqi@0 | 41 | #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp" |
aoqi@0 | 42 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
aoqi@0 | 43 | #include "gc_implementation/g1/g1OopClosures.inline.hpp" |
aoqi@0 | 44 | #include "gc_implementation/g1/g1RemSet.inline.hpp" |
tschatzl@7091 | 45 | #include "gc_implementation/g1/heapRegionManager.inline.hpp" |
aoqi@0 | 46 | #include "gc_implementation/parNew/parOopClosures.inline.hpp" |
aoqi@0 | 47 | #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" |
aoqi@0 | 48 | #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" |
aoqi@0 | 49 | #include "oops/oop.pcgc.inline.hpp" |
aoqi@0 | 50 | #endif // INCLUDE_ALL_GCS |
aoqi@0 | 51 | |
aoqi@0 | 52 | int InstanceMirrorKlass::_offset_of_static_fields = 0; |
aoqi@0 | 53 | |
aoqi@0 | 54 | #ifdef ASSERT |
aoqi@0 | 55 | template <class T> void assert_is_in(T *p) { |
aoqi@0 | 56 | T heap_oop = oopDesc::load_heap_oop(p); |
aoqi@0 | 57 | if (!oopDesc::is_null(heap_oop)) { |
aoqi@0 | 58 | oop o = oopDesc::decode_heap_oop_not_null(heap_oop); |
aoqi@0 | 59 | assert(Universe::heap()->is_in(o), "should be in heap"); |
aoqi@0 | 60 | } |
aoqi@0 | 61 | } |
aoqi@0 | 62 | template <class T> void assert_is_in_closed_subset(T *p) { |
aoqi@0 | 63 | T heap_oop = oopDesc::load_heap_oop(p); |
aoqi@0 | 64 | if (!oopDesc::is_null(heap_oop)) { |
aoqi@0 | 65 | oop o = oopDesc::decode_heap_oop_not_null(heap_oop); |
aoqi@0 | 66 | assert(Universe::heap()->is_in_closed_subset(o), "should be in closed"); |
aoqi@0 | 67 | } |
aoqi@0 | 68 | } |
aoqi@0 | 69 | template <class T> void assert_is_in_reserved(T *p) { |
aoqi@0 | 70 | T heap_oop = oopDesc::load_heap_oop(p); |
aoqi@0 | 71 | if (!oopDesc::is_null(heap_oop)) { |
aoqi@0 | 72 | oop o = oopDesc::decode_heap_oop_not_null(heap_oop); |
aoqi@0 | 73 | assert(Universe::heap()->is_in_reserved(o), "should be in reserved"); |
aoqi@0 | 74 | } |
aoqi@0 | 75 | } |
aoqi@0 | 76 | template <class T> void assert_nothing(T *p) {} |
aoqi@0 | 77 | |
aoqi@0 | 78 | #else |
aoqi@0 | 79 | template <class T> void assert_is_in(T *p) {} |
aoqi@0 | 80 | template <class T> void assert_is_in_closed_subset(T *p) {} |
aoqi@0 | 81 | template <class T> void assert_is_in_reserved(T *p) {} |
aoqi@0 | 82 | template <class T> void assert_nothing(T *p) {} |
aoqi@0 | 83 | #endif // ASSERT |
aoqi@0 | 84 | |
aoqi@0 | 85 | #define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE( \ |
aoqi@0 | 86 | T, start_p, count, do_oop, \ |
aoqi@0 | 87 | assert_fn) \ |
aoqi@0 | 88 | { \ |
aoqi@0 | 89 | T* p = (T*)(start_p); \ |
aoqi@0 | 90 | T* const end = p + (count); \ |
aoqi@0 | 91 | while (p < end) { \ |
aoqi@0 | 92 | (assert_fn)(p); \ |
aoqi@0 | 93 | do_oop; \ |
aoqi@0 | 94 | ++p; \ |
aoqi@0 | 95 | } \ |
aoqi@0 | 96 | } |
aoqi@0 | 97 | |
aoqi@0 | 98 | #define InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE( \ |
aoqi@0 | 99 | T, start_p, count, low, high, \ |
aoqi@0 | 100 | do_oop, assert_fn) \ |
aoqi@0 | 101 | { \ |
aoqi@0 | 102 | T* const l = (T*)(low); \ |
aoqi@0 | 103 | T* const h = (T*)(high); \ |
aoqi@0 | 104 | assert(mask_bits((intptr_t)l, sizeof(T)-1) == 0 && \ |
aoqi@0 | 105 | mask_bits((intptr_t)h, sizeof(T)-1) == 0, \ |
aoqi@0 | 106 | "bounded region must be properly aligned"); \ |
aoqi@0 | 107 | T* p = (T*)(start_p); \ |
aoqi@0 | 108 | T* end = p + (count); \ |
aoqi@0 | 109 | if (p < l) p = l; \ |
aoqi@0 | 110 | if (end > h) end = h; \ |
aoqi@0 | 111 | while (p < end) { \ |
aoqi@0 | 112 | (assert_fn)(p); \ |
aoqi@0 | 113 | do_oop; \ |
aoqi@0 | 114 | ++p; \ |
aoqi@0 | 115 | } \ |
aoqi@0 | 116 | } |
aoqi@0 | 117 | |
aoqi@0 | 118 | |
aoqi@0 | 119 | #define InstanceMirrorKlass_OOP_ITERATE(start_p, count, \ |
aoqi@0 | 120 | do_oop, assert_fn) \ |
aoqi@0 | 121 | { \ |
aoqi@0 | 122 | if (UseCompressedOops) { \ |
aoqi@0 | 123 | InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \ |
aoqi@0 | 124 | start_p, count, \ |
aoqi@0 | 125 | do_oop, assert_fn) \ |
aoqi@0 | 126 | } else { \ |
aoqi@0 | 127 | InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(oop, \ |
aoqi@0 | 128 | start_p, count, \ |
aoqi@0 | 129 | do_oop, assert_fn) \ |
aoqi@0 | 130 | } \ |
aoqi@0 | 131 | } |
aoqi@0 | 132 | |
aoqi@0 | 133 | // The following macros call specialized macros, passing either oop or |
aoqi@0 | 134 | // narrowOop as the specialization type. These test the UseCompressedOops |
aoqi@0 | 135 | // flag. |
aoqi@0 | 136 | #define InstanceMirrorKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high, \ |
aoqi@0 | 137 | do_oop, assert_fn) \ |
aoqi@0 | 138 | { \ |
aoqi@0 | 139 | if (UseCompressedOops) { \ |
aoqi@0 | 140 | InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \ |
aoqi@0 | 141 | start_p, count, \ |
aoqi@0 | 142 | low, high, \ |
aoqi@0 | 143 | do_oop, assert_fn) \ |
aoqi@0 | 144 | } else { \ |
aoqi@0 | 145 | InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop, \ |
aoqi@0 | 146 | start_p, count, \ |
aoqi@0 | 147 | low, high, \ |
aoqi@0 | 148 | do_oop, assert_fn) \ |
aoqi@0 | 149 | } \ |
aoqi@0 | 150 | } |
aoqi@0 | 151 | |
aoqi@0 | 152 | |
aoqi@0 | 153 | void InstanceMirrorKlass::oop_follow_contents(oop obj) { |
aoqi@0 | 154 | InstanceKlass::oop_follow_contents(obj); |
aoqi@0 | 155 | |
aoqi@0 | 156 | // Follow the klass field in the mirror. |
aoqi@0 | 157 | Klass* klass = java_lang_Class::as_Klass(obj); |
aoqi@0 | 158 | if (klass != NULL) { |
aoqi@0 | 159 | // An anonymous class doesn't have its own class loader, so the call |
aoqi@0 | 160 | // to follow_klass will mark and push its java mirror instead of the |
aoqi@0 | 161 | // class loader. When handling the java mirror for an anonymous class |
aoqi@0 | 162 | // we need to make sure its class loader data is claimed, this is done |
aoqi@0 | 163 | // by calling follow_class_loader explicitly. For non-anonymous classes |
aoqi@0 | 164 | // the call to follow_class_loader is made when the class loader itself |
aoqi@0 | 165 | // is handled. |
aoqi@0 | 166 | if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { |
aoqi@0 | 167 | MarkSweep::follow_class_loader(klass->class_loader_data()); |
aoqi@0 | 168 | } else { |
aoqi@0 | 169 | MarkSweep::follow_klass(klass); |
aoqi@0 | 170 | } |
aoqi@0 | 171 | } else { |
aoqi@0 | 172 | // If klass is NULL then this a mirror for a primitive type. |
aoqi@0 | 173 | // We don't have to follow them, since they are handled as strong |
aoqi@0 | 174 | // roots in Universe::oops_do. |
aoqi@0 | 175 | assert(java_lang_Class::is_primitive(obj), "Sanity check"); |
aoqi@0 | 176 | } |
aoqi@0 | 177 | |
aoqi@0 | 178 | InstanceMirrorKlass_OOP_ITERATE( \ |
aoqi@0 | 179 | start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj), \ |
aoqi@0 | 180 | MarkSweep::mark_and_push(p), \ |
aoqi@0 | 181 | assert_is_in_closed_subset) |
aoqi@0 | 182 | } |
aoqi@0 | 183 | |
aoqi@0 | 184 | #if INCLUDE_ALL_GCS |
aoqi@0 | 185 | void InstanceMirrorKlass::oop_follow_contents(ParCompactionManager* cm, |
aoqi@0 | 186 | oop obj) { |
aoqi@0 | 187 | InstanceKlass::oop_follow_contents(cm, obj); |
aoqi@0 | 188 | |
aoqi@0 | 189 | // Follow the klass field in the mirror. |
aoqi@0 | 190 | Klass* klass = java_lang_Class::as_Klass(obj); |
aoqi@0 | 191 | if (klass != NULL) { |
aoqi@0 | 192 | // An anonymous class doesn't have its own class loader, so the call |
aoqi@0 | 193 | // to follow_klass will mark and push its java mirror instead of the |
aoqi@0 | 194 | // class loader. When handling the java mirror for an anonymous class |
aoqi@0 | 195 | // we need to make sure its class loader data is claimed, this is done |
aoqi@0 | 196 | // by calling follow_class_loader explicitly. For non-anonymous classes |
aoqi@0 | 197 | // the call to follow_class_loader is made when the class loader itself |
aoqi@0 | 198 | // is handled. |
aoqi@0 | 199 | if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { |
aoqi@0 | 200 | PSParallelCompact::follow_class_loader(cm, klass->class_loader_data()); |
aoqi@0 | 201 | } else { |
aoqi@0 | 202 | PSParallelCompact::follow_klass(cm, klass); |
aoqi@0 | 203 | } |
aoqi@0 | 204 | } else { |
aoqi@0 | 205 | // If klass is NULL then this a mirror for a primitive type. |
aoqi@0 | 206 | // We don't have to follow them, since they are handled as strong |
aoqi@0 | 207 | // roots in Universe::oops_do. |
aoqi@0 | 208 | assert(java_lang_Class::is_primitive(obj), "Sanity check"); |
aoqi@0 | 209 | } |
aoqi@0 | 210 | |
aoqi@0 | 211 | InstanceMirrorKlass_OOP_ITERATE( \ |
aoqi@0 | 212 | start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj), \ |
aoqi@0 | 213 | PSParallelCompact::mark_and_push(cm, p), \ |
aoqi@0 | 214 | assert_is_in) |
aoqi@0 | 215 | } |
aoqi@0 | 216 | #endif // INCLUDE_ALL_GCS |
aoqi@0 | 217 | |
aoqi@0 | 218 | int InstanceMirrorKlass::oop_adjust_pointers(oop obj) { |
aoqi@0 | 219 | int size = oop_size(obj); |
aoqi@0 | 220 | InstanceKlass::oop_adjust_pointers(obj); |
aoqi@0 | 221 | |
aoqi@0 | 222 | InstanceMirrorKlass_OOP_ITERATE( \ |
aoqi@0 | 223 | start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj), \ |
aoqi@0 | 224 | MarkSweep::adjust_pointer(p), \ |
aoqi@0 | 225 | assert_nothing) |
aoqi@0 | 226 | return size; |
aoqi@0 | 227 | } |
aoqi@0 | 228 | |
aoqi@0 | 229 | #define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(T, nv_suffix) \ |
aoqi@0 | 230 | InstanceMirrorKlass_OOP_ITERATE( \ |
aoqi@0 | 231 | start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj), \ |
aoqi@0 | 232 | (closure)->do_oop##nv_suffix(p), \ |
aoqi@0 | 233 | assert_is_in_closed_subset) \ |
aoqi@0 | 234 | return oop_size(obj); \ |
aoqi@0 | 235 | |
aoqi@0 | 236 | #define InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(T, nv_suffix, mr) \ |
aoqi@0 | 237 | InstanceMirrorKlass_BOUNDED_OOP_ITERATE( \ |
aoqi@0 | 238 | start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj), \ |
aoqi@0 | 239 | mr.start(), mr.end(), \ |
aoqi@0 | 240 | (closure)->do_oop##nv_suffix(p), \ |
aoqi@0 | 241 | assert_is_in_closed_subset) \ |
aoqi@0 | 242 | return oop_size(obj); \ |
aoqi@0 | 243 | |
aoqi@0 | 244 | |
aoqi@0 | 245 | // Macro to define InstanceMirrorKlass::oop_oop_iterate for virtual/nonvirtual for |
aoqi@0 | 246 | // all closures. Macros calling macros above for each oop size. |
aoqi@0 | 247 | |
aoqi@0 | 248 | #define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
aoqi@0 | 249 | \ |
aoqi@0 | 250 | int InstanceMirrorKlass:: \ |
aoqi@0 | 251 | oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ |
aoqi@0 | 252 | /* Get size before changing pointers */ \ |
aoqi@0 | 253 | SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
aoqi@0 | 254 | \ |
aoqi@0 | 255 | InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \ |
aoqi@0 | 256 | \ |
aoqi@0 | 257 | if_do_metadata_checked(closure, nv_suffix) { \ |
aoqi@0 | 258 | Klass* klass = java_lang_Class::as_Klass(obj); \ |
aoqi@0 | 259 | /* We'll get NULL for primitive mirrors. */ \ |
aoqi@0 | 260 | if (klass != NULL) { \ |
aoqi@0 | 261 | closure->do_klass##nv_suffix(klass); \ |
aoqi@0 | 262 | } \ |
aoqi@0 | 263 | } \ |
aoqi@0 | 264 | \ |
aoqi@0 | 265 | if (UseCompressedOops) { \ |
aoqi@0 | 266 | InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix); \ |
aoqi@0 | 267 | } else { \ |
aoqi@0 | 268 | InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix); \ |
aoqi@0 | 269 | } \ |
aoqi@0 | 270 | } |
aoqi@0 | 271 | |
aoqi@0 | 272 | #if INCLUDE_ALL_GCS |
aoqi@0 | 273 | #define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ |
aoqi@0 | 274 | \ |
aoqi@0 | 275 | int InstanceMirrorKlass:: \ |
aoqi@0 | 276 | oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ |
aoqi@0 | 277 | /* Get size before changing pointers */ \ |
aoqi@0 | 278 | SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
aoqi@0 | 279 | \ |
aoqi@0 | 280 | InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \ |
aoqi@0 | 281 | \ |
aoqi@0 | 282 | if (UseCompressedOops) { \ |
aoqi@0 | 283 | InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix); \ |
aoqi@0 | 284 | } else { \ |
aoqi@0 | 285 | InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix); \ |
aoqi@0 | 286 | } \ |
aoqi@0 | 287 | } |
aoqi@0 | 288 | #endif // INCLUDE_ALL_GCS |
aoqi@0 | 289 | |
aoqi@0 | 290 | |
aoqi@0 | 291 | #define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ |
aoqi@0 | 292 | \ |
aoqi@0 | 293 | int InstanceMirrorKlass:: \ |
aoqi@0 | 294 | oop_oop_iterate##nv_suffix##_m(oop obj, \ |
aoqi@0 | 295 | OopClosureType* closure, \ |
aoqi@0 | 296 | MemRegion mr) { \ |
aoqi@0 | 297 | SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \ |
aoqi@0 | 298 | \ |
aoqi@0 | 299 | InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \ |
aoqi@0 | 300 | \ |
aoqi@0 | 301 | if_do_metadata_checked(closure, nv_suffix) { \ |
aoqi@0 | 302 | if (mr.contains(obj)) { \ |
aoqi@0 | 303 | Klass* klass = java_lang_Class::as_Klass(obj); \ |
aoqi@0 | 304 | /* We'll get NULL for primitive mirrors. */ \ |
aoqi@0 | 305 | if (klass != NULL) { \ |
aoqi@0 | 306 | closure->do_klass##nv_suffix(klass); \ |
aoqi@0 | 307 | } \ |
aoqi@0 | 308 | } \ |
aoqi@0 | 309 | } \ |
aoqi@0 | 310 | \ |
aoqi@0 | 311 | if (UseCompressedOops) { \ |
aoqi@0 | 312 | InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr); \ |
aoqi@0 | 313 | } else { \ |
aoqi@0 | 314 | InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, mr); \ |
aoqi@0 | 315 | } \ |
aoqi@0 | 316 | } |
aoqi@0 | 317 | |
aoqi@0 | 318 | ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN) |
aoqi@0 | 319 | ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN) |
aoqi@0 | 320 | #if INCLUDE_ALL_GCS |
aoqi@0 | 321 | ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
aoqi@0 | 322 | ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
aoqi@0 | 323 | #endif // INCLUDE_ALL_GCS |
aoqi@0 | 324 | ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m) |
aoqi@0 | 325 | ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m) |
aoqi@0 | 326 | |
aoqi@0 | 327 | #if INCLUDE_ALL_GCS |
aoqi@0 | 328 | void InstanceMirrorKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
aoqi@0 | 329 | // Note that we don't have to follow the mirror -> klass pointer, since all |
aoqi@0 | 330 | // klasses that are dirty will be scavenged when we iterate over the |
aoqi@0 | 331 | // ClassLoaderData objects. |
aoqi@0 | 332 | |
aoqi@0 | 333 | InstanceKlass::oop_push_contents(pm, obj); |
aoqi@0 | 334 | InstanceMirrorKlass_OOP_ITERATE( \ |
aoqi@0 | 335 | start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\ |
aoqi@0 | 336 | if (PSScavenge::should_scavenge(p)) { \ |
aoqi@0 | 337 | pm->claim_or_forward_depth(p); \ |
aoqi@0 | 338 | }, \ |
aoqi@0 | 339 | assert_nothing ) |
aoqi@0 | 340 | } |
aoqi@0 | 341 | |
aoqi@0 | 342 | int InstanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { |
aoqi@0 | 343 | int size = oop_size(obj); |
aoqi@0 | 344 | InstanceKlass::oop_update_pointers(cm, obj); |
aoqi@0 | 345 | |
aoqi@0 | 346 | InstanceMirrorKlass_OOP_ITERATE( \ |
aoqi@0 | 347 | start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\ |
aoqi@0 | 348 | PSParallelCompact::adjust_pointer(p), \ |
aoqi@0 | 349 | assert_nothing) |
aoqi@0 | 350 | return size; |
aoqi@0 | 351 | } |
aoqi@0 | 352 | #endif // INCLUDE_ALL_GCS |
aoqi@0 | 353 | |
aoqi@0 | 354 | int InstanceMirrorKlass::instance_size(KlassHandle k) { |
aoqi@0 | 355 | if (k() != NULL && k->oop_is_instance()) { |
aoqi@0 | 356 | return align_object_size(size_helper() + InstanceKlass::cast(k())->static_field_size()); |
aoqi@0 | 357 | } |
aoqi@0 | 358 | return size_helper(); |
aoqi@0 | 359 | } |
aoqi@0 | 360 | |
aoqi@0 | 361 | instanceOop InstanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) { |
aoqi@0 | 362 | // Query before forming handle. |
aoqi@0 | 363 | int size = instance_size(k); |
aoqi@0 | 364 | KlassHandle h_k(THREAD, this); |
aoqi@0 | 365 | instanceOop i = (instanceOop)CollectedHeap::obj_allocate(h_k, size, CHECK_NULL); |
aoqi@0 | 366 | |
aoqi@0 | 367 | // Since mirrors can be variable sized because of the static fields, store |
aoqi@0 | 368 | // the size in the mirror itself. |
aoqi@0 | 369 | java_lang_Class::set_oop_size(i, size); |
aoqi@0 | 370 | |
aoqi@0 | 371 | return i; |
aoqi@0 | 372 | } |
aoqi@0 | 373 | |
aoqi@0 | 374 | int InstanceMirrorKlass::oop_size(oop obj) const { |
aoqi@0 | 375 | return java_lang_Class::oop_size(obj); |
aoqi@0 | 376 | } |
aoqi@0 | 377 | |
aoqi@0 | 378 | int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) { |
aoqi@0 | 379 | Klass* k = java_lang_Class::as_Klass(obj); |
aoqi@0 | 380 | if (k != NULL && k->oop_is_instance()) { |
aoqi@0 | 381 | return InstanceKlass::cast(k)->static_oop_field_count(); |
aoqi@0 | 382 | } |
aoqi@0 | 383 | return 0; |
aoqi@0 | 384 | } |