< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page
@@ -195,16 +195,26 @@
  
  void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
    return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
  }
  
+ static markWord make_prototype(Klass* kls) {
+   markWord prototype = markWord::prototype();
+ #ifdef _LP64
+   if (UseCompactObjectHeaders) {
+     prototype = prototype.set_klass(kls);
+   }
+ #endif
+   return prototype;
+ }
+ 
  // "Normal" instantiation is preceeded 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(KlassID id) : _id(id),
-                            _prototype_header(markWord::prototype()),
+                            _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()));

@@ -742,12 +752,14 @@
  
    if (WizardMode) {
       // print header
       obj->mark().print_on(st);
       st->cr();
-      st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
-      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);
< prev index next >