49 // CodeHeap is malloc()'ed at startup and never deleted during shutdown,
50 // so that the generated assembly code is always there when it's needed.
51 // This may cause memory leak, but is necessary, for now. See 4423824,
52 // 4422213 or 4436291 for details.
53 static CodeHeap * _heap;
54 static int _number_of_blobs;
55 static int _number_of_adapters;
56 static int _number_of_nmethods;
57 static int _number_of_nmethods_with_dependencies;
58 static bool _needs_cache_clean;
59 static nmethod* _scavenge_root_nmethods; // linked via nm->scavenge_root_link()
60 static nmethod* _saved_nmethods; // Linked list of speculatively disconnected nmethods.
61
62 static void verify_if_often() PRODUCT_RETURN;
63
64 static void mark_scavenge_root_nmethods() PRODUCT_RETURN;
65 static void verify_perm_nmethods(CodeBlobClosure* f_or_null) PRODUCT_RETURN;
66
67 static int _codemem_full_count;
68
69 public:
70
71 // Initialization
72 static void initialize();
73
74 static void report_codemem_full();
75
76 // Allocation/administration
77 static CodeBlob* allocate(int size, bool is_critical = false); // allocates a new CodeBlob
78 static void commit(CodeBlob* cb); // called when the allocated CodeBlob has been filled
79 static int alignment_unit(); // guaranteed alignment of all CodeBlobs
80 static int alignment_offset(); // guaranteed offset of first CodeBlob byte within alignment unit (i.e., allocation header)
81 static void free(CodeBlob* cb); // frees a CodeBlob
82 static void flush(); // flushes all CodeBlobs
83 static bool contains(void *p); // returns whether p is included
84 static void blobs_do(void f(CodeBlob* cb)); // iterates over all CodeBlobs
85 static void blobs_do(CodeBlobClosure* f); // iterates over all CodeBlobs
86 static void nmethods_do(void f(nmethod* nm)); // iterates over all nmethods
87 static void alive_nmethods_do(void f(nmethod* nm)); // iterates over all alive nmethods
88
89 // Lookup
90 static CodeBlob* find_blob(void* start);
91 static nmethod* find_nmethod(void* start);
92
133 static void verify_oops();
134 // If "unloading_occurred" is true, then unloads (i.e., breaks root links
135 // to) any unmarked codeBlobs in the cache. Sets "marked_for_unloading"
136 // to "true" iff some code got unloaded.
137 static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
138 static void oops_do(OopClosure* f) {
139 CodeBlobToOopClosure oopc(f, /*do_marking=*/ false);
140 blobs_do(&oopc);
141 }
142 static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN;
143 static void scavenge_root_nmethods_do(CodeBlobClosure* f);
144
145 static nmethod* scavenge_root_nmethods() { return _scavenge_root_nmethods; }
146 static void set_scavenge_root_nmethods(nmethod* nm) { _scavenge_root_nmethods = nm; }
147 static void add_scavenge_root_nmethod(nmethod* nm);
148 static void drop_scavenge_root_nmethod(nmethod* nm);
149 static void prune_scavenge_root_nmethods();
150
151 // Printing/debugging
152 static void print(); // prints summary
153 static void print_internals();
154 static void verify(); // verifies the code cache
155 static void print_trace(const char* event, CodeBlob* cb, int size = 0) PRODUCT_RETURN;
156 static void print_summary(outputStream* st, bool detailed = true); // Prints a summary of the code cache usage
157 static void log_state(outputStream* st);
158
159 // The full limits of the codeCache
160 static address low_bound() { return (address) _heap->low_boundary(); }
161 static address high_bound() { return (address) _heap->high_boundary(); }
162 static address high() { return (address) _heap->high(); }
163
164 // Profiling
165 static address first_address(); // first address used for CodeBlobs
166 static address last_address(); // last address used for CodeBlobs
167 static size_t capacity() { return _heap->capacity(); }
168 static size_t max_capacity() { return _heap->max_capacity(); }
169 static size_t unallocated_capacity() { return _heap->unallocated_capacity(); }
170 static bool needs_flushing() { return unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace; }
171 static double reverse_free_ratio();
172
173 static bool needs_cache_clean() { return _needs_cache_clean; }
|
49 // CodeHeap is malloc()'ed at startup and never deleted during shutdown,
50 // so that the generated assembly code is always there when it's needed.
51 // This may cause memory leak, but is necessary, for now. See 4423824,
52 // 4422213 or 4436291 for details.
53 static CodeHeap * _heap;
54 static int _number_of_blobs;
55 static int _number_of_adapters;
56 static int _number_of_nmethods;
57 static int _number_of_nmethods_with_dependencies;
58 static bool _needs_cache_clean;
59 static nmethod* _scavenge_root_nmethods; // linked via nm->scavenge_root_link()
60 static nmethod* _saved_nmethods; // Linked list of speculatively disconnected nmethods.
61
62 static void verify_if_often() PRODUCT_RETURN;
63
64 static void mark_scavenge_root_nmethods() PRODUCT_RETURN;
65 static void verify_perm_nmethods(CodeBlobClosure* f_or_null) PRODUCT_RETURN;
66
67 static int _codemem_full_count;
68
69 static void print_details();
70 static void print_content();
71 static void print_oop_map_usage();
72 static void print_dependency_checking_time();
73
74 public:
75
76 // Initialization
77 static void initialize();
78 static void init_printing_options(const char* options);
79
80 static void report_codemem_full();
81
82 // Allocation/administration
83 static CodeBlob* allocate(int size, bool is_critical = false); // allocates a new CodeBlob
84 static void commit(CodeBlob* cb); // called when the allocated CodeBlob has been filled
85 static int alignment_unit(); // guaranteed alignment of all CodeBlobs
86 static int alignment_offset(); // guaranteed offset of first CodeBlob byte within alignment unit (i.e., allocation header)
87 static void free(CodeBlob* cb); // frees a CodeBlob
88 static void flush(); // flushes all CodeBlobs
89 static bool contains(void *p); // returns whether p is included
90 static void blobs_do(void f(CodeBlob* cb)); // iterates over all CodeBlobs
91 static void blobs_do(CodeBlobClosure* f); // iterates over all CodeBlobs
92 static void nmethods_do(void f(nmethod* nm)); // iterates over all nmethods
93 static void alive_nmethods_do(void f(nmethod* nm)); // iterates over all alive nmethods
94
95 // Lookup
96 static CodeBlob* find_blob(void* start);
97 static nmethod* find_nmethod(void* start);
98
139 static void verify_oops();
140 // If "unloading_occurred" is true, then unloads (i.e., breaks root links
141 // to) any unmarked codeBlobs in the cache. Sets "marked_for_unloading"
142 // to "true" iff some code got unloaded.
143 static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred);
144 static void oops_do(OopClosure* f) {
145 CodeBlobToOopClosure oopc(f, /*do_marking=*/ false);
146 blobs_do(&oopc);
147 }
148 static void asserted_non_scavengable_nmethods_do(CodeBlobClosure* f = NULL) PRODUCT_RETURN;
149 static void scavenge_root_nmethods_do(CodeBlobClosure* f);
150
151 static nmethod* scavenge_root_nmethods() { return _scavenge_root_nmethods; }
152 static void set_scavenge_root_nmethods(nmethod* nm) { _scavenge_root_nmethods = nm; }
153 static void add_scavenge_root_nmethod(nmethod* nm);
154 static void drop_scavenge_root_nmethod(nmethod* nm);
155 static void prune_scavenge_root_nmethods();
156
157 // Printing/debugging
158 static void print(); // prints summary
159 static void verify(); // verifies the code cache
160 static void print_trace(const char* event, CodeBlob* cb, int size = 0) PRODUCT_RETURN;
161 static void print_summary(outputStream* st, bool detailed = true); // Prints a summary of the code cache usage
162 static void log_state(outputStream* st);
163
164 // The full limits of the codeCache
165 static address low_bound() { return (address) _heap->low_boundary(); }
166 static address high_bound() { return (address) _heap->high_boundary(); }
167 static address high() { return (address) _heap->high(); }
168
169 // Profiling
170 static address first_address(); // first address used for CodeBlobs
171 static address last_address(); // last address used for CodeBlobs
172 static size_t capacity() { return _heap->capacity(); }
173 static size_t max_capacity() { return _heap->max_capacity(); }
174 static size_t unallocated_capacity() { return _heap->unallocated_capacity(); }
175 static bool needs_flushing() { return unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace; }
176 static double reverse_free_ratio();
177
178 static bool needs_cache_clean() { return _needs_cache_clean; }
|