Path: blob/master/src/hotspot/share/gc/g1/g1CodeRootSetTable.hpp
40961 views
/*1* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223#ifndef SHARE_GC_G1_G1CODEROOTSETTABLE_HPP24#define SHARE_GC_G1_G1CODEROOTSETTABLE_HPP2526#include "utilities/hashtable.hpp"2728class nmethod;2930class G1CodeRootSetTable : public Hashtable<nmethod*, mtGC> {31friend class G1CodeRootSetTest;32typedef HashtableEntry<nmethod*, mtGC> Entry;3334static G1CodeRootSetTable* volatile _purge_list;3536G1CodeRootSetTable* _purge_next;3738unsigned int compute_hash(nmethod* nm) {39uintptr_t hash = (uintptr_t)nm;40return hash ^ (hash >> 7); // code heap blocks are 128byte aligned41}4243void remove_entry(Entry* e, Entry* previous);44Entry* new_entry(nmethod* nm);4546public:47G1CodeRootSetTable(int size) : Hashtable<nmethod*, mtGC>(size, sizeof(Entry)), _purge_next(NULL) {}48~G1CodeRootSetTable();4950// Needs to be protected by locks51bool add(nmethod* nm);52bool remove(nmethod* nm);5354// Can be called without locking55bool contains(nmethod* nm);5657int entry_size() const { return BasicHashtable<mtGC>::entry_size(); }5859void copy_to(G1CodeRootSetTable* new_table);60void nmethods_do(CodeBlobClosure* blk);6162template<typename CB>63int remove_if(CB& should_remove);6465static void purge_list_append(G1CodeRootSetTable* tbl);66static void purge();6768static size_t static_mem_size() {69return sizeof(_purge_list);70}7172size_t mem_size();73};7475#endif // SHARE_GC_G1_G1CODEROOTSETTABLE_HPP767778