697 }
698
699 // Choose the heap base address and oop encoding mode
700 // when compressed oops are used:
701 // Unscaled - Use 32-bits oops without encoding when
702 // NarrowOopHeapBaseMin + heap_size < 4Gb
703 // ZeroBased - Use zero based compressed oops with encoding when
704 // NarrowOopHeapBaseMin + heap_size < 32Gb
705 // HeapBased - Use compressed oops with heap base + encoding.
706
707 jint Universe::initialize_heap() {
708 jint status = JNI_ERR;
709
710 #if !INCLUDE_ALL_GCS
711 if (UseParallelGC) {
712 fatal("UseParallelGC not supported in this VM.");
713 } else if (UseG1GC) {
714 fatal("UseG1GC not supported in this VM.");
715 } else if (UseConcMarkSweepGC) {
716 fatal("UseConcMarkSweepGC not supported in this VM.");
717 }
718 #else
719 if (UseParallelGC) {
720 status = Universe::create_heap<ParallelScavengeHeap, GenerationSizer>();
721 } else if (UseG1GC) {
722 status = Universe::create_heap<G1CollectedHeap, G1CollectorPolicyExt>();
723 } else if (UseConcMarkSweepGC) {
724 status = Universe::create_heap<GenCollectedHeap, ConcurrentMarkSweepPolicy>();
725 }
726 #endif
727 else { // UseSerialGC
728 // Don't assert that UseSerialGC is set here because there are cases
729 // where no GC it set and we then fall back to using SerialGC.
730 status = Universe::create_heap<GenCollectedHeap, MarkSweepPolicy>();
731 }
732
733 if (status != JNI_OK) {
734 return status;
735 }
736
737 ThreadLocalAllocBuffer::set_max_size(Universe::heap()->max_tlab_size());
738
739 #ifdef _LP64
740 if (UseCompressedOops) {
741 // Subtract a page because something can get allocated at heap base.
742 // This also makes implicit null checking work, because the
743 // memory+1 page below heap_base needs to cause a signal.
744 // See needs_explicit_null_check.
745 // Only set the heap base for compressed oops because it indicates
746 // compressed oops for pstack code.
747 if ((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) {
748 // Didn't reserve heap below 4Gb. Must shift.
749 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
750 }
|
697 }
698
699 // Choose the heap base address and oop encoding mode
700 // when compressed oops are used:
701 // Unscaled - Use 32-bits oops without encoding when
702 // NarrowOopHeapBaseMin + heap_size < 4Gb
703 // ZeroBased - Use zero based compressed oops with encoding when
704 // NarrowOopHeapBaseMin + heap_size < 32Gb
705 // HeapBased - Use compressed oops with heap base + encoding.
706
707 jint Universe::initialize_heap() {
708 jint status = JNI_ERR;
709
710 #if !INCLUDE_ALL_GCS
711 if (UseParallelGC) {
712 fatal("UseParallelGC not supported in this VM.");
713 } else if (UseG1GC) {
714 fatal("UseG1GC not supported in this VM.");
715 } else if (UseConcMarkSweepGC) {
716 fatal("UseConcMarkSweepGC not supported in this VM.");
717 #else
718 if (UseParallelGC) {
719 status = Universe::create_heap<ParallelScavengeHeap, GenerationSizer>();
720 } else if (UseG1GC) {
721 status = Universe::create_heap<G1CollectedHeap, G1CollectorPolicyExt>();
722 } else if (UseConcMarkSweepGC) {
723 status = Universe::create_heap<GenCollectedHeap, ConcurrentMarkSweepPolicy>();
724 #endif
725 } else if (UseSerialGC) {
726 status = Universe::create_heap<GenCollectedHeap, MarkSweepPolicy>();
727 } else {
728 ShouldNotReachHere();
729 }
730
731 if (status != JNI_OK) {
732 return status;
733 }
734
735 ThreadLocalAllocBuffer::set_max_size(Universe::heap()->max_tlab_size());
736
737 #ifdef _LP64
738 if (UseCompressedOops) {
739 // Subtract a page because something can get allocated at heap base.
740 // This also makes implicit null checking work, because the
741 // memory+1 page below heap_base needs to cause a signal.
742 // See needs_explicit_null_check.
743 // Only set the heap base for compressed oops because it indicates
744 // compressed oops for pstack code.
745 if ((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) {
746 // Didn't reserve heap below 4Gb. Must shift.
747 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
748 }
|