< prev index next >

src/share/vm/oops/klass.cpp

Print this page




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/dictionary.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc_implementation/shared/markSweep.inline.hpp"
  31 #include "gc_interface/collectedHeap.inline.hpp"
  32 #include "memory/heapInspection.hpp"
  33 #include "memory/metadataFactory.hpp"
  34 #include "memory/oopFactory.hpp"
  35 #include "memory/resourceArea.hpp"
  36 #include "oops/instanceKlass.hpp"
  37 #include "oops/klass.inline.hpp"
  38 #include "oops/oop.inline2.hpp"
  39 #include "runtime/atomic.inline.hpp"
  40 #include "runtime/orderAccess.inline.hpp"
  41 #include "trace/traceMacros.hpp"
  42 #include "utilities/stack.hpp"
  43 #include "utilities/macros.hpp"
  44 #if INCLUDE_ALL_GCS
  45 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
  46 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  47 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
  48 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
  49 #endif // INCLUDE_ALL_GCS



  50 
  51 bool Klass::is_cloneable() const {
  52   return _access_flags.is_cloneable() ||
  53          is_subtype_of(SystemDictionary::Cloneable_klass());
  54 }
  55 
  56 void Klass::set_is_cloneable() {
  57   if (oop_is_instance() && InstanceKlass::cast(this)->reference_type() != REF_NONE) {
  58     // Reference cloning should not be intrinsified and always happen in JVM_Clone.
  59   } else {
  60     _access_flags.set_is_cloneable();
  61   }
  62 }
  63 
  64 void Klass::set_name(Symbol* n) {
  65   _name = n;
  66   if (_name != NULL) _name->increment_refcount();
  67 }
  68 
  69 bool Klass::is_subclass_of(const Klass* k) const {


 180   set_secondary_supers(NULL);
 181   set_secondary_super_cache(NULL);
 182   _primary_supers[0] = k;
 183   set_super_check_offset(in_bytes(primary_supers_offset()));
 184 
 185   // The constructor is used from init_self_patching_vtbl_list,
 186   // which doesn't zero out the memory before calling the constructor.
 187   // Need to set the field explicitly to not hit an assert that the field
 188   // should be NULL before setting it.
 189   _java_mirror = NULL;
 190 
 191   set_modifier_flags(0);
 192   set_layout_helper(Klass::_lh_neutral_value);
 193   set_name(NULL);
 194   AccessFlags af;
 195   af.set_flags(0);
 196   set_access_flags(af);
 197   set_subklass(NULL);
 198   set_next_sibling(NULL);
 199   set_next_link(NULL);
 200   TRACE_INIT_ID(this);
 201 
 202   set_prototype_header(markOopDesc::prototype());
 203   set_biased_lock_revocation_count(0);
 204   set_last_biased_lock_bulk_revocation_time(0);
 205 
 206   // The klass doesn't have any references at this point.
 207   clear_modified_oops();
 208   clear_accumulated_modified_oops();
 209   _shared_class_path_index = -1;
 210 }
 211 
 212 jint Klass::array_layout_helper(BasicType etype) {
 213   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 214   // Note that T_ARRAY is not allowed here.
 215   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 216   int  esize = type2aelembytes(etype);
 217   bool isobj = (etype == T_OBJECT);
 218   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
 219   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
 220 


 509     klass_update_barrier_set(v);
 510   }
 511 }
 512 
 513 void Klass::klass_oop_store(volatile oop* p, oop v) {
 514   assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata");
 515   assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object");
 516 
 517   klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile.
 518   OrderAccess::release_store_ptr(p, v);
 519   klass_update_barrier_set(v);
 520 }
 521 
 522 void Klass::oops_do(OopClosure* cl) {
 523   cl->do_oop(&_java_mirror);
 524 }
 525 
 526 void Klass::remove_unshareable_info() {
 527   assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
 528 

 529   set_subklass(NULL);
 530   set_next_sibling(NULL);
 531   // Clear the java mirror
 532   set_java_mirror(NULL);
 533   set_next_link(NULL);
 534 
 535   // Null out class_loader_data because we don't share that yet.
 536   set_class_loader_data(NULL);
 537 }
 538 
 539 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
 540   TRACE_INIT_ID(this);
 541   // If an exception happened during CDS restore, some of these fields may already be
 542   // set.  We leave the class on the CLD list, even if incomplete so that we don't
 543   // modify the CLD list outside a safepoint.
 544   if (class_loader_data() == NULL) {
 545     // Restore class_loader_data
 546     set_class_loader_data(loader_data);
 547 
 548     // Add to class loader list first before creating the mirror
 549     // (same order as class file parsing)
 550     loader_data->add_class(this);
 551   }
 552 
 553   // Recreate the class mirror.
 554   // Only recreate it if not present.  A previous attempt to restore may have
 555   // gotten an OOM later but keep the mirror if it was created.
 556   if (java_mirror() == NULL) {
 557     java_lang_Class::create_mirror(this, class_loader(), protection_domain, CHECK);
 558   }
 559 }
 560 




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/javaClasses.hpp"
  27 #include "classfile/dictionary.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc_implementation/shared/markSweep.inline.hpp"
  31 #include "gc_interface/collectedHeap.inline.hpp"
  32 #include "memory/heapInspection.hpp"
  33 #include "memory/metadataFactory.hpp"
  34 #include "memory/oopFactory.hpp"
  35 #include "memory/resourceArea.hpp"
  36 #include "oops/instanceKlass.hpp"
  37 #include "oops/klass.inline.hpp"
  38 #include "oops/oop.inline2.hpp"
  39 #include "runtime/atomic.inline.hpp"
  40 #include "runtime/orderAccess.inline.hpp"

  41 #include "utilities/stack.hpp"
  42 #include "utilities/macros.hpp"
  43 #if INCLUDE_ALL_GCS
  44 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
  45 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  46 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
  47 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
  48 #endif // INCLUDE_ALL_GCS
  49 #if INCLUDE_JFR
  50 #include "jfr/support/jfrTraceIdExtension.hpp"
  51 #endif
  52 
  53 bool Klass::is_cloneable() const {
  54   return _access_flags.is_cloneable() ||
  55          is_subtype_of(SystemDictionary::Cloneable_klass());
  56 }
  57 
  58 void Klass::set_is_cloneable() {
  59   if (oop_is_instance() && InstanceKlass::cast(this)->reference_type() != REF_NONE) {
  60     // Reference cloning should not be intrinsified and always happen in JVM_Clone.
  61   } else {
  62     _access_flags.set_is_cloneable();
  63   }
  64 }
  65 
  66 void Klass::set_name(Symbol* n) {
  67   _name = n;
  68   if (_name != NULL) _name->increment_refcount();
  69 }
  70 
  71 bool Klass::is_subclass_of(const Klass* k) const {


 182   set_secondary_supers(NULL);
 183   set_secondary_super_cache(NULL);
 184   _primary_supers[0] = k;
 185   set_super_check_offset(in_bytes(primary_supers_offset()));
 186 
 187   // The constructor is used from init_self_patching_vtbl_list,
 188   // which doesn't zero out the memory before calling the constructor.
 189   // Need to set the field explicitly to not hit an assert that the field
 190   // should be NULL before setting it.
 191   _java_mirror = NULL;
 192 
 193   set_modifier_flags(0);
 194   set_layout_helper(Klass::_lh_neutral_value);
 195   set_name(NULL);
 196   AccessFlags af;
 197   af.set_flags(0);
 198   set_access_flags(af);
 199   set_subklass(NULL);
 200   set_next_sibling(NULL);
 201   set_next_link(NULL);

 202 
 203   set_prototype_header(markOopDesc::prototype());
 204   set_biased_lock_revocation_count(0);
 205   set_last_biased_lock_bulk_revocation_time(0);
 206 
 207   // The klass doesn't have any references at this point.
 208   clear_modified_oops();
 209   clear_accumulated_modified_oops();
 210   _shared_class_path_index = -1;
 211 }
 212 
 213 jint Klass::array_layout_helper(BasicType etype) {
 214   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 215   // Note that T_ARRAY is not allowed here.
 216   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 217   int  esize = type2aelembytes(etype);
 218   bool isobj = (etype == T_OBJECT);
 219   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
 220   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
 221 


 510     klass_update_barrier_set(v);
 511   }
 512 }
 513 
 514 void Klass::klass_oop_store(volatile oop* p, oop v) {
 515   assert(!Universe::heap()->is_in_reserved((void*)p), "Should store pointer into metadata");
 516   assert(v == NULL || Universe::heap()->is_in_reserved((void*)v), "Should store pointer to an object");
 517 
 518   klass_update_barrier_set_pre((oop*)p, v); // Cast away volatile.
 519   OrderAccess::release_store_ptr(p, v);
 520   klass_update_barrier_set(v);
 521 }
 522 
 523 void Klass::oops_do(OopClosure* cl) {
 524   cl->do_oop(&_java_mirror);
 525 }
 526 
 527 void Klass::remove_unshareable_info() {
 528   assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
 529 
 530   JFR_ONLY(REMOVE_ID(this);)
 531   set_subklass(NULL);
 532   set_next_sibling(NULL);
 533   // Clear the java mirror
 534   set_java_mirror(NULL);
 535   set_next_link(NULL);
 536 
 537   // Null out class_loader_data because we don't share that yet.
 538   set_class_loader_data(NULL);
 539 }
 540 
 541 void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) {
 542   JFR_ONLY(RESTORE_ID(this);)
 543   // If an exception happened during CDS restore, some of these fields may already be
 544   // set.  We leave the class on the CLD list, even if incomplete so that we don't
 545   // modify the CLD list outside a safepoint.
 546   if (class_loader_data() == NULL) {
 547     // Restore class_loader_data
 548     set_class_loader_data(loader_data);
 549 
 550     // Add to class loader list first before creating the mirror
 551     // (same order as class file parsing)
 552     loader_data->add_class(this);
 553   }
 554 
 555   // Recreate the class mirror.
 556   // Only recreate it if not present.  A previous attempt to restore may have
 557   // gotten an OOM later but keep the mirror if it was created.
 558   if (java_mirror() == NULL) {
 559     java_lang_Class::create_mirror(this, class_loader(), protection_domain, CHECK);
 560   }
 561 }
 562 


< prev index next >