< prev index next >

src/share/vm/gc/g1/sparsePRT.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  *


 103   if (_entries != NULL) {
 104     FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries);
 105     _entries = NULL;
 106   }
 107   if (_buckets != NULL) {
 108     FREE_C_HEAP_ARRAY(int, _buckets);
 109     _buckets = NULL;
 110   }
 111 }
 112 
 113 void RSHashTable::clear() {
 114   _occupied_entries = 0;
 115   _occupied_cards = 0;
 116   guarantee(_entries != NULL, "INV");
 117   guarantee(_buckets != NULL, "INV");
 118 
 119   guarantee(_capacity <= ((size_t)1 << (sizeof(int)*BitsPerByte-1)) - 1,
 120                 "_capacity too large");
 121 
 122   // This will put -1 == NullEntry in the key field of all entries.
 123   memset(_entries, NullEntry, _num_entries * SparsePRTEntry::size());
 124   memset(_buckets, NullEntry, _capacity * sizeof(int));
 125   _free_list = NullEntry;
 126   _free_region = 0;
 127 }
 128 
 129 bool RSHashTable::add_card(RegionIdx_t region_ind, CardIdx_t card_index) {
 130   SparsePRTEntry* e = entry_for_region_ind_create(region_ind);
 131   assert(e != NULL && e->r_ind() == region_ind,
 132          "Postcondition of call above.");
 133   SparsePRTEntry::AddCardResult res = e->add_card(card_index);
 134   if (res == SparsePRTEntry::added) _occupied_cards++;
 135   assert(e->num_valid_cards() > 0, "Postcondition");
 136   return res != SparsePRTEntry::overflow;
 137 }
 138 
 139 SparsePRTEntry* RSHashTable::get_entry(RegionIdx_t region_ind) const {
 140   int ind = (int) (region_ind & capacity_mask());
 141   int cur_ind = _buckets[ind];
 142   SparsePRTEntry* cur;
 143   while (cur_ind != NullEntry &&
 144          (cur = entry(cur_ind))->r_ind() != region_ind) {


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


 103   if (_entries != NULL) {
 104     FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries);
 105     _entries = NULL;
 106   }
 107   if (_buckets != NULL) {
 108     FREE_C_HEAP_ARRAY(int, _buckets);
 109     _buckets = NULL;
 110   }
 111 }
 112 
 113 void RSHashTable::clear() {
 114   _occupied_entries = 0;
 115   _occupied_cards = 0;
 116   guarantee(_entries != NULL, "INV");
 117   guarantee(_buckets != NULL, "INV");
 118 
 119   guarantee(_capacity <= ((size_t)1 << (sizeof(int)*BitsPerByte-1)) - 1,
 120                 "_capacity too large");
 121 
 122   // This will put -1 == NullEntry in the key field of all entries.
 123   memset((void*)_entries, NullEntry, _num_entries * SparsePRTEntry::size());
 124   memset((void*)_buckets, NullEntry, _capacity * sizeof(int));
 125   _free_list = NullEntry;
 126   _free_region = 0;
 127 }
 128 
 129 bool RSHashTable::add_card(RegionIdx_t region_ind, CardIdx_t card_index) {
 130   SparsePRTEntry* e = entry_for_region_ind_create(region_ind);
 131   assert(e != NULL && e->r_ind() == region_ind,
 132          "Postcondition of call above.");
 133   SparsePRTEntry::AddCardResult res = e->add_card(card_index);
 134   if (res == SparsePRTEntry::added) _occupied_cards++;
 135   assert(e->num_valid_cards() > 0, "Postcondition");
 136   return res != SparsePRTEntry::overflow;
 137 }
 138 
 139 SparsePRTEntry* RSHashTable::get_entry(RegionIdx_t region_ind) const {
 140   int ind = (int) (region_ind & capacity_mask());
 141   int cur_ind = _buckets[ind];
 142   SparsePRTEntry* cur;
 143   while (cur_ind != NullEntry &&
 144          (cur = entry(cur_ind))->r_ind() != region_ind) {


< prev index next >