src/hotspot/share/gc/z/zCollectedHeap.cpp
branchstuefe-new-metaspace-branch
changeset 58494 54c1ba464b78
parent 58199 595fcbebaa77
parent 58294 872465abbfe3
child 59272 54750b448264
equal deleted inserted replaced
58475:e3aa9f95b85e 58494:54c1ba464b78
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 #include "precompiled.hpp"
    24 #include "precompiled.hpp"
    25 #include "gc/shared/gcHeapSummary.hpp"
    25 #include "gc/shared/gcHeapSummary.hpp"
    26 #include "gc/shared/locationPrinter.hpp"
       
    27 #include "gc/shared/suspendibleThreadSet.hpp"
    26 #include "gc/shared/suspendibleThreadSet.hpp"
    28 #include "gc/z/zCollectedHeap.hpp"
    27 #include "gc/z/zCollectedHeap.hpp"
    29 #include "gc/z/zGlobals.hpp"
    28 #include "gc/z/zGlobals.hpp"
    30 #include "gc/z/zHeap.inline.hpp"
    29 #include "gc/z/zHeap.inline.hpp"
    31 #include "gc/z/zNMethod.hpp"
    30 #include "gc/z/zNMethod.hpp"
    32 #include "gc/z/zObjArrayAllocator.hpp"
    31 #include "gc/z/zObjArrayAllocator.hpp"
       
    32 #include "gc/z/zOop.inline.hpp"
    33 #include "gc/z/zServiceability.hpp"
    33 #include "gc/z/zServiceability.hpp"
    34 #include "gc/z/zStat.hpp"
    34 #include "gc/z/zStat.hpp"
    35 #include "gc/z/zUtils.inline.hpp"
    35 #include "gc/z/zUtils.inline.hpp"
    36 #include "memory/metaspace/classLoaderMetaspace.hpp"
    36 #include "memory/metaspace/classLoaderMetaspace.hpp"
    37 #include "memory/metaspace/metaspaceEnums.hpp"
    37 #include "memory/metaspace/metaspaceEnums.hpp"
    68 jint ZCollectedHeap::initialize() {
    68 jint ZCollectedHeap::initialize() {
    69   if (!_heap.is_initialized()) {
    69   if (!_heap.is_initialized()) {
    70     return JNI_ENOMEM;
    70     return JNI_ENOMEM;
    71   }
    71   }
    72 
    72 
    73   Universe::calculate_verify_data((HeapWord*)ZAddressReservedStart,
    73   Universe::calculate_verify_data((HeapWord*)0, (HeapWord*)UINTPTR_MAX);
    74                                   (HeapWord*)ZAddressReservedEnd);
       
    75 
    74 
    76   return JNI_OK;
    75   return JNI_OK;
    77 }
    76 }
    78 
    77 
    79 void ZCollectedHeap::initialize_serviceability() {
    78 void ZCollectedHeap::initialize_serviceability() {
   116 bool ZCollectedHeap::is_in(const void* p) const {
   115 bool ZCollectedHeap::is_in(const void* p) const {
   117   return _heap.is_in((uintptr_t)p);
   116   return _heap.is_in((uintptr_t)p);
   118 }
   117 }
   119 
   118 
   120 uint32_t ZCollectedHeap::hash_oop(oop obj) const {
   119 uint32_t ZCollectedHeap::hash_oop(oop obj) const {
   121   return _heap.hash_oop(obj);
   120   return _heap.hash_oop(ZOop::to_address(obj));
   122 }
   121 }
   123 
   122 
   124 HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
   123 HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
   125   const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(requested_size));
   124   const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(requested_size));
   126   const uintptr_t addr = _heap.alloc_tlab(size_in_bytes);
   125   const uintptr_t addr = _heap.alloc_tlab(size_in_bytes);
   285   _heap.worker_threads_do(tc);
   284   _heap.worker_threads_do(tc);
   286   _runtime_workers.threads_do(tc);
   285   _runtime_workers.threads_do(tc);
   287 }
   286 }
   288 
   287 
   289 VirtualSpaceSummary ZCollectedHeap::create_heap_space_summary() {
   288 VirtualSpaceSummary ZCollectedHeap::create_heap_space_summary() {
   290   const size_t capacity_in_words = capacity() / HeapWordSize;
   289   return VirtualSpaceSummary((HeapWord*)0, (HeapWord*)capacity(), (HeapWord*)max_capacity());
   291   const size_t max_capacity_in_words = max_capacity() / HeapWordSize;
       
   292   HeapWord* const heap_start = (HeapWord*)ZAddressReservedStart;
       
   293   return VirtualSpaceSummary(heap_start,
       
   294                              heap_start + capacity_in_words,
       
   295                              heap_start + max_capacity_in_words);
       
   296 }
   290 }
   297 
   291 
   298 void ZCollectedHeap::safepoint_synchronize_begin() {
   292 void ZCollectedHeap::safepoint_synchronize_begin() {
   299   SuspendibleThreadSet::synchronize();
   293   SuspendibleThreadSet::synchronize();
   300 }
   294 }
   312 }
   306 }
   313 
   307 
   314 void ZCollectedHeap::print_on_error(outputStream* st) const {
   308 void ZCollectedHeap::print_on_error(outputStream* st) const {
   315   CollectedHeap::print_on_error(st);
   309   CollectedHeap::print_on_error(st);
   316 
   310 
   317   st->print_cr("Address Space");
       
   318   st->print_cr( "     Start:             " PTR_FORMAT, ZAddressSpaceStart);
       
   319   st->print_cr( "     End:               " PTR_FORMAT, ZAddressSpaceEnd);
       
   320   st->print_cr( "     Size:              " SIZE_FORMAT_W(-15) " (" PTR_FORMAT ")", ZAddressSpaceSize, ZAddressSpaceSize);
       
   321   st->print_cr( "Heap");
   311   st->print_cr( "Heap");
   322   st->print_cr( "     GlobalPhase:       %u", ZGlobalPhase);
   312   st->print_cr( "     GlobalPhase:       %u", ZGlobalPhase);
   323   st->print_cr( "     GlobalSeqNum:      %u", ZGlobalSeqNum);
   313   st->print_cr( "     GlobalSeqNum:      %u", ZGlobalSeqNum);
   324   st->print_cr( "     Offset Max:        " SIZE_FORMAT_W(-15) " (" PTR_FORMAT ")", ZAddressOffsetMax, ZAddressOffsetMax);
   314   st->print_cr( "     Offset Max:        " SIZE_FORMAT_W(-15) " (" PTR_FORMAT ")", ZAddressOffsetMax, ZAddressOffsetMax);
   325   st->print_cr( "     Page Size Small:   " SIZE_FORMAT_W(-15) " (" PTR_FORMAT ")", ZPageSizeSmall, ZPageSizeSmall);
   315   st->print_cr( "     Page Size Small:   " SIZE_FORMAT_W(-15) " (" PTR_FORMAT ")", ZPageSizeSmall, ZPageSizeSmall);
   352 void ZCollectedHeap::print_tracing_info() const {
   342 void ZCollectedHeap::print_tracing_info() const {
   353   // Does nothing
   343   // Does nothing
   354 }
   344 }
   355 
   345 
   356 bool ZCollectedHeap::print_location(outputStream* st, void* addr) const {
   346 bool ZCollectedHeap::print_location(outputStream* st, void* addr) const {
   357   if (LocationPrinter::is_valid_obj(addr)) {
   347   return _heap.print_location(st, (uintptr_t)addr);
   358     st->print(INTPTR_FORMAT " is a %s oop: ", p2i(addr),
       
   359               ZAddress::is_good(reinterpret_cast<uintptr_t>(addr)) ? "good" : "bad");
       
   360     cast_to_oop(addr)->print_on(st);
       
   361     return true;
       
   362   }
       
   363   return false;
       
   364 }
   348 }
   365 
   349 
   366 void ZCollectedHeap::verify(VerifyOption option /* ignored */) {
   350 void ZCollectedHeap::verify(VerifyOption option /* ignored */) {
   367   _heap.verify();
   351   _heap.verify();
   368 }
   352 }
   369 
   353 
   370 bool ZCollectedHeap::is_oop(oop object) const {
   354 bool ZCollectedHeap::is_oop(oop object) const {
   371   return CollectedHeap::is_oop(object) && _heap.is_oop(object);
   355   return _heap.is_oop(ZOop::to_address(object));
   372 }
   356 }
   373 
       
   374 void ZCollectedHeap::check_oop_location(void* addr) const {
       
   375   assert(is_object_aligned(addr), "address is not aligned");
       
   376 
       
   377   const uintptr_t addr_int = reinterpret_cast<uintptr_t>(addr);
       
   378   assert(addr_int >= ZAddressSpaceStart, "address is outside of the heap");
       
   379   assert(addr_int < ZAddressSpaceEnd,    "address is outside of the heap");
       
   380 }