comparison src/share/vm/code/codeCache.cpp @ 7595:9deda4d8e126

8005204: Code Cache Reduction: command line options implementation Summary: Adding more detailed output on CodeCache usage Reviewed-by: kvn, vladidan Contributed-by: Alexander Harlap <alexander.harlap@oracle.com>
author vladidan
date Mon, 14 Jan 2013 13:52:08 -0500
parents 8966c2d65d96
children ebb32c4589f3 a7fb14888912
comparison
equal deleted inserted replaced
7594:94fa3c4e7643 7595:9deda4d8e126
28 #include "code/compiledIC.hpp" 28 #include "code/compiledIC.hpp"
29 #include "code/dependencies.hpp" 29 #include "code/dependencies.hpp"
30 #include "code/icBuffer.hpp" 30 #include "code/icBuffer.hpp"
31 #include "code/nmethod.hpp" 31 #include "code/nmethod.hpp"
32 #include "code/pcDesc.hpp" 32 #include "code/pcDesc.hpp"
33 #include "compiler/compileBroker.hpp"
33 #include "gc_implementation/shared/markSweep.hpp" 34 #include "gc_implementation/shared/markSweep.hpp"
34 #include "memory/allocation.inline.hpp" 35 #include "memory/allocation.inline.hpp"
35 #include "memory/gcLocker.hpp" 36 #include "memory/gcLocker.hpp"
36 #include "memory/iterator.hpp" 37 #include "memory/iterator.hpp"
37 #include "memory/resourceArea.hpp" 38 #include "memory/resourceArea.hpp"
38 #include "oops/method.hpp" 39 #include "oops/method.hpp"
39 #include "oops/objArrayOop.hpp" 40 #include "oops/objArrayOop.hpp"
40 #include "oops/oop.inline.hpp" 41 #include "oops/oop.inline.hpp"
41 #include "runtime/handles.inline.hpp" 42 #include "runtime/handles.inline.hpp"
43 #include "runtime/arguments.hpp"
42 #include "runtime/icache.hpp" 44 #include "runtime/icache.hpp"
43 #include "runtime/java.hpp" 45 #include "runtime/java.hpp"
44 #include "runtime/mutexLocker.hpp" 46 #include "runtime/mutexLocker.hpp"
45 #include "services/memoryService.hpp" 47 #include "services/memoryService.hpp"
46 #include "utilities/xmlstream.hpp" 48 #include "utilities/xmlstream.hpp"
166 cb = next(cb); 168 cb = next(cb);
167 } 169 }
168 return (nmethod*)cb; 170 return (nmethod*)cb;
169 } 171 }
170 172
173 static size_t maxCodeCacheUsed = 0;
174
171 CodeBlob* CodeCache::allocate(int size) { 175 CodeBlob* CodeCache::allocate(int size) {
172 // Do not seize the CodeCache lock here--if the caller has not 176 // Do not seize the CodeCache lock here--if the caller has not
173 // already done so, we are going to lose bigtime, since the code 177 // already done so, we are going to lose bigtime, since the code
174 // cache will contain a garbage CodeBlob until the caller can 178 // cache will contain a garbage CodeBlob until the caller can
175 // run the constructor for the CodeBlob subclass he is busy 179 // run the constructor for the CodeBlob subclass he is busy
190 tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (%d bytes)", 194 tty->print_cr("code cache extended to [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (%d bytes)",
191 (intptr_t)_heap->begin(), (intptr_t)_heap->end(), 195 (intptr_t)_heap->begin(), (intptr_t)_heap->end(),
192 (address)_heap->end() - (address)_heap->begin()); 196 (address)_heap->end() - (address)_heap->begin());
193 } 197 }
194 } 198 }
199 maxCodeCacheUsed = MAX2(maxCodeCacheUsed, ((address)_heap->high_boundary() -
200 (address)_heap->low_boundary()) - unallocated_capacity());
195 verify_if_often(); 201 verify_if_often();
196 print_trace("allocation", cb, size); 202 print_trace("allocation", cb, size);
197 return cb; 203 return cb;
198 } 204 }
199 205
926 } 932 }
927 933
928 FREE_C_HEAP_ARRAY(int, buckets, mtCode); 934 FREE_C_HEAP_ARRAY(int, buckets, mtCode);
929 } 935 }
930 936
937 #endif // !PRODUCT
938
931 void CodeCache::print() { 939 void CodeCache::print() {
940 print_summary(tty);
941
942 #ifndef PRODUCT
943 if (!Verbose) return;
944
932 CodeBlob_sizes live; 945 CodeBlob_sizes live;
933 CodeBlob_sizes dead; 946 CodeBlob_sizes dead;
934 947
935 FOR_ALL_BLOBS(p) { 948 FOR_ALL_BLOBS(p) {
936 if (!p->is_alive()) { 949 if (!p->is_alive()) {
951 if (!dead.is_empty()) { 964 if (!dead.is_empty()) {
952 dead.print("dead"); 965 dead.print("dead");
953 } 966 }
954 967
955 968
956 if (Verbose) { 969 if (WizardMode) {
957 // print the oop_map usage 970 // print the oop_map usage
958 int code_size = 0; 971 int code_size = 0;
959 int number_of_blobs = 0; 972 int number_of_blobs = 0;
960 int number_of_oop_maps = 0; 973 int number_of_oop_maps = 0;
961 int map_size = 0; 974 int map_size = 0;
975 tty->print_cr(" code size = %d", code_size); 988 tty->print_cr(" code size = %d", code_size);
976 tty->print_cr(" #oop_maps = %d", number_of_oop_maps); 989 tty->print_cr(" #oop_maps = %d", number_of_oop_maps);
977 tty->print_cr(" map size = %d", map_size); 990 tty->print_cr(" map size = %d", map_size);
978 } 991 }
979 992
980 } 993 #endif // !PRODUCT
981 994 }
982 #endif // PRODUCT 995
983 996 void CodeCache::print_summary(outputStream* st, bool detailed) {
984 void CodeCache::print_bounds(outputStream* st) { 997 size_t total = (_heap->high_boundary() - _heap->low_boundary());
985 st->print_cr("Code Cache [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")", 998 st->print_cr("CodeCache: size=" SIZE_FORMAT "Kb used=" SIZE_FORMAT
986 _heap->low_boundary(), 999 "Kb max_used=" SIZE_FORMAT "Kb free=" SIZE_FORMAT
987 _heap->high(), 1000 "Kb max_free_chunk=" SIZE_FORMAT "Kb",
988 _heap->high_boundary()); 1001 total/K, (total - unallocated_capacity())/K,
989 st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT 1002 maxCodeCacheUsed/K, unallocated_capacity()/K, largest_free_block()/K);
990 " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT "Kb" 1003
991 " largest_free_block=" SIZE_FORMAT, 1004 if (detailed) {
992 nof_blobs(), nof_nmethods(), nof_adapters(), 1005 st->print_cr(" bounds [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT "]",
993 unallocated_capacity()/K, largest_free_block()); 1006 _heap->low_boundary(),
1007 _heap->high(),
1008 _heap->high_boundary());
1009 st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
1010 " adapters=" UINT32_FORMAT,
1011 nof_blobs(), nof_nmethods(), nof_adapters());
1012 st->print_cr(" compilation: %s", CompileBroker::should_compile_new_jobs() ?
1013 "enabled" : Arguments::mode() == Arguments::_int ?
1014 "disabled (interpreter mode)" :
1015 "disabled (not enough contiguous free space left)");
1016 }
994 } 1017 }
995 1018
996 void CodeCache::log_state(outputStream* st) { 1019 void CodeCache::log_state(outputStream* st) {
997 st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" 1020 st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
998 " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'" 1021 " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'"