comparison src/share/vm/memory/universe.cpp @ 14422:2b8e28fdf503

Merge
author kvn
date Tue, 05 Nov 2013 17:38:04 -0800
parents e2722a66aba7 209aa13ab8c0
children da862781b584
comparison
equal deleted inserted replaced
14421:3068270ba476 14422:2b8e28fdf503
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),
675 // ZeroBased - Use zero based compressed oops with encoding when 675 // ZeroBased - Use zero based compressed oops with encoding when
676 // NarrowOopHeapBaseMin + heap_size < 32Gb 676 // NarrowOopHeapBaseMin + heap_size < 32Gb
677 // HeapBased - Use compressed oops with heap base + encoding. 677 // HeapBased - Use compressed oops with heap base + encoding.
678 678
679 // 4Gb 679 // 4Gb
680 static const uint64_t NarrowOopHeapMax = (uint64_t(max_juint) + 1); 680 static const uint64_t UnscaledOopHeapMax = (uint64_t(max_juint) + 1);
681 // 32Gb 681 // 32Gb
682 // OopEncodingHeapMax == NarrowOopHeapMax << LogMinObjAlignmentInBytes; 682 // OopEncodingHeapMax == UnscaledOopHeapMax << LogMinObjAlignmentInBytes;
683 683
684 char* Universe::preferred_heap_base(size_t heap_size, size_t alignment, 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"); 685 assert(is_size_aligned((size_t)OopEncodingHeapMax, alignment), "Must be");
686 assert(is_size_aligned((size_t)NarrowOopHeapMax, alignment), "Must be"); 686 assert(is_size_aligned((size_t)UnscaledOopHeapMax, alignment), "Must be");
687 assert(is_size_aligned(heap_size, alignment), "Must be"); 687 assert(is_size_aligned(heap_size, alignment), "Must be");
688 688
689 uintx heap_base_min_address_aligned = align_size_up(HeapBaseMinAddress, alignment); 689 uintx heap_base_min_address_aligned = align_size_up(HeapBaseMinAddress, alignment);
690 690
691 size_t base = 0; 691 size_t base = 0;
700 base = heap_base_min_address_aligned; 700 base = heap_base_min_address_aligned;
701 701
702 // If the total size is small enough to allow UnscaledNarrowOop then 702 // If the total size is small enough to allow UnscaledNarrowOop then
703 // just use UnscaledNarrowOop. 703 // just use UnscaledNarrowOop.
704 } else if ((total_size <= OopEncodingHeapMax) && (mode != HeapBasedNarrowOop)) { 704 } else if ((total_size <= OopEncodingHeapMax) && (mode != HeapBasedNarrowOop)) {
705 if ((total_size <= NarrowOopHeapMax) && (mode == UnscaledNarrowOop) && 705 if ((total_size <= UnscaledOopHeapMax) && (mode == UnscaledNarrowOop) &&
706 (Universe::narrow_oop_shift() == 0)) { 706 (Universe::narrow_oop_shift() == 0)) {
707 // Use 32-bits oops without encoding and 707 // Use 32-bits oops without encoding and
708 // place heap's top on the 4Gb boundary 708 // place heap's top on the 4Gb boundary
709 base = (NarrowOopHeapMax - heap_size); 709 base = (UnscaledOopHeapMax - heap_size);
710 } else { 710 } else {
711 // Can't reserve with NarrowOopShift == 0 711 // Can't reserve with NarrowOopShift == 0
712 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); 712 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
713
713 if (mode == UnscaledNarrowOop || 714 if (mode == UnscaledNarrowOop ||
714 mode == ZeroBasedNarrowOop && total_size <= NarrowOopHeapMax) { 715 mode == ZeroBasedNarrowOop && total_size <= UnscaledOopHeapMax) {
716
715 // Use zero based compressed oops with encoding and 717 // Use zero based compressed oops with encoding and
716 // place heap's top on the 32Gb boundary in case 718 // place heap's top on the 32Gb boundary in case
717 // total_size > 4Gb or failed to reserve below 4Gb. 719 // total_size > 4Gb or failed to reserve below 4Gb.
718 base = (OopEncodingHeapMax - heap_size); 720 uint64_t heap_top = OopEncodingHeapMax;
721
722 // For small heaps, save some space for compressed class pointer
723 // space so it can be decoded with no base.
724 if (UseCompressedClassPointers && !UseSharedSpaces &&
725 OopEncodingHeapMax <= 32*G) {
726
727 uint64_t class_space = align_size_up(CompressedClassSpaceSize, alignment);
728 assert(is_size_aligned((size_t)OopEncodingHeapMax-class_space,
729 alignment), "difference must be aligned too");
730 uint64_t new_top = OopEncodingHeapMax-class_space;
731
732 if (total_size <= new_top) {
733 heap_top = new_top;
734 }
735 }
736
737 // Align base to the adjusted top of the heap
738 base = heap_top - heap_size;
719 } 739 }
720 } 740 }
721 } else { 741 } else {
722 // UnscaledNarrowOop encoding didn't work, and no base was found for ZeroBasedOops or 742 // UnscaledNarrowOop encoding didn't work, and no base was found for ZeroBasedOops or
723 // HeapBasedNarrowOop encoding was requested. So, can't reserve below 32Gb. 743 // HeapBasedNarrowOop encoding was requested. So, can't reserve below 32Gb.
735 Universe::set_narrow_oop_use_implicit_null_checks(true); 755 Universe::set_narrow_oop_use_implicit_null_checks(true);
736 } else { 756 } else {
737 // Set to a non-NULL value so the ReservedSpace ctor computes 757 // Set to a non-NULL value so the ReservedSpace ctor computes
738 // the correct no-access prefix. 758 // the correct no-access prefix.
739 // The final value will be set in initialize_heap() below. 759 // The final value will be set in initialize_heap() below.
740 Universe::set_narrow_oop_base((address)NarrowOopHeapMax); 760 Universe::set_narrow_oop_base((address)UnscaledOopHeapMax);
741 #if defined(_WIN64) || defined(AIX) 761 #if defined(_WIN64) || defined(AIX)
742 if (UseLargePages) { 762 if (UseLargePages) {
743 // Cannot allocate guard pages for implicit checks in indexed 763 // Cannot allocate guard pages for implicit checks in indexed
744 // addressing mode when large pages are specified on windows. 764 // addressing mode when large pages are specified on windows.
745 Universe::set_narrow_oop_use_implicit_null_checks(false); 765 Universe::set_narrow_oop_use_implicit_null_checks(false);
836 // Don't need guard page for implicit checks in indexed addressing 856 // Don't need guard page for implicit checks in indexed addressing
837 // mode with zero based Compressed Oops. 857 // mode with zero based Compressed Oops.
838 Universe::set_narrow_oop_use_implicit_null_checks(true); 858 Universe::set_narrow_oop_use_implicit_null_checks(true);
839 } 859 }
840 #endif // _WIN64 860 #endif // _WIN64
841 if((uint64_t)Universe::heap()->reserved_region().end() > NarrowOopHeapMax) { 861 if((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) {
842 // Can't reserve heap below 4Gb. 862 // Can't reserve heap below 4Gb.
843 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); 863 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
844 } else { 864 } else {
845 Universe::set_narrow_oop_shift(0); 865 Universe::set_narrow_oop_shift(0);
846 if (verbose) { 866 if (verbose) {
875 } 895 }
876 896
877 897
878 // Reserve the Java heap, which is now the same for all GCs. 898 // Reserve the Java heap, which is now the same for all GCs.
879 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) { 899 ReservedSpace Universe::reserve_heap(size_t heap_size, size_t alignment) {
900 assert(alignment <= Arguments::conservative_max_heap_alignment(),
901 err_msg("actual alignment "SIZE_FORMAT" must be within maximum heap alignment "SIZE_FORMAT,
902 alignment, Arguments::conservative_max_heap_alignment()));
880 size_t total_reserved = align_size_up(heap_size, alignment); 903 size_t total_reserved = align_size_up(heap_size, alignment);
881 assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())), 904 assert(!UseCompressedOops || (total_reserved <= (OopEncodingHeapMax - os::vm_page_size())),
882 "heap size is too big for compressed oops"); 905 "heap size is too big for compressed oops");
883 906
884 bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size()); 907 bool use_large_pages = UseLargePages && is_size_aligned(alignment, os::large_page_size());
885 assert(!UseLargePages 908 assert(!UseLargePages
886 || UseParallelOldGC 909 || UseParallelGC
887 || use_large_pages, "Wrong alignment to use large pages"); 910 || use_large_pages, "Wrong alignment to use large pages");
888 911
889 char* addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::UnscaledNarrowOop); 912 char* addr = Universe::preferred_heap_base(total_reserved, alignment, Universe::UnscaledNarrowOop);
890 913
891 ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages, addr); 914 ReservedHeapSpace total_rs(total_reserved, alignment, use_large_pages, addr);
1029 // These are the only Java fields that are currently set during shared space dumping. 1052 // These are the only Java fields that are currently set during shared space dumping.
1030 // We prefer to not handle this generally, so we always reinitialize these detail messages. 1053 // We prefer to not handle this generally, so we always reinitialize these detail messages.
1031 Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false); 1054 Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false);
1032 java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg()); 1055 java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg());
1033 1056
1034 msg = java_lang_String::create_from_str("Metadata space", CHECK_false); 1057 msg = java_lang_String::create_from_str("Metaspace", CHECK_false);
1035 java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg()); 1058 java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg());
1036 msg = java_lang_String::create_from_str("Class Metadata space", CHECK_false); 1059 msg = java_lang_String::create_from_str("Compressed class space", CHECK_false);
1037 java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg()); 1060 java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg());
1038 1061
1039 msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false); 1062 msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false);
1040 java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg()); 1063 java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg());
1041 1064