changeset 13386:58902da25a31

8185296: java_lang_Class::array_klass should be array_klass_acquire Reviewed-by: eosterlund, kbarrett
author coleenp
date Wed, 26 Jul 2017 10:41:07 -0400
parents 877b95d69748
children 136f607c4bba
files src/share/vm/classfile/javaClasses.cpp src/share/vm/classfile/javaClasses.hpp src/share/vm/oops/instanceKlass.cpp src/share/vm/oops/oop.hpp src/share/vm/oops/oop.inline.hpp
diffstat 5 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/javaClasses.cpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/src/share/vm/classfile/javaClasses.cpp	Wed Jul 26 10:41:07 2017 -0400
@@ -1082,8 +1082,8 @@
   return name;
 }
 
-Klass* java_lang_Class::array_klass(oop java_class) {
-  Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset));
+Klass* java_lang_Class::array_klass_acquire(oop java_class) {
+  Klass* k = ((Klass*)java_class->metadata_field_acquire(_array_klass_offset));
   assert(k == NULL || k->is_klass() && k->is_array_klass(), "should be array klass");
   return k;
 }
--- a/src/share/vm/classfile/javaClasses.hpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/src/share/vm/classfile/javaClasses.hpp	Wed Jul 26 10:41:07 2017 -0400
@@ -236,7 +236,7 @@
   static BasicType primitive_type(oop java_class);
   static oop primitive_mirror(BasicType t);
   // JVM_NewArray support
-  static Klass* array_klass(oop java_class);
+  static Klass* array_klass_acquire(oop java_class);
   static void release_set_array_klass(oop java_class, Klass* klass);
   // compiler support for class operations
   static int klass_offset_in_bytes()                { return _klass_offset; }
--- a/src/share/vm/oops/instanceKlass.cpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/src/share/vm/oops/instanceKlass.cpp	Wed Jul 26 10:41:07 2017 -0400
@@ -2949,7 +2949,7 @@
     st->print(BULLET"fake entry for mirror: ");
     mirrored_klass->print_value_on_maybe_null(st);
     st->cr();
-    Klass* array_klass = java_lang_Class::array_klass(obj);
+    Klass* array_klass = java_lang_Class::array_klass_acquire(obj);
     st->print(BULLET"fake entry for array: ");
     array_klass->print_value_on_maybe_null(st);
     st->cr();
--- a/src/share/vm/oops/oop.hpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/src/share/vm/oops/oop.hpp	Wed Jul 26 10:41:07 2017 -0400
@@ -204,6 +204,7 @@
   inline Metadata* metadata_field(int offset) const;
   inline void metadata_field_put(int offset, Metadata* value);
 
+  inline Metadata* metadata_field_acquire(int offset) const;
   inline void release_metadata_field_put(int offset, Metadata* value);
 
   inline jbyte byte_field(int offset) const;
--- a/src/share/vm/oops/oop.inline.hpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/src/share/vm/oops/oop.inline.hpp	Wed Jul 26 10:41:07 2017 -0400
@@ -446,6 +446,10 @@
 Metadata* oopDesc::metadata_field(int offset) const           { return *metadata_field_addr(offset);   }
 void oopDesc::metadata_field_put(int offset, Metadata* value) { *metadata_field_addr(offset) = value;  }
 
+Metadata* oopDesc::metadata_field_acquire(int offset) const   {
+  return (Metadata*)OrderAccess::load_ptr_acquire(metadata_field_addr(offset));
+}
+
 void oopDesc::release_metadata_field_put(int offset, Metadata* value) {
   OrderAccess::release_store_ptr(metadata_field_addr(offset), value);
 }