741 size_t CodeCache::unallocated_capacity() {
742 size_t unallocated_cap = 0;
743 FOR_ALL_HEAPS(heap) {
744 unallocated_cap += (*heap)->unallocated_capacity();
745 }
746 return unallocated_cap;
747 }
748
749 size_t CodeCache::max_capacity() {
750 size_t max_cap = 0;
751 FOR_ALL_HEAPS(heap) {
752 max_cap += (*heap)->max_capacity();
753 }
754 return max_cap;
755 }
756
757 /**
758 * Returns true if a CodeHeap is full and sets code_blob_type accordingly.
759 */
760 bool CodeCache::is_full(int* code_blob_type) {
761 FOR_ALL_HEAPS(heap) {
762 if ((*heap)->unallocated_capacity() < CodeCacheMinimumFreeSpace) {
763 *code_blob_type = (*heap)->code_blob_type();
764 return true;
765 }
766 }
767 return false;
768 }
769
770 /**
771 * Returns the reverse free ratio. E.g., if 25% (1/4) of the code heap
772 * is free, reverse_free_ratio() returns 4.
773 */
774 double CodeCache::reverse_free_ratio(int code_blob_type) {
775 CodeHeap* heap = get_code_heap(code_blob_type);
776 if (heap == NULL) {
777 return 0;
778 }
779 double unallocated_capacity = (double)(heap->unallocated_capacity() - CodeCacheMinimumFreeSpace);
780 double max_capacity = (double)heap->max_capacity();
781 return max_capacity / unallocated_capacity;
782 }
783
996 FOR_ALL_BLOBS(cb, *heap) {
997 if (cb->is_alive()) {
998 cb->verify();
999 }
1000 }
1001 }
1002 }
1003
1004 // A CodeHeap is full. Print out warning and report event.
1005 void CodeCache::report_codemem_full(int code_blob_type, bool print) {
1006 // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event
1007 CodeHeap* heap = get_code_heap(code_blob_type);
1008 assert(heap != NULL, "heap is null");
1009
1010 if (!heap->was_full() || print) {
1011 // Not yet reported for this heap, report
1012 heap->report_full();
1013 if (SegmentedCodeCache) {
1014 warning("%s is full. Compiler has been disabled.", CodeCache::get_code_heap_name(code_blob_type));
1015 warning("Try increasing the code heap size using -XX:%s=",
1016 (code_blob_type == CodeBlobType::MethodNonProfiled) ? "NonProfiledCodeHeapSize" : "ProfiledCodeHeapSize");
1017 } else {
1018 warning("CodeCache is full. Compiler has been disabled.");
1019 warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
1020 }
1021 ResourceMark rm;
1022 stringStream s;
1023 // Dump code cache into a buffer before locking the tty,
1024 {
1025 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1026 print_summary(&s);
1027 }
1028 ttyLocker ttyl;
1029 tty->print("%s", s.as_string());
1030 }
1031
1032 _codemem_full_count++;
1033 EventCodeCacheFull event;
1034 if (event.should_commit()) {
1035 event.set_codeBlobType((u1)code_blob_type);
1036 event.set_startAddress((u8)heap->low_boundary());
|
741 size_t CodeCache::unallocated_capacity() {
742 size_t unallocated_cap = 0;
743 FOR_ALL_HEAPS(heap) {
744 unallocated_cap += (*heap)->unallocated_capacity();
745 }
746 return unallocated_cap;
747 }
748
749 size_t CodeCache::max_capacity() {
750 size_t max_cap = 0;
751 FOR_ALL_HEAPS(heap) {
752 max_cap += (*heap)->max_capacity();
753 }
754 return max_cap;
755 }
756
757 /**
758 * Returns true if a CodeHeap is full and sets code_blob_type accordingly.
759 */
760 bool CodeCache::is_full(int* code_blob_type) {
761 FOR_ALL_HEAPS(heap_iterator) {
762 CodeHeap* heap = *heap_iterator;
763 // Do not check the non-nmethod code heap because we can store
764 // non-nmethod code in the non-profiled code heap (see comment
765 // 'fallback solution' in CodeCache::allocate).
766 if (heap->code_blob_type() != CodeBlobType::NonNMethod &&
767 heap->unallocated_capacity() < CodeCacheMinimumFreeSpace) {
768 *code_blob_type = heap->code_blob_type();
769 return true;
770 }
771 }
772 return false;
773 }
774
775 /**
776 * Returns the reverse free ratio. E.g., if 25% (1/4) of the code heap
777 * is free, reverse_free_ratio() returns 4.
778 */
779 double CodeCache::reverse_free_ratio(int code_blob_type) {
780 CodeHeap* heap = get_code_heap(code_blob_type);
781 if (heap == NULL) {
782 return 0;
783 }
784 double unallocated_capacity = (double)(heap->unallocated_capacity() - CodeCacheMinimumFreeSpace);
785 double max_capacity = (double)heap->max_capacity();
786 return max_capacity / unallocated_capacity;
787 }
788
1001 FOR_ALL_BLOBS(cb, *heap) {
1002 if (cb->is_alive()) {
1003 cb->verify();
1004 }
1005 }
1006 }
1007 }
1008
1009 // A CodeHeap is full. Print out warning and report event.
1010 void CodeCache::report_codemem_full(int code_blob_type, bool print) {
1011 // Get nmethod heap for the given CodeBlobType and build CodeCacheFull event
1012 CodeHeap* heap = get_code_heap(code_blob_type);
1013 assert(heap != NULL, "heap is null");
1014
1015 if (!heap->was_full() || print) {
1016 // Not yet reported for this heap, report
1017 heap->report_full();
1018 if (SegmentedCodeCache) {
1019 warning("%s is full. Compiler has been disabled.", CodeCache::get_code_heap_name(code_blob_type));
1020 warning("Try increasing the code heap size using -XX:%s=",
1021 (code_blob_type == CodeBlobType::MethodProfiled) ? "ProfiledCodeHeapSize" : "NonProfiledCodeHeapSize");
1022 } else {
1023 warning("CodeCache is full. Compiler has been disabled.");
1024 warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
1025 }
1026 ResourceMark rm;
1027 stringStream s;
1028 // Dump code cache into a buffer before locking the tty,
1029 {
1030 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1031 print_summary(&s);
1032 }
1033 ttyLocker ttyl;
1034 tty->print("%s", s.as_string());
1035 }
1036
1037 _codemem_full_count++;
1038 EventCodeCacheFull event;
1039 if (event.should_commit()) {
1040 event.set_codeBlobType((u1)code_blob_type);
1041 event.set_startAddress((u8)heap->low_boundary());
|