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