提交 e6f75963 编写于 作者: J johnc

7127708: G1: change task num types from int to uint in concurrent mark

Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich.
Reviewed-by: johnc
Contributed-by: NKaushik Srenevasan <kaushik@twitter.com>
上级 7a9dad8d
...@@ -399,9 +399,9 @@ protected: ...@@ -399,9 +399,9 @@ protected:
// last claimed region // last claimed region
// marking tasks // marking tasks
uint _max_task_num; // maximum task number uint _max_worker_id;// maximum worker id
uint _active_tasks; // task num currently active uint _active_tasks; // task num currently active
CMTask** _tasks; // task queue array (max_task_num len) CMTask** _tasks; // task queue array (max_worker_id len)
CMTaskQueueSet* _task_queues; // task queue set CMTaskQueueSet* _task_queues; // task queue set
ParallelTaskTerminator _terminator; // for termination ParallelTaskTerminator _terminator; // for termination
...@@ -492,8 +492,8 @@ protected: ...@@ -492,8 +492,8 @@ protected:
ParallelTaskTerminator* terminator() { return &_terminator; } ParallelTaskTerminator* terminator() { return &_terminator; }
// It claims the next available region to be scanned by a marking // It claims the next available region to be scanned by a marking
// task. It might return NULL if the next region is empty or we have // task/thread. It might return NULL if the next region is empty or
// run out of regions. In the latter case, out_of_regions() // we have run out of regions. In the latter case, out_of_regions()
// determines whether we've really run out of regions or the task // determines whether we've really run out of regions or the task
// should call claim_region() again. This might seem a bit // should call claim_region() again. This might seem a bit
// awkward. Originally, the code was written so that claim_region() // awkward. Originally, the code was written so that claim_region()
...@@ -505,7 +505,7 @@ protected: ...@@ -505,7 +505,7 @@ protected:
// method. So, this way, each task will spend very little time in // method. So, this way, each task will spend very little time in
// claim_region() and is allowed to call the regular clock method // claim_region() and is allowed to call the regular clock method
// frequently. // frequently.
HeapRegion* claim_region(int task); HeapRegion* claim_region(uint worker_id);
// It determines whether we've run out of regions to scan. // It determines whether we've run out of regions to scan.
bool out_of_regions() { return _finger == _heap_end; } bool out_of_regions() { return _finger == _heap_end; }
...@@ -537,8 +537,8 @@ protected: ...@@ -537,8 +537,8 @@ protected:
bool has_aborted() { return _has_aborted; } bool has_aborted() { return _has_aborted; }
// Methods to enter the two overflow sync barriers // Methods to enter the two overflow sync barriers
void enter_first_sync_barrier(int task_num); void enter_first_sync_barrier(uint worker_id);
void enter_second_sync_barrier(int task_num); void enter_second_sync_barrier(uint worker_id);
ForceOverflowSettings* force_overflow_conc() { ForceOverflowSettings* force_overflow_conc() {
return &_force_overflow_conc; return &_force_overflow_conc;
...@@ -626,14 +626,14 @@ public: ...@@ -626,14 +626,14 @@ public:
double all_task_accum_vtime() { double all_task_accum_vtime() {
double ret = 0.0; double ret = 0.0;
for (int i = 0; i < (int)_max_task_num; ++i) for (uint i = 0; i < _max_worker_id; ++i)
ret += _accum_task_vtime[i]; ret += _accum_task_vtime[i];
return ret; return ret;
} }
// Attempts to steal an object from the task queues of other tasks // Attempts to steal an object from the task queues of other tasks
bool try_stealing(int task_num, int* hash_seed, oop& obj) { bool try_stealing(uint worker_id, int* hash_seed, oop& obj) {
return _task_queues->steal(task_num, hash_seed, obj); return _task_queues->steal(worker_id, hash_seed, obj);
} }
ConcurrentMark(ReservedSpace rs, uint max_regions); ConcurrentMark(ReservedSpace rs, uint max_regions);
...@@ -823,7 +823,7 @@ public: ...@@ -823,7 +823,7 @@ public:
// Returns the card bitmap for a given task or worker id. // Returns the card bitmap for a given task or worker id.
BitMap* count_card_bitmap_for(uint worker_id) { BitMap* count_card_bitmap_for(uint worker_id) {
assert(0 <= worker_id && worker_id < _max_task_num, "oob"); assert(0 <= worker_id && worker_id < _max_worker_id, "oob");
assert(_count_card_bitmaps != NULL, "uninitialized"); assert(_count_card_bitmaps != NULL, "uninitialized");
BitMap* task_card_bm = &_count_card_bitmaps[worker_id]; BitMap* task_card_bm = &_count_card_bitmaps[worker_id];
assert(task_card_bm->size() == _card_bm.size(), "size mismatch"); assert(task_card_bm->size() == _card_bm.size(), "size mismatch");
...@@ -833,7 +833,7 @@ public: ...@@ -833,7 +833,7 @@ public:
// Returns the array containing the marked bytes for each region, // Returns the array containing the marked bytes for each region,
// for the given worker or task id. // for the given worker or task id.
size_t* count_marked_bytes_array_for(uint worker_id) { size_t* count_marked_bytes_array_for(uint worker_id) {
assert(0 <= worker_id && worker_id < _max_task_num, "oob"); assert(0 <= worker_id && worker_id < _max_worker_id, "oob");
assert(_count_marked_bytes != NULL, "uninitialized"); assert(_count_marked_bytes != NULL, "uninitialized");
size_t* marked_bytes_array = _count_marked_bytes[worker_id]; size_t* marked_bytes_array = _count_marked_bytes[worker_id];
assert(marked_bytes_array != NULL, "uninitialized"); assert(marked_bytes_array != NULL, "uninitialized");
...@@ -939,7 +939,7 @@ private: ...@@ -939,7 +939,7 @@ private:
global_stack_transfer_size = 16 global_stack_transfer_size = 16
}; };
int _task_id; uint _worker_id;
G1CollectedHeap* _g1h; G1CollectedHeap* _g1h;
ConcurrentMark* _cm; ConcurrentMark* _cm;
CMBitMap* _nextMarkBitMap; CMBitMap* _nextMarkBitMap;
...@@ -1115,8 +1115,8 @@ public: ...@@ -1115,8 +1115,8 @@ public:
_elapsed_time_ms = os::elapsedTime() * 1000.0 - _elapsed_time_ms; _elapsed_time_ms = os::elapsedTime() * 1000.0 - _elapsed_time_ms;
} }
// returns the task ID // returns the worker ID associated with this task.
int task_id() { return _task_id; } uint worker_id() { return _worker_id; }
// From TerminatorTerminator. It determines whether this task should // From TerminatorTerminator. It determines whether this task should
// exit the termination protocol after it's entered it. // exit the termination protocol after it's entered it.
...@@ -1170,7 +1170,7 @@ public: ...@@ -1170,7 +1170,7 @@ public:
_finger = new_finger; _finger = new_finger;
} }
CMTask(int task_num, ConcurrentMark *cm, CMTask(uint worker_id, ConcurrentMark *cm,
size_t* marked_bytes, BitMap* card_bm, size_t* marked_bytes, BitMap* card_bm,
CMTaskQueue* task_queue, CMTaskQueueSet* task_queues); CMTaskQueue* task_queue, CMTaskQueueSet* task_queues);
......
...@@ -279,7 +279,7 @@ inline void CMTask::push(oop obj) { ...@@ -279,7 +279,7 @@ inline void CMTask::push(oop obj) {
assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); assert(_nextMarkBitMap->isMarked(objAddr), "invariant");
if (_cm->verbose_high()) { if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%d] pushing "PTR_FORMAT, _task_id, (void*) obj); gclog_or_tty->print_cr("[%u] pushing "PTR_FORMAT, _worker_id, (void*) obj);
} }
if (!_task_queue->push(obj)) { if (!_task_queue->push(obj)) {
...@@ -287,9 +287,9 @@ inline void CMTask::push(oop obj) { ...@@ -287,9 +287,9 @@ inline void CMTask::push(oop obj) {
// to the global stack. // to the global stack.
if (_cm->verbose_medium()) { if (_cm->verbose_medium()) {
gclog_or_tty->print_cr("[%d] task queue overflow, " gclog_or_tty->print_cr("[%u] task queue overflow, "
"moving entries to the global stack", "moving entries to the global stack",
_task_id); _worker_id);
} }
move_entries_to_global_stack(); move_entries_to_global_stack();
...@@ -318,8 +318,8 @@ inline void CMTask::push(oop obj) { ...@@ -318,8 +318,8 @@ inline void CMTask::push(oop obj) {
inline void CMTask::deal_with_reference(oop obj) { inline void CMTask::deal_with_reference(oop obj) {
if (_cm->verbose_high()) { if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%d] we're dealing with reference = "PTR_FORMAT, gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT,
_task_id, (void*) obj); _worker_id, (void*) obj);
} }
++_refs_reached; ++_refs_reached;
...@@ -335,8 +335,8 @@ inline void CMTask::deal_with_reference(oop obj) { ...@@ -335,8 +335,8 @@ inline void CMTask::deal_with_reference(oop obj) {
HeapRegion* hr = _g1h->heap_region_containing_raw(obj); HeapRegion* hr = _g1h->heap_region_containing_raw(obj);
if (!hr->obj_allocated_since_next_marking(obj)) { if (!hr->obj_allocated_since_next_marking(obj)) {
if (_cm->verbose_high()) { if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%d] "PTR_FORMAT" is not considered marked", gclog_or_tty->print_cr("[%u] "PTR_FORMAT" is not considered marked",
_task_id, (void*) obj); _worker_id, (void*) obj);
} }
// we need to mark it first // we need to mark it first
...@@ -350,8 +350,8 @@ inline void CMTask::deal_with_reference(oop obj) { ...@@ -350,8 +350,8 @@ inline void CMTask::deal_with_reference(oop obj) {
if (_finger != NULL && objAddr < _finger) { if (_finger != NULL && objAddr < _finger) {
if (_cm->verbose_high()) { if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%d] below the local finger ("PTR_FORMAT"), " gclog_or_tty->print_cr("[%u] below the local finger ("PTR_FORMAT"), "
"pushing it", _task_id, _finger); "pushing it", _worker_id, _finger);
} }
push(obj); push(obj);
} else if (_curr_region != NULL && objAddr < _region_limit) { } else if (_curr_region != NULL && objAddr < _region_limit) {
...@@ -367,9 +367,9 @@ inline void CMTask::deal_with_reference(oop obj) { ...@@ -367,9 +367,9 @@ inline void CMTask::deal_with_reference(oop obj) {
// correctness problems. // correctness problems.
if (_cm->verbose_high()) { if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%d] below the global finger " gclog_or_tty->print_cr("[%u] below the global finger "
"("PTR_FORMAT"), pushing it", "("PTR_FORMAT"), pushing it",
_task_id, global_finger); _worker_id, global_finger);
} }
push(obj); push(obj);
} else { } else {
...@@ -382,9 +382,9 @@ inline void CMTask::deal_with_reference(oop obj) { ...@@ -382,9 +382,9 @@ inline void CMTask::deal_with_reference(oop obj) {
// see long comment above // see long comment above
if (_cm->verbose_high()) { if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%d] below the global finger " gclog_or_tty->print_cr("[%u] below the global finger "
"("PTR_FORMAT"), pushing it", "("PTR_FORMAT"), pushing it",
_task_id, global_finger); _worker_id, global_finger);
} }
push(obj); push(obj);
} }
......
...@@ -111,9 +111,9 @@ inline void G1CMOopClosure::do_oop_nv(T* p) { ...@@ -111,9 +111,9 @@ inline void G1CMOopClosure::do_oop_nv(T* p) {
oop obj = oopDesc::load_decode_heap_oop(p); oop obj = oopDesc::load_decode_heap_oop(p);
if (_cm->verbose_high()) { if (_cm->verbose_high()) {
gclog_or_tty->print_cr("[%d] we're looking at location " gclog_or_tty->print_cr("[%u] we're looking at location "
"*"PTR_FORMAT" = "PTR_FORMAT, "*"PTR_FORMAT" = "PTR_FORMAT,
_task->task_id(), p, (void*) obj); _task->worker_id(), p, (void*) obj);
} }
_task->deal_with_reference(obj); _task->deal_with_reference(obj);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册