< prev index next >

src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp

Print this page
rev 56448 : imported patch 8220310.mut.0
rev 56449 : imported patch 8220310.mut.1_thomas
rev 56451 : imported patch 8220310.mut.1-3_kim
rev 56453 : imported patch 8220310.mut.2-kim
rev 56454 : [mq]: 8220310.mut.2-evensplit


   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1BiasedArray.hpp"

  27 #include "gc/g1/g1RegionToSpaceMapper.hpp"
  28 #include "logging/log.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 #include "memory/virtualspace.hpp"
  31 #include "runtime/java.hpp"
  32 #include "runtime/os.inline.hpp"
  33 #include "services/memTracker.hpp"
  34 #include "utilities/align.hpp"
  35 #include "utilities/bitMap.inline.hpp"
  36 #include "utilities/formatBuffer.hpp"
  37 
  38 G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs,
  39                                              size_t used_size,
  40                                              size_t page_size,
  41                                              size_t region_granularity,
  42                                              size_t commit_factor,
  43                                              MemoryType type) :
  44   _listener(NULL),
  45   _storage(rs, used_size, page_size),
  46   _region_granularity(region_granularity),
  47   _commit_map(rs.size() * commit_factor / region_granularity, mtGC) {
  48   guarantee(is_power_of_2(page_size), "must be");
  49   guarantee(is_power_of_2(region_granularity), "must be");
  50 
  51   MemTracker::record_virtual_memory_type((address)rs.base(), type);
  52 }
  53 
  54 // G1RegionToSpaceMapper implementation where the region granularity is larger than
  55 // or the same as the commit granularity.
  56 // Basically, the space corresponding to one region region spans several OS pages.
  57 class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper {
  58  private:
  59   size_t _pages_per_region;
  60 
  61  public:
  62   G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs,
  63                                       size_t actual_size,
  64                                       size_t page_size,
  65                                       size_t alloc_granularity,
  66                                       size_t commit_factor,
  67                                       MemoryType type) :
  68     G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
  69     _pages_per_region(alloc_granularity / (page_size * commit_factor)) {
  70 
  71     guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity");
  72   }
  73 
  74   virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
  75     size_t const start_page = (size_t)start_idx * _pages_per_region;
  76     bool zero_filled = _storage.commit(start_page, num_regions * _pages_per_region);

  77     if (AlwaysPreTouch) {
  78       _storage.pretouch(start_page, num_regions * _pages_per_region, pretouch_gang);
  79     }
  80     _commit_map.set_range(start_idx, start_idx + num_regions);
  81     fire_on_commit(start_idx, num_regions, zero_filled);
  82   }
  83 
  84   virtual void uncommit_regions(uint start_idx, size_t num_regions) {
  85     _storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region);
  86     _commit_map.clear_range(start_idx, start_idx + num_regions);
  87   }
  88 };
  89 
  90 // G1RegionToSpaceMapper implementation where the region granularity is smaller
  91 // than the commit granularity.
  92 // Basically, the contents of one OS page span several regions.
  93 class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
  94  private:
  95   class CommitRefcountArray : public G1BiasedMappedArray<uint> {
  96    protected:
  97      virtual uint default_value() const { return 0; }
  98   };




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1BiasedArray.hpp"
  27 #include "gc/g1/g1MemoryNodeManager.hpp"
  28 #include "gc/g1/g1RegionToSpaceMapper.hpp"
  29 #include "logging/log.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "memory/virtualspace.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/os.inline.hpp"
  34 #include "services/memTracker.hpp"
  35 #include "utilities/align.hpp"
  36 #include "utilities/bitMap.inline.hpp"
  37 #include "utilities/formatBuffer.hpp"
  38 
  39 G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs,
  40                                              size_t used_size,
  41                                              size_t page_size,
  42                                              size_t region_granularity,
  43                                              size_t commit_factor,
  44                                              MemoryType type) :
  45   _listener(NULL),
  46   _storage(rs, used_size, page_size, type),
  47   _region_granularity(region_granularity),
  48   _commit_map(rs.size() * commit_factor / region_granularity, mtGC) {
  49   guarantee(is_power_of_2(page_size), "must be");
  50   guarantee(is_power_of_2(region_granularity), "must be");
  51 
  52   MemTracker::record_virtual_memory_type((address)rs.base(), type);
  53 }
  54 
  55 // G1RegionToSpaceMapper implementation where the region granularity is larger than
  56 // or the same as the commit granularity.
  57 // Basically, the space corresponding to one region region spans several OS pages.
  58 class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper {
  59  private:
  60   size_t _pages_per_region;
  61 
  62  public:
  63   G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs,
  64                                       size_t actual_size,
  65                                       size_t page_size,
  66                                       size_t alloc_granularity,
  67                                       size_t commit_factor,
  68                                       MemoryType type) :
  69     G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
  70     _pages_per_region(alloc_granularity / (page_size * commit_factor)) {
  71 
  72     guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity");
  73   }
  74 
  75   virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
  76     const size_t start_page = (size_t)start_idx * _pages_per_region;
  77     const size_t size_in_pages = num_regions * _pages_per_region;
  78     bool zero_filled = _storage.commit(start_page, size_in_pages);
  79     if (AlwaysPreTouch) {
  80       _storage.pretouch(start_page, size_in_pages, pretouch_gang);
  81     }
  82     _commit_map.set_range(start_idx, start_idx + num_regions);
  83     fire_on_commit(start_idx, num_regions, zero_filled);
  84   }
  85 
  86   virtual void uncommit_regions(uint start_idx, size_t num_regions) {
  87     _storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region);
  88     _commit_map.clear_range(start_idx, start_idx + num_regions);
  89   }
  90 };
  91 
  92 // G1RegionToSpaceMapper implementation where the region granularity is smaller
  93 // than the commit granularity.
  94 // Basically, the contents of one OS page span several regions.
  95 class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
  96  private:
  97   class CommitRefcountArray : public G1BiasedMappedArray<uint> {
  98    protected:
  99      virtual uint default_value() const { return 0; }
 100   };


< prev index next >