universe.cpp (3733:5876f980ea19) universe.cpp (3743:bdb5f8c9978b)
1/*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *

--- 137 unchanged lines hidden (view full) ---

146bool Universe::_bootstrapping = false;
147bool Universe::_fully_initialized = false;
148
149size_t Universe::_heap_capacity_at_last_gc;
150size_t Universe::_heap_used_at_last_gc = 0;
151
152CollectedHeap* Universe::_collectedHeap = NULL;
153
1/*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *

--- 137 unchanged lines hidden (view full) ---

146bool Universe::_bootstrapping = false;
147bool Universe::_fully_initialized = false;
148
149size_t Universe::_heap_capacity_at_last_gc;
150size_t Universe::_heap_used_at_last_gc = 0;
151
152CollectedHeap* Universe::_collectedHeap = NULL;
153
154NarrowPtrStruct Universe::_narrow_oop = { NULL, 0, true };
155NarrowPtrStruct Universe::_narrow_klass = { NULL, 0, true };
156address Universe::_narrow_ptrs_base;
154NarrowOopStruct Universe::_narrow_oop = { NULL, 0, true };
157
158
159void Universe::basic_type_classes_do(void f(Klass*)) {
160 f(boolArrayKlassObj());
161 f(byteArrayKlassObj());
162 f(charArrayKlassObj());
163 f(intArrayKlassObj());
164 f(shortArrayKlassObj());

--- 584 unchanged lines hidden (view full) ---

749}
750
751jint Universe::initialize_heap() {
752
753 if (UseParallelGC) {
754#ifndef SERIALGC
755 Universe::_collectedHeap = new ParallelScavengeHeap();
756#else // SERIALGC
155
156
157void Universe::basic_type_classes_do(void f(Klass*)) {
158 f(boolArrayKlassObj());
159 f(byteArrayKlassObj());
160 f(charArrayKlassObj());
161 f(intArrayKlassObj());
162 f(shortArrayKlassObj());

--- 584 unchanged lines hidden (view full) ---

747}
748
749jint Universe::initialize_heap() {
750
751 if (UseParallelGC) {
752#ifndef SERIALGC
753 Universe::_collectedHeap = new ParallelScavengeHeap();
754#else // SERIALGC
757 fatal("UseParallelGC not supported in this VM.");
755 fatal("UseParallelGC not supported in java kernel vm.");
758#endif // SERIALGC
759
760 } else if (UseG1GC) {
761#ifndef SERIALGC
762 G1CollectorPolicy* g1p = new G1CollectorPolicy();
763 G1CollectedHeap* g1h = new G1CollectedHeap(g1p);
764 Universe::_collectedHeap = g1h;
765#else // SERIALGC

--- 8 unchanged lines hidden (view full) ---

774 } else if (UseConcMarkSweepGC) {
775#ifndef SERIALGC
776 if (UseAdaptiveSizePolicy) {
777 gc_policy = new ASConcurrentMarkSweepPolicy();
778 } else {
779 gc_policy = new ConcurrentMarkSweepPolicy();
780 }
781#else // SERIALGC
756#endif // SERIALGC
757
758 } else if (UseG1GC) {
759#ifndef SERIALGC
760 G1CollectorPolicy* g1p = new G1CollectorPolicy();
761 G1CollectedHeap* g1h = new G1CollectedHeap(g1p);
762 Universe::_collectedHeap = g1h;
763#else // SERIALGC

--- 8 unchanged lines hidden (view full) ---

772 } else if (UseConcMarkSweepGC) {
773#ifndef SERIALGC
774 if (UseAdaptiveSizePolicy) {
775 gc_policy = new ASConcurrentMarkSweepPolicy();
776 } else {
777 gc_policy = new ConcurrentMarkSweepPolicy();
778 }
779#else // SERIALGC
782 fatal("UseConcMarkSweepGC not supported in this VM.");
780 fatal("UseConcMarkSweepGC not supported in java kernel vm.");
783#endif // SERIALGC
784 } else { // default old generation
785 gc_policy = new MarkSweepPolicy();
786 }
787
788 Universe::_collectedHeap = new GenCollectedHeap(gc_policy);
789 }
790

--- 13 unchanged lines hidden (view full) ---

804 bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose);
805 if (verbose) {
806 tty->cr();
807 tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
808 Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
809 }
810 if ((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax) {
811 // Can't reserve heap below 32Gb.
781#endif // SERIALGC
782 } else { // default old generation
783 gc_policy = new MarkSweepPolicy();
784 }
785
786 Universe::_collectedHeap = new GenCollectedHeap(gc_policy);
787 }
788

--- 13 unchanged lines hidden (view full) ---

802 bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose);
803 if (verbose) {
804 tty->cr();
805 tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
806 Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
807 }
808 if ((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax) {
809 // Can't reserve heap below 32Gb.
812 // keep the Universe::narrow_oop_base() set in Universe::reserve_heap()
810 Universe::set_narrow_oop_base(Universe::heap()->base() - os::vm_page_size());
813 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
814 if (verbose) {
815 tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base());
816 }
817 } else {
818 Universe::set_narrow_oop_base(0);
819 if (verbose) {
820 tty->print(", zero based Compressed Oops");

--- 14 unchanged lines hidden (view full) ---

835 tty->print(", 32-bits Oops");
836 }
837 }
838 }
839 if (verbose) {
840 tty->cr();
841 tty->cr();
842 }
811 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
812 if (verbose) {
813 tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base());
814 }
815 } else {
816 Universe::set_narrow_oop_base(0);
817 if (verbose) {
818 tty->print(", zero based Compressed Oops");

--- 14 unchanged lines hidden (view full) ---

833 tty->print(", 32-bits Oops");
834 }
835 }
836 }
837 if (verbose) {
838 tty->cr();
839 tty->cr();
840 }
843 if (UseCompressedKlassPointers) {
844 Universe::set_narrow_klass_base(Universe::narrow_oop_base());
845 Universe::set_narrow_klass_shift(MIN2(Universe::narrow_oop_shift(), LogKlassAlignmentInBytes));
846 }
847 Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
848 }
841 }
849 // Universe::narrow_oop_base() is one page below the metaspace
850 // base. The actual metaspace base depends on alignment constraints
851 // so we don't know its exact location here.
852 assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - os::vm_page_size() - ClassMetaspaceSize) ||
842 assert(Universe::narrow_oop_base() == (Universe::heap()->base() - os::vm_page_size()) ||
853 Universe::narrow_oop_base() == NULL, "invalid value");
854 assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
855 Universe::narrow_oop_shift() == 0, "invalid value");
856#endif
857
858 // We will never reach the CATCH below since Exceptions::_throw will cause
859 // the VM to exit if an exception is thrown during initialization
860

--- 5 unchanged lines hidden (view full) ---

866 return JNI_OK;
867}
868
869
870// Reserve the Java heap, which is now the same for all GCs.
871ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
872 // Add in the class metaspace area so the classes in the headers can
873 // be compressed the same as instances.
843 Universe::narrow_oop_base() == NULL, "invalid value");
844 assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
845 Universe::narrow_oop_shift() == 0, "invalid value");
846#endif
847
848 // We will never reach the CATCH below since Exceptions::_throw will cause
849 // the VM to exit if an exception is thrown during initialization
850

--- 5 unchanged lines hidden (view full) ---

856 return JNI_OK;
857}
858
859
860// Reserve the Java heap, which is now the same for all GCs.
861ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
862 // Add in the class metaspace area so the classes in the headers can
863 // be compressed the same as instances.
874 // Need to round class space size up because it's below the heap and
875 // the actual alignment depends on its size.
876 size_t metaspace_size = align_size_up(ClassMetaspaceSize, alignment);
877 size_t total_reserved = align_size_up(heap_size + metaspace_size, alignment);
864 size_t total_reserved = align_size_up(heap_size + ClassMetaspaceSize, alignment);
878 char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop);
879
880 ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr);
881
882 if (UseCompressedOops) {
883 if (addr != NULL && !total_rs.is_reserved()) {
884 // Failed to reserve at specified address - the requested memory
885 // region is taken already, for example, by 'java' launcher.

--- 17 unchanged lines hidden (view full) ---

903 }
904 }
905
906 if (!total_rs.is_reserved()) {
907 vm_exit_during_initialization(err_msg("Could not reserve enough space for object heap %d bytes", total_reserved));
908 return total_rs;
909 }
910
865 char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop);
866
867 ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr);
868
869 if (UseCompressedOops) {
870 if (addr != NULL && !total_rs.is_reserved()) {
871 // Failed to reserve at specified address - the requested memory
872 // region is taken already, for example, by 'java' launcher.

--- 17 unchanged lines hidden (view full) ---

890 }
891 }
892
893 if (!total_rs.is_reserved()) {
894 vm_exit_during_initialization(err_msg("Could not reserve enough space for object heap %d bytes", total_reserved));
895 return total_rs;
896 }
897
911 // Split the reserved space into main Java heap and a space for
912 // classes so that they can be compressed using the same algorithm
913 // as compressed oops. If compress oops and compress klass ptrs are
914 // used we need the meta space first: if the alignment used for
915 // compressed oops is greater than the one used for compressed klass
916 // ptrs, a metadata space on top of the heap could become
917 // unreachable.
918 ReservedSpace class_rs = total_rs.first_part(metaspace_size);
919 ReservedSpace heap_rs = total_rs.last_part(metaspace_size, alignment);
898 // Split the reserved space into main Java heap and a space for classes
899 // so that they can be compressed using the same algorithm as compressed oops
900 ReservedSpace heap_rs = total_rs.first_part(heap_size);
901 ReservedSpace class_rs = total_rs.last_part(heap_size, alignment);
920 Metaspace::initialize_class_space(class_rs);
902 Metaspace::initialize_class_space(class_rs);
921
922 if (UseCompressedOops) {
923 // Universe::initialize_heap() will reset this to NULL if unscaled
924 // or zero-based narrow oops are actually used.
925 address base = (address)(total_rs.base() - os::vm_page_size());
926 Universe::set_narrow_oop_base(base);
927 }
928 return heap_rs;
929}
930
931
932// It's the caller's repsonsibility to ensure glitch-freedom
933// (if required).
934void Universe::update_heap_info_at_gc() {
935 _heap_capacity_at_last_gc = heap()->capacity();

--- 327 unchanged lines hidden (view full) ---

1263 heap()->print_on(st);
1264 } else {
1265 heap()->print_extended_on(st);
1266 }
1267 st->print_cr("}");
1268}
1269
1270void Universe::verify(bool silent, VerifyOption option) {
903 return heap_rs;
904}
905
906
907// It's the caller's repsonsibility to ensure glitch-freedom
908// (if required).
909void Universe::update_heap_info_at_gc() {
910 _heap_capacity_at_last_gc = heap()->capacity();

--- 327 unchanged lines hidden (view full) ---

1238 heap()->print_on(st);
1239 } else {
1240 heap()->print_extended_on(st);
1241 }
1242 st->print_cr("}");
1243}
1244
1245void Universe::verify(bool silent, VerifyOption option) {
1271 if (SharedSkipVerify) {
1272 return;
1273 }
1274
1275 // The use of _verify_in_progress is a temporary work around for
1276 // 6320749. Don't bother with a creating a class to set and clear
1277 // it since it is only used in this method and the control flow is
1278 // straight forward.
1279 _verify_in_progress = true;
1280
1281 COMPILER2_PRESENT(
1282 assert(!DerivedPointerTable::is_active(),

--- 244 unchanged lines hidden ---
1246 // The use of _verify_in_progress is a temporary work around for
1247 // 6320749. Don't bother with a creating a class to set and clear
1248 // it since it is only used in this method and the control flow is
1249 // straight forward.
1250 _verify_in_progress = true;
1251
1252 COMPILER2_PRESENT(
1253 assert(!DerivedPointerTable::is_active(),

--- 244 unchanged lines hidden ---