< prev index next >

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

Print this page


   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  *


  29 #include "utilities/debug.hpp"
  30 
  31 uintptr_t** G1FromCardCache::_cache = NULL;
  32 uint        G1FromCardCache::_max_regions = 0;
  33 size_t      G1FromCardCache::_static_mem_size = 0;
  34 #ifdef ASSERT
  35 uint   G1FromCardCache::_max_workers = 0;
  36 #endif
  37 
  38 void G1FromCardCache::initialize(uint num_par_rem_sets, uint max_num_regions) {
  39   guarantee(max_num_regions > 0, "Heap size must be valid");
  40   guarantee(_cache == NULL, "Should not call this multiple times");
  41 
  42   _max_regions = max_num_regions;
  43 #ifdef ASSERT
  44   _max_workers = num_par_rem_sets;
  45 #endif
  46   _cache = Padded2DArray<uintptr_t, mtGC>::create_unfreeable(_max_regions,
  47                                                              num_par_rem_sets,
  48                                                              &_static_mem_size);
  49 
  50   invalidate(0, _max_regions);
  51 }
  52 
  53 void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) {
  54   guarantee((size_t)start_idx + new_num_regions <= max_uintx,
  55             "Trying to invalidate beyond maximum region, from %u size " SIZE_FORMAT,
  56             start_idx, new_num_regions);
  57   uint end_idx = (start_idx + (uint)new_num_regions);
  58   assert(end_idx <= _max_regions, "Must be within max.");
  59 
  60   for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
  61     for (uint j = start_idx; j < end_idx; j++) {
  62       set(i, j, InvalidCard);
  63     }
  64   }
  65 }
  66 
  67 #ifndef PRODUCT
  68 void G1FromCardCache::print(outputStream* out) {
  69   for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
  70     for (uint j = 0; j < _max_regions; j++) {
   1 /*
   2  * Copyright (c) 2001, 2018, 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  *


  29 #include "utilities/debug.hpp"
  30 
  31 uintptr_t** G1FromCardCache::_cache = NULL;
  32 uint        G1FromCardCache::_max_regions = 0;
  33 size_t      G1FromCardCache::_static_mem_size = 0;
  34 #ifdef ASSERT
  35 uint   G1FromCardCache::_max_workers = 0;
  36 #endif
  37 
  38 void G1FromCardCache::initialize(uint num_par_rem_sets, uint max_num_regions) {
  39   guarantee(max_num_regions > 0, "Heap size must be valid");
  40   guarantee(_cache == NULL, "Should not call this multiple times");
  41 
  42   _max_regions = max_num_regions;
  43 #ifdef ASSERT
  44   _max_workers = num_par_rem_sets;
  45 #endif
  46   _cache = Padded2DArray<uintptr_t, mtGC>::create_unfreeable(_max_regions,
  47                                                              num_par_rem_sets,
  48                                                              &_static_mem_size);


  49 }
  50 
  51 void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) {
  52   guarantee((size_t)start_idx + new_num_regions <= max_uintx,
  53             "Trying to invalidate beyond maximum region, from %u size " SIZE_FORMAT,
  54             start_idx, new_num_regions);
  55   uint end_idx = (start_idx + (uint)new_num_regions);
  56   assert(end_idx <= _max_regions, "Must be within max.");
  57 
  58   for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
  59     for (uint j = start_idx; j < end_idx; j++) {
  60       set(i, j, InvalidCard);
  61     }
  62   }
  63 }
  64 
  65 #ifndef PRODUCT
  66 void G1FromCardCache::print(outputStream* out) {
  67   for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
  68     for (uint j = 0; j < _max_regions; j++) {
< prev index next >