< prev index next >

src/hotspot/os/posix/os_posix.hpp

Print this page

        

*** 232,341 **** PlatformParker(); }; // Workaround for a bug in macOSX kernel's pthread support (fixed in Mojave?). // Avoid ever allocating a pthread_mutex_t at the same address as one of our ! // former pthread_cond_t, by using freelists of mutexes and condvars. // Conditional to avoid extra indirection and padding loss on other platforms. #ifdef __APPLE__ #define PLATFORM_MONITOR_IMPL_INDIRECT 1 #else #define PLATFORM_MONITOR_IMPL_INDIRECT 0 #endif ! // Platform specific implementations that underpin VM Mutex/Monitor classes ! ! class PlatformMutex : public CHeapObj<mtSynchronizer> { ! #if PLATFORM_MONITOR_IMPL_INDIRECT ! class Mutex : public CHeapObj<mtSynchronizer> { ! public: pthread_mutex_t _mutex; ! Mutex* _next; ! Mutex(); ! ~Mutex(); }; ! Mutex* _impl; ! static pthread_mutex_t _freelist_lock; // used for mutex and cond freelists ! static Mutex* _mutex_freelist; - protected: - class WithFreeListLocked; pthread_mutex_t* mutex() { return &(_impl->_mutex); } public: ! PlatformMutex(); // Use freelist allocation of impl. ! ~PlatformMutex(); static void init(); // Initialize the freelist. #else ! pthread_mutex_t _mutex; ! protected: ! pthread_mutex_t* mutex() { return &_mutex; } public: static void init() {} // Nothing needed for the non-indirect case. ! PlatformMutex(); ! ~PlatformMutex(); #endif // PLATFORM_MONITOR_IMPL_INDIRECT - private: - // Disable copying - PlatformMutex(const PlatformMutex&); - PlatformMutex& operator=(const PlatformMutex&); - public: void lock(); void unlock(); bool try_lock(); - }; - - class PlatformMonitor : public PlatformMutex { - #if PLATFORM_MONITOR_IMPL_INDIRECT - class Cond : public CHeapObj<mtSynchronizer> { - public: - pthread_cond_t _cond; - Cond* _next; - - Cond(); - ~Cond(); - }; - - Cond* _impl; - - static Cond* _cond_freelist; - - pthread_cond_t* cond() { return &(_impl->_cond); } - - public: - PlatformMonitor(); // Use freelist allocation of impl. - ~PlatformMonitor(); - - #else - - pthread_cond_t _cond; - pthread_cond_t* cond() { return &_cond; } - - public: - PlatformMonitor(); - ~PlatformMonitor(); - - #endif // PLATFORM_MONITOR_IMPL_INDIRECT - - private: - // Disable copying - PlatformMonitor(const PlatformMonitor&); - PlatformMonitor& operator=(const PlatformMonitor&); - - public: int wait(jlong millis); void notify(); void notify_all(); }; --- 232,296 ---- PlatformParker(); }; // Workaround for a bug in macOSX kernel's pthread support (fixed in Mojave?). // Avoid ever allocating a pthread_mutex_t at the same address as one of our ! // former pthread_cond_t, by using a freelist of mutex/condvar pairs. // Conditional to avoid extra indirection and padding loss on other platforms. #ifdef __APPLE__ #define PLATFORM_MONITOR_IMPL_INDIRECT 1 #else #define PLATFORM_MONITOR_IMPL_INDIRECT 0 #endif ! // Platform specific implementation that underpins VM Monitor/Mutex class ! class PlatformMonitor : public CHeapObj<mtSynchronizer> { ! class Impl : public CHeapObj<mtSynchronizer> { ! public: pthread_mutex_t _mutex; ! pthread_cond_t _cond; ! Impl* _next; ! Impl(); ! ~Impl(); }; ! #if PLATFORM_MONITOR_IMPL_INDIRECT ! Impl* _impl; pthread_mutex_t* mutex() { return &(_impl->_mutex); } + pthread_cond_t* cond() { return &(_impl->_cond); } + + class WithFreeListLocked; + static pthread_mutex_t _freelist_lock; + static Impl* _freelist; public: ! PlatformMonitor(); // Use freelist allocation of impl. ! ~PlatformMonitor(); static void init(); // Initialize the freelist. #else ! Impl _impl; ! pthread_mutex_t* mutex() { return &(_impl._mutex); } ! pthread_cond_t* cond() { return &(_impl._cond); } public: static void init() {} // Nothing needed for the non-indirect case. ! // Default constructor and destructor. #endif // PLATFORM_MONITOR_IMPL_INDIRECT public: void lock(); void unlock(); bool try_lock(); int wait(jlong millis); void notify(); void notify_all(); };
< prev index next >