src/share/vm/memory/metaspace.cpp

changeset 6417
daef39043d2c
parent 6337
ab36007d6358
child 6418
bc7714614ad8
equal deleted inserted replaced
6416:537c8e21b118 6417:daef39043d2c
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
1525 } 1530 }
1526 1531
1527 // Don't shrink unless it's significant 1532 // Don't shrink unless it's significant
1528 if (shrink_bytes >= MinMetaspaceExpansion && 1533 if (shrink_bytes >= MinMetaspaceExpansion &&
1529 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) { 1534 ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) {
1530 MetaspaceGC::dec_capacity_until_GC(shrink_bytes); 1535 size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
1536 Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
1537 new_capacity_until_GC,
1538 MetaspaceGCThresholdUpdater::ComputeNewSize);
1531 } 1539 }
1532 } 1540 }
1533 1541
1534 // Metadebug methods 1542 // Metadebug methods
1535 1543
3129 vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL); 3137 vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL);
3130 } 3138 }
3131 } 3139 }
3132 3140
3133 MetaspaceGC::initialize(); 3141 MetaspaceGC::initialize();
3142 _tracer = new MetaspaceTracer();
3134 } 3143 }
3135 3144
3136 Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype, 3145 Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype,
3137 size_t chunk_word_size, 3146 size_t chunk_word_size,
3138 size_t chunk_bunch) { 3147 size_t chunk_bunch) {
3217 MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) { 3226 MetaWord* Metaspace::expand_and_allocate(size_t word_size, MetadataType mdtype) {
3218 size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord); 3227 size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord);
3219 assert(delta_bytes > 0, "Must be"); 3228 assert(delta_bytes > 0, "Must be");
3220 3229
3221 size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes); 3230 size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes);
3231
3232 // capacity_until_GC might be updated concurrently, must calculate previous value.
3222 size_t before_inc = after_inc - delta_bytes; 3233 size_t before_inc = after_inc - delta_bytes;
3223 3234
3235 tracer()->report_gc_threshold(before_inc, after_inc,
3236 MetaspaceGCThresholdUpdater::ExpandAndAllocate);
3224 if (PrintGCDetails && Verbose) { 3237 if (PrintGCDetails && Verbose) {
3225 gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT 3238 gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
3226 " to " SIZE_FORMAT, before_inc, after_inc); 3239 " to " SIZE_FORMAT, before_inc, after_inc);
3227 } 3240 }
3228 3241

mercurial