changeset 8677:80d32985a3eb

8206406: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list Reviewed-by: dholmes
author aph
date Mon, 09 Jul 2018 15:35:45 +0100
parents bae7d3cdf6af
children 792ccf73293a
files src/share/vm/runtime/stubCodeGenerator.cpp src/share/vm/runtime/stubCodeGenerator.hpp
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/stubCodeGenerator.cpp	Wed Jul 11 02:36:23 2018 -0700
+++ b/src/share/vm/runtime/stubCodeGenerator.cpp	Mon Jul 09 15:35:45 2018 +0100
@@ -34,12 +34,12 @@
 
 // Implementation of StubCodeDesc
 
-StubCodeDesc* StubCodeDesc::_list = NULL;
-int           StubCodeDesc::_count = 0;
+StubCodeDesc* volatile StubCodeDesc::_list = NULL;
+int                    StubCodeDesc::_count = 0;
 
 
 StubCodeDesc* StubCodeDesc::desc_for(address pc) {
-  StubCodeDesc* p = _list;
+  StubCodeDesc* p = (StubCodeDesc*)OrderAccess::load_ptr_acquire(&_list);
   while (p != NULL && !p->contains(pc)) p = p->_next;
   // p == NULL || p->contains(pc)
   return p;
@@ -47,7 +47,7 @@
 
 
 StubCodeDesc* StubCodeDesc::desc_for_index(int index) {
-  StubCodeDesc* p = _list;
+  StubCodeDesc* p = (StubCodeDesc*)OrderAccess::load_ptr_acquire(&_list);
   while (p != NULL && p->index() != index) p = p->_next;
   return p;
 }
--- a/src/share/vm/runtime/stubCodeGenerator.hpp	Wed Jul 11 02:36:23 2018 -0700
+++ b/src/share/vm/runtime/stubCodeGenerator.hpp	Mon Jul 09 15:35:45 2018 +0100
@@ -38,7 +38,7 @@
 
 class StubCodeDesc: public CHeapObj<mtCode> {
  protected:
-  static StubCodeDesc* _list;                  // the list of all descriptors
+  static StubCodeDesc* volatile _list;         // the list of all descriptors
   static int           _count;                 // length of list
 
   StubCodeDesc*        _next;                  // the next element in the linked list
@@ -69,13 +69,13 @@
 
   StubCodeDesc(const char* group, const char* name, address begin) {
     assert(name != NULL, "no name specified");
-    _next           = _list;
+    _next           = (StubCodeDesc*)OrderAccess::load_ptr_acquire(&_list);
     _group          = group;
     _name           = name;
     _index          = ++_count; // (never zero)
     _begin          = begin;
     _end            = NULL;
-    _list           = this;
+    OrderAccess::release_store_ptr(&_list, this);
   };
 
   const char* group() const                      { return _group; }