< prev index next >

src/hotspot/share/memory/metaspace.cpp

Print this page




 935 
 936 void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address cds_base) {
 937   assert(!DumpSharedSpaces, "narrow_klass is set by MetaspaceShared class.");
 938   // Figure out the narrow_klass_base and the narrow_klass_shift.  The
 939   // narrow_klass_base is the lower of the metaspace base and the cds base
 940   // (if cds is enabled).  The narrow_klass_shift depends on the distance
 941   // between the lower base and higher address.
 942   address lower_base;
 943   address higher_address;
 944 #if INCLUDE_CDS
 945   if (UseSharedSpaces) {
 946     higher_address = MAX2((address)(cds_base + MetaspaceShared::core_spaces_size()),
 947                           (address)(metaspace_base + compressed_class_space_size()));
 948     lower_base = MIN2(metaspace_base, cds_base);
 949   } else
 950 #endif
 951   {
 952     higher_address = metaspace_base + compressed_class_space_size();
 953     lower_base = metaspace_base;
 954 
 955     uint64_t klass_encoding_max = UnscaledClassSpaceMax << LogKlassAlignmentInBytes;

 956     // If compressed class space fits in lower 32G, we don't need a base.
 957     if (higher_address <= (address)klass_encoding_max) {
 958       lower_base = 0; // Effectively lower base is zero.
 959     }
 960   }
 961 
 962   Universe::set_narrow_klass_base(lower_base);
 963 
 964   // CDS uses LogKlassAlignmentInBytes for narrow_klass_shift. See
 965   // MetaspaceShared::initialize_dumptime_shared_and_meta_spaces() for
 966   // how dump time narrow_klass_shift is set. Although, CDS can work
 967   // with zero-shift mode also, to be consistent with AOT it uses
 968   // LogKlassAlignmentInBytes for klass shift so archived java heap objects
 969   // can be used at same time as AOT code.
 970   if (!UseSharedSpaces
 971       && (uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) {
 972     Universe::set_narrow_klass_shift(0);
 973   } else {
 974     Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes);
 975   }




 935 
 936 void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address cds_base) {
 937   assert(!DumpSharedSpaces, "narrow_klass is set by MetaspaceShared class.");
 938   // Figure out the narrow_klass_base and the narrow_klass_shift.  The
 939   // narrow_klass_base is the lower of the metaspace base and the cds base
 940   // (if cds is enabled).  The narrow_klass_shift depends on the distance
 941   // between the lower base and higher address.
 942   address lower_base;
 943   address higher_address;
 944 #if INCLUDE_CDS
 945   if (UseSharedSpaces) {
 946     higher_address = MAX2((address)(cds_base + MetaspaceShared::core_spaces_size()),
 947                           (address)(metaspace_base + compressed_class_space_size()));
 948     lower_base = MIN2(metaspace_base, cds_base);
 949   } else
 950 #endif
 951   {
 952     higher_address = metaspace_base + compressed_class_space_size();
 953     lower_base = metaspace_base;
 954 
 955     // Using oopDesc::_metadata high bits so LogKlassAlignmentInBytes shift is no longer possible
 956     uint64_t klass_encoding_max = UnscaledClassSpaceMax;
 957     // If compressed class space fits in lower 32G, we don't need a base.
 958     if (higher_address <= (address)klass_encoding_max) {
 959       lower_base = 0; // Effectively lower base is zero.
 960     }
 961   }
 962 
 963   Universe::set_narrow_klass_base(lower_base);
 964 
 965   // CDS uses LogKlassAlignmentInBytes for narrow_klass_shift. See
 966   // MetaspaceShared::initialize_dumptime_shared_and_meta_spaces() for
 967   // how dump time narrow_klass_shift is set. Although, CDS can work
 968   // with zero-shift mode also, to be consistent with AOT it uses
 969   // LogKlassAlignmentInBytes for klass shift so archived java heap objects
 970   // can be used at same time as AOT code.
 971   if (!UseSharedSpaces
 972       && (uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) {
 973     Universe::set_narrow_klass_shift(0);
 974   } else {
 975     Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes);
 976   }


< prev index next >