Path: blob/master/src/hotspot/share/gc/g1/g1CodeCacheRemSet.hpp
40961 views
/*1* Copyright (c) 2014, 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*22*/2324#ifndef SHARE_GC_G1_G1CODECACHEREMSET_HPP25#define SHARE_GC_G1_G1CODECACHEREMSET_HPP2627class CodeBlobClosure;28class G1CodeRootSetTable;29class HeapRegion;30class nmethod;3132// Implements storage for a set of code roots.33// All methods that modify the set are not thread-safe except if otherwise noted.34class G1CodeRootSet {35friend class G1CodeRootSetTest;36private:3738const static size_t SmallSize = 32;39const static size_t Threshold = 24;40const static size_t LargeSize = 512;4142G1CodeRootSetTable* _table;43G1CodeRootSetTable* load_acquire_table();4445size_t _length;4647void move_to_large();48void allocate_small_table();4950public:51G1CodeRootSet() : _table(NULL), _length(0) {}52~G1CodeRootSet();5354static void purge();5556static size_t static_mem_size();5758void add(nmethod* method);5960bool remove(nmethod* method);6162// Safe to call without synchronization, but may return false negatives.63bool contains(nmethod* method);6465void clear();6667void nmethods_do(CodeBlobClosure* blk) const;6869// Remove all nmethods which no longer contain pointers into our "owner" region70void clean(HeapRegion* owner);7172bool is_empty() {73bool empty = length() == 0;74assert(empty == (_table == NULL), "is empty only if table is deallocated");75return empty;76}7778// Length in elements79size_t length() const { return _length; }8081// Memory size in bytes taken by this set.82size_t mem_size();8384};8586#endif // SHARE_GC_G1_G1CODECACHEREMSET_HPP878889