13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCache.hpp"
27 #include "code/nmethod.hpp"
28 #include "gc/g1/g1CodeRootSetTable.hpp"
29 #include "gc/g1/g1CodeCacheRemSet.hpp"
30 #include "gc/g1/heapRegion.hpp"
31 #include "memory/heap.hpp"
32 #include "memory/iterator.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "utilities/hashtable.inline.hpp"
35 #include "utilities/stack.inline.hpp"
36
37 G1CodeRootSetTable* volatile G1CodeRootSetTable::_purge_list = NULL;
38
39 size_t G1CodeRootSetTable::mem_size() {
40 return sizeof(G1CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket<mtGC>) * table_size());
41 }
42
43 G1CodeRootSetTable::Entry* G1CodeRootSetTable::new_entry(nmethod* nm) {
44 unsigned int hash = compute_hash(nm);
45 Entry* entry = (Entry*) new_entry_free_list();
46 if (entry == NULL) {
47 entry = (Entry*) NEW_C_HEAP_ARRAY2(char, entry_size(), mtGC, CURRENT_PC);
48 }
49 entry->set_next(NULL);
50 entry->set_hash(hash);
51 entry->set_literal(nm);
52 return entry;
257 }
258 }
259
260 class CleanCallback : public StackObj {
261 class PointsIntoHRDetectionClosure : public OopClosure {
262 HeapRegion* _hr;
263 public:
264 bool _points_into;
265 PointsIntoHRDetectionClosure(HeapRegion* hr) : _hr(hr), _points_into(false) {}
266
267 void do_oop(narrowOop* o) {
268 do_oop_work(o);
269 }
270
271 void do_oop(oop* o) {
272 do_oop_work(o);
273 }
274
275 template <typename T>
276 void do_oop_work(T* p) {
277 if (_hr->is_in(oopDesc::load_decode_heap_oop(p))) {
278 _points_into = true;
279 }
280 }
281 };
282
283 PointsIntoHRDetectionClosure _detector;
284 CodeBlobToOopClosure _blobs;
285
286 public:
287 CleanCallback(HeapRegion* hr) : _detector(hr), _blobs(&_detector, !CodeBlobToOopClosure::FixRelocations) {}
288
289 bool operator() (nmethod* nm) {
290 _detector._points_into = false;
291 _blobs.do_code_blob(nm);
292 return !_detector._points_into;
293 }
294 };
295
296 void G1CodeRootSet::clean(HeapRegion* owner) {
297 CleanCallback should_clean(owner);
|
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCache.hpp"
27 #include "code/nmethod.hpp"
28 #include "gc/g1/g1CodeRootSetTable.hpp"
29 #include "gc/g1/g1CodeCacheRemSet.hpp"
30 #include "gc/g1/heapRegion.hpp"
31 #include "memory/heap.hpp"
32 #include "memory/iterator.hpp"
33 #include "oops/access.inline.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "utilities/hashtable.inline.hpp"
36 #include "utilities/stack.inline.hpp"
37
38 G1CodeRootSetTable* volatile G1CodeRootSetTable::_purge_list = NULL;
39
40 size_t G1CodeRootSetTable::mem_size() {
41 return sizeof(G1CodeRootSetTable) + (entry_size() * number_of_entries()) + (sizeof(HashtableBucket<mtGC>) * table_size());
42 }
43
44 G1CodeRootSetTable::Entry* G1CodeRootSetTable::new_entry(nmethod* nm) {
45 unsigned int hash = compute_hash(nm);
46 Entry* entry = (Entry*) new_entry_free_list();
47 if (entry == NULL) {
48 entry = (Entry*) NEW_C_HEAP_ARRAY2(char, entry_size(), mtGC, CURRENT_PC);
49 }
50 entry->set_next(NULL);
51 entry->set_hash(hash);
52 entry->set_literal(nm);
53 return entry;
258 }
259 }
260
261 class CleanCallback : public StackObj {
262 class PointsIntoHRDetectionClosure : public OopClosure {
263 HeapRegion* _hr;
264 public:
265 bool _points_into;
266 PointsIntoHRDetectionClosure(HeapRegion* hr) : _hr(hr), _points_into(false) {}
267
268 void do_oop(narrowOop* o) {
269 do_oop_work(o);
270 }
271
272 void do_oop(oop* o) {
273 do_oop_work(o);
274 }
275
276 template <typename T>
277 void do_oop_work(T* p) {
278 if (_hr->is_in(RawAccess<>::oop_load(p))) {
279 _points_into = true;
280 }
281 }
282 };
283
284 PointsIntoHRDetectionClosure _detector;
285 CodeBlobToOopClosure _blobs;
286
287 public:
288 CleanCallback(HeapRegion* hr) : _detector(hr), _blobs(&_detector, !CodeBlobToOopClosure::FixRelocations) {}
289
290 bool operator() (nmethod* nm) {
291 _detector._points_into = false;
292 _blobs.do_code_blob(nm);
293 return !_detector._points_into;
294 }
295 };
296
297 void G1CodeRootSet::clean(HeapRegion* owner) {
298 CleanCallback should_clean(owner);
|