< prev index next >
src/hotspot/share/gc/z/zCollectedHeap.cpp
Print this page
@@ -21,21 +21,88 @@
* questions.
*/
#include "precompiled.hpp"
#include "gc/shared/gcHeapSummary.hpp"
+#include "gc/shared/memAllocator.hpp"
#include "gc/shared/suspendibleThreadSet.hpp"
#include "gc/z/zCollectedHeap.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zHeap.inline.hpp"
#include "gc/z/zNMethod.hpp"
#include "gc/z/zServiceability.hpp"
#include "gc/z/zStat.hpp"
#include "gc/z/zUtils.inline.hpp"
#include "memory/universe.hpp"
+#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/mutexLocker.hpp"
+class PinAllocating {
+private:
+ const HeapWord* _mem;
+public:
+ PinAllocating(HeapWord* mem) :
+ _mem(mem) {
+ ZHeap::heap()->pin_allocating((uintptr_t)_mem);
+ }
+
+ ~PinAllocating() {
+ ZHeap::heap()->unpin_allocating((uintptr_t)_mem);
+ }
+};
+
+class ZObjArrayAllocator: public ObjArrayAllocator {
+private:
+ const bool _is_large;
+ const size_t _chunk_size;
+
+ void mem_clear_large(HeapWord* mem) const {
+ log_info(gc)("ZMemClearer " PTR_FORMAT " " SIZE_FORMAT " M", p2i(mem), _word_size * BytesPerWord / M);
+ assert(mem != NULL, "cannot initialize NULL object");
+ const size_t hs = oopDesc::header_size();
+ assert(_word_size >= hs, "unexpected object size");
+ oopDesc::set_klass_gap(mem, 0);
+
+ PinAllocating pin_allocating(mem);
+
+ size_t offset = hs;
+ while (offset + _chunk_size < _word_size) {
+ Copy::fill_to_aligned_words(mem + offset, _chunk_size);
+ offset += _chunk_size;
+
+ {
+ ThreadBlockInVM tbivm(JavaThread::current());
+ }
+
+ // Fix colors
+ mem = (HeapWord*)ZAddress::good((uintptr_t)mem);
+ }
+
+ if (offset < _word_size) {
+ Copy::fill_to_aligned_words(mem + offset, _word_size - offset);
+ }
+ }
+
+protected:
+ virtual HeapWord* mem_clear(HeapWord* mem) const {
+ if (_is_large) {
+ mem_clear_large(mem);
+ } else {
+ mem = ObjArrayAllocator::mem_clear(mem);
+ }
+ return (HeapWord*)ZAddress::good((uintptr_t)mem);
+ }
+
+public:
+ ZObjArrayAllocator(Klass* klass, size_t word_size, int length, bool do_zero,
+ Thread* thread = Thread::current()) :
+ ObjArrayAllocator(klass, word_size, length, do_zero, thread),
+ _is_large(static_cast<size_t>(length) > ZObjectSizeLimitMedium),
+ _chunk_size(ZObjectSizeLimitMedium / BytesPerWord)
+ {}
+};
+
ZCollectedHeap* ZCollectedHeap::heap() {
CollectedHeap* heap = Universe::heap();
assert(heap != NULL, "Uninitialized access to ZCollectedHeap::heap()");
assert(heap->kind() == CollectedHeap::Z, "Invalid name");
return (ZCollectedHeap*)heap;
@@ -125,10 +192,15 @@
}
return (HeapWord*)addr;
}
+oop ZCollectedHeap::array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS) {
+ ZObjArrayAllocator allocator(klass, size, length, do_zero, THREAD);
+ return allocator.allocate();
+}
+
HeapWord* ZCollectedHeap::mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) {
const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(size));
return (HeapWord*)_heap.alloc_object(size_in_bytes);
}
< prev index next >