Skip to content
Permalink
Browse files

8234779: Provide idiom for declaring classes noncopyable

Add NONCOPYABLE macro and uses.

Reviewed-by: dholmes, pliden, coleenp
  • Loading branch information
Kim Barrett
Kim Barrett committed Dec 4, 2019
1 parent 3e0a524 commit 577e87e5b27a3f4c590258b370a42c511f724cbc
Showing with 101 additions and 131 deletions.
  1. +2 −2 src/hotspot/os/aix/os_perf_aix.cpp
  2. +5 −6 src/hotspot/os/bsd/os_perf_bsd.cpp
  3. +3 −3 src/hotspot/os/bsd/semaphore_bsd.hpp
  4. +2 −2 src/hotspot/os/linux/os_perf_linux.cpp
  5. +2 −3 src/hotspot/os/linux/waitBarrier_linux.hpp
  6. +3 −7 src/hotspot/os/posix/os_posix.hpp
  7. +2 −3 src/hotspot/os/posix/semaphore_posix.hpp
  8. +2 −2 src/hotspot/os/solaris/os_perf_solaris.cpp
  9. +3 −6 src/hotspot/os/solaris/os_solaris.hpp
  10. +2 −2 src/hotspot/os/windows/os_perf_windows.cpp
  11. +2 −6 src/hotspot/os/windows/os_windows.hpp
  12. +2 −3 src/hotspot/os/windows/semaphore_windows.hpp
  13. +1 −3 src/hotspot/share/gc/g1/g1FreeIdSet.hpp
  14. +1 −3 src/hotspot/share/gc/g1/g1SharedDirtyCardQueue.hpp
  15. +1 −3 src/hotspot/share/gc/shared/oopStorage.hpp
  16. +3 −9 src/hotspot/share/gc/shared/oopStorage.inline.hpp
  17. +2 −4 src/hotspot/share/gc/shared/oopStorageParState.hpp
  18. +7 −6 src/hotspot/share/gc/shared/ptrQueue.hpp
  19. +3 −3 src/hotspot/share/gc/shared/taskqueue.hpp
  20. +3 −4 src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.hpp
  21. +2 −2 src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
  22. +3 −3 src/hotspot/share/gc/shenandoah/shenandoahHeapRegionSet.hpp
  23. +2 −3 src/hotspot/share/gc/z/zArray.hpp
  24. +2 −3 src/hotspot/share/gc/z/zList.hpp
  25. +2 −2 src/hotspot/share/jfr/jni/jfrJavaCall.hpp
  26. +3 −3 src/hotspot/share/memory/metaspaceClosure.hpp
  27. +2 −3 src/hotspot/share/oops/array.hpp
  28. +5 −5 src/hotspot/share/runtime/os_perf.hpp
  29. +2 −3 src/hotspot/share/runtime/semaphore.hpp
  30. +2 −3 src/hotspot/share/runtime/thread.hpp
  31. +3 −5 src/hotspot/share/utilities/bitMap.hpp
  32. +13 −0 src/hotspot/share/utilities/globalDefinitions.hpp
  33. +2 −4 src/hotspot/share/utilities/lockFreeStack.hpp
  34. +1 −2 src/hotspot/share/utilities/ostream.hpp
  35. +2 −4 src/hotspot/share/utilities/singleWriterSynchronizer.hpp
  36. +2 −3 src/hotspot/share/utilities/waitBarrier.hpp
  37. +2 −3 src/hotspot/share/utilities/waitBarrier_generic.hpp
@@ -28,6 +28,7 @@
#include "os_aix.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"

#include CPU_HEADER(vm_version_ext)

@@ -884,8 +885,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;
@@ -26,6 +26,7 @@
#include "memory/resourceArea.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"
#include CPU_HEADER(vm_version_ext)

#ifdef __APPLE__
@@ -72,8 +73,8 @@ class CPUPerformanceInterface::CPUPerformance : public CHeapObj<mtInternal> {
int cpu_load_total_process(double* cpu_load);
int cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad);

CPUPerformance(const CPUPerformance& rhs); // no impl
CPUPerformance& operator=(const CPUPerformance& rhs); // no impl
NONCOPYABLE(CPUPerformance);

