130
131 // Manages free chunks.
132 class G1CodeRootChunkManager VALUE_OBJ_CLASS_SPEC {
133 private:
134 // Global free chunk list management
135 FreeList<G1CodeRootChunk> _free_list;
136 // Total number of chunks handed out
137 size_t _num_chunks_handed_out;
138
139 public:
140 G1CodeRootChunkManager();
141
142 G1CodeRootChunk* new_chunk();
143 void free_chunk(G1CodeRootChunk* chunk);
144 // Free all elements of the given list.
145 void free_all_chunks(FreeList<G1CodeRootChunk>* list);
146
147 void initialize();
148 void purge_chunks(size_t keep_ratio);
149
150 size_t static_mem_size();
151 size_t fl_mem_size();
152
153 #ifndef PRODUCT
154 size_t num_chunks_handed_out() const;
155 size_t num_free_chunks() const;
156 #endif
157 };
158
159 // Implements storage for a set of code roots.
160 // All methods that modify the set are not thread-safe except if otherwise noted.
161 class G1CodeRootSet VALUE_OBJ_CLASS_SPEC {
162 private:
163 // Global default free chunk manager instance.
164 static G1CodeRootChunkManager _default_chunk_manager;
165
166 G1CodeRootChunk* new_chunk() { return _manager->new_chunk(); }
167 void free_chunk(G1CodeRootChunk* chunk) { _manager->free_chunk(chunk); }
168 // Free all elements of the given list.
169 void free_all_chunks(FreeList<G1CodeRootChunk>* list) { _manager->free_all_chunks(list); }
170
171 // Return the chunk that contains the given nmethod, NULL otherwise.
172 // Scans the list of chunks backwards, as this method is used to add new
173 // entries, which are typically added in bulk for a single nmethod.
174 G1CodeRootChunk* find(nmethod* method);
175 void free(G1CodeRootChunk* chunk);
176
177 size_t _length;
178 FreeList<G1CodeRootChunk> _list;
179 G1CodeRootChunkManager* _manager;
180
181 public:
182 // If an instance is initialized with a chunk manager of NULL, use the global
183 // default one.
184 G1CodeRootSet(G1CodeRootChunkManager* manager = NULL);
185 ~G1CodeRootSet();
186
187 static void purge_chunks(size_t keep_ratio);
188
189 static size_t static_mem_size();
190 static size_t free_chunks_mem_size();
191
192 // Search for the code blob from the recently allocated ones to find duplicates more quickly, as this
193 // method is likely to be repeatedly called with the same nmethod.
194 void add(nmethod* method);
195
196 void remove(nmethod* method);
197 nmethod* pop();
198
199 bool contains(nmethod* method);
200
201 void clear();
202
203 void nmethods_do(CodeBlobClosure* blk) const;
204
205 bool is_empty() { return length() == 0; }
206
207 // Length in elements
208 size_t length() const { return _length; }
209
210 // Memory size in bytes taken by this set.
211 size_t mem_size();
212
213 static void test() PRODUCT_RETURN;
214 };
215
216 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP
|
130
131 // Manages free chunks.
132 class G1CodeRootChunkManager VALUE_OBJ_CLASS_SPEC {
133 private:
134 // Global free chunk list management
135 FreeList<G1CodeRootChunk> _free_list;
136 // Total number of chunks handed out
137 size_t _num_chunks_handed_out;
138
139 public:
140 G1CodeRootChunkManager();
141
142 G1CodeRootChunk* new_chunk();
143 void free_chunk(G1CodeRootChunk* chunk);
144 // Free all elements of the given list.
145 void free_all_chunks(FreeList<G1CodeRootChunk>* list);
146
147 void initialize();
148 void purge_chunks(size_t keep_ratio);
149
150 static size_t static_mem_size();
151 size_t fl_mem_size();
152
153 #ifndef PRODUCT
154 size_t num_chunks_handed_out() const;
155 size_t num_free_chunks() const;
156 #endif
157 };
158
159 // Implements storage for a set of code roots.
160 // All methods that modify the set are not thread-safe except if otherwise noted.
161 class G1CodeRootSet VALUE_OBJ_CLASS_SPEC {
162 private:
163 // Global default free chunk manager instance.
164 static G1CodeRootChunkManager _default_chunk_manager;
165
166 G1CodeRootChunk* new_chunk() { return _manager->new_chunk(); }
167 void free_chunk(G1CodeRootChunk* chunk) { _manager->free_chunk(chunk); }
168 // Free all elements of the given list.
169 void free_all_chunks(FreeList<G1CodeRootChunk>* list) { _manager->free_all_chunks(list); }
170
171 // Return the chunk that contains the given nmethod, NULL otherwise.
172 // Scans the list of chunks backwards, as this method is used to add new
173 // entries, which are typically added in bulk for a single nmethod.
174 G1CodeRootChunk* find(nmethod* method);
175 void free(G1CodeRootChunk* chunk);
176
177 size_t _length;
178 FreeList<G1CodeRootChunk> _list;
179 G1CodeRootChunkManager* _manager;
180
181 public:
182 // If an instance is initialized with a chunk manager of NULL, use the global
183 // default one.
184 G1CodeRootSet(G1CodeRootChunkManager* manager = NULL);
185 ~G1CodeRootSet();
186
187 static void purge_chunks(size_t keep_ratio);
188
189 static size_t free_chunks_static_mem_size();
190 static size_t free_chunks_mem_size();
191
192 // Search for the code blob from the recently allocated ones to find duplicates more quickly, as this
193 // method is likely to be repeatedly called with the same nmethod.
194 void add(nmethod* method);
195
196 void remove(nmethod* method);
197 nmethod* pop();
198
199 bool contains(nmethod* method);
200
201 void clear();
202
203 void nmethods_do(CodeBlobClosure* blk) const;
204
205 bool is_empty() { return length() == 0; }
206
207 // Length in elements
208 size_t length() const { return _length; }
209
210 // Static data memory size in bytes of this set.
211 static size_t static_mem_size();
212 // Memory size in bytes taken by this set.
213 size_t mem_size();
214
215 static void test() PRODUCT_RETURN;
216 };
217
218 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1CODECACHEREMSET_HPP
|