< prev index next >

src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp

Print this page


   1 /*
   2  * Copyright (c) 2001, 2014, 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  *


 745 
 746 DirtyCardToOopClosure*
 747 CompactibleFreeListSpace::new_dcto_cl(ExtendedOopClosure* cl,
 748                                       CardTableModRefBS::PrecisionStyle precision,
 749                                       HeapWord* boundary) {
 750   return new FreeListSpace_DCTOC(this, _collector, cl, precision, boundary);
 751 }
 752 
 753 
 754 // Note on locking for the space iteration functions:
 755 // since the collector's iteration activities are concurrent with
 756 // allocation activities by mutators, absent a suitable mutual exclusion
 757 // mechanism the iterators may go awry. For instance a block being iterated
 758 // may suddenly be allocated or divided up and part of it allocated and
 759 // so on.
 760 
 761 // Apply the given closure to each block in the space.
 762 void CompactibleFreeListSpace::blk_iterate_careful(BlkClosureCareful* cl) {
 763   assert_lock_strong(freelistLock());
 764   HeapWord *cur, *limit;
 765   for (cur = bottom(), limit = end(); cur < limit;
 766        cur += cl->do_blk_careful(cur));



 767 }
 768 
 769 // Apply the given closure to each block in the space.
 770 void CompactibleFreeListSpace::blk_iterate(BlkClosure* cl) {
 771   assert_lock_strong(freelistLock());
 772   HeapWord *cur, *limit;
 773   for (cur = bottom(), limit = end(); cur < limit;
 774        cur += cl->do_blk(cur));
 775 }
 776 
 777 // Apply the given closure to each oop in the space.
 778 void CompactibleFreeListSpace::oop_iterate(ExtendedOopClosure* cl) {
 779   assert_lock_strong(freelistLock());
 780   HeapWord *cur, *limit;
 781   size_t curSize;
 782   for (cur = bottom(), limit = end(); cur < limit;
 783        cur += curSize) {
 784     curSize = block_size(cur);
 785     if (block_is_obj(cur)) {
 786       oop(cur)->oop_iterate(cl);


   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  *


 745 
 746 DirtyCardToOopClosure*
 747 CompactibleFreeListSpace::new_dcto_cl(ExtendedOopClosure* cl,
 748                                       CardTableModRefBS::PrecisionStyle precision,
 749                                       HeapWord* boundary) {
 750   return new FreeListSpace_DCTOC(this, _collector, cl, precision, boundary);
 751 }
 752 
 753 
 754 // Note on locking for the space iteration functions:
 755 // since the collector's iteration activities are concurrent with
 756 // allocation activities by mutators, absent a suitable mutual exclusion
 757 // mechanism the iterators may go awry. For instance a block being iterated
 758 // may suddenly be allocated or divided up and part of it allocated and
 759 // so on.
 760 
 761 // Apply the given closure to each block in the space.
 762 void CompactibleFreeListSpace::blk_iterate_careful(BlkClosureCareful* cl) {
 763   assert_lock_strong(freelistLock());
 764   HeapWord *cur, *limit;
 765   size_t res;
 766   for (cur = bottom(), limit = end(); cur < limit; cur += res) {
 767     res = cl->do_blk_careful(cur);
 768     assert(cur + res > cur, "Not monotonically increasing ?");
 769   }
 770 }
 771 
 772 // Apply the given closure to each block in the space.
 773 void CompactibleFreeListSpace::blk_iterate(BlkClosure* cl) {
 774   assert_lock_strong(freelistLock());
 775   HeapWord *cur, *limit;
 776   for (cur = bottom(), limit = end(); cur < limit;
 777        cur += cl->do_blk(cur));
 778 }
 779 
 780 // Apply the given closure to each oop in the space.
 781 void CompactibleFreeListSpace::oop_iterate(ExtendedOopClosure* cl) {
 782   assert_lock_strong(freelistLock());
 783   HeapWord *cur, *limit;
 784   size_t curSize;
 785   for (cur = bottom(), limit = end(); cur < limit;
 786        cur += curSize) {
 787     curSize = block_size(cur);
 788     if (block_is_obj(cur)) {
 789       oop(cur)->oop_iterate(cl);


< prev index next >