< prev index next >

src/hotspot/share/oops/oop.hpp

Print this page

        

@@ -26,20 +26,57 @@
 #define SHARE_OOPS_OOP_HPP
 
 #include "memory/iterator.hpp"
 #include "memory/memRegion.hpp"
 #include "oops/access.hpp"
+#include "oops/arrayStorageProperties.hpp"
 #include "oops/metadata.hpp"
 #include "runtime/atomic.hpp"
 #include "utilities/macros.hpp"
 
 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
 // the format of Java objects so the fields can be accessed from C++.
 // oopDesc is abstract.
 // (see oopHierarchy for complete oop class hierarchy)
 //
 // no virtual functions allowed
+//
+// oopDesc::_mark - the "oop mark word" encoding to be found separately in markOop.hpp
+//
+// oopDesc::_metadata - encodes both the object's klass pointer and potentially
+//                      "storage properties" (currently confined to arrays in the form of
+//                      ArrayStorageProperties). Storage properties are peculiar to the
+//                      *instance*, and not necessarily the "type".
+//
+// The overall size of the _metadata field is dependent on "UseCompressedClassPointers",
+// hence the terms "narrow" (32 bits) vs "wide" (64 bits).
+//
+// "Wide" encoding of _metadata:
+// bit number          |63             0|
+// bit length          |--3|-----61-----|
+// --------------------------------------
+// _klass              [xxx| Klass*     ]
+// _wide_storage_props [ sp|            ]
+// --------------------------------------
+// with:
+//    xxx = klass_mask(), Klass* = Klass pointer to be masked
+//    sp = storage properties, bit number: wide_storage_props_shift
+//
+// "Narrow" encoding of _metadata:
+// bit number            |31             0|
+// bit length            |--3|-----29-----|
+// ----------------------------------------
+// _compressed_klass     [xxx| narrowKlass]
+// _narrow_storage_props [ sp|            ]
+// ----------------------------------------
+// with:
+//   xxx = compressed_klass_mask(), narrowKlass = compressed Klass pointer to be masked
+//         narrowKlass may be further decoded (Klass::decode_klass()) to produce Klass*
+//   sp = storage properties, bit number: narrow_storage_props_shift
+//
+// Storage properties encodings are current confined to arrayStorageProperties.hpp
+
 
 extern bool always_do_update_barrier;
 
 // Forward declarations.
 class OopClosure;

@@ -57,10 +94,12 @@
  private:
   volatile markOop _mark;
   union _metadata {
     Klass*      _klass;
     narrowKlass _compressed_klass;
+    uintptr_t   _wide_storage_props;
+    uint32_t   _narrow_storage_props;
   } _metadata;
 
  public:
   inline markOop  mark()          const;
   inline markOop  mark_raw()      const;

@@ -77,10 +116,21 @@
   // Used only to re-initialize the mark word (e.g., of promoted
   // objects during a GC) -- requires a valid klass pointer
   inline void init_mark();
   inline void init_mark_raw();
 
+  enum {
+    storage_props_nof_bits     = LogKlassAlignmentInBytes, // This alignment gives us some "free bits"
+    narrow_storage_props_shift = (sizeof(narrowKlass) << 3) - storage_props_nof_bits,
+    wide_storage_props_shift   = (sizeof(Klass*) << 3) - storage_props_nof_bits
+  };
+
+  static inline narrowKlass compressed_klass_mask();
+  static inline narrowKlass compressed_klass_masked(narrowKlass raw);
+  static inline uintptr_t   klass_mask();
+  static inline Klass*      klass_masked(uintptr_t raw);
+
   inline Klass* klass() const;
   inline Klass* klass_or_null() const volatile;
   inline Klass* klass_or_null_acquire() const volatile;
   static inline Klass** klass_addr(HeapWord* mem);
   static inline narrowKlass* compressed_klass_addr(HeapWord* mem);

@@ -88,10 +138,17 @@
   inline narrowKlass* compressed_klass_addr();
 
   inline void set_klass(Klass* k);
   static inline void release_set_klass(HeapWord* mem, Klass* klass);
 
+  // Extra container metadata specific to arrays (encoded into high bits of _metadata)
+  static inline uintptr_t* wide_metadata_addr(HeapWord* mem);
+  inline ArrayStorageProperties array_storage_properties() const;
+  inline void set_metadata(ArrayStorageProperties storage_props, Klass* k);
+  static inline void release_set_metadata(HeapWord* mem, ArrayStorageProperties storage_props, Klass* klass);
+
+
   // For klass field compression
   inline int klass_gap() const;
   inline void set_klass_gap(int z);
   static inline void set_klass_gap(HeapWord* mem, int z);
   // For when the klass pointer is being used as a linked list "next" field.

@@ -114,16 +171,20 @@
   // type test operations (inlined in oop.inline.hpp)
   inline bool is_instance()            const;
   inline bool is_array()               const;
   inline bool is_objArray()            const;
   inline bool is_typeArray()           const;
+  inline bool is_value()               const;
+  inline bool is_valueArray()          const;
 
   // type test operations that don't require inclusion of oop.inline.hpp.
   bool is_instance_noinline()          const;
   bool is_array_noinline()             const;
   bool is_objArray_noinline()          const;
   bool is_typeArray_noinline()         const;
+  bool is_value_noinline()             const;
+  bool is_valueArray_noinline()        const;
 
  protected:
   inline oop        as_oop() const { return const_cast<oopDesc*>(this); }
 
  public:
< prev index next >