692 } |
692 } |
693 |
693 |
694 return JNI_OK; |
694 return JNI_OK; |
695 } |
695 } |
696 |
696 |
697 template <class Heap, class Policy> |
697 CollectedHeap* Universe::create_heap() { |
698 jint Universe::create_heap() { |
|
699 assert(_collectedHeap == NULL, "Heap already created"); |
698 assert(_collectedHeap == NULL, "Heap already created"); |
700 Policy* policy = new Policy(); |
|
701 policy->initialize_all(); |
|
702 _collectedHeap = new Heap(policy); |
|
703 return _collectedHeap->initialize(); |
|
704 } |
|
705 |
|
706 // Choose the heap base address and oop encoding mode |
|
707 // when compressed oops are used: |
|
708 // Unscaled - Use 32-bits oops without encoding when |
|
709 // NarrowOopHeapBaseMin + heap_size < 4Gb |
|
710 // ZeroBased - Use zero based compressed oops with encoding when |
|
711 // NarrowOopHeapBaseMin + heap_size < 32Gb |
|
712 // HeapBased - Use compressed oops with heap base + encoding. |
|
713 |
|
714 jint Universe::initialize_heap() { |
|
715 jint status = JNI_ERR; |
|
716 |
|
717 #if !INCLUDE_ALL_GCS |
699 #if !INCLUDE_ALL_GCS |
718 if (UseParallelGC) { |
700 if (UseParallelGC) { |
719 fatal("UseParallelGC not supported in this VM."); |
701 fatal("UseParallelGC not supported in this VM."); |
720 } else if (UseG1GC) { |
702 } else if (UseG1GC) { |
721 fatal("UseG1GC not supported in this VM."); |
703 fatal("UseG1GC not supported in this VM."); |
722 } else if (UseConcMarkSweepGC) { |
704 } else if (UseConcMarkSweepGC) { |
723 fatal("UseConcMarkSweepGC not supported in this VM."); |
705 fatal("UseConcMarkSweepGC not supported in this VM."); |
724 #else |
706 #else |
725 if (UseParallelGC) { |
707 if (UseParallelGC) { |
726 status = Universe::create_heap<ParallelScavengeHeap, GenerationSizer>(); |
708 return Universe::create_heap_with_policy<ParallelScavengeHeap, GenerationSizer>(); |
727 } else if (UseG1GC) { |
709 } else if (UseG1GC) { |
728 status = Universe::create_heap<G1CollectedHeap, G1CollectorPolicyExt>(); |
710 return Universe::create_heap_with_policy<G1CollectedHeap, G1CollectorPolicyExt>(); |
729 } else if (UseConcMarkSweepGC) { |
711 } else if (UseConcMarkSweepGC) { |
730 status = Universe::create_heap<GenCollectedHeap, ConcurrentMarkSweepPolicy>(); |
712 return Universe::create_heap_with_policy<GenCollectedHeap, ConcurrentMarkSweepPolicy>(); |
731 #endif |
713 #endif |
732 } else if (UseSerialGC) { |
714 } else if (UseSerialGC) { |
733 status = Universe::create_heap<GenCollectedHeap, MarkSweepPolicy>(); |
715 return Universe::create_heap_with_policy<GenCollectedHeap, MarkSweepPolicy>(); |
734 } else { |
716 } |
735 ShouldNotReachHere(); |
717 |
736 } |
718 ShouldNotReachHere(); |
737 |
719 return NULL; |
|
720 } |
|
721 |
|
722 // Choose the heap base address and oop encoding mode |
|
723 // when compressed oops are used: |
|
724 // Unscaled - Use 32-bits oops without encoding when |
|
725 // NarrowOopHeapBaseMin + heap_size < 4Gb |
|
726 // ZeroBased - Use zero based compressed oops with encoding when |
|
727 // NarrowOopHeapBaseMin + heap_size < 32Gb |
|
728 // HeapBased - Use compressed oops with heap base + encoding. |
|
729 |
|
730 jint Universe::initialize_heap() { |
|
731 jint status = JNI_ERR; |
|
732 |
|
733 _collectedHeap = create_heap_ext(); |
|
734 if (_collectedHeap == NULL) { |
|
735 _collectedHeap = create_heap(); |
|
736 } |
|
737 |
|
738 status = _collectedHeap->initialize(); |
738 if (status != JNI_OK) { |
739 if (status != JNI_OK) { |
739 return status; |
740 return status; |
740 } |
741 } |
741 |
742 |
742 ThreadLocalAllocBuffer::set_max_size(Universe::heap()->max_tlab_size()); |
743 ThreadLocalAllocBuffer::set_max_size(Universe::heap()->max_tlab_size()); |