src/share/vm/memory/universe.cpp

Print this page




 859   assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - os::vm_page_size() - ClassMetaspaceSize) ||
 860          Universe::narrow_oop_base() == NULL, "invalid value");
 861   assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
 862          Universe::narrow_oop_shift() == 0, "invalid value");
 863 #endif
 864 
 865   // We will never reach the CATCH below since Exceptions::_throw will cause
 866   // the VM to exit if an exception is thrown during initialization
 867 
 868   if (UseTLAB) {
 869     assert(Universe::heap()->supports_tlab_allocation(),
 870            "Should support thread-local allocation buffers");
 871     ThreadLocalAllocBuffer::startup_initialization();
 872   }
 873   return JNI_OK;
 874 }
 875 
 876 
 877 // Reserve the Java heap, which is now the same for all GCs.
 878 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {

 879   // Add in the class metaspace area so the classes in the headers can
 880   // be compressed the same as instances.
 881   // Need to round class space size up because it's below the heap and
 882   // the actual alignment depends on its size.
 883   Universe::set_class_metaspace_size(align_size_up(ClassMetaspaceSize, alignment));
 884   size_t total_reserved = align_size_up(heap_size + Universe::class_metaspace_size(), alignment);
 885   assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())),
 886       "heap size is too big for compressed oops");
 887   char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop);
 888 
 889   ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr);
 890 
 891   if (UseCompressedOops) {
 892     if (addr != NULL && !total_rs.is_reserved()) {
 893       // Failed to reserve at specified address - the requested memory
 894       // region is taken already, for example, by 'java' launcher.
 895       // Try again to reserver heap higher.
 896       addr = Universe::preferred_heap_base(total_reserved, Universe::ZeroBasedNarrowOop);
 897 
 898       ReservedHeapSpace total_rs0(total_reserved, alignment,
 899                                   UseLargePages, addr);
 900 
 901       if (addr != NULL && !total_rs0.is_reserved()) {
 902         // Failed to reserve at specified address again - give up.
 903         addr = Universe::preferred_heap_base(total_reserved, Universe::HeapBasedNarrowOop);
 904         assert(addr == NULL, "");




 859   assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - os::vm_page_size() - ClassMetaspaceSize) ||
 860          Universe::narrow_oop_base() == NULL, "invalid value");
 861   assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
 862          Universe::narrow_oop_shift() == 0, "invalid value");
 863 #endif
 864 
 865   // We will never reach the CATCH below since Exceptions::_throw will cause
 866   // the VM to exit if an exception is thrown during initialization
 867 
 868   if (UseTLAB) {
 869     assert(Universe::heap()->supports_tlab_allocation(),
 870            "Should support thread-local allocation buffers");
 871     ThreadLocalAllocBuffer::startup_initialization();
 872   }
 873   return JNI_OK;
 874 }
 875 
 876 
 877 // Reserve the Java heap, which is now the same for all GCs.
 878 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
 879   assert(alignment <= Arguments::max_heap_alignment(), "actual alignment must be within maximum heap alignment");
 880   // Add in the class metaspace area so the classes in the headers can
 881   // be compressed the same as instances.
 882   // Need to round class space size up because it's below the heap and
 883   // the actual alignment depends on its size.
 884   Universe::set_class_metaspace_size(align_size_up(ClassMetaspaceSize, alignment));
 885   size_t total_reserved = align_size_up(heap_size, alignment) + Universe::class_metaspace_size();
 886   assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())),
 887       "heap size is too big for compressed oops");
 888   char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop);
 889 
 890   ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr);
 891 
 892   if (UseCompressedOops) {
 893     if (addr != NULL && !total_rs.is_reserved()) {
 894       // Failed to reserve at specified address - the requested memory
 895       // region is taken already, for example, by 'java' launcher.
 896       // Try again to reserver heap higher.
 897       addr = Universe::preferred_heap_base(total_reserved, Universe::ZeroBasedNarrowOop);
 898 
 899       ReservedHeapSpace total_rs0(total_reserved, alignment,
 900                                   UseLargePages, addr);
 901 
 902       if (addr != NULL && !total_rs0.is_reserved()) {
 903         // Failed to reserve at specified address again - give up.
 904         addr = Universe::preferred_heap_base(total_reserved, Universe::HeapBasedNarrowOop);
 905         assert(addr == NULL, "");