src/share/vm/memory/metaspace.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/memory

src/share/vm/memory/metaspace.cpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 #include "precompiled.hpp"

  25 #include "gc/shared/collectedHeap.hpp"
  26 #include "gc/shared/collectorPolicy.hpp"
  27 #include "gc/shared/gcLocker.hpp"
  28 #include "logging/log.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "memory/binaryTreeDictionary.hpp"
  31 #include "memory/filemap.hpp"
  32 #include "memory/freeList.hpp"
  33 #include "memory/metachunk.hpp"
  34 #include "memory/metaspace.hpp"
  35 #include "memory/metaspaceGCThresholdUpdater.hpp"
  36 #include "memory/metaspaceShared.hpp"
  37 #include "memory/metaspaceTracer.hpp"
  38 #include "memory/resourceArea.hpp"
  39 #include "memory/universe.hpp"
  40 #include "runtime/atomic.hpp"
  41 #include "runtime/globals.hpp"
  42 #include "runtime/init.hpp"
  43 #include "runtime/java.hpp"
  44 #include "runtime/mutex.hpp"


2995 #endif
2996   {
2997     higher_address = metaspace_base + compressed_class_space_size();
2998     lower_base = metaspace_base;
2999 
3000     uint64_t klass_encoding_max = UnscaledClassSpaceMax << LogKlassAlignmentInBytes;
3001     // If compressed class space fits in lower 32G, we don't need a base.
3002     if (higher_address <= (address)klass_encoding_max) {
3003       lower_base = 0; // Effectively lower base is zero.
3004     }
3005   }
3006 
3007   Universe::set_narrow_klass_base(lower_base);
3008 
3009   if ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) {
3010     Universe::set_narrow_klass_shift(0);
3011   } else {
3012     assert(!UseSharedSpaces, "Cannot shift with UseSharedSpaces");
3013     Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes);
3014   }

3015 }
3016 
3017 #if INCLUDE_CDS
3018 // Return TRUE if the specified metaspace_base and cds_base are close enough
3019 // to work with compressed klass pointers.
3020 bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) {
3021   assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS");
3022   assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
3023   address lower_base = MIN2((address)metaspace_base, cds_base);
3024   address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()),
3025                                 (address)(metaspace_base + compressed_class_space_size()));
3026   return ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax);
3027 }
3028 #endif
3029 
3030 // Try to allocate the metaspace at the requested addr.
3031 void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) {
3032   assert(using_class_space(), "called improperly");
3033   assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
3034   assert(compressed_class_space_size() < KlassEncodingMetaspaceMax,




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 #include "precompiled.hpp"
  25 #include "aot/aotLoader.hpp"
  26 #include "gc/shared/collectedHeap.hpp"
  27 #include "gc/shared/collectorPolicy.hpp"
  28 #include "gc/shared/gcLocker.hpp"
  29 #include "logging/log.hpp"
  30 #include "memory/allocation.hpp"
  31 #include "memory/binaryTreeDictionary.hpp"
  32 #include "memory/filemap.hpp"
  33 #include "memory/freeList.hpp"
  34 #include "memory/metachunk.hpp"
  35 #include "memory/metaspace.hpp"
  36 #include "memory/metaspaceGCThresholdUpdater.hpp"
  37 #include "memory/metaspaceShared.hpp"
  38 #include "memory/metaspaceTracer.hpp"
  39 #include "memory/resourceArea.hpp"
  40 #include "memory/universe.hpp"
  41 #include "runtime/atomic.hpp"
  42 #include "runtime/globals.hpp"
  43 #include "runtime/init.hpp"
  44 #include "runtime/java.hpp"
  45 #include "runtime/mutex.hpp"


2996 #endif
2997   {
2998     higher_address = metaspace_base + compressed_class_space_size();
2999     lower_base = metaspace_base;
3000 
3001     uint64_t klass_encoding_max = UnscaledClassSpaceMax << LogKlassAlignmentInBytes;
3002     // If compressed class space fits in lower 32G, we don't need a base.
3003     if (higher_address <= (address)klass_encoding_max) {
3004       lower_base = 0; // Effectively lower base is zero.
3005     }
3006   }
3007 
3008   Universe::set_narrow_klass_base(lower_base);
3009 
3010   if ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) {
3011     Universe::set_narrow_klass_shift(0);
3012   } else {
3013     assert(!UseSharedSpaces, "Cannot shift with UseSharedSpaces");
3014     Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes);
3015   }
3016   AOTLoader::set_narrow_klass_shift();
3017 }
3018 
3019 #if INCLUDE_CDS
3020 // Return TRUE if the specified metaspace_base and cds_base are close enough
3021 // to work with compressed klass pointers.
3022 bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base) {
3023   assert(cds_base != 0 && UseSharedSpaces, "Only use with CDS");
3024   assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
3025   address lower_base = MIN2((address)metaspace_base, cds_base);
3026   address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()),
3027                                 (address)(metaspace_base + compressed_class_space_size()));
3028   return ((uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax);
3029 }
3030 #endif
3031 
3032 // Try to allocate the metaspace at the requested addr.
3033 void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) {
3034   assert(using_class_space(), "called improperly");
3035   assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs");
3036   assert(compressed_class_space_size() < KlassEncodingMetaspaceMax,


src/share/vm/memory/metaspace.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File