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