8206406: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list

Mon, 09 Jul 2018 15:35:45 +0100

author
aph
date
Mon, 09 Jul 2018 15:35:45 +0100
changeset 9352
80d32985a3eb
parent 9351
bae7d3cdf6af
child 9355
792ccf73293a

8206406: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
Reviewed-by: dholmes

src/share/vm/runtime/stubCodeGenerator.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/stubCodeGenerator.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/runtime/stubCodeGenerator.cpp	Wed Jul 11 02:36:23 2018 -0700
     1.2 +++ b/src/share/vm/runtime/stubCodeGenerator.cpp	Mon Jul 09 15:35:45 2018 +0100
     1.3 @@ -34,12 +34,12 @@
     1.4  
     1.5  // Implementation of StubCodeDesc
     1.6  
     1.7 -StubCodeDesc* StubCodeDesc::_list = NULL;
     1.8 -int           StubCodeDesc::_count = 0;
     1.9 +StubCodeDesc* volatile StubCodeDesc::_list = NULL;
    1.10 +int                    StubCodeDesc::_count = 0;
    1.11  
    1.12  
    1.13  StubCodeDesc* StubCodeDesc::desc_for(address pc) {
    1.14 -  StubCodeDesc* p = _list;
    1.15 +  StubCodeDesc* p = (StubCodeDesc*)OrderAccess::load_ptr_acquire(&_list);
    1.16    while (p != NULL && !p->contains(pc)) p = p->_next;
    1.17    // p == NULL || p->contains(pc)
    1.18    return p;
    1.19 @@ -47,7 +47,7 @@
    1.20  
    1.21  
    1.22  StubCodeDesc* StubCodeDesc::desc_for_index(int index) {
    1.23 -  StubCodeDesc* p = _list;
    1.24 +  StubCodeDesc* p = (StubCodeDesc*)OrderAccess::load_ptr_acquire(&_list);
    1.25    while (p != NULL && p->index() != index) p = p->_next;
    1.26    return p;
    1.27  }
     2.1 --- a/src/share/vm/runtime/stubCodeGenerator.hpp	Wed Jul 11 02:36:23 2018 -0700
     2.2 +++ b/src/share/vm/runtime/stubCodeGenerator.hpp	Mon Jul 09 15:35:45 2018 +0100
     2.3 @@ -38,7 +38,7 @@
     2.4  
     2.5  class StubCodeDesc: public CHeapObj<mtCode> {
     2.6   protected:
     2.7 -  static StubCodeDesc* _list;                  // the list of all descriptors
     2.8 +  static StubCodeDesc* volatile _list;         // the list of all descriptors
     2.9    static int           _count;                 // length of list
    2.10  
    2.11    StubCodeDesc*        _next;                  // the next element in the linked list
    2.12 @@ -69,13 +69,13 @@
    2.13  
    2.14    StubCodeDesc(const char* group, const char* name, address begin) {
    2.15      assert(name != NULL, "no name specified");
    2.16 -    _next           = _list;
    2.17 +    _next           = (StubCodeDesc*)OrderAccess::load_ptr_acquire(&_list);
    2.18      _group          = group;
    2.19      _name           = name;
    2.20      _index          = ++_count; // (never zero)
    2.21      _begin          = begin;
    2.22      _end            = NULL;
    2.23 -    _list           = this;
    2.24 +    OrderAccess::release_store_ptr(&_list, this);
    2.25    };
    2.26  
    2.27    const char* group() const                      { return _group; }

mercurial