< prev index next >

src/share/vm/memory/universe.cpp

Print this page




 865     } else {
 866       Universe::set_narrow_oop_base(0);
 867 #ifdef _WIN64
 868       if (!Universe::narrow_oop_use_implicit_null_checks()) {
 869         // Don't need guard page for implicit checks in indexed addressing
 870         // mode with zero based Compressed Oops.
 871         Universe::set_narrow_oop_use_implicit_null_checks(true);
 872       }
 873 #endif //  _WIN64
 874       if((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) {
 875         // Can't reserve heap below 4Gb.
 876         Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
 877       } else {
 878         Universe::set_narrow_oop_shift(0);
 879       }
 880     }
 881 
 882     Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
 883 
 884     if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
 885       Universe::print_compressed_oops_mode();
 886     }
 887   }
 888   // Universe::narrow_oop_base() is one page below the heap.
 889   assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() -
 890          os::vm_page_size()) ||
 891          Universe::narrow_oop_base() == NULL, "invalid value");
 892   assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
 893          Universe::narrow_oop_shift() == 0, "invalid value");
 894 #endif
 895 
 896   // We will never reach the CATCH below since Exceptions::_throw will cause
 897   // the VM to exit if an exception is thrown during initialization
 898 
 899   if (UseTLAB) {
 900     assert(Universe::heap()->supports_tlab_allocation(),
 901            "Should support thread-local allocation buffers");
 902     ThreadLocalAllocBuffer::startup_initialization();
 903   }
 904   return JNI_OK;
 905 }
 906 
 907 void Universe::print_compressed_oops_mode() {
 908   tty->cr();
 909   tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
 910               Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
 911 
 912   tty->print(", Compressed Oops mode: %s", narrow_oop_mode_to_string(narrow_oop_mode()));
 913 
 914   if (Universe::narrow_oop_base() != 0) {
 915     tty->print(":" PTR_FORMAT, Universe::narrow_oop_base());
 916   }
 917 
 918   if (Universe::narrow_oop_shift() != 0) {
 919     tty->print(", Oop shift amount: %d", Universe::narrow_oop_shift());
 920   }
 921 
 922   tty->cr();
 923   tty->cr();
 924 }
 925 
 926 // Reserve the Java heap, which is now the same for all GCs.
 927 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
 928   assert(alignment <= Arguments::conservative_max_heap_alignment(),
 929       err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT,
 930           alignment, Arguments::conservative_max_heap_alignment()));
 931   size_t total_reserved = align_size_up(heap_size, alignment);
 932   assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())),
 933       "heap size is too big for compressed oops");
 934 
 935   bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size());
 936   assert(!UseLargePages
 937       || UseParallelGC
 938       || use_large_pages, "Wrong alignment to use large pages");
 939 
 940   char* addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::UnscaledNarrowOop);
 941 
 942   ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages, addr);
 943 




 865     } else {
 866       Universe::set_narrow_oop_base(0);
 867 #ifdef _WIN64
 868       if (!Universe::narrow_oop_use_implicit_null_checks()) {
 869         // Don't need guard page for implicit checks in indexed addressing
 870         // mode with zero based Compressed Oops.
 871         Universe::set_narrow_oop_use_implicit_null_checks(true);
 872       }
 873 #endif //  _WIN64
 874       if((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) {
 875         // Can't reserve heap below 4Gb.
 876         Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
 877       } else {
 878         Universe::set_narrow_oop_shift(0);
 879       }
 880     }
 881 
 882     Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
 883 
 884     if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
 885       Universe::print_compressed_oops_mode(tty);
 886     }
 887   }
 888   // Universe::narrow_oop_base() is one page below the heap.
 889   assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() -
 890          os::vm_page_size()) ||
 891          Universe::narrow_oop_base() == NULL, "invalid value");
 892   assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
 893          Universe::narrow_oop_shift() == 0, "invalid value");
 894 #endif
 895 
 896   // We will never reach the CATCH below since Exceptions::_throw will cause
 897   // the VM to exit if an exception is thrown during initialization
 898 
 899   if (UseTLAB) {
 900     assert(Universe::heap()->supports_tlab_allocation(),
 901            "Should support thread-local allocation buffers");
 902     ThreadLocalAllocBuffer::startup_initialization();
 903   }
 904   return JNI_OK;
 905 }
 906 
 907 void Universe::print_compressed_oops_mode(outputStream* st) {
 908   st->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",

 909               Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
 910 
 911   st->print(", Compressed Oops mode: %s", narrow_oop_mode_to_string(narrow_oop_mode()));
 912 
 913   if (Universe::narrow_oop_base() != 0) {
 914     st->print(":" PTR_FORMAT, Universe::narrow_oop_base());
 915   }
 916 
 917   if (Universe::narrow_oop_shift() != 0) {
 918     st->print(", Oop shift amount: %d", Universe::narrow_oop_shift());
 919   }
 920 
 921   st->cr();

 922 }
 923 
 924 // Reserve the Java heap, which is now the same for all GCs.
 925 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
 926   assert(alignment <= Arguments::conservative_max_heap_alignment(),
 927       err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT,
 928           alignment, Arguments::conservative_max_heap_alignment()));
 929   size_t total_reserved = align_size_up(heap_size, alignment);
 930   assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())),
 931       "heap size is too big for compressed oops");
 932 
 933   bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size());
 934   assert(!UseLargePages
 935       || UseParallelGC
 936       || use_large_pages, "Wrong alignment to use large pages");
 937 
 938   char* addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::UnscaledNarrowOop);
 939 
 940   ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages, addr);
 941 


< prev index next >