< prev index next >

src/hotspot/share/oops/klass.inline.hpp

Print this page
@@ -57,28 +57,46 @@
  // of this function must ensure that a safepoint doesn't happen while interpreting the return value.
  inline bool Klass::is_loader_alive() const {
    return class_loader_data()->is_alive();
  }
  
- inline markWord Klass::prototype_header() const {
-   assert(UseCompactObjectHeaders, "only use with compact object headers");
+ inline void Klass::set_prototype_header(markWord header) {
+ #ifdef ASSERT
+   if (EnableValhalla && !UseCompactObjectHeaders) {
+     assert(!is_inline_klass() || header.is_inline_type(), "Unexpected prototype");
+     assert(_prototype_header.value() == 0 || _prototype_header == markWord::prototype(),
+            "Prototype already set");
  #ifdef _LP64
+     assert(header == markWord::prototype() ||
+            header.is_inline_type() ||
+            header.is_flat_array() ||
+            header.is_null_free_array(),
+            "unknown prototype header");
+ #else
+     assert(header == markWord::prototype() ||
+            header.is_inline_type(),
+            "unknown prototype header");
+ #endif
+   }
+ #endif // ASSERT
+   _prototype_header = header;
+ }
+ 
+ inline markWord Klass::prototype_header() const {
    // You only need prototypes for allocating objects. If the class is not instantiable, it won't live in
    // class space and have no narrow Klass ID. But in that case we should not need the prototype.
-   assert(_prototype_header.narrow_klass() > 0, "Klass " PTR_FORMAT ": invalid prototype (" PTR_FORMAT ")",
+   assert(!UseCompactObjectHeaders || _prototype_header.narrow_klass() > 0, "Klass " PTR_FORMAT ": invalid prototype (" PTR_FORMAT ")",
           p2i(this), _prototype_header.value());
- #endif
    return _prototype_header;
  }
  
- // This is only used when dumping the archive. In other cases,
- // the _prototype_header is already initialized to the right thing.
- inline void Klass::set_prototype_header(markWord header) {
-   assert(UseCompactObjectHeaders, "only with compact headers");
-   _prototype_header = header;
+ // May no longer be required (was used to avoid a bootstrapping problem...
+ inline markWord Klass::default_prototype_header(Klass* k) {
+   return (k == nullptr) ? markWord::prototype() : k->prototype_header();
  }
  
+ 
  // Loading the java_mirror does not keep its holder alive. See Klass::keep_alive().
  inline oop Klass::java_mirror() const {
    return _java_mirror.resolve();
  }
  
< prev index next >