mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 20:03:39 +00:00
8248346: Move OopStorage mutex setup out from OopStorageSet
Reviewed-by: kbarrett, eosterlund
This commit is contained in:
parent
51b7c76a95
commit
46f86477ad
@ -731,15 +731,21 @@ void OopStorage::release(const oop* const* ptrs, size_t size) {
|
||||
|
||||
const size_t initial_active_array_size = 8;
|
||||
|
||||
OopStorage::OopStorage(const char* name,
|
||||
Mutex* allocation_mutex,
|
||||
Mutex* active_mutex) :
|
||||
static Mutex* make_oopstorage_mutex(const char* storage_name,
|
||||
const char* kind,
|
||||
int rank) {
|
||||
char name[256];
|
||||
os::snprintf(name, sizeof(name), "%s %s lock", storage_name, kind);
|
||||
return new PaddedMutex(rank, name, true, Mutex::_safepoint_check_never);
|
||||
}
|
||||
|
||||
OopStorage::OopStorage(const char* name) :
|
||||
_name(os::strdup(name)),
|
||||
_active_array(ActiveArray::create(initial_active_array_size)),
|
||||
_allocation_list(),
|
||||
_deferred_updates(NULL),
|
||||
_allocation_mutex(allocation_mutex),
|
||||
_active_mutex(active_mutex),
|
||||
_allocation_mutex(make_oopstorage_mutex(name, "alloc", Mutex::oopstorage)),
|
||||
_active_mutex(make_oopstorage_mutex(name, "active", Mutex::oopstorage - 1)),
|
||||
_allocation_count(0),
|
||||
_concurrent_iteration_count(0),
|
||||
_needs_cleanup(false)
|
||||
|
||||
@ -74,7 +74,7 @@ class outputStream;
|
||||
|
||||
class OopStorage : public CHeapObj<mtGC> {
|
||||
public:
|
||||
OopStorage(const char* name, Mutex* allocation_mutex, Mutex* active_mutex);
|
||||
explicit OopStorage(const char* name);
|
||||
~OopStorage();
|
||||
|
||||
// These count and usage accessors are racy unless at a safepoint.
|
||||
|
||||
@ -25,8 +25,6 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "gc/shared/oopStorage.hpp"
|
||||
#include "gc/shared/oopStorageSet.hpp"
|
||||
#include "runtime/mutex.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
@ -34,28 +32,14 @@
|
||||
// +1 for NULL singular entry.
|
||||
OopStorage* OopStorageSet::storages[all_count + 1] = {};
|
||||
|
||||
static Mutex* make_oopstorage_mutex(const char* storage_name,
|
||||
const char* kind,
|
||||
int rank) {
|
||||
char name[256];
|
||||
os::snprintf(name, sizeof(name), "%s %s lock", storage_name, kind);
|
||||
return new PaddedMutex(rank, name, true, Mutex::_safepoint_check_never);
|
||||
}
|
||||
|
||||
static OopStorage* make_oopstorage(const char* name) {
|
||||
Mutex* alloc = make_oopstorage_mutex(name, "alloc", Mutex::oopstorage);
|
||||
Mutex* active = make_oopstorage_mutex(name, "active", Mutex::oopstorage - 1);
|
||||
return new OopStorage(name, alloc, active);
|
||||
}
|
||||
|
||||
void OopStorageSet::initialize() {
|
||||
storages[jni_global_index] = make_oopstorage("JNI Global");
|
||||
storages[vm_global_index] = make_oopstorage("VM Global");
|
||||
storages[jni_weak_index] = make_oopstorage("JNI Weak");
|
||||
storages[vm_weak_index] = make_oopstorage("VM Weak");
|
||||
storages[string_table_weak_index] = make_oopstorage("StringTable Weak");
|
||||
storages[jni_global_index] = new OopStorage("JNI Global");
|
||||
storages[vm_global_index] = new OopStorage("VM Global");
|
||||
storages[jni_weak_index] = new OopStorage("JNI Weak");
|
||||
storages[vm_weak_index] = new OopStorage("VM Weak");
|
||||
storages[string_table_weak_index] = new OopStorage("StringTable Weak");
|
||||
storages[resolved_method_table_weak_index] =
|
||||
make_oopstorage("ResolvedMethodTable Weak");
|
||||
new OopStorage("ResolvedMethodTable Weak");
|
||||
|
||||
// Ensure we have all of them.
|
||||
STATIC_ASSERT(all_count == 6);
|
||||
|
||||
@ -183,27 +183,14 @@ public:
|
||||
OopStorageTest();
|
||||
~OopStorageTest();
|
||||
|
||||
Mutex _allocation_mutex;
|
||||
Mutex _active_mutex;
|
||||
OopStorage _storage;
|
||||
|
||||
static const int _active_rank = Mutex::leaf - 1;
|
||||
static const int _allocate_rank = Mutex::leaf;
|
||||
|
||||
class CountingIterateClosure;
|
||||
template<bool is_const> class VM_CountAtSafepoint;
|
||||
};
|
||||
|
||||
OopStorageTest::OopStorageTest() :
|
||||
_allocation_mutex(_allocate_rank,
|
||||
"test_OopStorage_allocation",
|
||||
false,
|
||||
Mutex::_safepoint_check_never),
|
||||
_active_mutex(_active_rank,
|
||||
"test_OopStorage_active",
|
||||
false,
|
||||
Mutex::_safepoint_check_never),
|
||||
_storage("Test Storage", &_allocation_mutex, &_active_mutex)
|
||||
_storage("Test Storage")
|
||||
{ }
|
||||
|
||||
OopStorageTest::~OopStorageTest() {
|
||||
|
||||
@ -67,11 +67,6 @@ public:
|
||||
|
||||
static WorkGang* _workers;
|
||||
|
||||
static const int _active_rank = Mutex::leaf - 1;
|
||||
static const int _allocate_rank = Mutex::leaf;
|
||||
|
||||
Mutex _allocate_mutex;
|
||||
Mutex _active_mutex;
|
||||
OopStorage _storage;
|
||||
oop* _entries[_storage_entries];
|
||||
};
|
||||
@ -92,15 +87,7 @@ WorkGang* OopStorageParIterPerf::workers() const {
|
||||
}
|
||||
|
||||
OopStorageParIterPerf::OopStorageParIterPerf() :
|
||||
_allocate_mutex(_allocate_rank,
|
||||
"test_OopStorage_parperf_allocate",
|
||||
false,
|
||||
Mutex::_safepoint_check_never),
|
||||
_active_mutex(_active_rank,
|
||||
"test_OopStorage_parperf_active",
|
||||
false,
|
||||
Mutex::_safepoint_check_never),
|
||||
_storage("Test Storage", &_allocate_mutex, &_active_mutex)
|
||||
_storage("Test Storage")
|
||||
{
|
||||
for (size_t i = 0; i < _storage_entries; ++i) {
|
||||
_entries[i] = _storage.allocate();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user