< prev index next >

src/share/vm/oops/objArrayKlass.cpp

Print this page




  39 #include "oops/objArrayKlass.inline.hpp"
  40 #include "oops/objArrayOop.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "oops/oop.inline2.hpp"
  43 #include "oops/symbol.hpp"
  44 #include "runtime/handles.inline.hpp"
  45 #include "runtime/mutexLocker.hpp"
  46 #include "runtime/orderAccess.inline.hpp"
  47 #include "utilities/copy.hpp"
  48 #include "utilities/macros.hpp"
  49 #if INCLUDE_ALL_GCS
  50 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp"
  51 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  52 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
  53 #include "gc_implementation/g1/g1RemSet.inline.hpp"
  54 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
  55 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
  56 #include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
  57 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
  58 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"


  59 #include "oops/oop.pcgc.inline.hpp"
  60 #endif // INCLUDE_ALL_GCS
  61 
  62 ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS) {
  63   assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(),
  64       "array klasses must be same size as InstanceKlass");
  65 
  66   int size = ArrayKlass::static_size(ObjArrayKlass::header_size());
  67 
  68   return new (loader_data, size, THREAD) ObjArrayKlass(n, klass_handle, name);
  69 }
  70 
  71 Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
  72                                                 int n, KlassHandle element_klass, TRAPS) {
  73 
  74   // Eagerly allocate the direct array supertype.
  75   KlassHandle super_klass = KlassHandle();
  76   if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) {
  77     KlassHandle element_super (THREAD, element_klass->super());
  78     if (element_super.not_null()) {


 225         sizes += 1;
 226         if (*sizes < 0) {
 227           THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
 228         }
 229       }
 230     }
 231   }
 232   return h_array();
 233 }
 234 
 235 // Either oop or narrowOop depending on UseCompressedOops.
 236 template <class T> void ObjArrayKlass::do_copy(arrayOop s, T* src,
 237                                arrayOop d, T* dst, int length, TRAPS) {
 238 
 239   BarrierSet* bs = Universe::heap()->barrier_set();
 240   // For performance reasons, we assume we are that the write barrier we
 241   // are using has optimized modes for arrays of references.  At least one
 242   // of the asserts below will fail if this is not the case.
 243   assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
 244   assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");






 245 
 246   if (s == d) {
 247     // since source and destination are equal we do not need conversion checks.
 248     assert(length > 0, "sanity check");
 249     bs->write_ref_array_pre(dst, length);
 250     Copy::conjoint_oops_atomic(src, dst, length);
 251   } else {
 252     // We have to make sure all elements conform to the destination array
 253     Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
 254     Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
 255     if (stype == bound || stype->is_subtype_of(bound)) {
 256       // elements are guaranteed to be subtypes, so no check necessary
 257       bs->write_ref_array_pre(dst, length);
 258       Copy::conjoint_oops_atomic(src, dst, length);
 259     } else {
 260       // slow case: need individual subtype checks
 261       // note: don't use obj_at_put below because it includes a redundant store check
 262       T* from = src;
 263       T* end = from + length;
 264       for (T* p = dst; from < end; from++, p++) {




  39 #include "oops/objArrayKlass.inline.hpp"
  40 #include "oops/objArrayOop.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "oops/oop.inline2.hpp"
  43 #include "oops/symbol.hpp"
  44 #include "runtime/handles.inline.hpp"
  45 #include "runtime/mutexLocker.hpp"
  46 #include "runtime/orderAccess.inline.hpp"
  47 #include "utilities/copy.hpp"
  48 #include "utilities/macros.hpp"
  49 #if INCLUDE_ALL_GCS
  50 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp"
  51 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  52 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
  53 #include "gc_implementation/g1/g1RemSet.inline.hpp"
  54 #include "gc_implementation/g1/heapRegionManager.inline.hpp"
  55 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
  56 #include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
  57 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
  58 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
  59 #include "gc_implementation/shenandoah/shenandoahBarrierSet.inline.hpp"
  60 #include "gc_implementation/shenandoah/shenandoahOopClosures.inline.hpp"
  61 #include "oops/oop.pcgc.inline.hpp"
  62 #endif // INCLUDE_ALL_GCS
  63 
  64 ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS) {
  65   assert(ObjArrayKlass::header_size() <= InstanceKlass::header_size(),
  66       "array klasses must be same size as InstanceKlass");
  67 
  68   int size = ArrayKlass::static_size(ObjArrayKlass::header_size());
  69 
  70   return new (loader_data, size, THREAD) ObjArrayKlass(n, klass_handle, name);
  71 }
  72 
  73 Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data,
  74                                                 int n, KlassHandle element_klass, TRAPS) {
  75 
  76   // Eagerly allocate the direct array supertype.
  77   KlassHandle super_klass = KlassHandle();
  78   if (!Universe::is_bootstrapping() || SystemDictionary::Object_klass_loaded()) {
  79     KlassHandle element_super (THREAD, element_klass->super());
  80     if (element_super.not_null()) {


 227         sizes += 1;
 228         if (*sizes < 0) {
 229           THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
 230         }
 231       }
 232     }
 233   }
 234   return h_array();
 235 }
 236 
 237 // Either oop or narrowOop depending on UseCompressedOops.
 238 template <class T> void ObjArrayKlass::do_copy(arrayOop s, T* src,
 239                                arrayOop d, T* dst, int length, TRAPS) {
 240 
 241   BarrierSet* bs = Universe::heap()->barrier_set();
 242   // For performance reasons, we assume we are that the write barrier we
 243   // are using has optimized modes for arrays of references.  At least one
 244   // of the asserts below will fail if this is not the case.
 245   assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
 246   assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
 247 
 248 #if INCLUDE_ALL_GCS
 249   if (UseShenandoahGC) {
 250     ShenandoahBarrierSet::barrier_set()->arraycopy_barrier(src, dst, length);
 251   }
 252 #endif
 253 
 254   if (s == d) {
 255     // since source and destination are equal we do not need conversion checks.
 256     assert(length > 0, "sanity check");
 257     bs->write_ref_array_pre(dst, length);
 258     Copy::conjoint_oops_atomic(src, dst, length);
 259   } else {
 260     // We have to make sure all elements conform to the destination array
 261     Klass* bound = ObjArrayKlass::cast(d->klass())->element_klass();
 262     Klass* stype = ObjArrayKlass::cast(s->klass())->element_klass();
 263     if (stype == bound || stype->is_subtype_of(bound)) {
 264       // elements are guaranteed to be subtypes, so no check necessary
 265       bs->write_ref_array_pre(dst, length);
 266       Copy::conjoint_oops_atomic(src, dst, length);
 267     } else {
 268       // slow case: need individual subtype checks
 269       // note: don't use obj_at_put below because it includes a redundant store check
 270       T* from = src;
 271       T* end = from + length;
 272       for (T* p = dst; from < end; from++, p++) {


< prev index next >