8234779: Provide idiom for declaring classes noncopyable

Add NONCOPYABLE macro and uses.

Reviewed-by: dholmes, pliden, coleenp
This commit is contained in:
Kim Barrett 2019-12-03 19:09:30 -05:00
parent 3e0a524547
commit 577e87e5b2
37 changed files with 101 additions and 131 deletions

View File

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

View File

@ -26,6 +26,7 @@
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "runtime/os_perf.hpp" #include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"
#include CPU_HEADER(vm_version_ext) #include CPU_HEADER(vm_version_ext)
#ifdef __APPLE__ #ifdef __APPLE__
@ -72,8 +73,8 @@ class CPUPerformanceInterface::CPUPerformance : public CHeapObj<mtInternal> {
int cpu_load_total_process(double* cpu_load); int cpu_load_total_process(double* cpu_load);
int cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad); int cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad);
CPUPerformance(const CPUPerformance& rhs); // no impl NONCOPYABLE(CPUPerformance);
CPUPerformance& operator=(const CPUPerformance& rhs); // no impl
public: public:
CPUPerformance(); CPUPerformance();
bool initialize(); bool initialize();
@ -264,8 +265,7 @@ class SystemProcessInterface::SystemProcesses : public CHeapObj<mtInternal> {
private: private:
SystemProcesses(); SystemProcesses();
bool initialize(); bool initialize();
SystemProcesses(const SystemProcesses& rhs); // no impl NONCOPYABLE(SystemProcesses);
SystemProcesses& operator=(const SystemProcesses& rhs); // no impl
~SystemProcesses(); ~SystemProcesses();
//information about system processes //information about system processes
@ -407,8 +407,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface; friend class NetworkPerformanceInterface;
private: private:
NetworkPerformance(); NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl NONCOPYABLE(NetworkPerformance);
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
bool initialize(); bool initialize();
~NetworkPerformance(); ~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const; int network_utilization(NetworkInterface** network_interfaces) const;

View File

@ -25,6 +25,8 @@
#ifndef OS_BSD_SEMAPHORE_BSD_HPP #ifndef OS_BSD_SEMAPHORE_BSD_HPP
#define OS_BSD_SEMAPHORE_BSD_HPP #define OS_BSD_SEMAPHORE_BSD_HPP
#include "utilities/globalDefinitions.hpp"
#ifndef __APPLE__ #ifndef __APPLE__
// Use POSIX semaphores. // Use POSIX semaphores.
# include "semaphore_posix.hpp" # include "semaphore_posix.hpp"
@ -37,9 +39,7 @@
class OSXSemaphore : public CHeapObj<mtInternal>{ class OSXSemaphore : public CHeapObj<mtInternal>{
semaphore_t _semaphore; semaphore_t _semaphore;
// Prevent copying and assignment. NONCOPYABLE(OSXSemaphore);
OSXSemaphore(const OSXSemaphore&);
OSXSemaphore& operator=(const OSXSemaphore&);
public: public:
OSXSemaphore(uint value = 0); OSXSemaphore(uint value = 0);

View File

@ -28,6 +28,7 @@
#include "os_linux.inline.hpp" #include "os_linux.inline.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "runtime/os_perf.hpp" #include "runtime/os_perf.hpp"
#include "utilities/globalDefinitions.hpp"
#include CPU_HEADER(vm_version_ext) #include CPU_HEADER(vm_version_ext)
@ -948,8 +949,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
friend class NetworkPerformanceInterface; friend class NetworkPerformanceInterface;
private: private:
NetworkPerformance(); NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl NONCOPYABLE(NetworkPerformance);
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
bool initialize(); bool initialize();
~NetworkPerformance(); ~NetworkPerformance();
int64_t read_counter(const char* iface, const char* counter) const; int64_t read_counter(const char* iface, const char* counter) const;

View File

@ -26,13 +26,12 @@
#define OS_LINUX_WAITBARRIER_LINUX_HPP #define OS_LINUX_WAITBARRIER_LINUX_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
class LinuxWaitBarrier : public CHeapObj<mtInternal> { class LinuxWaitBarrier : public CHeapObj<mtInternal> {
volatile int _futex_barrier; volatile int _futex_barrier;
// Prevent copying and assignment of LinuxWaitBarrier instances. NONCOPYABLE(LinuxWaitBarrier);
LinuxWaitBarrier(const LinuxWaitBarrier&);
LinuxWaitBarrier& operator=(const LinuxWaitBarrier&);
public: public:
LinuxWaitBarrier() : _futex_barrier(0) {}; LinuxWaitBarrier() : _futex_barrier(0) {};

View File

@ -285,10 +285,8 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
#endif // PLATFORM_MONITOR_IMPL_INDIRECT #endif // PLATFORM_MONITOR_IMPL_INDIRECT
private: private:
// Disable copying NONCOPYABLE(PlatformMutex);
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
public: public:
void lock(); void lock();
@ -329,9 +327,7 @@ class PlatformMonitor : public PlatformMutex {
#endif // PLATFORM_MONITOR_IMPL_INDIRECT #endif // PLATFORM_MONITOR_IMPL_INDIRECT
private: private:
// Disable copying NONCOPYABLE(PlatformMonitor);
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);
public: public:
int wait(jlong millis); int wait(jlong millis);

View File

@ -26,15 +26,14 @@
#define OS_POSIX_SEMAPHORE_POSIX_HPP #define OS_POSIX_SEMAPHORE_POSIX_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include <semaphore.h> #include <semaphore.h>
class PosixSemaphore : public CHeapObj<mtInternal> { class PosixSemaphore : public CHeapObj<mtInternal> {
sem_t _semaphore; sem_t _semaphore;
// Prevent copying and assignment. NONCOPYABLE(PosixSemaphore);
PosixSemaphore(const PosixSemaphore&);
PosixSemaphore& operator=(const PosixSemaphore&);
public: public:
PosixSemaphore(uint value = 0); PosixSemaphore(uint value = 0);

View File

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

View File

@ -334,9 +334,7 @@ class PlatformParker : public CHeapObj<mtSynchronizer> {
// Platform specific implementations that underpin VM Mutex/Monitor classes // Platform specific implementations that underpin VM Mutex/Monitor classes
class PlatformMutex : public CHeapObj<mtSynchronizer> { class PlatformMutex : public CHeapObj<mtSynchronizer> {
// Disable copying NONCOPYABLE(PlatformMutex);
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
protected: protected:
mutex_t _mutex; // Native mutex for locking mutex_t _mutex; // Native mutex for locking
@ -352,9 +350,8 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
class PlatformMonitor : public PlatformMutex { class PlatformMonitor : public PlatformMutex {
private: private:
cond_t _cond; // Native condition variable for blocking cond_t _cond; // Native condition variable for blocking
// Disable copying
PlatformMonitor(const PlatformMonitor&); NONCOPYABLE(PlatformMonitor);
PlatformMonitor& operator=(const PlatformMonitor&);
public: public:
PlatformMonitor(); PlatformMonitor();

View File

@ -30,6 +30,7 @@
#include "pdh_interface.hpp" #include "pdh_interface.hpp"
#include "runtime/os_perf.hpp" #include "runtime/os_perf.hpp"
#include "runtime/os.hpp" #include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#include CPU_HEADER(vm_version_ext) #include CPU_HEADER(vm_version_ext)
#include <math.h> #include <math.h>
@ -1355,8 +1356,7 @@ class NetworkPerformanceInterface::NetworkPerformance : public CHeapObj<mtIntern
bool _iphlp_attached; bool _iphlp_attached;
NetworkPerformance(); NetworkPerformance();
NetworkPerformance(const NetworkPerformance& rhs); // no impl NONCOPYABLE(NetworkPerformance);
NetworkPerformance& operator=(const NetworkPerformance& rhs); // no impl
bool initialize(); bool initialize();
~NetworkPerformance(); ~NetworkPerformance();
int network_utilization(NetworkInterface** network_interfaces) const; int network_utilization(NetworkInterface** network_interfaces) const;

View File

@ -190,9 +190,7 @@ class PlatformParker : public CHeapObj<mtSynchronizer> {
// Platform specific implementations that underpin VM Mutex/Monitor classes // Platform specific implementations that underpin VM Mutex/Monitor classes
class PlatformMutex : public CHeapObj<mtSynchronizer> { class PlatformMutex : public CHeapObj<mtSynchronizer> {
// Disable copying NONCOPYABLE(PlatformMutex);
PlatformMutex(const PlatformMutex&);
PlatformMutex& operator=(const PlatformMutex&);
protected: protected:
CRITICAL_SECTION _mutex; // Native mutex for locking CRITICAL_SECTION _mutex; // Native mutex for locking
@ -208,9 +206,7 @@ class PlatformMutex : public CHeapObj<mtSynchronizer> {
class PlatformMonitor : public PlatformMutex { class PlatformMonitor : public PlatformMutex {
private: private:
CONDITION_VARIABLE _cond; // Native condition variable for blocking CONDITION_VARIABLE _cond; // Native condition variable for blocking
// Disable copying NONCOPYABLE(PlatformMonitor);
PlatformMonitor(const PlatformMonitor&);
PlatformMonitor& operator=(const PlatformMonitor&);
public: public:
PlatformMonitor(); PlatformMonitor();

View File

@ -26,15 +26,14 @@
#define OS_WINDOWS_SEMAPHORE_WINDOWS_HPP #define OS_WINDOWS_SEMAPHORE_WINDOWS_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include <windows.h> #include <windows.h>
class WindowsSemaphore : public CHeapObj<mtInternal> { class WindowsSemaphore : public CHeapObj<mtInternal> {
HANDLE _semaphore; HANDLE _semaphore;
// Prevent copying and assignment. NONCOPYABLE(WindowsSemaphore);
WindowsSemaphore(const WindowsSemaphore&);
WindowsSemaphore& operator=(const WindowsSemaphore&);
public: public:
WindowsSemaphore(uint value = 0); WindowsSemaphore(uint value = 0);

View File

@ -44,9 +44,7 @@ class G1FreeIdSet {
uint head_index(uintx head) const; uint head_index(uintx head) const;
uintx make_head(uint index, uintx old_head) const; uintx make_head(uint index, uintx old_head) const;
// Noncopyable. NONCOPYABLE(G1FreeIdSet);
G1FreeIdSet(const G1FreeIdSet&);
G1FreeIdSet& operator=(const G1FreeIdSet&);
public: public:
G1FreeIdSet(uint start, uint size); G1FreeIdSet(uint start, uint size);

View File

@ -37,9 +37,7 @@ class G1SharedDirtyCardQueue {
void** _buffer; void** _buffer;
size_t _index; size_t _index;
// Noncopyable NONCOPYABLE(G1SharedDirtyCardQueue);
G1SharedDirtyCardQueue(const G1SharedDirtyCardQueue&);
G1SharedDirtyCardQueue& operator=(const G1SharedDirtyCardQueue&);
public: public:
G1SharedDirtyCardQueue(G1DirtyCardQueueSet* qset); G1SharedDirtyCardQueue(G1DirtyCardQueueSet* qset);

View File

@ -193,9 +193,7 @@ private:
const Block* _head; const Block* _head;
const Block* _tail; const Block* _tail;
// Noncopyable. NONCOPYABLE(AllocationList);
AllocationList(const AllocationList&);
AllocationList& operator=(const AllocationList&);
public: public:
AllocationList(); AllocationList();

View File

@ -48,9 +48,7 @@ class OopStorage::ActiveArray {
ActiveArray(size_t size); ActiveArray(size_t size);
~ActiveArray(); ~ActiveArray();
// Noncopyable NONCOPYABLE(ActiveArray);
ActiveArray(const ActiveArray&);
ActiveArray& operator=(const ActiveArray&);
static size_t blocks_offset(); static size_t blocks_offset();
Block* const* base_ptr() const; Block* const* base_ptr() const;
@ -118,9 +116,7 @@ class OopStorage::AllocationListEntry {
mutable const Block* _prev; mutable const Block* _prev;
mutable const Block* _next; mutable const Block* _next;
// Noncopyable. NONCOPYABLE(AllocationListEntry);
AllocationListEntry(const AllocationListEntry&);
AllocationListEntry& operator=(const AllocationListEntry&);
public: public:
AllocationListEntry(); AllocationListEntry();
@ -153,9 +149,7 @@ class OopStorage::Block /* No base class, to avoid messing up alignment. */ {
template<typename F, typename BlockPtr> template<typename F, typename BlockPtr>
static bool iterate_impl(F f, BlockPtr b); static bool iterate_impl(F f, BlockPtr b);
// Noncopyable. NONCOPYABLE(Block);
Block(const Block&);
Block& operator=(const Block&);
public: public:
const AllocationListEntry& allocation_list_entry() const; const AllocationListEntry& allocation_list_entry() const;

View File

@ -26,7 +26,7 @@
#define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP #define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
#include "gc/shared/oopStorage.hpp" #include "gc/shared/oopStorage.hpp"
#include "utilities/macros.hpp" #include "utilities/globalDefinitions.hpp"
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Support for parallel and optionally concurrent state iteration. // Support for parallel and optionally concurrent state iteration.
@ -134,9 +134,7 @@ class OopStorage::BasicParState {
uint _estimated_thread_count; uint _estimated_thread_count;
bool _concurrent; bool _concurrent;
// Noncopyable. NONCOPYABLE(BasicParState);
BasicParState(const BasicParState&);
BasicParState& operator=(const BasicParState&);
struct IterationData; struct IterationData;

View File

@ -28,6 +28,7 @@
#include "memory/padded.hpp" #include "memory/padded.hpp"
#include "utilities/align.hpp" #include "utilities/align.hpp"
#include "utilities/debug.hpp" #include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/lockFreeStack.hpp" #include "utilities/lockFreeStack.hpp"
#include "utilities/sizes.hpp" #include "utilities/sizes.hpp"
@ -44,9 +45,7 @@ class PtrQueueSet;
class PtrQueue { class PtrQueue {
friend class VMStructs; friend class VMStructs;
// Noncopyable - not defined. NONCOPYABLE(PtrQueue);
PtrQueue(const PtrQueue&);
PtrQueue& operator=(const PtrQueue&);
// The ptr queue set to which this queue belongs. // The ptr queue set to which this queue belongs.
PtrQueueSet* const _qset; PtrQueueSet* const _qset;
@ -205,6 +204,8 @@ class BufferNode {
BufferNode() : _index(0), _next(NULL) { } BufferNode() : _index(0), _next(NULL) { }
~BufferNode() { } ~BufferNode() { }
NONCOPYABLE(BufferNode);
static size_t buffer_offset() { static size_t buffer_offset() {
return offset_of(BufferNode, _buffer); return offset_of(BufferNode, _buffer);
} }
@ -273,6 +274,8 @@ class BufferNode::Allocator {
void delete_list(BufferNode* list); void delete_list(BufferNode* list);
bool try_transfer_pending(); bool try_transfer_pending();
NONCOPYABLE(Allocator);
public: public:
Allocator(const char* name, size_t buffer_size); Allocator(const char* name, size_t buffer_size);
~Allocator(); ~Allocator();
@ -295,9 +298,7 @@ public:
class PtrQueueSet { class PtrQueueSet {
BufferNode::Allocator* _allocator; BufferNode::Allocator* _allocator;
// Noncopyable - not defined. NONCOPYABLE(PtrQueueSet);
PtrQueueSet(const PtrQueueSet&);
PtrQueueSet& operator=(const PtrQueueSet&);
protected: protected:
bool _all_active; bool _all_active;

View File

@ -28,6 +28,7 @@
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "memory/padded.hpp" #include "memory/padded.hpp"
#include "oops/oopsHierarchy.hpp" #include "oops/oopsHierarchy.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ostream.hpp" #include "utilities/ostream.hpp"
#include "utilities/stack.hpp" #include "utilities/stack.hpp"
@ -514,9 +515,8 @@ class TaskTerminator : public StackObj {
private: private:
ParallelTaskTerminator* _terminator; ParallelTaskTerminator* _terminator;
// Noncopyable. NONCOPYABLE(TaskTerminator);
TaskTerminator(const TaskTerminator&);
TaskTerminator& operator=(const TaskTerminator&);
public: public:
TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set); TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
~TaskTerminator(); ~TaskTerminator();

View File

@ -30,6 +30,7 @@
#include "gc/shenandoah/shenandoahNMethod.hpp" #include "gc/shenandoah/shenandoahNMethod.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "memory/iterator.hpp" #include "memory/iterator.hpp"
#include "utilities/globalDefinitions.hpp"
class ShenandoahHeap; class ShenandoahHeap;
class ShenandoahHeapRegion; class ShenandoahHeapRegion;
@ -53,10 +54,8 @@ private:
ShenandoahParallelCodeHeapIterator* _iters; ShenandoahParallelCodeHeapIterator* _iters;
int _length; int _length;
private: NONCOPYABLE(ShenandoahParallelCodeCacheIterator);
// Noncopyable.
ShenandoahParallelCodeCacheIterator(const ShenandoahParallelCodeCacheIterator& o);
ShenandoahParallelCodeCacheIterator& operator=(const ShenandoahParallelCodeCacheIterator& o);
public: public:
ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps); ShenandoahParallelCodeCacheIterator(const GrowableArray<CodeHeap*>* heaps);
~ShenandoahParallelCodeCacheIterator(); ~ShenandoahParallelCodeCacheIterator();

View File

@ -34,6 +34,7 @@
#include "gc/shenandoah/shenandoahSharedVariables.hpp" #include "gc/shenandoah/shenandoahSharedVariables.hpp"
#include "gc/shenandoah/shenandoahUnload.hpp" #include "gc/shenandoah/shenandoahUnload.hpp"
#include "services/memoryManager.hpp" #include "services/memoryManager.hpp"
#include "utilities/globalDefinitions.hpp"
class ConcurrentGCTimer; class ConcurrentGCTimer;
class ReferenceProcessor; class ReferenceProcessor;
@ -70,8 +71,7 @@ private:
DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0); DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
// No implicit copying: iterators should be passed by reference to capture the state // No implicit copying: iterators should be passed by reference to capture the state
ShenandoahRegionIterator(const ShenandoahRegionIterator& that); NONCOPYABLE(ShenandoahRegionIterator);
ShenandoahRegionIterator& operator=(const ShenandoahRegionIterator& o);
public: public:
ShenandoahRegionIterator(); ShenandoahRegionIterator();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved. * Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as * under the terms of the GNU General Public License version 2 only, as
@ -27,6 +27,7 @@
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahHeap.hpp"
#include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp"
#include "utilities/globalDefinitions.hpp"
class ShenandoahHeapRegionSet; class ShenandoahHeapRegionSet;
@ -40,8 +41,7 @@ private:
DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0); DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
// No implicit copying: iterators should be passed by reference to capture the state // No implicit copying: iterators should be passed by reference to capture the state
ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSetIterator& that); NONCOPYABLE(ShenandoahHeapRegionSetIterator);
ShenandoahHeapRegionSetIterator& operator=(const ShenandoahHeapRegionSetIterator& o);
public: public:
ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set); ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set);

View File

@ -25,6 +25,7 @@
#define SHARE_GC_Z_ZARRAY_HPP #define SHARE_GC_Z_ZARRAY_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
template <typename T> template <typename T>
class ZArray { class ZArray {
@ -35,9 +36,7 @@ private:
size_t _size; size_t _size;
size_t _capacity; size_t _capacity;
// Copy and assignment are not allowed NONCOPYABLE(ZArray);
ZArray(const ZArray<T>& array);
ZArray<T>& operator=(const ZArray<T>& array);
void expand(size_t new_capacity); void expand(size_t new_capacity);

View File

@ -25,6 +25,7 @@
#define SHARE_GC_Z_ZLIST_HPP #define SHARE_GC_Z_ZLIST_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
template <typename T> class ZList; template <typename T> class ZList;
@ -55,9 +56,7 @@ private:
ZListNode<T> _head; ZListNode<T> _head;
size_t _size; size_t _size;
// Passing by value and assignment is not allowed NONCOPYABLE(ZList);
ZList(const ZList<T>& list);
ZList<T>& operator=(const ZList<T>& list);
void verify() const; void verify() const;

View File

@ -28,6 +28,7 @@
#include "jni.h" #include "jni.h"
#include "jfr/utilities/jfrAllocation.hpp" #include "jfr/utilities/jfrAllocation.hpp"
#include "utilities/exceptions.hpp" #include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
class JavaCallArguments; class JavaCallArguments;
class JavaThread; class JavaThread;
@ -86,8 +87,7 @@ class JfrJavaArguments : public StackObj {
int _java_stack_slots; int _java_stack_slots;
Parameters(); Parameters();
Parameters(const Parameters&); // no impl NONCOPYABLE(Parameters);
Parameters& operator=(const Parameters&); // no impl
void push(const JavaValue& value); void push(const JavaValue& value);
void push_large(const JavaValue& value); void push_large(const JavaValue& value);

View File

@ -28,6 +28,7 @@
#include "logging/log.hpp" #include "logging/log.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "oops/array.hpp" #include "oops/array.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/growableArray.hpp" #include "utilities/growableArray.hpp"
#include "utilities/hashtable.inline.hpp" #include "utilities/hashtable.inline.hpp"
@ -108,9 +109,8 @@ public:
class Ref : public CHeapObj<mtInternal> { class Ref : public CHeapObj<mtInternal> {
Writability _writability; Writability _writability;
Ref* _next; Ref* _next;
// Noncopyable. NONCOPYABLE(Ref);
Ref(const Ref&);
Ref& operator=(const Ref&);
protected: protected:
virtual void** mpp() const = 0; virtual void** mpp() const = 0;
Ref(Writability w) : _writability(w), _next(NULL) {} Ref(Writability w) : _writability(w), _next(NULL) {}

View File

@ -29,6 +29,7 @@
#include "memory/metaspace.hpp" #include "memory/metaspace.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "utilities/align.hpp" #include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp"
// Array for metadata allocation // Array for metadata allocation
@ -49,9 +50,7 @@ protected:
} }
private: private:
// Turn off copy constructor and assignment operator. NONCOPYABLE(Array);
Array(const Array<T>&);
void operator=(const Array<T>&);
void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() { void* operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() {
size_t word_size = Array::size(length); size_t word_size = Array::size(length);

View File

@ -26,6 +26,7 @@
#define SHARE_RUNTIME_OS_PERF_HPP #define SHARE_RUNTIME_OS_PERF_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#define FUNCTIONALITY_NOT_IMPLEMENTED -8 #define FUNCTIONALITY_NOT_IMPLEMENTED -8
@ -190,9 +191,8 @@ class NetworkInterface : public ResourceObj {
uint64_t _bytes_out; uint64_t _bytes_out;
NetworkInterface* _next; NetworkInterface* _next;
NetworkInterface(); // no impl NONCOPYABLE(NetworkInterface);
NetworkInterface(const NetworkInterface& rhs); // no impl
NetworkInterface& operator=(const NetworkInterface& rhs); // no impl
public: public:
NetworkInterface(const char* name, uint64_t bytes_in, uint64_t bytes_out, NetworkInterface* next) : NetworkInterface(const char* name, uint64_t bytes_in, uint64_t bytes_out, NetworkInterface* next) :
_name(NULL), _name(NULL),
@ -268,8 +268,8 @@ class NetworkPerformanceInterface : public CHeapObj<mtInternal> {
private: private:
class NetworkPerformance; class NetworkPerformance;
NetworkPerformance* _impl; NetworkPerformance* _impl;
NetworkPerformanceInterface(const NetworkPerformanceInterface& rhs); // no impl NONCOPYABLE(NetworkPerformanceInterface);
NetworkPerformanceInterface& operator=(const NetworkPerformanceInterface& rhs); // no impl
public: public:
NetworkPerformanceInterface(); NetworkPerformanceInterface();
bool initialize(); bool initialize();

View File

@ -26,6 +26,7 @@
#define SHARE_RUNTIME_SEMAPHORE_HPP #define SHARE_RUNTIME_SEMAPHORE_HPP
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#if defined(LINUX) || defined(SOLARIS) || defined(AIX) #if defined(LINUX) || defined(SOLARIS) || defined(AIX)
# include "semaphore_posix.hpp" # include "semaphore_posix.hpp"
@ -43,9 +44,7 @@ class JavaThread;
class Semaphore : public CHeapObj<mtSynchronizer> { class Semaphore : public CHeapObj<mtSynchronizer> {
SemaphoreImpl _impl; SemaphoreImpl _impl;
// Prevent copying and assignment of Semaphore instances. NONCOPYABLE(Semaphore);
Semaphore(const Semaphore&);
Semaphore& operator=(const Semaphore&);
public: public:
Semaphore(uint value = 0) : _impl(value) {} Semaphore(uint value = 0) : _impl(value) {}

View File

@ -48,6 +48,7 @@
#include "runtime/unhandledOops.hpp" #include "runtime/unhandledOops.hpp"
#include "utilities/align.hpp" #include "utilities/align.hpp"
#include "utilities/exceptions.hpp" #include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#ifdef ZERO #ifdef ZERO
# include "stack_zero.hpp" # include "stack_zero.hpp"
@ -875,9 +876,7 @@ class NonJavaThread::Iterator : public StackObj {
uint _protect_enter; uint _protect_enter;
NonJavaThread* _current; NonJavaThread* _current;
// Noncopyable. NONCOPYABLE(Iterator);
Iterator(const Iterator&);
Iterator& operator=(const Iterator&);
public: public:
Iterator(); Iterator();

View File

@ -27,6 +27,7 @@
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "utilities/globalDefinitions.hpp"
// Forward decl; // Forward decl;
class BitMapClosure; class BitMapClosure;
@ -390,9 +391,7 @@ class ArenaBitMap : public BitMap {
ArenaBitMap(Arena* arena, idx_t size_in_bits); ArenaBitMap(Arena* arena, idx_t size_in_bits);
private: private:
// Don't allow copy or assignment. NONCOPYABLE(ArenaBitMap);
ArenaBitMap(const ArenaBitMap&);
ArenaBitMap& operator=(const ArenaBitMap&);
}; };
// A BitMap with storage in the CHeap. // A BitMap with storage in the CHeap.
@ -401,8 +400,7 @@ class CHeapBitMap : public BitMap {
private: private:
// Don't allow copy or assignment, to prevent the // Don't allow copy or assignment, to prevent the
// allocated memory from leaking out to other instances. // allocated memory from leaking out to other instances.
CHeapBitMap(const CHeapBitMap&); NONCOPYABLE(CHeapBitMap);
CHeapBitMap& operator=(const CHeapBitMap&);
// NMT memory type // NMT memory type
MEMFLAGS _flags; MEMFLAGS _flags;

View File

@ -69,6 +69,19 @@
// This file holds all globally used constants & types, class (forward) // This file holds all globally used constants & types, class (forward)
// declarations and a few frequently used utility functions. // declarations and a few frequently used utility functions.
// Declare the named class to be noncopyable. This macro must be used in
// a private part of the class's definition, followed by a semi-colon.
// Doing so provides private declarations for the class's copy constructor
// and assignment operator. Because these operations are private, most
// potential callers will fail to compile because they are inaccessible.
// The operations intentionally lack a definition, to provoke link-time
// failures for calls from contexts where they are accessible, e.g. from
// within the class or from a friend of the class.
// Note: The lack of definitions is still not completely bullet-proof, as
// an apparent call might be optimized away by copy elision.
// For C++11 the declarations should be changed to deleted definitions.
#define NONCOPYABLE(C) C(C const&); C& operator=(C const&) /* next token must be ; */
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Printf-style formatters for fixed- and variable-width types as pointers and // Printf-style formatters for fixed- and variable-width types as pointers and
// integers. These are derived from the definitions in inttypes.h. If the platform // integers. These are derived from the definitions in inttypes.h. If the platform

View File

@ -27,7 +27,7 @@
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
#include "utilities/debug.hpp" #include "utilities/debug.hpp"
#include "utilities/macros.hpp" #include "utilities/globalDefinitions.hpp"
// The LockFreeStack class template provides a lock-free LIFO. The objects // The LockFreeStack class template provides a lock-free LIFO. The objects
// in the sequence are intrusively linked via a member in the objects. As // in the sequence are intrusively linked via a member in the objects. As
@ -69,9 +69,7 @@ class LockFreeStack {
} while (old != cur); } while (old != cur);
} }
// Noncopyable. NONCOPYABLE(LockFreeStack);
LockFreeStack(const LockFreeStack&);
LockFreeStack& operator=(const LockFreeStack&);
public: public:
LockFreeStack() : _top(NULL) {} LockFreeStack() : _top(NULL) {}

View File

@ -43,8 +43,7 @@ DEBUG_ONLY(class ResourceMark;)
// -XX:+DisplayVMOutputToStderr // -XX:+DisplayVMOutputToStderr
class outputStream : public ResourceObj { class outputStream : public ResourceObj {
private: private:
outputStream(const outputStream&); NONCOPYABLE(outputStream);
outputStream& operator=(const outputStream&);
protected: protected:
int _indentation; // current indentation int _indentation; // current indentation

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,9 +55,7 @@ class SingleWriterSynchronizer {
DEBUG_ONLY(volatile uint _writers;) DEBUG_ONLY(volatile uint _writers;)
// Noncopyable. NONCOPYABLE(SingleWriterSynchronizer);
SingleWriterSynchronizer(const SingleWriterSynchronizer&);
SingleWriterSynchronizer& operator=(const SingleWriterSynchronizer&);
public: public:
SingleWriterSynchronizer(); SingleWriterSynchronizer();

View File

@ -28,6 +28,7 @@
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/thread.hpp" #include "runtime/thread.hpp"
#include "utilities/debug.hpp" #include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/waitBarrier_generic.hpp" #include "utilities/waitBarrier_generic.hpp"
#if defined(LINUX) #if defined(LINUX)
@ -81,9 +82,7 @@ template <typename WaitBarrierImpl>
class WaitBarrierType : public CHeapObj<mtInternal> { class WaitBarrierType : public CHeapObj<mtInternal> {
WaitBarrierImpl _impl; WaitBarrierImpl _impl;
// Prevent copying and assignment of WaitBarrier instances. NONCOPYABLE(WaitBarrierType);
WaitBarrierType(const WaitBarrierDefault&);
WaitBarrierType& operator=(const WaitBarrierDefault&);
#ifdef ASSERT #ifdef ASSERT
int _last_arm_tag; int _last_arm_tag;

View File

@ -27,6 +27,7 @@
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/semaphore.hpp" #include "runtime/semaphore.hpp"
#include "utilities/globalDefinitions.hpp"
// In addition to the barrier tag, it uses two counters to keep the semaphore // In addition to the barrier tag, it uses two counters to keep the semaphore
// count correct and not leave any late thread waiting. // count correct and not leave any late thread waiting.
@ -39,9 +40,7 @@ class GenericWaitBarrier : public CHeapObj<mtInternal> {
volatile int _barrier_threads; volatile int _barrier_threads;
Semaphore _sem_barrier; Semaphore _sem_barrier;
// Prevent copying and assignment of GenericWaitBarrier instances. NONCOPYABLE(GenericWaitBarrier);
GenericWaitBarrier(const GenericWaitBarrier&);
GenericWaitBarrier& operator=(const GenericWaitBarrier&);
int wake_if_needed(); int wake_if_needed();