131
132 private:
133 static size_t bytes_allocated_in_freelists();
134 static int allocated_segments();
135 static size_t freelists_length();
136
137 // Make private to prevent unsafe calls. Not all CodeBlob*'s are embedded in a CodeHeap.
138 static bool contains(CodeBlob *p) { fatal("don't call me!"); return false; }
139
140 public:
141 // Initialization
142 static void initialize();
143 static size_t page_size(bool aligned = true, size_t min_pages = 1); // Returns the page size used by the CodeCache
144
145 static int code_heap_compare(CodeHeap* const &lhs, CodeHeap* const &rhs);
146
147 static void add_heap(CodeHeap* heap);
148 static const GrowableArray<CodeHeap*>* heaps() { return _heaps; }
149 static const GrowableArray<CodeHeap*>* nmethod_heaps() { return _nmethod_heaps; }
150
151 // Allocation/administration
152 static CodeBlob* allocate(uint size, CodeBlobType code_blob_type, bool handle_alloc_failure = true, CodeBlobType orig_code_blob_type = CodeBlobType::All); // allocates a new CodeBlob
153 static void commit(CodeBlob* cb); // called when the allocated CodeBlob has been filled
154 static void free(CodeBlob* cb); // frees a CodeBlob
155 static void free_unused_tail(CodeBlob* cb, size_t used); // frees the unused tail of a CodeBlob (only used by TemplateInterpreter::initialize())
156 static bool contains(void *p); // returns whether p is included
157 static bool contains(nmethod* nm); // returns whether nm is included
158 static void blobs_do(void f(CodeBlob* cb)); // iterates over all CodeBlobs
159 static void nmethods_do(void f(nmethod* nm)); // iterates over all nmethods
160 static void nmethods_do(NMethodClosure* cl); // iterates over all nmethods
161 static void metadata_do(MetadataClosure* f); // iterates over metadata in alive nmethods
162
163 // Lookup
164 static CodeBlob* find_blob(void* start); // Returns the CodeBlob containing the given address
165 static CodeBlob* find_blob_fast(void* start); // Returns the CodeBlob containing the given address
166 static CodeBlob* find_blob_and_oopmap(void* start, int& slot); // Returns the CodeBlob containing the given address
167 static int find_oopmap_slot_fast(void* start); // Returns a fast oopmap slot if there is any; -1 otherwise
168 static nmethod* find_nmethod(void* start); // Returns the nmethod containing the given address
169
170 static int blob_count(); // Returns the total number of CodeBlobs in the cache
205 // on-stack nmethods. It's used in two places:
206 // 1. Used before the start of concurrent marking so that oops inside
207 // on-stack nmethods are visited.
208 // 2. Used at the end of (stw/concurrent) marking so that nmethod::_gc_epoch
209 // is up-to-date, which provides more accurate estimate of
210 // nmethod::is_cold.
211 static void arm_all_nmethods();
212
213 static void maybe_restart_compiler(size_t freed_memory);
214 static void do_unloading(bool unloading_occurred);
215 static uint8_t unloading_cycle() { return _unloading_cycle; }
216
217 static void increment_unloading_cycle();
218
219 static void release_exception_cache(ExceptionCache* entry);
220 static void purge_exception_caches();
221
222 // Printing/debugging
223 static void print(); // prints summary
224 static void print_internals();
225 static void print_memory_overhead();
226 static void verify(); // verifies the code cache
227 static void print_trace(const char* event, CodeBlob* cb, uint size = 0) PRODUCT_RETURN;
228 static void print_summary(outputStream* st, bool detailed = true); // Prints a summary of the code cache usage
229 static void log_state(outputStream* st);
230 LINUX_ONLY(static void write_perf_map(const char* filename, outputStream* st);) // Prints warnings and error messages to outputStream
231 static const char* get_code_heap_name(CodeBlobType code_blob_type) { return (heap_available(code_blob_type) ? get_code_heap(code_blob_type)->name() : "Unused"); }
232 static void report_codemem_full(CodeBlobType code_blob_type, bool print);
233
234 // Dcmd (Diagnostic commands)
235 static void print_codelist(outputStream* st);
236 static void print_layout(outputStream* st);
237
238 // The full limits of the codeCache
239 static address low_bound() { return _low_bound; }
240 static address low_bound(CodeBlobType code_blob_type);
241 static address high_bound() { return _high_bound; }
242 static address high_bound(CodeBlobType code_blob_type);
243
244 // Profiling
245 static size_t capacity();
246 static size_t unallocated_capacity(CodeBlobType code_blob_type);
247 static size_t unallocated_capacity();
248 static size_t max_capacity();
249
250 static double reverse_free_ratio();
251
252 static size_t max_distance_to_non_nmethod();
253 static bool is_non_nmethod(address addr);
|
131
132 private:
133 static size_t bytes_allocated_in_freelists();
134 static int allocated_segments();
135 static size_t freelists_length();
136
137 // Make private to prevent unsafe calls. Not all CodeBlob*'s are embedded in a CodeHeap.
138 static bool contains(CodeBlob *p) { fatal("don't call me!"); return false; }
139
140 public:
141 // Initialization
142 static void initialize();
143 static size_t page_size(bool aligned = true, size_t min_pages = 1); // Returns the page size used by the CodeCache
144
145 static int code_heap_compare(CodeHeap* const &lhs, CodeHeap* const &rhs);
146
147 static void add_heap(CodeHeap* heap);
148 static const GrowableArray<CodeHeap*>* heaps() { return _heaps; }
149 static const GrowableArray<CodeHeap*>* nmethod_heaps() { return _nmethod_heaps; }
150
151 static void* map_cached_code();
152 // Allocation/administration
153 static CodeBlob* allocate(uint size, CodeBlobType code_blob_type, bool handle_alloc_failure = true, CodeBlobType orig_code_blob_type = CodeBlobType::All); // allocates a new CodeBlob
154 static void commit(CodeBlob* cb); // called when the allocated CodeBlob has been filled
155 static void free(CodeBlob* cb); // frees a CodeBlob
156 static void free_unused_tail(CodeBlob* cb, size_t used); // frees the unused tail of a CodeBlob (only used by TemplateInterpreter::initialize())
157 static bool contains(void *p); // returns whether p is included
158 static bool contains(nmethod* nm); // returns whether nm is included
159 static void blobs_do(void f(CodeBlob* cb)); // iterates over all CodeBlobs
160 static void nmethods_do(void f(nmethod* nm)); // iterates over all nmethods
161 static void nmethods_do(NMethodClosure* cl); // iterates over all nmethods
162 static void metadata_do(MetadataClosure* f); // iterates over metadata in alive nmethods
163
164 // Lookup
165 static CodeBlob* find_blob(void* start); // Returns the CodeBlob containing the given address
166 static CodeBlob* find_blob_fast(void* start); // Returns the CodeBlob containing the given address
167 static CodeBlob* find_blob_and_oopmap(void* start, int& slot); // Returns the CodeBlob containing the given address
168 static int find_oopmap_slot_fast(void* start); // Returns a fast oopmap slot if there is any; -1 otherwise
169 static nmethod* find_nmethod(void* start); // Returns the nmethod containing the given address
170
171 static int blob_count(); // Returns the total number of CodeBlobs in the cache
206 // on-stack nmethods. It's used in two places:
207 // 1. Used before the start of concurrent marking so that oops inside
208 // on-stack nmethods are visited.
209 // 2. Used at the end of (stw/concurrent) marking so that nmethod::_gc_epoch
210 // is up-to-date, which provides more accurate estimate of
211 // nmethod::is_cold.
212 static void arm_all_nmethods();
213
214 static void maybe_restart_compiler(size_t freed_memory);
215 static void do_unloading(bool unloading_occurred);
216 static uint8_t unloading_cycle() { return _unloading_cycle; }
217
218 static void increment_unloading_cycle();
219
220 static void release_exception_cache(ExceptionCache* entry);
221 static void purge_exception_caches();
222
223 // Printing/debugging
224 static void print(); // prints summary
225 static void print_internals();
226 static void print_nmethods_on(outputStream* st);
227 static void print_memory_overhead();
228 static void verify(); // verifies the code cache
229 static void print_trace(const char* event, CodeBlob* cb, uint size = 0) PRODUCT_RETURN;
230 static void print_summary(outputStream* st, bool detailed = true); // Prints a summary of the code cache usage
231 static void log_state(outputStream* st);
232 LINUX_ONLY(static void write_perf_map(const char* filename, outputStream* st);) // Prints warnings and error messages to outputStream
233 static const char* get_code_heap_name(CodeBlobType code_blob_type) { return (heap_available(code_blob_type) ? get_code_heap(code_blob_type)->name() : "Unused"); }
234 static void report_codemem_full(CodeBlobType code_blob_type, bool print);
235
236 static void print_nmethod_statistics_on(outputStream* st);
237
238 // Dcmd (Diagnostic commands)
239 static void print_codelist(outputStream* st);
240 static void print_layout(outputStream* st);
241
242 // The full limits of the codeCache
243 static address low_bound() { return _low_bound; }
244 static address low_bound(CodeBlobType code_blob_type);
245 static address high_bound() { return _high_bound; }
246 static address high_bound(CodeBlobType code_blob_type);
247
248 // Profiling
249 static size_t capacity();
250 static size_t unallocated_capacity(CodeBlobType code_blob_type);
251 static size_t unallocated_capacity();
252 static size_t max_capacity();
253
254 static double reverse_free_ratio();
255
256 static size_t max_distance_to_non_nmethod();
257 static bool is_non_nmethod(address addr);
|