Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/universe.cpp @ 8506:c3657d00e343
-Merge with tip
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Thu, 21 Mar 2013 14:11:13 +0100 |
parents | 41fc46da946a 3c9bc17b9403 |
children | b9a918201d47 |
comparison
equal
deleted
inserted
replaced
8505:dee7c8b578c7 | 8506:c3657d00e343 |
---|---|
68 #include "services/memoryService.hpp" | 68 #include "services/memoryService.hpp" |
69 #include "utilities/copy.hpp" | 69 #include "utilities/copy.hpp" |
70 #include "utilities/events.hpp" | 70 #include "utilities/events.hpp" |
71 #include "utilities/hashtable.inline.hpp" | 71 #include "utilities/hashtable.inline.hpp" |
72 #include "utilities/preserveException.hpp" | 72 #include "utilities/preserveException.hpp" |
73 #ifndef SERIALGC | 73 #include "utilities/macros.hpp" |
74 #if INCLUDE_ALL_GCS | |
74 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" | 75 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp" |
75 #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp" | 76 #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp" |
76 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" | 77 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
77 #include "gc_implementation/g1/g1CollectorPolicy.hpp" | 78 #include "gc_implementation/g1/g1CollectorPolicy.hpp" |
78 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" | 79 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" |
79 #endif | 80 #endif // INCLUDE_ALL_GCS |
80 | 81 |
81 // Known objects | 82 // Known objects |
82 Klass* Universe::_boolArrayKlassObj = NULL; | 83 Klass* Universe::_boolArrayKlassObj = NULL; |
83 Klass* Universe::_byteArrayKlassObj = NULL; | 84 Klass* Universe::_byteArrayKlassObj = NULL; |
84 Klass* Universe::_charArrayKlassObj = NULL; | 85 Klass* Universe::_charArrayKlassObj = NULL; |
142 | 143 |
143 NarrowPtrStruct Universe::_narrow_oop = { NULL, 0, true }; | 144 NarrowPtrStruct Universe::_narrow_oop = { NULL, 0, true }; |
144 NarrowPtrStruct Universe::_narrow_klass = { NULL, 0, true }; | 145 NarrowPtrStruct Universe::_narrow_klass = { NULL, 0, true }; |
145 address Universe::_narrow_ptrs_base; | 146 address Universe::_narrow_ptrs_base; |
146 | 147 |
148 size_t Universe::_class_metaspace_size; | |
147 | 149 |
148 void Universe::basic_type_classes_do(void f(Klass*)) { | 150 void Universe::basic_type_classes_do(void f(Klass*)) { |
149 f(boolArrayKlassObj()); | 151 f(boolArrayKlassObj()); |
150 f(byteArrayKlassObj()); | 152 f(byteArrayKlassObj()); |
151 f(charArrayKlassObj()); | 153 f(charArrayKlassObj()); |
687 mode == HeapBasedNarrowOop, "mode is invalid"); | 689 mode == HeapBasedNarrowOop, "mode is invalid"); |
688 const size_t total_size = heap_size + HeapBaseMinAddress; | 690 const size_t total_size = heap_size + HeapBaseMinAddress; |
689 // Return specified base for the first request. | 691 // Return specified base for the first request. |
690 if (!FLAG_IS_DEFAULT(HeapBaseMinAddress) && (mode == UnscaledNarrowOop)) { | 692 if (!FLAG_IS_DEFAULT(HeapBaseMinAddress) && (mode == UnscaledNarrowOop)) { |
691 base = HeapBaseMinAddress; | 693 base = HeapBaseMinAddress; |
692 } else if (total_size <= OopEncodingHeapMax && (mode != HeapBasedNarrowOop)) { | 694 |
693 if (total_size <= NarrowOopHeapMax && (mode == UnscaledNarrowOop) && | 695 // If the total size and the metaspace size are small enough to allow |
696 // UnscaledNarrowOop then just use UnscaledNarrowOop. | |
697 } else if ((total_size <= OopEncodingHeapMax) && (mode != HeapBasedNarrowOop) && | |
698 (!UseCompressedKlassPointers || | |
699 (((OopEncodingHeapMax - heap_size) + Universe::class_metaspace_size()) <= KlassEncodingMetaspaceMax))) { | |
700 // We don't need to check the metaspace size here because it is always smaller | |
701 // than total_size. | |
702 if ((total_size <= NarrowOopHeapMax) && (mode == UnscaledNarrowOop) && | |
694 (Universe::narrow_oop_shift() == 0)) { | 703 (Universe::narrow_oop_shift() == 0)) { |
695 // Use 32-bits oops without encoding and | 704 // Use 32-bits oops without encoding and |
696 // place heap's top on the 4Gb boundary | 705 // place heap's top on the 4Gb boundary |
697 base = (NarrowOopHeapMax - heap_size); | 706 base = (NarrowOopHeapMax - heap_size); |
698 } else { | 707 } else { |
704 // place heap's top on the 32Gb boundary in case | 713 // place heap's top on the 32Gb boundary in case |
705 // total_size > 4Gb or failed to reserve below 4Gb. | 714 // total_size > 4Gb or failed to reserve below 4Gb. |
706 base = (OopEncodingHeapMax - heap_size); | 715 base = (OopEncodingHeapMax - heap_size); |
707 } | 716 } |
708 } | 717 } |
718 | |
719 // See if ZeroBaseNarrowOop encoding will work for a heap based at | |
720 // (KlassEncodingMetaspaceMax - class_metaspace_size()). | |
721 } else if (UseCompressedKlassPointers && (mode != HeapBasedNarrowOop) && | |
722 (Universe::class_metaspace_size() + HeapBaseMinAddress <= KlassEncodingMetaspaceMax) && | |
723 (KlassEncodingMetaspaceMax + heap_size - Universe::class_metaspace_size() <= OopEncodingHeapMax)) { | |
724 base = (KlassEncodingMetaspaceMax - Universe::class_metaspace_size()); | |
709 } else { | 725 } else { |
710 // Can't reserve below 32Gb. | 726 // UnscaledNarrowOop encoding didn't work, and no base was found for ZeroBasedOops or |
727 // HeapBasedNarrowOop encoding was requested. So, can't reserve below 32Gb. | |
711 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); | 728 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); |
712 } | 729 } |
730 | |
713 // Set narrow_oop_base and narrow_oop_use_implicit_null_checks | 731 // Set narrow_oop_base and narrow_oop_use_implicit_null_checks |
714 // used in ReservedHeapSpace() constructors. | 732 // used in ReservedHeapSpace() constructors. |
715 // The final values will be set in initialize_heap() below. | 733 // The final values will be set in initialize_heap() below. |
716 if (base != 0 && (base + heap_size) <= OopEncodingHeapMax) { | 734 if ((base != 0) && ((base + heap_size) <= OopEncodingHeapMax) && |
735 (!UseCompressedKlassPointers || (base + Universe::class_metaspace_size()) <= KlassEncodingMetaspaceMax)) { | |
717 // Use zero based compressed oops | 736 // Use zero based compressed oops |
718 Universe::set_narrow_oop_base(NULL); | 737 Universe::set_narrow_oop_base(NULL); |
719 // Don't need guard page for implicit checks in indexed | 738 // Don't need guard page for implicit checks in indexed |
720 // addressing mode with zero based Compressed Oops. | 739 // addressing mode with zero based Compressed Oops. |
721 Universe::set_narrow_oop_use_implicit_null_checks(true); | 740 Universe::set_narrow_oop_use_implicit_null_checks(true); |
738 } | 757 } |
739 | 758 |
740 jint Universe::initialize_heap() { | 759 jint Universe::initialize_heap() { |
741 | 760 |
742 if (UseParallelGC) { | 761 if (UseParallelGC) { |
743 #ifndef SERIALGC | 762 #if INCLUDE_ALL_GCS |
744 Universe::_collectedHeap = new ParallelScavengeHeap(); | 763 Universe::_collectedHeap = new ParallelScavengeHeap(); |
745 #else // SERIALGC | 764 #else // INCLUDE_ALL_GCS |
746 fatal("UseParallelGC not supported in this VM."); | 765 fatal("UseParallelGC not supported in this VM."); |
747 #endif // SERIALGC | 766 #endif // INCLUDE_ALL_GCS |
748 | 767 |
749 } else if (UseG1GC) { | 768 } else if (UseG1GC) { |
750 #ifndef SERIALGC | 769 #if INCLUDE_ALL_GCS |
751 G1CollectorPolicy* g1p = new G1CollectorPolicy(); | 770 G1CollectorPolicy* g1p = new G1CollectorPolicy(); |
752 G1CollectedHeap* g1h = new G1CollectedHeap(g1p); | 771 G1CollectedHeap* g1h = new G1CollectedHeap(g1p); |
753 Universe::_collectedHeap = g1h; | 772 Universe::_collectedHeap = g1h; |
754 #else // SERIALGC | 773 #else // INCLUDE_ALL_GCS |
755 fatal("UseG1GC not supported in java kernel vm."); | 774 fatal("UseG1GC not supported in java kernel vm."); |
756 #endif // SERIALGC | 775 #endif // INCLUDE_ALL_GCS |
757 | 776 |
758 } else { | 777 } else { |
759 GenCollectorPolicy *gc_policy; | 778 GenCollectorPolicy *gc_policy; |
760 | 779 |
761 if (UseSerialGC) { | 780 if (UseSerialGC) { |
762 gc_policy = new MarkSweepPolicy(); | 781 gc_policy = new MarkSweepPolicy(); |
763 } else if (UseConcMarkSweepGC) { | 782 } else if (UseConcMarkSweepGC) { |
764 #ifndef SERIALGC | 783 #if INCLUDE_ALL_GCS |
765 if (UseAdaptiveSizePolicy) { | 784 if (UseAdaptiveSizePolicy) { |
766 gc_policy = new ASConcurrentMarkSweepPolicy(); | 785 gc_policy = new ASConcurrentMarkSweepPolicy(); |
767 } else { | 786 } else { |
768 gc_policy = new ConcurrentMarkSweepPolicy(); | 787 gc_policy = new ConcurrentMarkSweepPolicy(); |
769 } | 788 } |
770 #else // SERIALGC | 789 #else // INCLUDE_ALL_GCS |
771 fatal("UseConcMarkSweepGC not supported in this VM."); | 790 fatal("UseConcMarkSweepGC not supported in this VM."); |
772 #endif // SERIALGC | 791 #endif // INCLUDE_ALL_GCS |
773 } else { // default old generation | 792 } else { // default old generation |
774 gc_policy = new MarkSweepPolicy(); | 793 gc_policy = new MarkSweepPolicy(); |
775 } | 794 } |
776 | 795 |
777 Universe::_collectedHeap = new GenCollectedHeap(gc_policy); | 796 Universe::_collectedHeap = new GenCollectedHeap(gc_policy); |
794 if (verbose) { | 813 if (verbose) { |
795 tty->cr(); | 814 tty->cr(); |
796 tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", | 815 tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", |
797 Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M); | 816 Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M); |
798 } | 817 } |
799 if ((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax) { | 818 if (((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax) || |
819 (UseCompressedKlassPointers && | |
820 ((uint64_t)Universe::heap()->base() + Universe::class_metaspace_size() > KlassEncodingMetaspaceMax))) { | |
800 // Can't reserve heap below 32Gb. | 821 // Can't reserve heap below 32Gb. |
801 // keep the Universe::narrow_oop_base() set in Universe::reserve_heap() | 822 // keep the Universe::narrow_oop_base() set in Universe::reserve_heap() |
802 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); | 823 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); |
803 if (verbose) { | 824 if (verbose) { |
804 tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base()); | 825 tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base()); |
860 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { | 881 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { |
861 // Add in the class metaspace area so the classes in the headers can | 882 // Add in the class metaspace area so the classes in the headers can |
862 // be compressed the same as instances. | 883 // be compressed the same as instances. |
863 // Need to round class space size up because it's below the heap and | 884 // Need to round class space size up because it's below the heap and |
864 // the actual alignment depends on its size. | 885 // the actual alignment depends on its size. |
865 size_t metaspace_size = align_size_up(ClassMetaspaceSize, alignment); | 886 Universe::set_class_metaspace_size(align_size_up(ClassMetaspaceSize, alignment)); |
866 size_t total_reserved = align_size_up(heap_size + metaspace_size, alignment); | 887 size_t total_reserved = align_size_up(heap_size + Universe::class_metaspace_size(), alignment); |
867 char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop); | 888 char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop); |
868 | 889 |
869 ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr); | 890 ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr); |
870 | 891 |
871 if (UseCompressedOops) { | 892 if (UseCompressedOops) { |
902 // as compressed oops. If compress oops and compress klass ptrs are | 923 // as compressed oops. If compress oops and compress klass ptrs are |
903 // used we need the meta space first: if the alignment used for | 924 // used we need the meta space first: if the alignment used for |
904 // compressed oops is greater than the one used for compressed klass | 925 // compressed oops is greater than the one used for compressed klass |
905 // ptrs, a metadata space on top of the heap could become | 926 // ptrs, a metadata space on top of the heap could become |
906 // unreachable. | 927 // unreachable. |
907 ReservedSpace class_rs = total_rs.first_part(metaspace_size); | 928 ReservedSpace class_rs = total_rs.first_part(Universe::class_metaspace_size()); |
908 ReservedSpace heap_rs = total_rs.last_part(metaspace_size, alignment); | 929 ReservedSpace heap_rs = total_rs.last_part(Universe::class_metaspace_size(), alignment); |
909 Metaspace::initialize_class_space(class_rs); | 930 Metaspace::initialize_class_space(class_rs); |
910 | 931 |
911 if (UseCompressedOops) { | 932 if (UseCompressedOops) { |
912 // Universe::initialize_heap() will reset this to NULL if unscaled | 933 // Universe::initialize_heap() will reset this to NULL if unscaled |
913 // or zero-based narrow oops are actually used. | 934 // or zero-based narrow oops are actually used. |