8185296: java_lang_Class::array_klass should be array_klass_acquire
authorcoleenp
Wed, 26 Jul 2017 10:41:07 -0400
changeset 46722 ae2cfffe2e64
parent 46721 5ea48e85ca90
child 46723 5c418c5fcade
8185296: java_lang_Class::array_klass should be array_klass_acquire Reviewed-by: eosterlund, kbarrett
hotspot/src/share/vm/classfile/javaClasses.cpp
hotspot/src/share/vm/classfile/javaClasses.hpp
hotspot/src/share/vm/oops/instanceKlass.cpp
hotspot/src/share/vm/oops/oop.hpp
hotspot/src/share/vm/oops/oop.inline.hpp
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/hotspot/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/hotspot/src/share/vm/classfile/javaClasses.hpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/hotspot/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/hotspot/src/share/vm/oops/instanceKlass.cpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/hotspot/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/hotspot/src/share/vm/oops/oop.hpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/hotspot/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/hotspot/src/share/vm/oops/oop.inline.hpp	Wed Jul 26 11:27:51 2017 +0200
+++ b/hotspot/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);
 }