8224932: Shenandoah: Rename ShenandoahHeapLock, make it general purpose lock
Reviewed-by: shade
This commit is contained in:
parent
b33580af3e
commit
36144f235b
@ -29,7 +29,7 @@
|
|||||||
#include "gc/shared/collectedHeap.hpp"
|
#include "gc/shared/collectedHeap.hpp"
|
||||||
#include "gc/shenandoah/shenandoahAsserts.hpp"
|
#include "gc/shenandoah/shenandoahAsserts.hpp"
|
||||||
#include "gc/shenandoah/shenandoahAllocRequest.hpp"
|
#include "gc/shenandoah/shenandoahAllocRequest.hpp"
|
||||||
#include "gc/shenandoah/shenandoahHeapLock.hpp"
|
#include "gc/shenandoah/shenandoahLock.hpp"
|
||||||
#include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
|
#include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
|
||||||
#include "gc/shenandoah/shenandoahSharedVariables.hpp"
|
#include "gc/shenandoah/shenandoahSharedVariables.hpp"
|
||||||
#include "services/memoryManager.hpp"
|
#include "services/memoryManager.hpp"
|
||||||
@ -103,6 +103,8 @@ public:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef ShenandoahLock ShenandoahHeapLock;
|
||||||
|
typedef ShenandoahLocker ShenandoahHeapLocker;
|
||||||
|
|
||||||
// Shenandoah GC is low-pause concurrent GC that uses Brooks forwarding pointers
|
// Shenandoah GC is low-pause concurrent GC that uses Brooks forwarding pointers
|
||||||
// to encode forwarding data. See BrooksPointer for details on forwarding data encoding.
|
// to encode forwarding data. See BrooksPointer for details on forwarding data encoding.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
|
* Copyright (c) 2017, 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
|
||||||
@ -21,13 +21,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHHEAPLOCK_HPP
|
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHLOCK_HPP
|
||||||
#define SHARE_GC_SHENANDOAH_SHENANDOAHHEAPLOCK_HPP
|
#define SHARE_GC_SHENANDOAH_SHENANDOAHLOCK_HPP
|
||||||
|
|
||||||
#include "memory/allocation.hpp"
|
#include "memory/allocation.hpp"
|
||||||
#include "runtime/thread.hpp"
|
#include "runtime/thread.hpp"
|
||||||
|
|
||||||
class ShenandoahHeapLock {
|
class ShenandoahLock {
|
||||||
private:
|
private:
|
||||||
enum LockState { unlocked = 0, locked = 1 };
|
enum LockState { unlocked = 0, locked = 1 };
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ private:
|
|||||||
DEFINE_PAD_MINUS_SIZE(2, DEFAULT_CACHE_LINE_SIZE, 0);
|
DEFINE_PAD_MINUS_SIZE(2, DEFAULT_CACHE_LINE_SIZE, 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShenandoahHeapLock() : _state(unlocked), _owner(NULL) {};
|
ShenandoahLock() : _state(unlocked), _owner(NULL) {};
|
||||||
|
|
||||||
void lock() {
|
void lock() {
|
||||||
Thread::SpinAcquire(&_state, "Shenandoah Heap Lock");
|
Thread::SpinAcquire(&_state, "Shenandoah Heap Lock");
|
||||||
@ -76,18 +76,21 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShenandoahHeapLocker : public StackObj {
|
class ShenandoahLocker : public StackObj {
|
||||||
private:
|
private:
|
||||||
ShenandoahHeapLock* _lock;
|
ShenandoahLock* const _lock;
|
||||||
public:
|
public:
|
||||||
ShenandoahHeapLocker(ShenandoahHeapLock* lock) {
|
ShenandoahLocker(ShenandoahLock* lock) : _lock(lock) {
|
||||||
_lock = lock;
|
if (_lock != NULL) {
|
||||||
_lock->lock();
|
_lock->lock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~ShenandoahHeapLocker() {
|
~ShenandoahLocker() {
|
||||||
_lock->unlock();
|
if (_lock != NULL) {
|
||||||
|
_lock->unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAPLOCK_HPP
|
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHLOCK_HPP
|
Loading…
x
Reference in New Issue
Block a user