38
38
class BoolObjectClosure ;
39
39
class OopClosure ;
40
40
41
- template <typename IsAlive>
42
- class CountingIsAliveClosure : public BoolObjectClosure {
43
- IsAlive* _inner;
44
-
45
- size_t _num_dead;
46
- size_t _num_total;
47
-
48
- public:
49
- CountingIsAliveClosure (IsAlive* cl) : _inner(cl), _num_dead(0 ), _num_total(0 ) { }
50
-
51
- virtual bool do_object_b (oop obj) {
52
- bool result = _inner->do_object_b (obj);
53
- _num_dead += !result;
54
- _num_total++;
55
- return result;
56
- }
57
-
58
- size_t num_dead () const { return _num_dead; }
59
- size_t num_total () const { return _num_total; }
60
- };
61
-
62
41
template <typename IsAlive, typename KeepAlive>
63
- class CountingSkippedIsAliveClosure : public Closure {
64
- CountingIsAliveClosure< IsAlive> _counting_is_alive ;
42
+ class WeakProcessor ::CountingClosure : public Closure {
43
+ IsAlive* _is_alive ;
65
44
KeepAlive* _keep_alive;
66
-
67
- size_t _num_skipped;
45
+ size_t _old_dead;
46
+ size_t _new_dead;
47
+ size_t _live;
68
48
69
49
public:
70
- CountingSkippedIsAliveClosure (IsAlive* is_alive, KeepAlive* keep_alive) :
71
- _counting_is_alive (is_alive), _keep_alive(keep_alive), _num_skipped(0 ) { }
50
+ CountingClosure (IsAlive* is_alive, KeepAlive* keep_alive) :
51
+ _is_alive (is_alive),
52
+ _keep_alive (keep_alive),
53
+ _old_dead (0 ),
54
+ _new_dead (0 ),
55
+ _live (0 )
56
+ {}
72
57
73
58
void do_oop (oop* p) {
74
59
oop obj = *p;
75
60
if (obj == NULL ) {
76
- _num_skipped++ ;
77
- } else if (_counting_is_alive. do_object_b (obj)) {
61
+ ++_old_dead ;
62
+ } else if (_is_alive-> do_object_b (obj)) {
78
63
_keep_alive->do_oop (p);
64
+ ++_live;
79
65
} else {
80
66
*p = NULL ;
67
+ ++_new_dead;
81
68
}
82
69
}
83
70
84
- size_t num_dead () const { return _counting_is_alive. num_dead () ; }
85
- size_t num_skipped () const { return _num_skipped ; }
86
- size_t num_total () const { return _counting_is_alive. num_total () + num_skipped () ; }
71
+ size_t dead () const { return _old_dead + _new_dead ; }
72
+ size_t new_dead () const { return _new_dead ; }
73
+ size_t total () const { return dead () + _live ; }
87
74
};
88
75
89
76
template <typename IsAlive, typename KeepAlive>
@@ -98,13 +85,13 @@ void WeakProcessor::Task::work(uint worker_id,
98
85
99
86
for (Iterator it = WeakProcessorPhases::oopstorage_iterator (); !it.is_end (); ++it) {
100
87
WeakProcessorPhase phase = *it;
101
- CountingSkippedIsAliveClosure <IsAlive, KeepAlive> cl (is_alive, keep_alive);
88
+ CountingClosure <IsAlive, KeepAlive> cl (is_alive, keep_alive);
102
89
WeakProcessorPhaseTimeTracker pt (_phase_times, phase, worker_id);
103
90
StorageState* cur_state = _storage_states.par_state (phase);
104
91
cur_state->oops_do (&cl);
105
- cur_state->increment_num_dead (cl.num_skipped () + cl. num_dead ());
92
+ cur_state->increment_num_dead (cl.dead ());
106
93
if (_phase_times != NULL ) {
107
- _phase_times->record_worker_items (worker_id, phase, cl.num_dead (), cl.num_total ());
94
+ _phase_times->record_worker_items (worker_id, phase, cl.new_dead (), cl.total ());
108
95
}
109
96
}
110
97
}
0 commit comments