comparison src/share/vm/memory/universe.cpp @ 12355:cefad50507d8

Merge with hs25-b53
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 11 Oct 2013 10:38:03 +0200
parents 58fc8e2b7b6d da051ce490eb
children 096c224171c4
comparison
equal deleted inserted replaced
12058:ccb4f2af2319 12355:cefad50507d8
600 java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(exc); 600 java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(exc);
601 return exc; 601 return exc;
602 } 602 }
603 } 603 }
604 604
605 static intptr_t non_oop_bits = 0; 605 intptr_t Universe::_non_oop_bits = 0;
606 606
607 void* Universe::non_oop_word() { 607 void* Universe::non_oop_word() {
608 // Neither the high bits nor the low bits of this value is allowed 608 // Neither the high bits nor the low bits of this value is allowed
609 // to look like (respectively) the high or low bits of a real oop. 609 // to look like (respectively) the high or low bits of a real oop.
610 // 610 //
614 // word will never look like that of a real oop. 614 // word will never look like that of a real oop.
615 // 615 //
616 // Using the OS-supplied non-memory-address word (usually 0 or -1) 616 // Using the OS-supplied non-memory-address word (usually 0 or -1)
617 // will take care of the high bits, however many there are. 617 // will take care of the high bits, however many there are.
618 618
619 if (non_oop_bits == 0) { 619 if (_non_oop_bits == 0) {
620 non_oop_bits = (intptr_t)os::non_memory_address_word() | 1; 620 _non_oop_bits = (intptr_t)os::non_memory_address_word() | 1;
621 } 621 }
622 622
623 return (void*)non_oop_bits; 623 return (void*)_non_oop_bits;
624 } 624 }
625 625
626 jint universe_init() { 626 jint universe_init() {
627 assert(!Universe::_fully_initialized, "called after initialize_vtables"); 627 assert(!Universe::_fully_initialized, "called after initialize_vtables");
628 guarantee(1 << LogHeapWordSize == sizeof(HeapWord), 628 guarantee(1 << LogHeapWordSize == sizeof(HeapWord),
679 // 4Gb 679 // 4Gb
680 static const uint64_t NarrowOopHeapMax = (uint64_t(max_juint) + 1); 680 static const uint64_t NarrowOopHeapMax = (uint64_t(max_juint) + 1);
681 // 32Gb 681 // 32Gb
682 // OopEncodingHeapMax == NarrowOopHeapMax << LogMinObjAlignmentInBytes; 682 // OopEncodingHeapMax == NarrowOopHeapMax << LogMinObjAlignmentInBytes;
683 683
684 char* Universe::preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode) { 684 char* Universe::preferred_heap_base(size_t heap_size, size_t alignment, NARROW_OOP_MODE mode) {
685 assert(is_size_aligned((size_t)OopEncodingHeapMax, alignment), "Must be");
686 assert(is_size_aligned((size_t)NarrowOopHeapMax, alignment), "Must be");
687 assert(is_size_aligned(heap_size, alignment), "Must be");
688
689 uintx heap_base_min_address_aligned = align_size_up(HeapBaseMinAddress, alignment);
690
685 size_t base = 0; 691 size_t base = 0;
686 #ifdef _LP64 692 #ifdef _LP64
687 if (UseCompressedOops) { 693 if (UseCompressedOops) {
688 assert(mode == UnscaledNarrowOop || 694 assert(mode == UnscaledNarrowOop ||
689 mode == ZeroBasedNarrowOop || 695 mode == ZeroBasedNarrowOop ||
690 mode == HeapBasedNarrowOop, "mode is invalid"); 696 mode == HeapBasedNarrowOop, "mode is invalid");
691 const size_t total_size = heap_size + HeapBaseMinAddress; 697 const size_t total_size = heap_size + heap_base_min_address_aligned;
692 // Return specified base for the first request. 698 // Return specified base for the first request.
693 if (!FLAG_IS_DEFAULT(HeapBaseMinAddress) && (mode == UnscaledNarrowOop)) { 699 if (!FLAG_IS_DEFAULT(HeapBaseMinAddress) && (mode == UnscaledNarrowOop)) {
694 base = HeapBaseMinAddress; 700 base = heap_base_min_address_aligned;
695 701
696 // If the total size is small enough to allow UnscaledNarrowOop then 702 // If the total size is small enough to allow UnscaledNarrowOop then
697 // just use UnscaledNarrowOop. 703 // just use UnscaledNarrowOop.
698 } else if ((total_size <= OopEncodingHeapMax) && (mode != HeapBasedNarrowOop)) { 704 } else if ((total_size <= OopEncodingHeapMax) && (mode != HeapBasedNarrowOop)) {
699 if ((total_size <= NarrowOopHeapMax) && (mode == UnscaledNarrowOop) && 705 if ((total_size <= NarrowOopHeapMax) && (mode == UnscaledNarrowOop) &&
740 } 746 }
741 #endif // _WIN64 747 #endif // _WIN64
742 } 748 }
743 } 749 }
744 #endif 750 #endif
751
752 assert(is_ptr_aligned((char*)base, alignment), "Must be");
745 return (char*)base; // also return NULL (don't care) for 32-bit VM 753 return (char*)base; // also return NULL (don't care) for 32-bit VM
746 } 754 }
747 755
748 jint Universe::initialize_heap() { 756 jint Universe::initialize_heap() {
749 757
862 } 870 }
863 871
864 872
865 // Reserve the Java heap, which is now the same for all GCs. 873 // Reserve the Java heap, which is now the same for all GCs.
866 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { 874 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
875 assert(alignment <= Arguments::conservative_max_heap_alignment(),
876 err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT,
877 alignment, Arguments::conservative_max_heap_alignment()));
867 size_t total_reserved = align_size_up(heap_size, alignment); 878 size_t total_reserved = align_size_up(heap_size, alignment);
868 assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())), 879 assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())),
869 "heap size is too big for compressed oops"); 880 "heap size is too big for compressed oops");
870 char* addr = Universe::preferred_heap_base(total_reserved, Universe::UnscaledNarrowOop); 881
871 882 bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size());
872 ReservedHeapSpace total_rs(total_reserved, alignment, UseLargePages, addr); 883 assert(!UseLargePages
884 || UseParallelGC
885 || use_large_pages, "Wrong alignment to use large pages");
886
887 char* addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::UnscaledNarrowOop);
888
889 ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages, addr);
873 890
874 if (UseCompressedOops) { 891 if (UseCompressedOops) {
875 if (addr != NULL && !total_rs.is_reserved()) { 892 if (addr != NULL && !total_rs.is_reserved()) {
876 // Failed to reserve at specified address - the requested memory 893 // Failed to reserve at specified address - the requested memory
877 // region is taken already, for example, by 'java' launcher. 894 // region is taken already, for example, by 'java' launcher.
878 // Try again to reserver heap higher. 895 // Try again to reserver heap higher.
879 addr = Universe::preferred_heap_base(total_reserved, Universe::ZeroBasedNarrowOop); 896 addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::ZeroBasedNarrowOop);
880 897
881 ReservedHeapSpace total_rs0(total_reserved, alignment, 898 ReservedHeapSpace total_rs0(total_reserved, alignment,
882 UseLargePages, addr); 899 use_large_pages, addr);
883 900
884 if (addr != NULL && !total_rs0.is_reserved()) { 901 if (addr != NULL && !total_rs0.is_reserved()) {
885 // Failed to reserve at specified address again - give up. 902 // Failed to reserve at specified address again - give up.
886 addr = Universe::preferred_heap_base(total_reserved, Universe::HeapBasedNarrowOop); 903 addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::HeapBasedNarrowOop);
887 assert(addr == NULL, ""); 904 assert(addr == NULL, "");
888 905
889 ReservedHeapSpace total_rs1(total_reserved, alignment, 906 ReservedHeapSpace total_rs1(total_reserved, alignment,
890 UseLargePages, addr); 907 use_large_pages, addr);
891 total_rs = total_rs1; 908 total_rs = total_rs1;
892 } else { 909 } else {
893 total_rs = total_rs0; 910 total_rs = total_rs0;
894 } 911 }
895 } 912 }
1012 Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false); 1029 Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false);
1013 java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg()); 1030 java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg());
1014 1031
1015 msg = java_lang_String::create_from_str("Metadata space", CHECK_false); 1032 msg = java_lang_String::create_from_str("Metadata space", CHECK_false);
1016 java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg()); 1033 java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg());
1017 msg = java_lang_String::create_from_str("Class Metadata space", CHECK_false); 1034 msg = java_lang_String::create_from_str("Compressed class space", CHECK_false);
1018 java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg()); 1035 java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg());
1019 1036
1020 msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false); 1037 msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false);
1021 java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg()); 1038 java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg());
1022 1039
1099 // ("weak") refs processing infrastructure initialization 1116 // ("weak") refs processing infrastructure initialization
1100 Universe::heap()->post_initialize(); 1117 Universe::heap()->post_initialize();
1101 1118
1102 // Initialize performance counters for metaspaces 1119 // Initialize performance counters for metaspaces
1103 MetaspaceCounters::initialize_performance_counters(); 1120 MetaspaceCounters::initialize_performance_counters();
1121 CompressedClassSpaceCounters::initialize_performance_counters();
1122
1104 MemoryService::add_metaspace_memory_pools(); 1123 MemoryService::add_metaspace_memory_pools();
1105 1124
1106 GC_locker::unlock(); // allow gc after bootstrapping 1125 GC_locker::unlock(); // allow gc after bootstrapping
1107 1126
1108 MemoryService::set_universe_heap(Universe::_collectedHeap); 1127 MemoryService::set_universe_heap(Universe::_collectedHeap);