# HG changeset patch # User aph # Date 1531146945 -3600 # Node ID 80d32985a3ebe55248108c98f17075bc4208dc04 # Parent bae7d3cdf6afb118c5febb856399064e7fcbd68f 8206406: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list Reviewed-by: dholmes diff -r bae7d3cdf6af -r 80d32985a3eb src/share/vm/runtime/stubCodeGenerator.cpp --- 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; } diff -r bae7d3cdf6af -r 80d32985a3eb src/share/vm/runtime/stubCodeGenerator.hpp --- 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 { 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; }