30 #include "memory/filemap.hpp" |
30 #include "memory/filemap.hpp" |
31 #include "memory/freeList.hpp" |
31 #include "memory/freeList.hpp" |
32 #include "memory/gcLocker.hpp" |
32 #include "memory/gcLocker.hpp" |
33 #include "memory/metachunk.hpp" |
33 #include "memory/metachunk.hpp" |
34 #include "memory/metaspace.hpp" |
34 #include "memory/metaspace.hpp" |
|
35 #include "memory/metaspaceGCThresholdUpdater.hpp" |
35 #include "memory/metaspaceShared.hpp" |
36 #include "memory/metaspaceShared.hpp" |
|
37 #include "memory/metaspaceTracer.hpp" |
36 #include "memory/resourceArea.hpp" |
38 #include "memory/resourceArea.hpp" |
37 #include "memory/universe.hpp" |
39 #include "memory/universe.hpp" |
38 #include "runtime/atomic.inline.hpp" |
40 #include "runtime/atomic.inline.hpp" |
39 #include "runtime/globals.hpp" |
41 #include "runtime/globals.hpp" |
40 #include "runtime/init.hpp" |
42 #include "runtime/init.hpp" |
55 size_t const allocation_from_dictionary_limit = 4 * K; |
57 size_t const allocation_from_dictionary_limit = 4 * K; |
56 |
58 |
57 MetaWord* last_allocated = 0; |
59 MetaWord* last_allocated = 0; |
58 |
60 |
59 size_t Metaspace::_compressed_class_space_size; |
61 size_t Metaspace::_compressed_class_space_size; |
|
62 const MetaspaceTracer* Metaspace::_tracer = NULL; |
60 |
63 |
61 // Used in declarations in SpaceManager and ChunkManager |
64 // Used in declarations in SpaceManager and ChunkManager |
62 enum ChunkIndex { |
65 enum ChunkIndex { |
63 ZeroIndex = 0, |
66 ZeroIndex = 0, |
64 SpecializedIndex = ZeroIndex, |
67 SpecializedIndex = ZeroIndex, |
1434 // increment the HWM. |
1437 // increment the HWM. |
1435 size_t expand_bytes = minimum_desired_capacity - capacity_until_GC; |
1438 size_t expand_bytes = minimum_desired_capacity - capacity_until_GC; |
1436 expand_bytes = align_size_up(expand_bytes, Metaspace::commit_alignment()); |
1439 expand_bytes = align_size_up(expand_bytes, Metaspace::commit_alignment()); |
1437 // Don't expand unless it's significant |
1440 // Don't expand unless it's significant |
1438 if (expand_bytes >= MinMetaspaceExpansion) { |
1441 if (expand_bytes >= MinMetaspaceExpansion) { |
1439 MetaspaceGC::inc_capacity_until_GC(expand_bytes); |
1442 size_t new_capacity_until_GC = MetaspaceGC::inc_capacity_until_GC(expand_bytes); |
1440 } |
1443 Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
1441 if (PrintGCDetails && Verbose) { |
1444 new_capacity_until_GC, |
1442 size_t new_capacity_until_GC = capacity_until_GC; |
1445 MetaspaceGCThresholdUpdater::ComputeNewSize); |
1443 gclog_or_tty->print_cr(" expanding:" |
1446 if (PrintGCDetails && Verbose) { |
1444 " minimum_desired_capacity: %6.1fKB" |
1447 gclog_or_tty->print_cr(" expanding:" |
1445 " expand_bytes: %6.1fKB" |
1448 " minimum_desired_capacity: %6.1fKB" |
1446 " MinMetaspaceExpansion: %6.1fKB" |
1449 " expand_bytes: %6.1fKB" |
1447 " new metaspace HWM: %6.1fKB", |
1450 " MinMetaspaceExpansion: %6.1fKB" |
1448 minimum_desired_capacity / (double) K, |
1451 " new metaspace HWM: %6.1fKB", |
1449 expand_bytes / (double) K, |
1452 minimum_desired_capacity / (double) K, |
1450 MinMetaspaceExpansion / (double) K, |
1453 expand_bytes / (double) K, |
1451 new_capacity_until_GC / (double) K); |
1454 MinMetaspaceExpansion / (double) K, |
|
1455 new_capacity_until_GC / (double) K); |
|
1456 } |
1452 } |
1457 } |
1453 return; |
1458 return; |
1454 } |
1459 } |
1455 |
1460 |
1456 // No expansion, now see if we want to shrink |
1461 // No expansion, now see if we want to shrink |
1526 } |
1531 } |
1527 |
1532 |
1528 // Don't shrink unless it's significant |
1533 // Don't shrink unless it's significant |
1529 if (shrink_bytes >= MinMetaspaceExpansion && |
1534 if (shrink_bytes >= MinMetaspaceExpansion && |
1530 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) { |
1535 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) { |
1531 MetaspaceGC::dec_capacity_until_GC(shrink_bytes); |
1536 size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes); |
|
1537 Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
|
1538 new_capacity_until_GC, |
|
1539 MetaspaceGCThresholdUpdater::ComputeNewSize); |
1532 } |
1540 } |
1533 } |
1541 } |
1534 |
1542 |
1535 // Metadebug methods |
1543 // Metadebug methods |
1536 |
1544 |
3130 vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL); |
3138 vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL); |
3131 } |
3139 } |
3132 } |
3140 } |
3133 |
3141 |
3134 MetaspaceGC::initialize(); |
3142 MetaspaceGC::initialize(); |
|
3143 _tracer = new MetaspaceTracer(); |
3135 } |
3144 } |
3136 |
3145 |
3137 Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype, |
3146 Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype, |
3138 size_t chunk_word_size, |
3147 size_t chunk_word_size, |
3139 size_t chunk_bunch) { |
3148 size_t chunk_bunch) { |
3218 MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) { |
3227 MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) { |
3219 size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord); |
3228 size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord); |
3220 assert(delta_bytes > 0, "Must be"); |
3229 assert(delta_bytes > 0, "Must be"); |
3221 |
3230 |
3222 size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes); |
3231 size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes); |
|
3232 |
|
3233 // capacity_until_GC might be updated concurrently, must calculate previous value. |
3223 size_t before_inc = after_inc - delta_bytes; |
3234 size_t before_inc = after_inc - delta_bytes; |
3224 |
3235 |
|
3236 tracer()->report_gc_threshold(before_inc, after_inc, |
|
3237 MetaspaceGCThresholdUpdater::ExpandAndAllocate); |
3225 if (PrintGCDetails && Verbose) { |
3238 if (PrintGCDetails && Verbose) { |
3226 gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT |
3239 gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT |
3227 " to " SIZE_FORMAT, before_inc, after_inc); |
3240 " to " SIZE_FORMAT, before_inc, after_inc); |
3228 } |
3241 } |
3229 |
3242 |