comparison src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.hpp @ 20211:82693fb204a5

8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet Summary: The test incorrectly assumed that it had been started with no other previous compilation activity. Fix this by allowing multiple code root free chunk lists, and use one separate from the global one to perform the test. Reviewed-by: brutisso
author tschatzl
date Wed, 16 Apr 2014 10:14:50 +0200
parents 191174b49bec
children 828056cf311f
comparison
equal deleted inserted replaced
20210:3a62cd59c8d8 20211:82693fb204a5
126 _top--; 126 _top--;
127 return *_top; 127 return *_top;
128 } 128 }
129 }; 129 };
130 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
131 // Implements storage for a set of code roots. 159 // Implements storage for a set of code roots.
132 // All methods that modify the set are not thread-safe except if otherwise noted. 160 // All methods that modify the set are not thread-safe except if otherwise noted.
133 class G1CodeRootSet VALUE_OBJ_CLASS_SPEC { 161 class G1CodeRootSet VALUE_OBJ_CLASS_SPEC {
134 private: 162 private:
135 // Global free chunk list management 163 // Global default free chunk manager instance.
136 static FreeList<G1CodeRootChunk> _free_list; 164 static G1CodeRootChunkManager _default_chunk_manager;
137 // Total number of chunks handed out 165
138 static size_t _num_chunks_handed_out; 166 G1CodeRootChunk* new_chunk() { return _manager->new_chunk(); }
139 167 void free_chunk(G1CodeRootChunk* chunk) { _manager->free_chunk(chunk); }
140 static G1CodeRootChunk* new_chunk();
141 static void free_chunk(G1CodeRootChunk* chunk);
142 // Free all elements of the given list. 168 // Free all elements of the given list.
143 static void free_all_chunks(FreeList<G1CodeRootChunk>* list); 169 void free_all_chunks(FreeList<G1CodeRootChunk>* list) { _manager->free_all_chunks(list); }
144 170
145 // Return the chunk that contains the given nmethod, NULL otherwise. 171 // Return the chunk that contains the given nmethod, NULL otherwise.
146 // Scans the list of chunks backwards, as this method is used to add new 172 // Scans the list of chunks backwards, as this method is used to add new
147 // entries, which are typically added in bulk for a single nmethod. 173 // entries, which are typically added in bulk for a single nmethod.
148 G1CodeRootChunk* find(nmethod* method); 174 G1CodeRootChunk* find(nmethod* method);
149 void free(G1CodeRootChunk* chunk); 175 void free(G1CodeRootChunk* chunk);
150 176
151 size_t _length; 177 size_t _length;
152 FreeList<G1CodeRootChunk> _list; 178 FreeList<G1CodeRootChunk> _list;
153 179 G1CodeRootChunkManager* _manager;
154 public: 180
155 G1CodeRootSet(); 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);
156 ~G1CodeRootSet(); 185 ~G1CodeRootSet();
157 186
158 static void initialize();
159 static void purge_chunks(size_t keep_ratio); 187 static void purge_chunks(size_t keep_ratio);
160 188
161 static size_t static_mem_size(); 189 static size_t static_mem_size();
162 static size_t fl_mem_size(); 190 static size_t free_chunks_mem_size();
163 191
164 // Search for the code blob from the recently allocated ones to find duplicates more quickly, as this 192 // Search for the code blob from the recently allocated ones to find duplicates more quickly, as this
165 // method is likely to be repeatedly called with the same nmethod. 193 // method is likely to be repeatedly called with the same nmethod.
166 void add(nmethod* method); 194 void add(nmethod* method);
167 195