Mercurial > hg > graal-compiler
comparison src/share/vm/memory/metaspace.cpp @ 17866:270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
Reviewed-by: jmasa, coleenp
author | ehelin |
---|---|
date | Mon, 31 Mar 2014 17:09:38 +0200 |
parents | 9fdaa79b0c27 |
children | 7384f6a12fc1 |
comparison
equal
deleted
inserted
replaced
17865:fa21c9537e6e | 17866:270d7cb38f40 |
---|---|
1445 void MetaspaceGC::compute_new_size() { | 1445 void MetaspaceGC::compute_new_size() { |
1446 assert(_shrink_factor <= 100, "invalid shrink factor"); | 1446 assert(_shrink_factor <= 100, "invalid shrink factor"); |
1447 uint current_shrink_factor = _shrink_factor; | 1447 uint current_shrink_factor = _shrink_factor; |
1448 _shrink_factor = 0; | 1448 _shrink_factor = 0; |
1449 | 1449 |
1450 const size_t used_after_gc = MetaspaceAux::allocated_capacity_bytes(); | 1450 const size_t used_after_gc = MetaspaceAux::capacity_bytes(); |
1451 const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC(); | 1451 const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC(); |
1452 | 1452 |
1453 const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; | 1453 const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; |
1454 const double maximum_used_percentage = 1.0 - minimum_free_percentage; | 1454 const double maximum_used_percentage = 1.0 - minimum_free_percentage; |
1455 | 1455 |
2535 #endif // PRODUCT | 2535 #endif // PRODUCT |
2536 | 2536 |
2537 // MetaspaceAux | 2537 // MetaspaceAux |
2538 | 2538 |
2539 | 2539 |
2540 size_t MetaspaceAux::_allocated_capacity_words[] = {0, 0}; | 2540 size_t MetaspaceAux::_capacity_words[] = {0, 0}; |
2541 size_t MetaspaceAux::_allocated_used_words[] = {0, 0}; | 2541 size_t MetaspaceAux::_used_words[] = {0, 0}; |
2542 | 2542 |
2543 size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) { | 2543 size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) { |
2544 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); | 2544 VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
2545 return list == NULL ? 0 : list->free_bytes(); | 2545 return list == NULL ? 0 : list->free_bytes(); |
2546 } | 2546 } |
2549 return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType); | 2549 return free_bytes(Metaspace::ClassType) + free_bytes(Metaspace::NonClassType); |
2550 } | 2550 } |
2551 | 2551 |
2552 void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) { | 2552 void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) { |
2553 assert_lock_strong(SpaceManager::expand_lock()); | 2553 assert_lock_strong(SpaceManager::expand_lock()); |
2554 assert(words <= allocated_capacity_words(mdtype), | 2554 assert(words <= capacity_words(mdtype), |
2555 err_msg("About to decrement below 0: words " SIZE_FORMAT | 2555 err_msg("About to decrement below 0: words " SIZE_FORMAT |
2556 " is greater than _allocated_capacity_words[%u] " SIZE_FORMAT, | 2556 " is greater than _capacity_words[%u] " SIZE_FORMAT, |
2557 words, mdtype, allocated_capacity_words(mdtype))); | 2557 words, mdtype, capacity_words(mdtype))); |
2558 _allocated_capacity_words[mdtype] -= words; | 2558 _capacity_words[mdtype] -= words; |
2559 } | 2559 } |
2560 | 2560 |
2561 void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) { | 2561 void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) { |
2562 assert_lock_strong(SpaceManager::expand_lock()); | 2562 assert_lock_strong(SpaceManager::expand_lock()); |
2563 // Needs to be atomic | 2563 // Needs to be atomic |
2564 _allocated_capacity_words[mdtype] += words; | 2564 _capacity_words[mdtype] += words; |
2565 } | 2565 } |
2566 | 2566 |
2567 void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) { | 2567 void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) { |
2568 assert(words <= allocated_used_words(mdtype), | 2568 assert(words <= used_words(mdtype), |
2569 err_msg("About to decrement below 0: words " SIZE_FORMAT | 2569 err_msg("About to decrement below 0: words " SIZE_FORMAT |
2570 " is greater than _allocated_used_words[%u] " SIZE_FORMAT, | 2570 " is greater than _used_words[%u] " SIZE_FORMAT, |
2571 words, mdtype, allocated_used_words(mdtype))); | 2571 words, mdtype, used_words(mdtype))); |
2572 // For CMS deallocation of the Metaspaces occurs during the | 2572 // For CMS deallocation of the Metaspaces occurs during the |
2573 // sweep which is a concurrent phase. Protection by the expand_lock() | 2573 // sweep which is a concurrent phase. Protection by the expand_lock() |
2574 // is not enough since allocation is on a per Metaspace basis | 2574 // is not enough since allocation is on a per Metaspace basis |
2575 // and protected by the Metaspace lock. | 2575 // and protected by the Metaspace lock. |
2576 jlong minus_words = (jlong) - (jlong) words; | 2576 jlong minus_words = (jlong) - (jlong) words; |
2577 Atomic::add_ptr(minus_words, &_allocated_used_words[mdtype]); | 2577 Atomic::add_ptr(minus_words, &_used_words[mdtype]); |
2578 } | 2578 } |
2579 | 2579 |
2580 void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) { | 2580 void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) { |
2581 // _allocated_used_words tracks allocations for | 2581 // _used_words tracks allocations for |
2582 // each piece of metadata. Those allocations are | 2582 // each piece of metadata. Those allocations are |
2583 // generally done concurrently by different application | 2583 // generally done concurrently by different application |
2584 // threads so must be done atomically. | 2584 // threads so must be done atomically. |
2585 Atomic::add_ptr(words, &_allocated_used_words[mdtype]); | 2585 Atomic::add_ptr(words, &_used_words[mdtype]); |
2586 } | 2586 } |
2587 | 2587 |
2588 size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) { | 2588 size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) { |
2589 size_t used = 0; | 2589 size_t used = 0; |
2590 ClassLoaderDataGraphMetaspaceIterator iter; | 2590 ClassLoaderDataGraphMetaspaceIterator iter; |
2627 return capacity * BytesPerWord; | 2627 return capacity * BytesPerWord; |
2628 } | 2628 } |
2629 | 2629 |
2630 size_t MetaspaceAux::capacity_bytes_slow() { | 2630 size_t MetaspaceAux::capacity_bytes_slow() { |
2631 #ifdef PRODUCT | 2631 #ifdef PRODUCT |
2632 // Use allocated_capacity_bytes() in PRODUCT instead of this function. | 2632 // Use capacity_bytes() in PRODUCT instead of this function. |
2633 guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT"); | 2633 guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT"); |
2634 #endif | 2634 #endif |
2635 size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType); | 2635 size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType); |
2636 size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType); | 2636 size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType); |
2637 assert(allocated_capacity_bytes() == class_capacity + non_class_capacity, | 2637 assert(capacity_bytes() == class_capacity + non_class_capacity, |
2638 err_msg("bad accounting: allocated_capacity_bytes() " SIZE_FORMAT | 2638 err_msg("bad accounting: capacity_bytes() " SIZE_FORMAT |
2639 " class_capacity + non_class_capacity " SIZE_FORMAT | 2639 " class_capacity + non_class_capacity " SIZE_FORMAT |
2640 " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT, | 2640 " class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT, |
2641 allocated_capacity_bytes(), class_capacity + non_class_capacity, | 2641 capacity_bytes(), class_capacity + non_class_capacity, |
2642 class_capacity, non_class_capacity)); | 2642 class_capacity, non_class_capacity)); |
2643 | 2643 |
2644 return class_capacity + non_class_capacity; | 2644 return class_capacity + non_class_capacity; |
2645 } | 2645 } |
2646 | 2646 |
2696 if (PrintGCDetails && Verbose) { | 2696 if (PrintGCDetails && Verbose) { |
2697 gclog_or_tty->print(" " SIZE_FORMAT | 2697 gclog_or_tty->print(" " SIZE_FORMAT |
2698 "->" SIZE_FORMAT | 2698 "->" SIZE_FORMAT |
2699 "(" SIZE_FORMAT ")", | 2699 "(" SIZE_FORMAT ")", |
2700 prev_metadata_used, | 2700 prev_metadata_used, |
2701 allocated_used_bytes(), | 2701 used_bytes(), |
2702 reserved_bytes()); | 2702 reserved_bytes()); |
2703 } else { | 2703 } else { |
2704 gclog_or_tty->print(" " SIZE_FORMAT "K" | 2704 gclog_or_tty->print(" " SIZE_FORMAT "K" |
2705 "->" SIZE_FORMAT "K" | 2705 "->" SIZE_FORMAT "K" |
2706 "(" SIZE_FORMAT "K)", | 2706 "(" SIZE_FORMAT "K)", |
2707 prev_metadata_used/K, | 2707 prev_metadata_used/K, |
2708 allocated_used_bytes()/K, | 2708 used_bytes()/K, |
2709 reserved_bytes()/K); | 2709 reserved_bytes()/K); |
2710 } | 2710 } |
2711 | 2711 |
2712 gclog_or_tty->print("]"); | 2712 gclog_or_tty->print("]"); |
2713 } | 2713 } |
2719 out->print_cr(" Metaspace " | 2719 out->print_cr(" Metaspace " |
2720 "used " SIZE_FORMAT "K, " | 2720 "used " SIZE_FORMAT "K, " |
2721 "capacity " SIZE_FORMAT "K, " | 2721 "capacity " SIZE_FORMAT "K, " |
2722 "committed " SIZE_FORMAT "K, " | 2722 "committed " SIZE_FORMAT "K, " |
2723 "reserved " SIZE_FORMAT "K", | 2723 "reserved " SIZE_FORMAT "K", |
2724 allocated_used_bytes()/K, | 2724 used_bytes()/K, |
2725 allocated_capacity_bytes()/K, | 2725 capacity_bytes()/K, |
2726 committed_bytes()/K, | 2726 committed_bytes()/K, |
2727 reserved_bytes()/K); | 2727 reserved_bytes()/K); |
2728 | 2728 |
2729 if (Metaspace::using_class_space()) { | 2729 if (Metaspace::using_class_space()) { |
2730 Metaspace::MetadataType ct = Metaspace::ClassType; | 2730 Metaspace::MetadataType ct = Metaspace::ClassType; |
2731 out->print_cr(" class space " | 2731 out->print_cr(" class space " |
2732 "used " SIZE_FORMAT "K, " | 2732 "used " SIZE_FORMAT "K, " |
2733 "capacity " SIZE_FORMAT "K, " | 2733 "capacity " SIZE_FORMAT "K, " |
2734 "committed " SIZE_FORMAT "K, " | 2734 "committed " SIZE_FORMAT "K, " |
2735 "reserved " SIZE_FORMAT "K", | 2735 "reserved " SIZE_FORMAT "K", |
2736 allocated_used_bytes(ct)/K, | 2736 used_bytes(ct)/K, |
2737 allocated_capacity_bytes(ct)/K, | 2737 capacity_bytes(ct)/K, |
2738 committed_bytes(ct)/K, | 2738 committed_bytes(ct)/K, |
2739 reserved_bytes(ct)/K); | 2739 reserved_bytes(ct)/K); |
2740 } | 2740 } |
2741 } | 2741 } |
2742 | 2742 |
2834 } | 2834 } |
2835 } | 2835 } |
2836 | 2836 |
2837 void MetaspaceAux::verify_capacity() { | 2837 void MetaspaceAux::verify_capacity() { |
2838 #ifdef ASSERT | 2838 #ifdef ASSERT |
2839 size_t running_sum_capacity_bytes = allocated_capacity_bytes(); | 2839 size_t running_sum_capacity_bytes = capacity_bytes(); |
2840 // For purposes of the running sum of capacity, verify against capacity | 2840 // For purposes of the running sum of capacity, verify against capacity |
2841 size_t capacity_in_use_bytes = capacity_bytes_slow(); | 2841 size_t capacity_in_use_bytes = capacity_bytes_slow(); |
2842 assert(running_sum_capacity_bytes == capacity_in_use_bytes, | 2842 assert(running_sum_capacity_bytes == capacity_in_use_bytes, |
2843 err_msg("allocated_capacity_words() * BytesPerWord " SIZE_FORMAT | 2843 err_msg("capacity_words() * BytesPerWord " SIZE_FORMAT |
2844 " capacity_bytes_slow()" SIZE_FORMAT, | 2844 " capacity_bytes_slow()" SIZE_FORMAT, |
2845 running_sum_capacity_bytes, capacity_in_use_bytes)); | 2845 running_sum_capacity_bytes, capacity_in_use_bytes)); |
2846 for (Metaspace::MetadataType i = Metaspace::ClassType; | 2846 for (Metaspace::MetadataType i = Metaspace::ClassType; |
2847 i < Metaspace:: MetadataTypeCount; | 2847 i < Metaspace:: MetadataTypeCount; |
2848 i = (Metaspace::MetadataType)(i + 1)) { | 2848 i = (Metaspace::MetadataType)(i + 1)) { |
2849 size_t capacity_in_use_bytes = capacity_bytes_slow(i); | 2849 size_t capacity_in_use_bytes = capacity_bytes_slow(i); |
2850 assert(allocated_capacity_bytes(i) == capacity_in_use_bytes, | 2850 assert(capacity_bytes(i) == capacity_in_use_bytes, |
2851 err_msg("allocated_capacity_bytes(%u) " SIZE_FORMAT | 2851 err_msg("capacity_bytes(%u) " SIZE_FORMAT |
2852 " capacity_bytes_slow(%u)" SIZE_FORMAT, | 2852 " capacity_bytes_slow(%u)" SIZE_FORMAT, |
2853 i, allocated_capacity_bytes(i), i, capacity_in_use_bytes)); | 2853 i, capacity_bytes(i), i, capacity_in_use_bytes)); |
2854 } | 2854 } |
2855 #endif | 2855 #endif |
2856 } | 2856 } |
2857 | 2857 |
2858 void MetaspaceAux::verify_used() { | 2858 void MetaspaceAux::verify_used() { |
2859 #ifdef ASSERT | 2859 #ifdef ASSERT |
2860 size_t running_sum_used_bytes = allocated_used_bytes(); | 2860 size_t running_sum_used_bytes = used_bytes(); |
2861 // For purposes of the running sum of used, verify against used | 2861 // For purposes of the running sum of used, verify against used |
2862 size_t used_in_use_bytes = used_bytes_slow(); | 2862 size_t used_in_use_bytes = used_bytes_slow(); |
2863 assert(allocated_used_bytes() == used_in_use_bytes, | 2863 assert(used_bytes() == used_in_use_bytes, |
2864 err_msg("allocated_used_bytes() " SIZE_FORMAT | 2864 err_msg("used_bytes() " SIZE_FORMAT |
2865 " used_bytes_slow()" SIZE_FORMAT, | 2865 " used_bytes_slow()" SIZE_FORMAT, |
2866 allocated_used_bytes(), used_in_use_bytes)); | 2866 used_bytes(), used_in_use_bytes)); |
2867 for (Metaspace::MetadataType i = Metaspace::ClassType; | 2867 for (Metaspace::MetadataType i = Metaspace::ClassType; |
2868 i < Metaspace:: MetadataTypeCount; | 2868 i < Metaspace:: MetadataTypeCount; |
2869 i = (Metaspace::MetadataType)(i + 1)) { | 2869 i = (Metaspace::MetadataType)(i + 1)) { |
2870 size_t used_in_use_bytes = used_bytes_slow(i); | 2870 size_t used_in_use_bytes = used_bytes_slow(i); |
2871 assert(allocated_used_bytes(i) == used_in_use_bytes, | 2871 assert(used_bytes(i) == used_in_use_bytes, |
2872 err_msg("allocated_used_bytes(%u) " SIZE_FORMAT | 2872 err_msg("used_bytes(%u) " SIZE_FORMAT |
2873 " used_bytes_slow(%u)" SIZE_FORMAT, | 2873 " used_bytes_slow(%u)" SIZE_FORMAT, |
2874 i, allocated_used_bytes(i), i, used_in_use_bytes)); | 2874 i, used_bytes(i), i, used_in_use_bytes)); |
2875 } | 2875 } |
2876 #endif | 2876 #endif |
2877 } | 2877 } |
2878 | 2878 |
2879 void MetaspaceAux::verify_metrics() { | 2879 void MetaspaceAux::verify_metrics() { |