< prev index next >

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

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


  59 
  60   if (previous == NULL) {
  61     set_entry(index, e->next());
  62   } else {
  63     previous->set_next(e->next());
  64   }
  65   free_entry(e);
  66 }
  67 
  68 G1CodeRootSetTable::~G1CodeRootSetTable() {
  69   for (int index = 0; index < table_size(); ++index) {
  70     for (Entry* e = bucket(index); e != NULL; ) {
  71       Entry* to_remove = e;
  72       // read next before freeing.
  73       e = e->next();
  74       unlink_entry(to_remove);
  75       FREE_C_HEAP_ARRAY(char, to_remove);
  76     }
  77   }
  78   assert(number_of_entries() == 0, "should have removed all entries");
  79   free_buckets();


  80   for (BasicHashtableEntry<mtGC>* e = new_entry_free_list(); e != NULL; e = new_entry_free_list()) {
  81     FREE_C_HEAP_ARRAY(char, e);
  82   }
  83 }
  84 
  85 bool G1CodeRootSetTable::add(nmethod* nm) {
  86   if (!contains(nm)) {
  87     Entry* e = new_entry(nm);
  88     int index = hash_to_index(e->hash());
  89     add_entry(index, e);
  90     return true;
  91   }
  92   return false;
  93 }
  94 
  95 bool G1CodeRootSetTable::contains(nmethod* nm) {
  96   int index = hash_to_index(compute_hash(nm));
  97   for (Entry* e = bucket(index); e != NULL; e = e->next()) {
  98     if (e->literal() == nm) {
  99       return true;


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


  59 
  60   if (previous == NULL) {
  61     set_entry(index, e->next());
  62   } else {
  63     previous->set_next(e->next());
  64   }
  65   free_entry(e);
  66 }
  67 
  68 G1CodeRootSetTable::~G1CodeRootSetTable() {
  69   for (int index = 0; index < table_size(); ++index) {
  70     for (Entry* e = bucket(index); e != NULL; ) {
  71       Entry* to_remove = e;
  72       // read next before freeing.
  73       e = e->next();
  74       unlink_entry(to_remove);
  75       FREE_C_HEAP_ARRAY(char, to_remove);
  76     }
  77   }
  78   assert(number_of_entries() == 0, "should have removed all entries");
  79   // Each of the entries in new_entry_free_list() have been allocated in
  80   // G1CodeRootSetTable::new_entry(). We never call the block allocator
  81   // in BasicHashtable::new_entry().
  82   for (BasicHashtableEntry<mtGC>* e = new_entry_free_list(); e != NULL; e = new_entry_free_list()) {
  83     FREE_C_HEAP_ARRAY(char, e);
  84   }
  85 }
  86 
  87 bool G1CodeRootSetTable::add(nmethod* nm) {
  88   if (!contains(nm)) {
  89     Entry* e = new_entry(nm);
  90     int index = hash_to_index(e->hash());
  91     add_entry(index, e);
  92     return true;
  93   }
  94   return false;
  95 }
  96 
  97 bool G1CodeRootSetTable::contains(nmethod* nm) {
  98   int index = hash_to_index(compute_hash(nm));
  99   for (Entry* e = bucket(index); e != NULL; e = e->next()) {
 100     if (e->literal() == nm) {
 101       return true;


< prev index next >