< prev index next >

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

Print this page

        

@@ -85,34 +85,41 @@
 
 void oopDesc::init_mark_raw() {
   set_mark_raw(markOopDesc::prototype_for_object(this));
 }
 
+narrowKlass oopDesc::compressed_klass_mask() { return ((narrowKlass) 1 << narrow_storage_props_shift) - 1; }
+uintptr_t   oopDesc::klass_mask()   { return ((uintptr_t) 1 << wide_storage_props_shift) - 1; }
+
+narrowKlass oopDesc::compressed_klass_masked(narrowKlass raw) { return raw & compressed_klass_mask(); }
+Klass*      oopDesc::klass_masked(uintptr_t raw)     { return reinterpret_cast<Klass*>(raw & klass_mask()); }
+
+
 Klass* oopDesc::klass() const {
   if (UseCompressedClassPointers) {
-    return CompressedKlassPointers::decode_not_null(_metadata._compressed_klass);
+    return CompressedKlassPointers::decode_not_null(compressed_klass_masked(_metadata._compressed_klass));
   } else {
-    return _metadata._klass;
+    return klass_masked(_metadata._wide_storage_props);
   }
 }
 
 Klass* oopDesc::klass_or_null() const volatile {
   if (UseCompressedClassPointers) {
-    return CompressedKlassPointers::decode(_metadata._compressed_klass);
+    return CompressedKlassPointers::decode(compressed_klass_masked(_metadata._compressed_klass));
   } else {
-    return _metadata._klass;
+    return klass_masked(_metadata._wide_storage_props);
   }
 }
 
 Klass* oopDesc::klass_or_null_acquire() const volatile {
   if (UseCompressedClassPointers) {
     // Workaround for non-const load_acquire parameter.
     const volatile narrowKlass* addr = &_metadata._compressed_klass;
     volatile narrowKlass* xaddr = const_cast<volatile narrowKlass*>(addr);
-    return CompressedKlassPointers::decode(OrderAccess::load_acquire(xaddr));
+    return CompressedKlassPointers::decode(compressed_klass_masked(OrderAccess::load_acquire(xaddr)));
   } else {
-    return OrderAccess::load_acquire(&_metadata._klass);
+    return klass_masked(OrderAccess::load_acquire(&_metadata._wide_storage_props));
   }
 }
 
 Klass** oopDesc::klass_addr(HeapWord* mem) {
   // Only used internally and with CMS and will not work with

@@ -120,10 +127,16 @@
   assert(!UseCompressedClassPointers, "only supported with uncompressed klass pointers");
   ByteSize offset = byte_offset_of(oopDesc, _metadata._klass);
   return (Klass**) (((char*)mem) + in_bytes(offset));
 }
 
+uintptr_t* oopDesc::wide_metadata_addr(HeapWord* mem) {
+  assert(!UseCompressedClassPointers, "only supported with uncompressed klass pointers");
+  ByteSize offset = byte_offset_of(oopDesc, _metadata._wide_storage_props);
+  return (uintptr_t*) (((char*)mem) + in_bytes(offset));
+}
+
 narrowKlass* oopDesc::compressed_klass_addr(HeapWord* mem) {
   assert(UseCompressedClassPointers, "only called by compressed klass pointers");
   ByteSize offset = byte_offset_of(oopDesc, _metadata._compressed_klass);
   return (narrowKlass*) (((char*)mem) + in_bytes(offset));
 }

@@ -138,10 +151,12 @@
 
 #define CHECK_SET_KLASS(k)                                                \
   do {                                                                    \
     assert(Universe::is_bootstrapping() || k != NULL, "NULL Klass");      \
     assert(Universe::is_bootstrapping() || k->is_klass(), "not a Klass"); \
+    assert(((reinterpret_cast<uintptr_t>(k) & (~ oopDesc::klass_mask())) == 0), \
+      "No room for storage props "); \
   } while (0)
 
 void oopDesc::set_klass(Klass* k) {
   CHECK_SET_KLASS(k);
   if (UseCompressedClassPointers) {

@@ -157,14 +172,44 @@
     OrderAccess::release_store(compressed_klass_addr(mem),
                                CompressedKlassPointers::encode_not_null(klass));
   } else {
     OrderAccess::release_store(klass_addr(mem), klass);
   }
+  assert(((oopDesc*)mem)->klass() == klass, "failed oopDesc::klass() encode/decode");
 }
 
+void oopDesc::set_metadata(ArrayStorageProperties storage_props, Klass* klass) {
+  CHECK_SET_KLASS(klass);
+  if (UseCompressedClassPointers) {
+    *compressed_klass_addr() = (CompressedKlassPointers::encode_not_null(klass) | storage_props.encode<narrowKlass>(narrow_storage_props_shift));
+  } else {
+    *wide_metadata_addr((HeapWord*)this) = (reinterpret_cast<uintptr_t>(klass) | storage_props.encode<uintptr_t>(wide_storage_props_shift));
+  }
+}
+
+void oopDesc::release_set_metadata(HeapWord* mem, ArrayStorageProperties storage_props, Klass* klass) {
+  CHECK_SET_KLASS(klass);
+  if (UseCompressedClassPointers) {
+    OrderAccess::release_store(oopDesc::compressed_klass_addr(mem),
+                               CompressedKlassPointers::encode_not_null(klass) | storage_props.encode<narrowKlass>(narrow_storage_props_shift));
+  } else {
+    OrderAccess::release_store(oopDesc::wide_metadata_addr(mem),
+                               (reinterpret_cast<uintptr_t>(klass) | storage_props.encode<uintptr_t>(wide_storage_props_shift)));
+  }
+}
 #undef CHECK_SET_KLASS
 
+
+ArrayStorageProperties oopDesc::array_storage_properties() const {
+  if (UseCompressedClassPointers) {
+    return ArrayStorageProperties(_metadata._narrow_storage_props >> narrow_storage_props_shift);
+  } else {
+    return ArrayStorageProperties(_metadata._wide_storage_props >> wide_storage_props_shift);
+  }
+}
+
+
 int oopDesc::klass_gap() const {
   return *(int*)(((intptr_t)this) + klass_gap_offset_in_bytes());
 }
 
 void oopDesc::set_klass_gap(HeapWord* mem, int v) {

@@ -275,10 +320,12 @@
 
 bool oopDesc::is_instance()  const { return klass()->is_instance_klass();  }
 bool oopDesc::is_array()     const { return klass()->is_array_klass();     }
 bool oopDesc::is_objArray()  const { return klass()->is_objArray_klass();  }
 bool oopDesc::is_typeArray() const { return klass()->is_typeArray_klass(); }
+bool oopDesc::is_value()     const { return klass()->is_value(); }
+bool oopDesc::is_valueArray()  const { return klass()->is_valueArray_klass(); }
 
 void*    oopDesc::field_addr_raw(int offset)     const { return reinterpret_cast<void*>(cast_from_oop<intptr_t>(as_oop()) + offset); }
 void*    oopDesc::field_addr(int offset)         const { return Access<>::resolve(as_oop())->field_addr_raw(offset); }
 
 template <class T>

@@ -328,10 +375,11 @@
 
 bool oopDesc::has_bias_pattern() const {
   return mark()->has_bias_pattern();
 }
 
+
 bool oopDesc::has_bias_pattern_raw() const {
   return mark_raw()->has_bias_pattern();
 }
 
 // Used only for markSweep, scavenging
< prev index next >