< prev index next >

src/share/vm/gc/g1/heapRegionRemSet.cpp

Print this page
rev 9830 : [mq]: rev.01
rev 9831 : [mq]: rev.02
   1 /*
   2  * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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  *


 768   // It's good to check this to make sure that the two methods are in sync.
 769   assert(verify_ready_for_par_iteration(), "post-condition");
 770 }
 771 
 772 void HeapRegionRemSet::scrub(CardTableModRefBS* ctbs,
 773                              BitMap* region_bm, BitMap* card_bm) {
 774   _other_regions.scrub(ctbs, region_bm, card_bm);
 775 }
 776 
 777 // Code roots support
 778 //
 779 // The code root set is protected by two separate locking schemes
 780 // When at safepoint the per-hrrs lock must be held during modifications
 781 // except when doing a full gc.
 782 // When not at safepoint the CodeCache_lock must be held during modifications.
 783 // When concurrent readers access the contains() function
 784 // (during the evacuation phase) no removals are allowed.
 785 
 786 void HeapRegionRemSet::add_strong_code_root(nmethod* nm) {
 787   assert(nm != NULL, "sanity");



 788   // Optimistic unlocked contains-check
 789   if (!_code_roots.contains(nm)) {
 790     MutexLockerEx ml(&_m, Mutex::_no_safepoint_check_flag);
 791     add_strong_code_root_locked(nm);
 792   }
 793 }
 794 
 795 void HeapRegionRemSet::add_strong_code_root_locked(nmethod* nm) {
 796   assert(nm != NULL, "sanity");






 797   _code_roots.add(nm);
 798 }
 799 
 800 void HeapRegionRemSet::remove_strong_code_root(nmethod* nm) {
 801   assert(nm != NULL, "sanity");
 802   assert_locked_or_safepoint(CodeCache_lock);
 803 
 804   MutexLockerEx ml(CodeCache_lock->owned_by_self() ? NULL : &_m, Mutex::_no_safepoint_check_flag);
 805   _code_roots.remove(nm);
 806 
 807   // Check that there were no duplicates
 808   guarantee(!_code_roots.contains(nm), "duplicate entry found");
 809 }
 810 
 811 void HeapRegionRemSet::strong_code_roots_do(CodeBlobClosure* blk) const {
 812   _code_roots.nmethods_do(blk);
 813 }
 814 
 815 void HeapRegionRemSet::clean_strong_code_roots(HeapRegion* hr) {
 816   _code_roots.clean(hr);


   1 /*
   2  * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  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  *


 768   // It's good to check this to make sure that the two methods are in sync.
 769   assert(verify_ready_for_par_iteration(), "post-condition");
 770 }
 771 
 772 void HeapRegionRemSet::scrub(CardTableModRefBS* ctbs,
 773                              BitMap* region_bm, BitMap* card_bm) {
 774   _other_regions.scrub(ctbs, region_bm, card_bm);
 775 }
 776 
 777 // Code roots support
 778 //
 779 // The code root set is protected by two separate locking schemes
 780 // When at safepoint the per-hrrs lock must be held during modifications
 781 // except when doing a full gc.
 782 // When not at safepoint the CodeCache_lock must be held during modifications.
 783 // When concurrent readers access the contains() function
 784 // (during the evacuation phase) no removals are allowed.
 785 
 786 void HeapRegionRemSet::add_strong_code_root(nmethod* nm) {
 787   assert(nm != NULL, "sanity");
 788   assert((!CodeCache_lock->owned_by_self() || SafepointSynchronize::is_at_safepoint()),
 789           "should call add_strong_code_root_locked instead.\n  CodeCache_lock->owned_by_self(): %s\n  is_at_safepoint(): %s",
 790           BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()));
 791   // Optimistic unlocked contains-check
 792   if (!_code_roots.contains(nm)) {
 793     MutexLockerEx ml(&_m, Mutex::_no_safepoint_check_flag);
 794     add_strong_code_root_locked(nm);
 795   }
 796 }
 797 
 798 void HeapRegionRemSet::add_strong_code_root_locked(nmethod* nm) {
 799   assert(nm != NULL, "sanity");
 800   assert((CodeCache_lock->owned_by_self() ||
 801          (SafepointSynchronize::is_at_safepoint() &&
 802           (_m.owned_by_self() || Thread::current()->is_VM_thread()))),
 803           "not safely locked.\n  CodeCache_lock->owned_by_self(): %s\n  is_at_safepoint(): %s\n  _m.owned_by_self(): %s\n  Thread::current()->is_VM_thread(): %s",
 804           BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()),
 805           BOOL_TO_STR(_m.owned_by_self()), BOOL_TO_STR(Thread::current()->is_VM_thread()));
 806   _code_roots.add(nm);
 807 }
 808 
 809 void HeapRegionRemSet::remove_strong_code_root(nmethod* nm) {
 810   assert(nm != NULL, "sanity");
 811   assert_locked_or_safepoint(CodeCache_lock);
 812 
 813   MutexLockerEx ml(CodeCache_lock->owned_by_self() ? NULL : &_m, Mutex::_no_safepoint_check_flag);
 814   _code_roots.remove(nm);
 815 
 816   // Check that there were no duplicates
 817   guarantee(!_code_roots.contains(nm), "duplicate entry found");
 818 }
 819 
 820 void HeapRegionRemSet::strong_code_roots_do(CodeBlobClosure* blk) const {
 821   _code_roots.nmethods_do(blk);
 822 }
 823 
 824 void HeapRegionRemSet::clean_strong_code_roots(HeapRegion* hr) {
 825   _code_roots.clean(hr);


< prev index next >