public:
CPUPerformance();
bool initialize();
@@ -264,8 +265,7 @@ class SystemProcessInterface::SystemProcesses : public CHeapObj<mtInternal> {
private:
SystemProcesses();
bool initialize();
SystemProcesses(const SystemProcesses& rhs); // no impl
SystemProcesses& operator=(const SystemProcesses& rhs); // no impl
NONCOPYABLE(SystemProcesses);
~SystemProcesses();

//information about system processes
@@ -407,8 +407,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;
@@ -25,6 +25,8 @@
#ifndef OS_BSD_SEMAPHORE_BSD_HPP
#define OS_BSD_SEMAPHORE_BSD_HPP

#include "utilities/globalDefinitions.hpp"

#ifndef __APPLE__
// Use POSIX semaphores.
# include "semaphore_posix.hpp"
@@ -37,9 +39,7 @@
class OSXSemaphore : public CHeapObj<mtInternal>{
semaphore_t _semaphore;

// Prevent copying and assignment.
OSXSemaphore(const OSXSemaphore&);
OSXSemaphore& operator=(const OSXSemaphore&);
NONCOPYABLE(OSXSemaphore);

public:
OSXSemaphore(uint value = 0);
@@ -28,6 +28,7 @@
#include "os_linux.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"

#include CPU_HEADER(vm_version_ext)

@@ -948,8 +949,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int64_t read_counter(const char* iface, const char* counter) const;
@@ -26,13 +26,12 @@
#define OS_LINUX_WAITBARRIER_LINUX_HPP

#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"

class LinuxWaitBarrier : public CHeapObj<mtInternal> {
volatile int _futex_barrier;

// Prevent copying and assignment of LinuxWaitBarrier instances.
LinuxWaitBarrier(const LinuxWaitBarrier&);
LinuxWaitBarrier& operator=(const LinuxWaitBarrier&);
NONCOPYABLE(LinuxWaitBarrier);

public:
LinuxWaitBarrier() : _futex_barrier(0) {};
@@ -285,10 +285,8 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {

#endif // PLATFORM_MONITOR_IMPL_INDIRECT

private:
// Disable copying
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
private:
NONCOPYABLE(PlatformMutex);

public:
void lock();
@@ -329,9 +327,7 @@ class PlatformMonitor : public PlatformMutex {
#endif // PLATFORM_MONITOR_IMPL_INDIRECT

private:
// Disable copying
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);
NONCOPYABLE(PlatformMonitor);

public:
int wait(jlong millis);
@@ -26,15 +26,14 @@
#define OS_POSIX_SEMAPHORE_POSIX_HPP

#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"

#include <semaphore.h>

class PosixSemaphore : public CHeapObj<mtInternal> {
sem_t _semaphore;

// Prevent copying and assignment.
PosixSemaphore(const PosixSemaphore&);
PosixSemaphore& operator=(const PosixSemaphore&);
NONCOPYABLE(PosixSemaphore);

public:
PosixSemaphore(uint value = 0);
@@ -28,6 +28,7 @@
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "os_solaris.inline.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"

#include CPU_HEADER(vm_version_ext)
@@ -737,8 +738,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface;
private:
NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;
@@ -334,9 +334,7 @@ class PlatformParker : public CHeapObj<mtSynchronizer> {
// Platform specific implementations that underpin VM Mutex/Monitor classes

class PlatformMutex : public CHeapObj<mtSynchronizer> {
// Disable copying
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
NONCOPYABLE(PlatformMutex);

protected:
mutex_t _mutex; // Native mutex for locking
@@ -352,9 +350,8 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
class PlatformMonitor : public PlatformMutex {
private:
cond_t _cond; // Native condition variable for blocking
// Disable copying
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);

NONCOPYABLE(PlatformMonitor);

public:
PlatformMonitor();
@@ -30,6 +30,7 @@
#include "pdh_interface.hpp"
#include "runtime/os_perf.hpp"
#include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include CPU_HEADER(vm_version_ext)
#include <math.h>
@@ -1355,8 +1356,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
bool _iphlp_attached;

NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
NONCOPYABLE(NetworkPerformance);
bool initialize();
~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const;
@@ -190,9 +190,7 @@ class PlatformParker : public CHeapObj<mtSynchronizer> {
// Platform specific implementations that underpin VM Mutex/Monitor classes

class PlatformMutex : public CHeapObj<mtSynchronizer> {
// Disable copying
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
NONCOPYABLE(PlatformMutex);

protected:
CRITICAL_SECTION _mutex; // Native mutex for locking
@@ -208,9 +206,7 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
class PlatformMonitor : public PlatformMutex {
private:
CONDITION_VARIABLE _cond; // Native condition variable for blocking
// Disable copying
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);
NONCOPYABLE(PlatformMonitor);

public:
PlatformMonitor();
@@ -26,15 +26,14 @@
#define OS_WINDOWS_SEMAPHORE_WINDOWS_HPP

#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"

#include <windows.h>

class WindowsSemaphore : public CHeapObj<mtInternal> {
HANDLE _semaphore;

// Prevent copying and assignment.
WindowsSemaphore(const WindowsSemaphore&);
WindowsSemaphore& operator=(const WindowsSemaphore&);
NONCOPYABLE(WindowsSemaphore);

public:
WindowsSemaphore(uint value = 0);
@@ -44,9 +44,7 @@ class G1FreeIdSet {
uint head_index(uintx head) const;
uintx make_head(uint index, uintx old_head) const;

// Noncopyable.
G1FreeIdSet(const G1FreeIdSet&);
G1FreeIdSet& operator=(const G1FreeIdSet&);
NONCOPYABLE(G1FreeIdSet);

public:
G1FreeIdSet(uint start, uint size);
@@ -37,9 +37,7 @@ class G1SharedDirtyCardQueue {
void** _buffer;
size_t _index;

// Noncopyable
G1SharedDirtyCardQueue(const G1SharedDirtyCardQueue&);
G1SharedDirtyCardQueue& operator=(const G1SharedDirtyCardQueue&);
NONCOPYABLE(G1SharedDirtyCardQueue);

public:
G1SharedDirtyCardQueue(G1DirtyCardQueueSet* qset);
@@ -193,9 +193,7 @@ class OopStorage : public CHeapObj<mtGC> {
const Block* _head;
const Block* _tail;

// Noncopyable.
AllocationList(const AllocationList&);
AllocationList& operator=(const AllocationList&);
NONCOPYABLE(AllocationList);

public:
AllocationList();
@@ -48,9 +48,7 @@ class OopStorage::ActiveArray {
ActiveArray(size_t size);
~ActiveArray();

// Noncopyable
ActiveArray(const ActiveArray&);
ActiveArray& operator=(const ActiveArray&);
NONCOPYABLE(ActiveArray);

static size_t blocks_offset();
Block* const* base_ptr() const;
@@ -118,9 +116,7 @@ class OopStorage::AllocationListEntry {
mutable const Block* _prev;
mutable const Block* _next;

// Noncopyable.
AllocationListEntry(const AllocationListEntry&);
AllocationListEntry& operator=(const AllocationListEntry&);
NONCOPYABLE(AllocationListEntry);

public:
AllocationListEntry();
@@ -153,9 +149,7 @@ class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
template<typename F, typename BlockPtr>
static bool iterate_impl(F f, BlockPtr b);

// Noncopyable.
Block(const Block&);
Block& operator=(const Block&);
NONCOPYABLE(Block);

public:
const AllocationListEntry& allocation_list_entry() const;
@@ -26,7 +26,7 @@
#define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP

#include "gc/shared/oopStorage.hpp"
#include "utilities/macros.hpp"
#include "utilities/globalDefinitions.hpp"

//////////////////////////////////////////////////////////////////////////////
// Support for parallel and optionally concurrent state iteration.
@@ -134,9 +134,7 @@ class OopStorage::BasicParState {
uint _estimated_thread_count;
bool _concurrent;

// Noncopyable.
BasicParState(const BasicParState&);
BasicParState& operator=(const BasicParState&);
NONCOPYABLE(BasicParState);

struct IterationData;

@@ -28,6 +28,7 @@
#include "memory/padded.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/lockFreeStack.hpp"
#include "utilities/sizes.hpp"

@@ -44,9 +45,7 @@ class PtrQueueSet;
class PtrQueue {
friend class VMStructs;

// Noncopyable - not defined.
PtrQueue(const PtrQueue&);
PtrQueue& operator=(const PtrQueue&);
NONCOPYABLE(PtrQueue);

// The ptr queue set to which this queue belongs.
PtrQueueSet* const _qset;
@@ -205,6 +204,8 @@ class BufferNode {
BufferNode() : _index(0), _next(NULL) { }
~BufferNode() { }

NONCOPYABLE(BufferNode);

static size_t buffer_offset() {
return offset_of(BufferNode, _buffer);
}
@@ -273,6 +274,8 @@ class BufferNode::Allocator {
void delete_list(BufferNode* list);
bool try_transfer_pending();

NONCOPYABLE(Allocator);

public:
Allocator(const char* name, size_t buffer_size);
~Allocator();
@@ -295,9 +298,7 @@ class BufferNode::Allocator {
class PtrQueueSet {
BufferNode::Allocator* _allocator;

// Noncopyable - not defined.
PtrQueueSet(const PtrQueueSet&);
PtrQueueSet& operator=(const PtrQueueSet&);
NONCOPYABLE(PtrQueueSet);

protected:
bool _all_active;

0 comments on commit 577e87e

Please sign in to comment.
You can’t perform that action at this time.