changeset 12055:f71f1d9a2e26

8166583: Add oopDesc::klass_or_null_acquire() Summary: Added new function. Reviewed-by: dholmes, tschatzl
author kbarrett
date Fri, 23 Sep 2016 18:23:12 -0400
parents c03738fe20c1
children c2ecbb9ee746
files src/share/vm/oops/oop.hpp src/share/vm/oops/oop.inline.hpp
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/oops/oop.hpp	Fri Sep 23 13:44:01 2016 -0700
+++ b/src/share/vm/oops/oop.hpp	Fri Sep 23 18:23:12 2016 -0400
@@ -83,6 +83,7 @@
 
   inline Klass* klass() const;
   inline Klass* klass_or_null() const volatile;
+  inline Klass* klass_or_null_acquire() const volatile;
   inline Klass** klass_addr();
   inline narrowKlass* compressed_klass_addr();
 
--- a/src/share/vm/oops/oop.inline.hpp	Fri Sep 23 13:44:01 2016 -0700
+++ b/src/share/vm/oops/oop.inline.hpp	Fri Sep 23 18:23:12 2016 -0400
@@ -109,7 +109,6 @@
 }
 
 Klass* oopDesc::klass_or_null() const volatile {
-  // can be NULL in CMS
   if (UseCompressedClassPointers) {
     return Klass::decode_klass(_metadata._compressed_klass);
   } else {
@@ -117,6 +116,17 @@
   }
 }
 
+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 Klass::decode_klass(OrderAccess::load_acquire(xaddr));
+  } else {
+    return (Klass*)OrderAccess::load_ptr_acquire(&_metadata._klass);
+  }
+}
+
 Klass** oopDesc::klass_addr() {
   // Only used internally and with CMS and will not work with
   // UseCompressedOops