Merge
This commit is contained in:
commit
d1fdfbc634
@ -112,7 +112,7 @@ void DirtyCardQueueSet::initialize(CardTableEntryClosure* cl,
|
|||||||
fl_owner);
|
fl_owner);
|
||||||
set_buffer_size(G1UpdateBufferSize);
|
set_buffer_size(G1UpdateBufferSize);
|
||||||
_shared_dirty_card_queue.set_lock(lock);
|
_shared_dirty_card_queue.set_lock(lock);
|
||||||
_free_ids = new FreeIdSet((int) num_par_ids(), _cbl_mon);
|
_free_ids = new FreeIdSet(num_par_ids(), _cbl_mon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirtyCardQueueSet::handle_zero_index_for_thread(JavaThread* t) {
|
void DirtyCardQueueSet::handle_zero_index_for_thread(JavaThread* t) {
|
||||||
|
@ -500,122 +500,42 @@ bool SequentialSubTasksDone::all_tasks_completed() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FreeIdSet::_stat_init = false;
|
FreeIdSet::FreeIdSet(uint size, Monitor* mon) :
|
||||||
FreeIdSet* FreeIdSet::_sets[NSets];
|
_size(size), _mon(mon), _hd(0), _waiters(0), _claimed(0)
|
||||||
bool FreeIdSet::_safepoint;
|
|
||||||
|
|
||||||
FreeIdSet::FreeIdSet(int sz, Monitor* mon) :
|
|
||||||
_sz(sz), _mon(mon), _hd(0), _waiters(0), _index(-1), _claimed(0)
|
|
||||||
{
|
{
|
||||||
_ids = NEW_C_HEAP_ARRAY(int, sz, mtInternal);
|
guarantee(size != 0, "must be");
|
||||||
for (int i = 0; i < sz; i++) _ids[i] = i+1;
|
_ids = NEW_C_HEAP_ARRAY(uint, size, mtGC);
|
||||||
_ids[sz-1] = end_of_list; // end of list.
|
for (uint i = 0; i < size - 1; i++) {
|
||||||
if (_stat_init) {
|
_ids[i] = i+1;
|
||||||
for (int j = 0; j < NSets; j++) _sets[j] = NULL;
|
|
||||||
_stat_init = true;
|
|
||||||
}
|
}
|
||||||
// Add to sets. (This should happen while the system is still single-threaded.)
|
_ids[size-1] = end_of_list; // end of list.
|
||||||
for (int j = 0; j < NSets; j++) {
|
|
||||||
if (_sets[j] == NULL) {
|
|
||||||
_sets[j] = this;
|
|
||||||
_index = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
guarantee(_index != -1, "Too many FreeIdSets in use!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeIdSet::~FreeIdSet() {
|
FreeIdSet::~FreeIdSet() {
|
||||||
_sets[_index] = NULL;
|
FREE_C_HEAP_ARRAY(uint, _ids);
|
||||||
FREE_C_HEAP_ARRAY(int, _ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeIdSet::set_safepoint(bool b) {
|
uint FreeIdSet::claim_par_id() {
|
||||||
_safepoint = b;
|
|
||||||
if (b) {
|
|
||||||
for (int j = 0; j < NSets; j++) {
|
|
||||||
if (_sets[j] != NULL && _sets[j]->_waiters > 0) {
|
|
||||||
Monitor* mon = _sets[j]->_mon;
|
|
||||||
mon->lock_without_safepoint_check();
|
|
||||||
mon->notify_all();
|
|
||||||
mon->unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FID_STATS 0
|
|
||||||
|
|
||||||
int FreeIdSet::claim_par_id() {
|
|
||||||
#if FID_STATS
|
|
||||||
thread_t tslf = thr_self();
|
|
||||||
tty->print("claim_par_id[%d]: sz = %d, claimed = %d\n", tslf, _sz, _claimed);
|
|
||||||
#endif
|
|
||||||
MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag);
|
MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag);
|
||||||
while (!_safepoint && _hd == end_of_list) {
|
while (_hd == end_of_list) {
|
||||||
_waiters++;
|
_waiters++;
|
||||||
#if FID_STATS
|
|
||||||
if (_waiters > 5) {
|
|
||||||
tty->print("claim_par_id waiting[%d]: %d waiters, %d claimed.\n",
|
|
||||||
tslf, _waiters, _claimed);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
_mon->wait(Mutex::_no_safepoint_check_flag);
|
_mon->wait(Mutex::_no_safepoint_check_flag);
|
||||||
_waiters--;
|
_waiters--;
|
||||||
}
|
}
|
||||||
if (_hd == end_of_list) {
|
uint res = _hd;
|
||||||
#if FID_STATS
|
_hd = _ids[res];
|
||||||
tty->print("claim_par_id[%d]: returning EOL.\n", tslf);
|
_ids[res] = claimed; // For debugging.
|
||||||
#endif
|
_claimed++;
|
||||||
return -1;
|
return res;
|
||||||
} else {
|
|
||||||
int res = _hd;
|
|
||||||
_hd = _ids[res];
|
|
||||||
_ids[res] = claimed; // For debugging.
|
|
||||||
_claimed++;
|
|
||||||
#if FID_STATS
|
|
||||||
tty->print("claim_par_id[%d]: returning %d, claimed = %d.\n",
|
|
||||||
tslf, res, _claimed);
|
|
||||||
#endif
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FreeIdSet::claim_perm_id(int i) {
|
void FreeIdSet::release_par_id(uint id) {
|
||||||
assert(0 <= i && i < _sz, "Out of range.");
|
|
||||||
MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag);
|
|
||||||
int prev = end_of_list;
|
|
||||||
int cur = _hd;
|
|
||||||
while (cur != end_of_list) {
|
|
||||||
if (cur == i) {
|
|
||||||
if (prev == end_of_list) {
|
|
||||||
_hd = _ids[cur];
|
|
||||||
} else {
|
|
||||||
_ids[prev] = _ids[cur];
|
|
||||||
}
|
|
||||||
_ids[cur] = claimed;
|
|
||||||
_claimed++;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
prev = cur;
|
|
||||||
cur = _ids[cur];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreeIdSet::release_par_id(int id) {
|
|
||||||
MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag);
|
MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag);
|
||||||
assert(_ids[id] == claimed, "Precondition.");
|
assert(_ids[id] == claimed, "Precondition.");
|
||||||
_ids[id] = _hd;
|
_ids[id] = _hd;
|
||||||
_hd = id;
|
_hd = id;
|
||||||
_claimed--;
|
_claimed--;
|
||||||
#if FID_STATS
|
if (_waiters > 0) {
|
||||||
tty->print("[%d] release_par_id(%d), waiters =%d, claimed = %d.\n",
|
|
||||||
thr_self(), id, _waiters, _claimed);
|
|
||||||
#endif
|
|
||||||
if (_waiters > 0)
|
|
||||||
// Notify all would be safer, but this is OK, right?
|
|
||||||
_mon->notify_all();
|
_mon->notify_all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,42 +379,29 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Represents a set of free small integer ids.
|
// Represents a set of free small integer ids.
|
||||||
class FreeIdSet : public CHeapObj<mtInternal> {
|
class FreeIdSet : public CHeapObj<mtGC> {
|
||||||
enum {
|
enum {
|
||||||
end_of_list = -1,
|
end_of_list = UINT_MAX,
|
||||||
claimed = -2
|
claimed = UINT_MAX - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
int _sz;
|
uint _size;
|
||||||
Monitor* _mon;
|
Monitor* _mon;
|
||||||
|
|
||||||
int* _ids;
|
uint* _ids;
|
||||||
int _hd;
|
uint _hd;
|
||||||
int _waiters;
|
uint _waiters;
|
||||||
int _claimed;
|
uint _claimed;
|
||||||
|
|
||||||
static bool _safepoint;
|
|
||||||
typedef FreeIdSet* FreeIdSetPtr;
|
|
||||||
static const int NSets = 10;
|
|
||||||
static FreeIdSetPtr _sets[NSets];
|
|
||||||
static bool _stat_init;
|
|
||||||
int _index;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FreeIdSet(int sz, Monitor* mon);
|
FreeIdSet(uint size, Monitor* mon);
|
||||||
~FreeIdSet();
|
~FreeIdSet();
|
||||||
|
|
||||||
static void set_safepoint(bool b);
|
|
||||||
|
|
||||||
// Attempt to claim the given id permanently. Returns "true" iff
|
|
||||||
// successful.
|
|
||||||
bool claim_perm_id(int i);
|
|
||||||
|
|
||||||
// Returns an unclaimed parallel id (waiting for one to be released if
|
// Returns an unclaimed parallel id (waiting for one to be released if
|
||||||
// necessary). Returns "-1" if a GC wakes up a wait for an id.
|
// necessary).
|
||||||
int claim_par_id();
|
uint claim_par_id();
|
||||||
|
|
||||||
void release_par_id(int id);
|
void release_par_id(uint id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHARE_VM_GC_SHARED_WORKGROUP_HPP
|
#endif // SHARE_VM_GC_SHARED_WORKGROUP_HPP
|
||||||
|
Loading…
Reference in New Issue
Block a user