src/hotspot/share/memory/metaspace/chunkAllocSequence.cpp
branchstuefe-new-metaspace-branch
changeset 58807 3863dfd99d8e
parent 58716 960e372a6065
child 58881 24152dbf6c78
equal deleted inserted replaced
58717:5e9e519e5dc9 58807:3863dfd99d8e
    57 
    57 
    58 };
    58 };
    59 
    59 
    60 // hard-coded chunk allocation sequences for various space types
    60 // hard-coded chunk allocation sequences for various space types
    61 
    61 
    62 ///////////////////////////
       
    63 // chunk allocation sequences for normal loaders:
       
    64 static const chklvl_t g_sequ_standard_non_class[] = {
    62 static const chklvl_t g_sequ_standard_non_class[] = {
    65     chklvl::CHUNK_LEVEL_4K,
    63     chklvl::CHUNK_LEVEL_4K,
    66     chklvl::CHUNK_LEVEL_4K,
    64     chklvl::CHUNK_LEVEL_4K,
    67     chklvl::CHUNK_LEVEL_4K,
    65     chklvl::CHUNK_LEVEL_4K,
    68     chklvl::CHUNK_LEVEL_4K,
    66     chklvl::CHUNK_LEVEL_4K,
    69     chklvl::CHUNK_LEVEL_64K
    67     chklvl::CHUNK_LEVEL_16K
    70     // .. repeat last
    68     // .. repeat last
    71 };
    69 };
    72 
    70 
    73 static const chklvl_t g_sequ_standard_class[] = {
    71 static const chklvl_t g_sequ_standard_class[] = {
    74     chklvl::CHUNK_LEVEL_2K,
    72     chklvl::CHUNK_LEVEL_2K,
    75     chklvl::CHUNK_LEVEL_2K,
    73     chklvl::CHUNK_LEVEL_2K,
    76     chklvl::CHUNK_LEVEL_2K,
    74     chklvl::CHUNK_LEVEL_2K,
    77     chklvl::CHUNK_LEVEL_2K,
    75     chklvl::CHUNK_LEVEL_2K,
    78     chklvl::CHUNK_LEVEL_32K
    76     chklvl::CHUNK_LEVEL_16K
    79     // .. repeat last
    77     // .. repeat last
    80 };
    78 };
    81 
    79 
    82 ///////////////////////////
       
    83 // chunk allocation sequences for reflection/anonymous loaders:
       
    84 // We allocate four smallish chunks before progressing to bigger chunks.
       
    85 static const chklvl_t g_sequ_anon_non_class[] = {
    80 static const chklvl_t g_sequ_anon_non_class[] = {
    86     chklvl::CHUNK_LEVEL_1K,
    81     chklvl::CHUNK_LEVEL_1K,
    87     chklvl::CHUNK_LEVEL_1K,
       
    88     chklvl::CHUNK_LEVEL_1K,
       
    89     chklvl::CHUNK_LEVEL_1K,
       
    90     chklvl::CHUNK_LEVEL_2K
       
    91     // .. repeat last
    82     // .. repeat last
    92 };
    83 };
    93 
    84 
    94 static const chklvl_t g_sequ_anon_class[] = {
    85 static const chklvl_t g_sequ_anon_class[] = {
    95     chklvl::CHUNK_LEVEL_1K,
    86     chklvl::CHUNK_LEVEL_1K,
       
    87     // .. repeat last
       
    88 };
       
    89 
       
    90 static const chklvl_t g_sequ_refl_non_class[] = {
       
    91     chklvl::CHUNK_LEVEL_2K,
       
    92     chklvl::CHUNK_LEVEL_1K
       
    93     // .. repeat last
       
    94 };
       
    95 
       
    96 static const chklvl_t g_sequ_refl_class[] = {
    96     chklvl::CHUNK_LEVEL_1K,
    97     chklvl::CHUNK_LEVEL_1K,
    97     chklvl::CHUNK_LEVEL_1K,
       
    98     chklvl::CHUNK_LEVEL_1K,
       
    99     chklvl::CHUNK_LEVEL_2K
       
   100     // .. repeat last
    98     // .. repeat last
   101 };
    99 };
   102 
   100 
   103 #define DEFINE_CLASS_FOR_ARRAY(what) \
   101 #define DEFINE_CLASS_FOR_ARRAY(what) \
   104   static ConstantChunkAllocSequence g_chunk_alloc_sequence_##what (g_sequ_##what, sizeof(g_sequ_##what)/sizeof(chklvl_t));
   102   static ConstantChunkAllocSequence g_chunk_alloc_sequence_##what (g_sequ_##what, sizeof(g_sequ_##what)/sizeof(chklvl_t));
   105 
   103 
   106 DEFINE_CLASS_FOR_ARRAY(standard_non_class)
   104 DEFINE_CLASS_FOR_ARRAY(standard_non_class)
   107 DEFINE_CLASS_FOR_ARRAY(standard_class)
   105 DEFINE_CLASS_FOR_ARRAY(standard_class)
   108 DEFINE_CLASS_FOR_ARRAY(anon_non_class)
   106 DEFINE_CLASS_FOR_ARRAY(anon_non_class)
   109 DEFINE_CLASS_FOR_ARRAY(anon_class)
   107 DEFINE_CLASS_FOR_ARRAY(anon_class)
       
   108 DEFINE_CLASS_FOR_ARRAY(refl_non_class)
       
   109 DEFINE_CLASS_FOR_ARRAY(refl_class)
   110 
   110 
   111 
   111 
   112 class BootLoaderChunkAllocSequence : public ChunkAllocSequence {
   112 class BootLoaderChunkAllocSequence : public ChunkAllocSequence {
   113 
   113 
   114   // For now, this mirrors what the old code did
   114   // For now, this mirrors what the old code did
   162 const ChunkAllocSequence* ChunkAllocSequence::alloc_sequence_by_space_type(MetaspaceType space_type, bool is_class) {
   162 const ChunkAllocSequence* ChunkAllocSequence::alloc_sequence_by_space_type(MetaspaceType space_type, bool is_class) {
   163 
   163 
   164   if (is_class) {
   164   if (is_class) {
   165     switch(space_type) {
   165     switch(space_type) {
   166     case StandardMetaspaceType:          return &g_chunk_alloc_sequence_standard_class;
   166     case StandardMetaspaceType:          return &g_chunk_alloc_sequence_standard_class;
   167     case ReflectionMetaspaceType:
   167     case ReflectionMetaspaceType:        return &g_chunk_alloc_sequence_refl_class;
   168     case UnsafeAnonymousMetaspaceType:   return &g_chunk_alloc_sequence_anon_class;
   168     case UnsafeAnonymousMetaspaceType:   return &g_chunk_alloc_sequence_anon_class;
   169     case BootMetaspaceType:              return &g_chunk_alloc_sequence_boot_non_class;
   169     case BootMetaspaceType:              return &g_chunk_alloc_sequence_boot_non_class;
   170     default: ShouldNotReachHere();
   170     default: ShouldNotReachHere();
   171     }
   171     }
   172   } else {
   172   } else {
   173     switch(space_type) {
   173     switch(space_type) {
   174     case StandardMetaspaceType:          return &g_chunk_alloc_sequence_standard_non_class;
   174     case StandardMetaspaceType:          return &g_chunk_alloc_sequence_standard_non_class;
   175     case ReflectionMetaspaceType:
   175     case ReflectionMetaspaceType:        return &g_chunk_alloc_sequence_refl_non_class;
   176     case UnsafeAnonymousMetaspaceType:   return &g_chunk_alloc_sequence_anon_non_class;
   176     case UnsafeAnonymousMetaspaceType:   return &g_chunk_alloc_sequence_anon_non_class;
   177     case BootMetaspaceType:              return &g_chunk_alloc_sequence_boot_non_class;
   177     case BootMetaspaceType:              return &g_chunk_alloc_sequence_boot_non_class;
   178     default: ShouldNotReachHere();
   178     default: ShouldNotReachHere();
   179     }
   179     }
   180   }
   180   }