Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/universe.cpp @ 23660:b5f3a471e646
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 01 Jun 2016 00:11:44 +0200 |
parents | 7848fc12602b 88ae10297731 |
children | f13e777eb255 |
comparison
equal
deleted
inserted
replaced
23411:d7cf78885a3a | 23660:b5f3a471e646 |
---|---|
112 oop Universe::_the_null_string = NULL; | 112 oop Universe::_the_null_string = NULL; |
113 oop Universe::_the_min_jint_string = NULL; | 113 oop Universe::_the_min_jint_string = NULL; |
114 LatestMethodCache* Universe::_finalizer_register_cache = NULL; | 114 LatestMethodCache* Universe::_finalizer_register_cache = NULL; |
115 LatestMethodCache* Universe::_loader_addClass_cache = NULL; | 115 LatestMethodCache* Universe::_loader_addClass_cache = NULL; |
116 LatestMethodCache* Universe::_pd_implies_cache = NULL; | 116 LatestMethodCache* Universe::_pd_implies_cache = NULL; |
117 LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL; | |
117 oop Universe::_out_of_memory_error_java_heap = NULL; | 118 oop Universe::_out_of_memory_error_java_heap = NULL; |
118 oop Universe::_out_of_memory_error_metaspace = NULL; | 119 oop Universe::_out_of_memory_error_metaspace = NULL; |
119 oop Universe::_out_of_memory_error_class_metaspace = NULL; | 120 oop Universe::_out_of_memory_error_class_metaspace = NULL; |
120 oop Universe::_out_of_memory_error_array_size = NULL; | 121 oop Universe::_out_of_memory_error_array_size = NULL; |
121 oop Universe::_out_of_memory_error_gc_overhead_limit = NULL; | 122 oop Universe::_out_of_memory_error_gc_overhead_limit = NULL; |
127 oop Universe::_arithmetic_exception_instance = NULL; | 128 oop Universe::_arithmetic_exception_instance = NULL; |
128 oop Universe::_virtual_machine_error_instance = NULL; | 129 oop Universe::_virtual_machine_error_instance = NULL; |
129 oop Universe::_vm_exception = NULL; | 130 oop Universe::_vm_exception = NULL; |
130 oop Universe::_allocation_context_notification_obj = NULL; | 131 oop Universe::_allocation_context_notification_obj = NULL; |
131 | 132 |
132 Method* Universe::_throw_illegal_access_error = NULL; | |
133 Array<int>* Universe::_the_empty_int_array = NULL; | 133 Array<int>* Universe::_the_empty_int_array = NULL; |
134 Array<u2>* Universe::_the_empty_short_array = NULL; | 134 Array<u2>* Universe::_the_empty_short_array = NULL; |
135 Array<Klass*>* Universe::_the_empty_klass_array = NULL; | 135 Array<Klass*>* Universe::_the_empty_klass_array = NULL; |
136 Array<Method*>* Universe::_the_empty_method_array = NULL; | 136 Array<Method*>* Universe::_the_empty_method_array = NULL; |
137 | 137 |
233 f->do_ptr((void**)&_the_empty_method_array); | 233 f->do_ptr((void**)&_the_empty_method_array); |
234 f->do_ptr((void**)&_the_empty_klass_array); | 234 f->do_ptr((void**)&_the_empty_klass_array); |
235 _finalizer_register_cache->serialize(f); | 235 _finalizer_register_cache->serialize(f); |
236 _loader_addClass_cache->serialize(f); | 236 _loader_addClass_cache->serialize(f); |
237 _pd_implies_cache->serialize(f); | 237 _pd_implies_cache->serialize(f); |
238 _throw_illegal_access_error_cache->serialize(f); | |
238 } | 239 } |
239 | 240 |
240 void Universe::check_alignment(uintx size, uintx alignment, const char* name) { | 241 void Universe::check_alignment(uintx size, uintx alignment, const char* name) { |
241 if (size < alignment || size % alignment != 0) { | 242 if (size < alignment || size % alignment != 0) { |
242 vm_exit_during_initialization( | 243 vm_exit_during_initialization( |
661 // We have a heap so create the Method* caches before | 662 // We have a heap so create the Method* caches before |
662 // Metaspace::initialize_shared_spaces() tries to populate them. | 663 // Metaspace::initialize_shared_spaces() tries to populate them. |
663 Universe::_finalizer_register_cache = new LatestMethodCache(); | 664 Universe::_finalizer_register_cache = new LatestMethodCache(); |
664 Universe::_loader_addClass_cache = new LatestMethodCache(); | 665 Universe::_loader_addClass_cache = new LatestMethodCache(); |
665 Universe::_pd_implies_cache = new LatestMethodCache(); | 666 Universe::_pd_implies_cache = new LatestMethodCache(); |
667 Universe::_throw_illegal_access_error_cache = new LatestMethodCache(); | |
666 | 668 |
667 if (UseSharedSpaces) { | 669 if (UseSharedSpaces) { |
668 // Read the data structures supporting the shared spaces (shared | 670 // Read the data structures supporting the shared spaces (shared |
669 // system dictionary, symbol table, etc.). After that, access to | 671 // system dictionary, symbol table, etc.). After that, access to |
670 // the file (other than the mapped regions) is no longer needed, and | 672 // the file (other than the mapped regions) is no longer needed, and |
845 // This also makes implicit null checking work, because the | 847 // This also makes implicit null checking work, because the |
846 // memory+1 page below heap_base needs to cause a signal. | 848 // memory+1 page below heap_base needs to cause a signal. |
847 // See needs_explicit_null_check. | 849 // See needs_explicit_null_check. |
848 // Only set the heap base for compressed oops because it indicates | 850 // Only set the heap base for compressed oops because it indicates |
849 // compressed oops for pstack code. | 851 // compressed oops for pstack code. |
850 bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose); | |
851 if (verbose) { | |
852 tty->cr(); | |
853 tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", | |
854 Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M); | |
855 } | |
856 if (((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax)) { | 852 if (((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax)) { |
857 // Can't reserve heap below 32Gb. | 853 // Can't reserve heap below 32Gb. |
858 // keep the Universe::narrow_oop_base() set in Universe::reserve_heap() | 854 // keep the Universe::narrow_oop_base() set in Universe::reserve_heap() |
859 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); | 855 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); |
860 #ifdef AIX | 856 #ifdef AIX |
861 // There is no protected page before the heap. This assures all oops | 857 // There is no protected page before the heap. This assures all oops |
862 // are decoded so that NULL is preserved, so this page will not be accessed. | 858 // are decoded so that NULL is preserved, so this page will not be accessed. |
863 Universe::set_narrow_oop_use_implicit_null_checks(false); | 859 Universe::set_narrow_oop_use_implicit_null_checks(false); |
864 #endif | 860 #endif |
865 if (verbose) { | |
866 tty->print(", %s: "PTR_FORMAT, | |
867 narrow_oop_mode_to_string(HeapBasedNarrowOop), | |
868 Universe::narrow_oop_base()); | |
869 } | |
870 } else { | 861 } else { |
871 Universe::set_narrow_oop_base(0); | 862 Universe::set_narrow_oop_base(0); |
872 if (verbose) { | |
873 tty->print(", %s", narrow_oop_mode_to_string(ZeroBasedNarrowOop)); | |
874 } | |
875 #ifdef _WIN64 | 863 #ifdef _WIN64 |
876 if (!Universe::narrow_oop_use_implicit_null_checks()) { | 864 if (!Universe::narrow_oop_use_implicit_null_checks()) { |
877 // Don't need guard page for implicit checks in indexed addressing | 865 // Don't need guard page for implicit checks in indexed addressing |
878 // mode with zero based Compressed Oops. | 866 // mode with zero based Compressed Oops. |
879 Universe::set_narrow_oop_use_implicit_null_checks(true); | 867 Universe::set_narrow_oop_use_implicit_null_checks(true); |
882 if((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) { | 870 if((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) { |
883 // Can't reserve heap below 4Gb. | 871 // Can't reserve heap below 4Gb. |
884 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); | 872 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); |
885 } else { | 873 } else { |
886 Universe::set_narrow_oop_shift(0); | 874 Universe::set_narrow_oop_shift(0); |
887 if (verbose) { | |
888 tty->print(", %s", narrow_oop_mode_to_string(UnscaledNarrowOop)); | |
889 } | |
890 } | 875 } |
891 } | 876 } |
892 | 877 |
893 if (verbose) { | |
894 tty->cr(); | |
895 tty->cr(); | |
896 } | |
897 Universe::set_narrow_ptrs_base(Universe::narrow_oop_base()); | 878 Universe::set_narrow_ptrs_base(Universe::narrow_oop_base()); |
879 | |
880 if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) { | |
881 Universe::print_compressed_oops_mode(); | |
882 } | |
898 } | 883 } |
899 // Universe::narrow_oop_base() is one page below the heap. | 884 // Universe::narrow_oop_base() is one page below the heap. |
900 assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - | 885 assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - |
901 os::vm_page_size()) || | 886 os::vm_page_size()) || |
902 Universe::narrow_oop_base() == NULL, "invalid value"); | 887 Universe::narrow_oop_base() == NULL, "invalid value"); |
913 ThreadLocalAllocBuffer::startup_initialization(); | 898 ThreadLocalAllocBuffer::startup_initialization(); |
914 } | 899 } |
915 return JNI_OK; | 900 return JNI_OK; |
916 } | 901 } |
917 | 902 |
903 void Universe::print_compressed_oops_mode() { | |
904 tty->cr(); | |
905 tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB", | |
906 Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M); | |
907 | |
908 tty->print(", Compressed Oops mode: %s", narrow_oop_mode_to_string(narrow_oop_mode())); | |
909 | |
910 if (Universe::narrow_oop_base() != 0) { | |
911 tty->print(":" PTR_FORMAT, Universe::narrow_oop_base()); | |
912 } | |
913 | |
914 if (Universe::narrow_oop_shift() != 0) { | |
915 tty->print(", Oop shift amount: %d", Universe::narrow_oop_shift()); | |
916 } | |
917 | |
918 tty->cr(); | |
919 tty->cr(); | |
920 } | |
918 | 921 |
919 // Reserve the Java heap, which is now the same for all GCs. | 922 // Reserve the Java heap, which is now the same for all GCs. |
920 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { | 923 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { |
921 assert(alignment <= Arguments::conservative_max_heap_alignment(), | 924 assert(alignment <= Arguments::conservative_max_heap_alignment(), |
922 err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT, | 925 err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT, |
982 | 985 |
983 | 986 |
984 const char* Universe::narrow_oop_mode_to_string(Universe::NARROW_OOP_MODE mode) { | 987 const char* Universe::narrow_oop_mode_to_string(Universe::NARROW_OOP_MODE mode) { |
985 switch (mode) { | 988 switch (mode) { |
986 case UnscaledNarrowOop: | 989 case UnscaledNarrowOop: |
987 return "32-bits Oops"; | 990 return "32-bit"; |
988 case ZeroBasedNarrowOop: | 991 case ZeroBasedNarrowOop: |
989 return "zero based Compressed Oops"; | 992 return "Zero based"; |
990 case HeapBasedNarrowOop: | 993 case HeapBasedNarrowOop: |
991 return "Compressed Oops with base"; | 994 return "Non-zero based"; |
992 } | 995 } |
993 | 996 |
994 ShouldNotReachHere(); | 997 ShouldNotReachHere(); |
995 return ""; | 998 return ""; |
996 } | 999 } |
1132 // Note null is okay; this method is used in itables, and if it is null, | 1135 // Note null is okay; this method is used in itables, and if it is null, |
1133 // then AbstractMethodError is thrown instead. | 1136 // then AbstractMethodError is thrown instead. |
1134 tty->print_cr("Unable to link/verify Unsafe.throwIllegalAccessError method"); | 1137 tty->print_cr("Unable to link/verify Unsafe.throwIllegalAccessError method"); |
1135 return false; // initialization failed (cannot throw exception yet) | 1138 return false; // initialization failed (cannot throw exception yet) |
1136 } | 1139 } |
1137 Universe::_throw_illegal_access_error = m; | 1140 Universe::_throw_illegal_access_error_cache->init( |
1141 SystemDictionary::misc_Unsafe_klass(), m); | |
1138 | 1142 |
1139 // Setup method for registering loaded classes in class loader vector | 1143 // Setup method for registering loaded classes in class loader vector |
1140 InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->link_class(CHECK_false); | 1144 InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->link_class(CHECK_false); |
1141 m = InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->find_method(vmSymbols::addClass_name(), vmSymbols::class_void_signature()); | 1145 m = InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->find_method(vmSymbols::addClass_name(), vmSymbols::class_void_signature()); |
1142 if (m == NULL || m->is_static()) { | 1146 if (m == NULL || m->is_static()) { |
1158 // <init> function before java_lang_Class is linked. Print error and exit. | 1162 // <init> function before java_lang_Class is linked. Print error and exit. |
1159 tty->print_cr("ProtectionDomain.impliesCreateAccessControlContext() has the wrong linkage"); | 1163 tty->print_cr("ProtectionDomain.impliesCreateAccessControlContext() has the wrong linkage"); |
1160 return false; // initialization failed | 1164 return false; // initialization failed |
1161 } | 1165 } |
1162 Universe::_pd_implies_cache->init( | 1166 Universe::_pd_implies_cache->init( |
1163 SystemDictionary::ProtectionDomain_klass(), m);; | 1167 SystemDictionary::ProtectionDomain_klass(), m); |
1164 } | 1168 } |
1165 | 1169 |
1166 // The folowing is initializing converter functions for serialization in | 1170 // The folowing is initializing converter functions for serialization in |
1167 // JVM.cpp. If we clean up the StrictMath code above we may want to find | 1171 // JVM.cpp. If we clean up the StrictMath code above we may want to find |
1168 // a better solution for this as well. | 1172 // a better solution for this as well. |