19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "gc/shared/oopStorage.inline.hpp"
28 #include "gc/shared/oopStorageParState.inline.hpp"
29 #include "gc/shared/oopStorageSet.hpp"
30 #include "gc/shared/weakProcessor.inline.hpp"
31 #include "gc/shared/weakProcessorPhases.hpp"
32 #include "gc/shared/weakProcessorPhaseTimes.hpp"
33 #include "memory/allocation.inline.hpp"
34 #include "memory/iterator.hpp"
35 #include "prims/resolvedMethodTable.hpp"
36 #include "runtime/globals.hpp"
37 #include "utilities/macros.hpp"
38
39 template <typename Container>
40 class OopsDoAndReportCounts {
41 public:
42 void operator()(BoolObjectClosure* is_alive, OopClosure* keep_alive, OopStorage* storage) {
43 Container::reset_dead_counter();
44
45 CountingSkippedIsAliveClosure<BoolObjectClosure, OopClosure> cl(is_alive, keep_alive);
46 storage->oops_do(&cl);
47
48 Container::inc_dead_counter(cl.num_dead() + cl.num_skipped());
49 Container::finish_dead_counter();
50 }
51 };
52
53 void WeakProcessor::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive) {
54 WeakProcessorPhases::Iterator pit = WeakProcessorPhases::serial_iterator();
55 for ( ; !pit.is_end(); ++pit) {
56 WeakProcessorPhases::processor(*pit)(is_alive, keep_alive);
57 }
58
59 OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
60 for ( ; !it.is_end(); ++it) {
61 if (OopStorageSet::string_table_weak() == *it) {
62 OopsDoAndReportCounts<StringTable>()(is_alive, keep_alive, *it);
63 } else if (OopStorageSet::resolved_method_table_weak() == *it) {
64 OopsDoAndReportCounts<ResolvedMethodTable>()(is_alive, keep_alive, *it);
65 } else {
66 it->weak_oops_do(is_alive, keep_alive);
67 }
68 }
69 }
70
71 void WeakProcessor::oops_do(OopClosure* closure) {
72 AlwaysTrueClosure always_true;
73 weak_oops_do(&always_true, closure);
74 }
75
76 uint WeakProcessor::ergo_workers(uint max_workers) {
77 // Ignore ParallelRefProcEnabled; that's for j.l.r.Reference processing.
78 if (ReferencesPerThread == 0) {
79 // Configuration says always use all the threads.
80 return max_workers;
81 }
82
83 // One thread per ReferencesPerThread references (or fraction thereof)
84 // in the various OopStorage objects, bounded by max_threads.
103 void WeakProcessor::Task::initialize() {
104 assert(_nworkers != 0, "must be");
105 assert(_phase_times == NULL || _nworkers <= _phase_times->max_threads(),
106 "nworkers (%u) exceeds max threads (%u)",
107 _nworkers, _phase_times->max_threads());
108
109 if (_phase_times) {
110 _phase_times->set_active_workers(_nworkers);
111 }
112
113 uint storage_count = WeakProcessorPhases::oopstorage_phase_count;
114 _storage_states = NEW_C_HEAP_ARRAY(StorageState, storage_count, mtGC);
115
116 StorageState* cur_state = _storage_states;
117 OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
118 for ( ; !it.is_end(); ++it, ++cur_state) {
119 assert(pointer_delta(cur_state, _storage_states, sizeof(StorageState)) < storage_count, "invariant");
120 new (cur_state) StorageState(*it, _nworkers);
121 }
122 assert(pointer_delta(cur_state, _storage_states, sizeof(StorageState)) == storage_count, "invariant");
123 StringTable::reset_dead_counter();
124 ResolvedMethodTable::reset_dead_counter();
125 }
126
127 WeakProcessor::Task::Task(uint nworkers) :
128 _phase_times(NULL),
129 _nworkers(nworkers),
130 _serial_phases_done(WeakProcessorPhases::serial_phase_count),
131 _storage_states(NULL)
132 {
133 initialize();
134 }
135
136 WeakProcessor::Task::Task(WeakProcessorPhaseTimes* phase_times, uint nworkers) :
137 _phase_times(phase_times),
138 _nworkers(nworkers),
139 _serial_phases_done(WeakProcessorPhases::serial_phase_count),
140 _storage_states(NULL)
141 {
142 initialize();
143 }
144
145 WeakProcessor::Task::~Task() {
146 if (_storage_states != NULL) {
147 StorageState* states = _storage_states;
148 for (uint i = 0; i < WeakProcessorPhases::oopstorage_phase_count; ++i) {
149 states->StorageState::~StorageState();
150 ++states;
151 }
152 FREE_C_HEAP_ARRAY(StorageState, _storage_states);
153 }
154 StringTable::finish_dead_counter();
155 ResolvedMethodTable::finish_dead_counter();
156 }
157
158 void WeakProcessor::GangTask::work(uint worker_id) {
159 _erased_do_work(this, worker_id);
160 }
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "gc/shared/oopStorage.inline.hpp"
28 #include "gc/shared/oopStorageParState.inline.hpp"
29 #include "gc/shared/oopStorageSet.hpp"
30 #include "gc/shared/weakProcessor.inline.hpp"
31 #include "gc/shared/weakProcessorPhases.hpp"
32 #include "gc/shared/weakProcessorPhaseTimes.hpp"
33 #include "memory/allocation.inline.hpp"
34 #include "memory/iterator.hpp"
35 #include "prims/resolvedMethodTable.hpp"
36 #include "runtime/globals.hpp"
37 #include "utilities/macros.hpp"
38
39 void WeakProcessor::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive) {
40 WeakProcessorPhases::Iterator pit = WeakProcessorPhases::serial_iterator();
41 for ( ; !pit.is_end(); ++pit) {
42 WeakProcessorPhases::processor(*pit)(is_alive, keep_alive);
43 }
44
45 OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
46 for ( ; !it.is_end(); ++it) {
47 if (it->can_notify()) {
48 CountingSkippedIsAliveClosure<BoolObjectClosure, OopClosure> cl(is_alive, keep_alive);
49 it->oops_do(&cl);
50 it->notify(cl.num_dead());
51 } else {
52 it->weak_oops_do(is_alive, keep_alive);
53 }
54 }
55 }
56
57 void WeakProcessor::oops_do(OopClosure* closure) {
58 AlwaysTrueClosure always_true;
59 weak_oops_do(&always_true, closure);
60 }
61
62 uint WeakProcessor::ergo_workers(uint max_workers) {
63 // Ignore ParallelRefProcEnabled; that's for j.l.r.Reference processing.
64 if (ReferencesPerThread == 0) {
65 // Configuration says always use all the threads.
66 return max_workers;
67 }
68
69 // One thread per ReferencesPerThread references (or fraction thereof)
70 // in the various OopStorage objects, bounded by max_threads.
89 void WeakProcessor::Task::initialize() {
90 assert(_nworkers != 0, "must be");
91 assert(_phase_times == NULL || _nworkers <= _phase_times->max_threads(),
92 "nworkers (%u) exceeds max threads (%u)",
93 _nworkers, _phase_times->max_threads());
94
95 if (_phase_times) {
96 _phase_times->set_active_workers(_nworkers);
97 }
98
99 uint storage_count = WeakProcessorPhases::oopstorage_phase_count;
100 _storage_states = NEW_C_HEAP_ARRAY(StorageState, storage_count, mtGC);
101
102 StorageState* cur_state = _storage_states;
103 OopStorageSet::Iterator it = OopStorageSet::weak_iterator();
104 for ( ; !it.is_end(); ++it, ++cur_state) {
105 assert(pointer_delta(cur_state, _storage_states, sizeof(StorageState)) < storage_count, "invariant");
106 new (cur_state) StorageState(*it, _nworkers);
107 }
108 assert(pointer_delta(cur_state, _storage_states, sizeof(StorageState)) == storage_count, "invariant");
109 }
110
111 WeakProcessor::Task::Task(uint nworkers) :
112 _phase_times(NULL),
113 _nworkers(nworkers),
114 _serial_phases_done(WeakProcessorPhases::serial_phase_count),
115 _storage_states(NULL)
116 {
117 initialize();
118 }
119
120 WeakProcessor::Task::Task(WeakProcessorPhaseTimes* phase_times, uint nworkers) :
121 _phase_times(phase_times),
122 _nworkers(nworkers),
123 _serial_phases_done(WeakProcessorPhases::serial_phase_count),
124 _storage_states(NULL)
125 {
126 initialize();
127 }
128
129 WeakProcessor::Task::~Task() {
130 if (_storage_states != NULL) {
131 StorageState* states = _storage_states;
132 for (uint i = 0; i < WeakProcessorPhases::oopstorage_phase_count; ++i) {
133 states->storage()->notify(states->num_dead());
134 states->StorageState::~StorageState();
135 ++states;
136 }
137 FREE_C_HEAP_ARRAY(StorageState, _storage_states);
138 }
139 }
140
141 void WeakProcessor::GangTask::work(uint worker_id) {
142 _erased_do_work(this, worker_id);
143 }
|