< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page
*** 272,38 ***
  #endif
    ShouldNotReachHere();
    return nullptr;
  }
  
- static markWord make_prototype(const Klass* kls) {
-   markWord prototype = markWord::prototype();
- #ifdef _LP64
-   if (UseCompactObjectHeaders) {
-     // With compact object headers, the narrow Klass ID is part of the mark word.
-     // We therfore seed the mark word with the narrow Klass ID.
-     // Note that only those Klass that can be instantiated have a narrow Klass ID.
-     // For those who don't, we leave the klass bits empty and assert if someone
-     // tries to use those.
-     const narrowKlass nk = CompressedKlassPointers::is_encodable(kls) ?
-         CompressedKlassPointers::encode(const_cast<Klass*>(kls)) : 0;
-     prototype = prototype.set_narrow_klass(nk);
-   }
- #endif
-   return prototype;
- }
- 
  Klass::Klass() : _kind(UnknownKlassKind) {
    assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
  }
  
  // "Normal" instantiation is preceded by a MetaspaceObj allocation
  // which zeros out memory - calloc equivalent.
  // The constructor is also used from CppVtableCloner,
  // which doesn't zero out the memory before calling the constructor.
! Klass::Klass(KlassKind kind) : _kind(kind),
-                                _prototype_header(make_prototype(this)),
                                 _shared_class_path_index(-1) {
    CDS_ONLY(_shared_class_flags = 0;)
    CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
    _primary_supers[0] = this;
    set_super_check_offset(in_bytes(primary_supers_offset()));
  }
--- 272,21 ---
  #endif
    ShouldNotReachHere();
    return nullptr;
  }
  
  Klass::Klass() : _kind(UnknownKlassKind) {
    assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
  }
  
  // "Normal" instantiation is preceded by a MetaspaceObj allocation
  // which zeros out memory - calloc equivalent.
  // The constructor is also used from CppVtableCloner,
  // which doesn't zero out the memory before calling the constructor.
! Klass::Klass(KlassKind kind, markWord prototype_header) : _kind(kind),
                                 _shared_class_path_index(-1) {
+   set_prototype_header(make_prototype_header(this, prototype_header));
    CDS_ONLY(_shared_class_flags = 0;)
    CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
    _primary_supers[0] = this;
    set_super_check_offset(in_bytes(primary_supers_offset()));
  }

*** 313,11 ***
    // Note that T_ARRAY is not allowed here.
    int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
    int  esize = type2aelembytes(etype);
    bool isobj = (etype == T_OBJECT);
    int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
!   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
  
    assert(lh < (int)_lh_neutral_value, "must look like an array layout");
    assert(layout_helper_is_array(lh), "correct kind");
    assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
    assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
--- 296,11 ---
    // Note that T_ARRAY is not allowed here.
    int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
    int  esize = type2aelembytes(etype);
    bool isobj = (etype == T_OBJECT);
    int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
!   int lh = array_layout_helper(tag, false, hsize, etype, exact_log2(esize));
  
    assert(lh < (int)_lh_neutral_value, "must look like an array layout");
    assert(layout_helper_is_array(lh), "correct kind");
    assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
    assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");

*** 1014,14 ***
  
    if (WizardMode) {
       // print header
       obj->mark().print_on(st);
       st->cr();
!      if (UseCompactObjectHeaders) {
!        st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
-        st->cr();
-      }
    }
  
    // print class
    st->print(BULLET"klass: ");
    obj->klass()->print_value_on(st);
--- 997,12 ---
  
    if (WizardMode) {
       // print header
       obj->mark().print_on(st);
       st->cr();
!      st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
!      st->cr();
    }
  
    // print class
    st->print(BULLET"klass: ");
    obj->klass()->print_value_on(st);
< prev index next >