Skip to content

Commit

Permalink
8295013: OopStorage should derive from CHeapObjBase
Browse files Browse the repository at this point in the history
Reviewed-by: stefank, tschatzl
  • Loading branch information
Kim Barrett committed Oct 11, 2022
1 parent 3a980b9 commit 94a9b04
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 177 deletions.
15 changes: 5 additions & 10 deletions src/hotspot/share/gc/shared/oopStorage.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -805,6 +805,10 @@ void OopStorage::release(const oop* const* ptrs, size_t size) {
}
}

OopStorage* OopStorage::create(const char* name, MEMFLAGS memflags) {
return new (memflags) OopStorage(name, memflags);
}

const size_t initial_active_array_size = 8;

static Mutex* make_oopstorage_mutex(const char* storage_name,
Expand All @@ -815,15 +819,6 @@ static Mutex* make_oopstorage_mutex(const char* storage_name,
return new PaddedMutex(rank, name);
}

void* OopStorage::operator new(size_t size, MEMFLAGS memflags) {
assert(size >= sizeof(OopStorage), "precondition");
return NEW_C_HEAP_ARRAY(char, size, memflags);
}

void OopStorage::operator delete(void* obj, MEMFLAGS /* memflags */) {
FREE_C_HEAP_ARRAY(char, obj);
}

OopStorage::OopStorage(const char* name, MEMFLAGS memflags) :
_name(os::strdup(name)),
_active_array(ActiveArray::create(initial_active_array_size, memflags)),
Expand Down
13 changes: 7 additions & 6 deletions src/hotspot/share/gc/shared/oopStorage.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -72,14 +72,11 @@ class outputStream;
// interactions for this protocol. Similarly, see the allocate() function for
// a discussion of allocation.

class OopStorage {
class OopStorage : public CHeapObjBase {
public:
explicit OopStorage(const char* name, MEMFLAGS memflags);
static OopStorage* create(const char* name, MEMFLAGS memflags);
~OopStorage();

void* operator new(size_t size, MEMFLAGS memflags);
void operator delete(void* obj, MEMFLAGS memflags);

// These count and usage accessors are racy unless at a safepoint.

// The number of allocated and not yet released entries.
Expand Down Expand Up @@ -282,6 +279,10 @@ class OopStorage {
// Flag indicating this storage object is a candidate for empty block deletion.
volatile bool _needs_cleanup;

// Clients construct via "create" factory function.
OopStorage(const char* name, MEMFLAGS memflags);
NONCOPYABLE(OopStorage);

bool try_add_block();
Block* block_for_allocation();
void log_block_transition(Block* block, const char* new_state) const;
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/oopStorageSet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,15 +34,15 @@ OopStorage* OopStorageSet::_storages[all_count] = {};
OopStorage* OopStorageSet::create_strong(const char* name, MEMFLAGS memflags) {
static uint registered_strong = 0;
assert(registered_strong < strong_count, "More registered strong storages than slots");
OopStorage* storage = new (memflags) OopStorage(name, memflags);
OopStorage* storage = OopStorage::create(name, memflags);
_storages[strong_start + registered_strong++] = storage;
return storage;
}

OopStorage* OopStorageSet::create_weak(const char* name, MEMFLAGS memflags) {
static uint registered_weak = 0;
assert(registered_weak < weak_count, "More registered strong storages than slots");
OopStorage* storage = new (memflags) OopStorage(name, memflags);
OopStorage* storage = OopStorage::create(name, memflags);
_storages[weak_start + registered_weak++] = storage;
return storage;
}
Expand Down

1 comment on commit 94a9b04

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.