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/zHeuristics.hpp"
31 #include "gc/z/zMark.inline.hpp"
32 #include "gc/z/zPage.inline.hpp"
33 #include "gc/z/zPageTable.inline.hpp"
34 #include "gc/z/zRelocationSet.inline.hpp"
35 #include "gc/z/zRelocationSetSelector.inline.hpp"
36 #include "gc/z/zResurrection.hpp"
37 #include "gc/z/zStat.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
166 }
167
168 return false;
169 }
170
171 uint ZHeap::nconcurrent_worker_threads() const {
172 return _workers.nconcurrent();
173 }
174
175 uint ZHeap::nconcurrent_no_boost_worker_threads() const {
176 return _workers.nconcurrent_no_boost();
177 }
178
179 void ZHeap::set_boost_worker_threads(bool boost) {
180 _workers.set_boost(boost);
181 }
182
183 void ZHeap::threads_do(ThreadClosure* tc) const {
184 _page_allocator.threads_do(tc);
185 _workers.threads_do(tc);
186 }
187
188 void ZHeap::out_of_memory() {
189 ResourceMark rm;
190
191 ZStatInc(ZCounterOutOfMemory);
192 log_info(gc)("Out Of Memory (%s)", Thread::current()->name());
193 }
194
195 ZPage* ZHeap::alloc_page(uint8_t type, size_t size, ZAllocationFlags flags) {
196 ZPage* const page = _page_allocator.alloc_page(type, size, flags);
197 if (page != NULL) {
198 // Insert page table entry
199 _page_table.insert(page);
200 }
201
202 return page;
203 }
204
205 void ZHeap::undo_alloc_page(ZPage* page) {
|
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/zHeuristics.hpp"
31 #include "gc/z/zMark.inline.hpp"
32 #include "gc/z/zPage.inline.hpp"
33 #include "gc/z/zPageTable.inline.hpp"
34 #include "gc/z/zRelocationSet.inline.hpp"
35 #include "gc/z/zRelocationSetSelector.inline.hpp"
36 #include "gc/z/zResurrection.hpp"
37 #include "gc/z/zStat.hpp"
38 #include "gc/z/zTask.hpp"
39 #include "gc/z/zThread.inline.hpp"
40 #include "gc/z/zVerify.hpp"
41 #include "gc/z/zWorkers.inline.hpp"
42 #include "logging/log.hpp"
43 #include "memory/iterator.hpp"
44 #include "memory/resourceArea.hpp"
45 #include "runtime/handshake.hpp"
46 #include "runtime/safepoint.hpp"
47 #include "runtime/thread.hpp"
48 #include "utilities/debug.hpp"
49
50 static const ZStatSampler ZSamplerHeapUsedBeforeMark("Memory", "Heap Used Before Mark", ZStatUnitBytes);
51 static const ZStatSampler ZSamplerHeapUsedAfterMark("Memory", "Heap Used After Mark", ZStatUnitBytes);
52 static const ZStatSampler ZSamplerHeapUsedBeforeRelocation("Memory", "Heap Used Before Relocation", ZStatUnitBytes);
53 static const ZStatSampler ZSamplerHeapUsedAfterRelocation("Memory", "Heap Used After Relocation", ZStatUnitBytes);
54 static const ZStatCounter ZCounterUndoPageAllocation("Memory", "Undo Page Allocation", ZStatUnitOpsPerSecond);
55 static const ZStatCounter ZCounterOutOfMemory("Memory", "Out Of Memory", ZStatUnitOpsPerSecond);
56
57 ZHeap* ZHeap::_heap = NULL;
58
167 }
168
169 return false;
170 }
171
172 uint ZHeap::nconcurrent_worker_threads() const {
173 return _workers.nconcurrent();
174 }
175
176 uint ZHeap::nconcurrent_no_boost_worker_threads() const {
177 return _workers.nconcurrent_no_boost();
178 }
179
180 void ZHeap::set_boost_worker_threads(bool boost) {
181 _workers.set_boost(boost);
182 }
183
184 void ZHeap::threads_do(ThreadClosure* tc) const {
185 _page_allocator.threads_do(tc);
186 _workers.threads_do(tc);
187 }
188
189 // Adapter class from AbstractGangTask to Ztask
190 class ZAbstractGangTaskAdapter : public ZTask {
191 private:
192 AbstractGangTask* _task;
193
194 public:
195 ZAbstractGangTaskAdapter(AbstractGangTask* task) :
196 ZTask(task->name()),
197 _task(task) { }
198
199 virtual void work() {
200 _task->work(ZThread::worker_id());
201 }
202 };
203
204 void ZHeap::run_task(AbstractGangTask* task) {
205 ZAbstractGangTaskAdapter ztask(task);
206 _workers.run_parallel(&ztask);
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) {
|