src/share/vm/memory/universe.cpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


 802   if (UseCompressedOops) {
 803     // Subtract a page because something can get allocated at heap base.
 804     // This also makes implicit null checking work, because the
 805     // memory+1 page below heap_base needs to cause a signal.
 806     // See needs_explicit_null_check.
 807     // Only set the heap base for compressed oops because it indicates
 808     // compressed oops for pstack code.
 809     bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose);
 810     if (verbose) {
 811       tty->cr();
 812       tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
 813                  Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
 814     }
 815     if (((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax) ||
 816         (UseCompressedKlassPointers &&
 817         ((uint64_t)Universe::heap()->base() + Universe::class_metaspace_size() > KlassEncodingMetaspaceMax))) {
 818       // Can't reserve heap below 32Gb.
 819       // keep the Universe::narrow_oop_base() set in Universe::reserve_heap()
 820       Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
 821       if (verbose) {
 822         tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base());


 823       }
 824     } else {
 825       Universe::set_narrow_oop_base(0);
 826       if (verbose) {
 827         tty->print(", zero based Compressed Oops");
 828       }
 829 #ifdef _WIN64
 830       if (!Universe::narrow_oop_use_implicit_null_checks()) {
 831         // Don't need guard page for implicit checks in indexed addressing
 832         // mode with zero based Compressed Oops.
 833         Universe::set_narrow_oop_use_implicit_null_checks(true);
 834       }
 835 #endif //  _WIN64
 836       if((uint64_t)Universe::heap()->reserved_region().end() > NarrowOopHeapMax) {
 837         // Can't reserve heap below 4Gb.
 838         Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
 839       } else {
 840         Universe::set_narrow_oop_shift(0);
 841         if (verbose) {
 842           tty->print(", 32-bits Oops");
 843         }
 844       }
 845     }
 846     if (verbose) {
 847       tty->cr();
 848       tty->cr();
 849     }
 850     if (UseCompressedKlassPointers) {
 851       Universe::set_narrow_klass_base(Universe::narrow_oop_base());
 852       Universe::set_narrow_klass_shift(MIN2(Universe::narrow_oop_shift(), LogKlassAlignmentInBytes));
 853     }
 854     Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
 855   }
 856   // Universe::narrow_oop_base() is one page below the metaspace
 857   // base. The actual metaspace base depends on alignment constraints
 858   // so we don't know its exact location here.
 859   assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - os::vm_page_size() - ClassMetaspaceSize) ||
 860          Universe::narrow_oop_base() == NULL, "invalid value");
 861   assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
 862          Universe::narrow_oop_shift() == 0, "invalid value");


 929   Metaspace::initialize_class_space(class_rs);
 930 
 931   if (UseCompressedOops) {
 932     // Universe::initialize_heap() will reset this to NULL if unscaled
 933     // or zero-based narrow oops are actually used.
 934     address base = (address)(total_rs.base() - os::vm_page_size());
 935     Universe::set_narrow_oop_base(base);
 936   }
 937   return heap_rs;
 938 }
 939 
 940 
 941 // It's the caller's repsonsibility to ensure glitch-freedom
 942 // (if required).
 943 void Universe::update_heap_info_at_gc() {
 944   _heap_capacity_at_last_gc = heap()->capacity();
 945   _heap_used_at_last_gc     = heap()->used();
 946 }
 947 
 948 



























 949 
 950 void universe2_init() {
 951   EXCEPTION_MARK;
 952   Universe::genesis(CATCH);
 953 }
 954 
 955 
 956 // This function is defined in JVM.cpp
 957 extern void initialize_converter_functions();
 958 
 959 bool universe_post_init() {
 960   assert(!is_init_completed(), "Error: initialization not yet completed!");
 961   Universe::_fully_initialized = true;
 962   EXCEPTION_MARK;
 963   { ResourceMark rm;
 964     Interpreter::initialize();      // needed for interpreter entry points
 965     if (!UseSharedSpaces) {
 966       HandleMark hm(THREAD);
 967       KlassHandle ok_h(THREAD, SystemDictionary::Object_klass());
 968       Universe::reinitialize_vtable_of(ok_h, CHECK_false);




 802   if (UseCompressedOops) {
 803     // Subtract a page because something can get allocated at heap base.
 804     // This also makes implicit null checking work, because the
 805     // memory+1 page below heap_base needs to cause a signal.
 806     // See needs_explicit_null_check.
 807     // Only set the heap base for compressed oops because it indicates
 808     // compressed oops for pstack code.
 809     bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose);
 810     if (verbose) {
 811       tty->cr();
 812       tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
 813                  Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
 814     }
 815     if (((uint64_t)Universe::heap()->reserved_region().end() > OopEncodingHeapMax) ||
 816         (UseCompressedKlassPointers &&
 817         ((uint64_t)Universe::heap()->base() + Universe::class_metaspace_size() > KlassEncodingMetaspaceMax))) {
 818       // Can't reserve heap below 32Gb.
 819       // keep the Universe::narrow_oop_base() set in Universe::reserve_heap()
 820       Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
 821       if (verbose) {
 822         tty->print(", %s: "PTR_FORMAT,
 823             narrow_oop_mode_to_string(HeapBasedNarrowOop),
 824             Universe::narrow_oop_base());
 825       }
 826     } else {
 827       Universe::set_narrow_oop_base(0);
 828       if (verbose) {
 829         tty->print(", %s", narrow_oop_mode_to_string(ZeroBasedNarrowOop));
 830       }
 831 #ifdef _WIN64
 832       if (!Universe::narrow_oop_use_implicit_null_checks()) {
 833         // Don't need guard page for implicit checks in indexed addressing
 834         // mode with zero based Compressed Oops.
 835         Universe::set_narrow_oop_use_implicit_null_checks(true);
 836       }
 837 #endif //  _WIN64
 838       if((uint64_t)Universe::heap()->reserved_region().end() > NarrowOopHeapMax) {
 839         // Can't reserve heap below 4Gb.
 840         Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
 841       } else {
 842         Universe::set_narrow_oop_shift(0);
 843         if (verbose) {
 844           tty->print(", %s", narrow_oop_mode_to_string(UnscaledNarrowOop));
 845         }
 846       }
 847     }
 848     if (verbose) {
 849       tty->cr();
 850       tty->cr();
 851     }
 852     if (UseCompressedKlassPointers) {
 853       Universe::set_narrow_klass_base(Universe::narrow_oop_base());
 854       Universe::set_narrow_klass_shift(MIN2(Universe::narrow_oop_shift(), LogKlassAlignmentInBytes));
 855     }
 856     Universe::set_narrow_ptrs_base(Universe::narrow_oop_base());
 857   }
 858   // Universe::narrow_oop_base() is one page below the metaspace
 859   // base. The actual metaspace base depends on alignment constraints
 860   // so we don't know its exact location here.
 861   assert((intptr_t)Universe::narrow_oop_base() <= (intptr_t)(Universe::heap()->base() - os::vm_page_size() - ClassMetaspaceSize) ||
 862          Universe::narrow_oop_base() == NULL, "invalid value");
 863   assert(Universe::narrow_oop_shift() == LogMinObjAlignmentInBytes ||
 864          Universe::narrow_oop_shift() == 0, "invalid value");


 931   Metaspace::initialize_class_space(class_rs);
 932 
 933   if (UseCompressedOops) {
 934     // Universe::initialize_heap() will reset this to NULL if unscaled
 935     // or zero-based narrow oops are actually used.
 936     address base = (address)(total_rs.base() - os::vm_page_size());
 937     Universe::set_narrow_oop_base(base);
 938   }
 939   return heap_rs;
 940 }
 941 
 942 
 943 // It's the caller's repsonsibility to ensure glitch-freedom
 944 // (if required).
 945 void Universe::update_heap_info_at_gc() {
 946   _heap_capacity_at_last_gc = heap()->capacity();
 947   _heap_used_at_last_gc     = heap()->used();
 948 }
 949 
 950 
 951 const char* Universe::narrow_oop_mode_to_string(Universe::NARROW_OOP_MODE mode) {
 952   switch (mode) {
 953     case UnscaledNarrowOop:
 954       return "32-bits Oops";
 955     case ZeroBasedNarrowOop:
 956       return "zero based Compressed Oops";
 957     case HeapBasedNarrowOop:
 958       return "Compressed Oops with base";
 959   }
 960 
 961   ShouldNotReachHere();
 962   return "";
 963 }
 964 
 965 
 966 Universe::NARROW_OOP_MODE Universe::narrow_oop_mode() {
 967   if (narrow_oop_base() != 0) {
 968     return HeapBasedNarrowOop;
 969   }
 970 
 971   if (narrow_oop_shift() != 0) {
 972     return ZeroBasedNarrowOop;
 973   }
 974 
 975   return UnscaledNarrowOop;
 976 }
 977 
 978 
 979 void universe2_init() {
 980   EXCEPTION_MARK;
 981   Universe::genesis(CATCH);
 982 }
 983 
 984 
 985 // This function is defined in JVM.cpp
 986 extern void initialize_converter_functions();
 987 
 988 bool universe_post_init() {
 989   assert(!is_init_completed(), "Error: initialization not yet completed!");
 990   Universe::_fully_initialized = true;
 991   EXCEPTION_MARK;
 992   { ResourceMark rm;
 993     Interpreter::initialize();      // needed for interpreter entry points
 994     if (!UseSharedSpaces) {
 995       HandleMark hm(THREAD);
 996       KlassHandle ok_h(THREAD, SystemDictionary::Object_klass());
 997       Universe::reinitialize_vtable_of(ok_h, CHECK_false);