17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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 #include "precompiled.hpp"
25 #include "gc/shared/locationPrinter.hpp"
26 #include "gc/z/zAddress.inline.hpp"
27 #include "gc/z/zGlobals.hpp"
28 #include "gc/z/zHeap.inline.hpp"
29 #include "gc/z/zHeapIterator.hpp"
30 #include "gc/z/zMark.inline.hpp"
31 #include "gc/z/zPage.inline.hpp"
32 #include "gc/z/zPageTable.inline.hpp"
33 #include "gc/z/zRelocationSet.inline.hpp"
34 #include "gc/z/zRelocationSetSelector.inline.hpp"
35 #include "gc/z/zResurrection.hpp"
36 #include "gc/z/zStat.hpp"
37 #include "gc/z/zThread.inline.hpp"
38 #include "gc/z/zVerify.hpp"
39 #include "gc/z/zWorkers.inline.hpp"
40 #include "logging/log.hpp"
41 #include "memory/iterator.hpp"
42 #include "memory/resourceArea.hpp"
43 #include "runtime/handshake.hpp"
44 #include "runtime/safepoint.hpp"
45 #include "runtime/thread.hpp"
46 #include "utilities/debug.hpp"
47
48 static const ZStatSampler ZSamplerHeapUsedBeforeMark("Memory", "Heap Used Before Mark", ZStatUnitBytes);
49 static const ZStatSampler ZSamplerHeapUsedAfterMark("Memory", "Heap Used After Mark", ZStatUnitBytes);
50 static const ZStatSampler ZSamplerHeapUsedBeforeRelocation("Memory", "Heap Used Before Relocation", ZStatUnitBytes);
51 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes);
52 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond);
53 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond);
54
55 ZHeap* ZHeap::_heap = NULL;
56
187 }
188
189 uint ZHeap::nconcurrent_worker_threads() const {
190 return _workers.nconcurrent();
191 }
192
193 uint ZHeap::nconcurrent_no_boost_worker_threads() const {
194 return _workers.nconcurrent_no_boost();
195 }
196
197 void ZHeap::set_boost_worker_threads(bool boost) {
198 _workers.set_boost(boost);
199 }
200
201 void ZHeap::worker_threads_do(ThreadClosure* tc) const {
202 _workers.threads_do(tc);
203 }
204
205 void ZHeap::print_worker_threads_on(outputStream* st) const {
206 _workers.print_threads_on(st);
207 }
208
209 void ZHeap::out_of_memory() {
210 ResourceMark rm;
211
212 ZStatInc(ZCounterOutOfMemory);
213 log_info(gc)("Out Of Memory (%s)", Thread::current()->name());
214 }
215
216 ZPage* ZHeap::alloc_page(uint8_t type, size_t size, ZAllocationFlags flags) {
217 ZPage* const page = _page_allocator.alloc_page(type, size, flags);
218 if (page != NULL) {
219 // Insert page table entry
220 _page_table.insert(page);
221 }
222
223 return page;
224 }
225
226 void ZHeap::undo_alloc_page(ZPage* page) {
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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 #include "precompiled.hpp"
25 #include "gc/shared/locationPrinter.hpp"
26 #include "gc/z/zAddress.inline.hpp"
27 #include "gc/z/zGlobals.hpp"
28 #include "gc/z/zHeap.inline.hpp"
29 #include "gc/z/zHeapIterator.hpp"
30 #include "gc/z/zMark.inline.hpp"
31 #include "gc/z/zPage.inline.hpp"
32 #include "gc/z/zPageTable.inline.hpp"
33 #include "gc/z/zRelocationSet.inline.hpp"
34 #include "gc/z/zRelocationSetSelector.inline.hpp"
35 #include "gc/z/zResurrection.hpp"
36 #include "gc/z/zStat.hpp"
37 #include "gc/z/zTask.hpp"
38 #include "gc/z/zThread.inline.hpp"
39 #include "gc/z/zVerify.hpp"
40 #include "gc/z/zWorkers.inline.hpp"
41 #include "logging/log.hpp"
42 #include "memory/iterator.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "runtime/handshake.hpp"
45 #include "runtime/safepoint.hpp"
46 #include "runtime/thread.hpp"
47 #include "utilities/debug.hpp"
48
49 static const ZStatSampler ZSamplerHeapUsedBeforeMark("Memory", "Heap Used Before Mark", ZStatUnitBytes);
50 static const ZStatSampler ZSamplerHeapUsedAfterMark("Memory", "Heap Used After Mark", ZStatUnitBytes);
51 static const ZStatSampler ZSamplerHeapUsedBeforeRelocation("Memory", "Heap Used Before Relocation", ZStatUnitBytes);
52 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes);
53 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond);
54 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond);
55
56 ZHeap* ZHeap::_heap = NULL;
57
188 }
189
190 uint ZHeap::nconcurrent_worker_threads() const {
191 return _workers.nconcurrent();
192 }
193
194 uint ZHeap::nconcurrent_no_boost_worker_threads() const {
195 return _workers.nconcurrent_no_boost();
196 }
197
198 void ZHeap::set_boost_worker_threads(bool boost) {
199 _workers.set_boost(boost);
200 }
201
202 void ZHeap::worker_threads_do(ThreadClosure* tc) const {
203 _workers.threads_do(tc);
204 }
205
206 void ZHeap::print_worker_threads_on(outputStream* st) const {
207 _workers.print_threads_on(st);
208 }
209
210 // Adapter class from AbstractGangTask to Ztask
211 class ZAbstractGangTaskAdapter : public ZTask {
212 private:
213 AbstractGangTask* _task;
214
215 public:
216 ZAbstractGangTaskAdapter(AbstractGangTask* task) :
217 ZTask(task->name()),
218 _task(task) { }
219
220 virtual void work() {
221 _task->work(ZThread::worker_id());
222 }
223 };
224
225 void ZHeap::run_task(AbstractGangTask* task) {
226 ZAbstractGangTaskAdapter ztask(task);
227 _workers.run_parallel(&ztask);
228 }
229
230 void ZHeap::out_of_memory() {
231 ResourceMark rm;
232
233 ZStatInc(ZCounterOutOfMemory);
234 log_info(gc)("Out Of Memory (%s)", Thread::current()->name());
235 }
236
237 ZPage* ZHeap::alloc_page(uint8_t type, size_t size, ZAllocationFlags flags) {
238 ZPage* const page = _page_allocator.alloc_page(type, size, flags);
239 if (page != NULL) {
240 // Insert page table entry
241 _page_table.insert(page);
242 }
243
244 return page;
245 }
246
247 void ZHeap::undo_alloc_page(ZPage* page) {
|