duke@435: /* jmasa@3730: * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: jmasa@3730: #ifndef SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP jmasa@3730: #define SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP stefank@2314: stefank@2314: #include "memory/allocation.hpp" stefank@2314: #include "runtime/mutex.hpp" stefank@2314: #include "utilities/debug.hpp" stefank@2314: #include "utilities/globalDefinitions.hpp" stefank@2314: #include "utilities/ostream.hpp" stefank@2314: duke@435: // A FreeBlockDictionary is an abstract superclass that will allow duke@435: // a number of alternative implementations in the future. jmasa@3730: template zgu@3900: class FreeBlockDictionary: public CHeapObj { duke@435: public: duke@435: enum Dither { duke@435: atLeast, duke@435: exactly, duke@435: roughly duke@435: }; duke@435: enum DictionaryChoice { duke@435: dictionaryBinaryTree = 0, duke@435: dictionarySplayTree = 1, duke@435: dictionarySkipList = 2 duke@435: }; duke@435: duke@435: private: coleenp@4037: // This field is added and can be set to point to the coleenp@4037: // the Mutex used to synchronize access to the coleenp@4037: // dictionary so that assertion checking can be done. coleenp@4037: // For example it is set to point to _parDictionaryAllocLock. duke@435: NOT_PRODUCT(Mutex* _lock;) duke@435: duke@435: public: jmasa@3732: virtual void remove_chunk(Chunk* fc) = 0; jmasa@3732: virtual Chunk* get_chunk(size_t size, Dither dither = atLeast) = 0; jmasa@3732: virtual void return_chunk(Chunk* chunk) = 0; jmasa@3732: virtual size_t total_chunk_size(debug_only(const Mutex* lock)) const = 0; jmasa@3732: virtual size_t max_chunk_size() const = 0; jmasa@3732: virtual size_t min_size() const = 0; duke@435: // Reset the dictionary to the initial conditions for a single duke@435: // block. duke@435: virtual void reset(HeapWord* addr, size_t size) = 0; duke@435: virtual void reset() = 0; duke@435: jmasa@4196: virtual void dict_census_update(size_t size, bool split, bool birth) = 0; jmasa@3732: virtual bool coal_dict_over_populated(size_t size) = 0; jmasa@3732: virtual void begin_sweep_dict_census(double coalSurplusPercent, ysr@1580: float inter_sweep_current, float inter_sweep_estimate, ysr@1580: float intra__sweep_current) = 0; jmasa@3732: virtual void end_sweep_dict_census(double splitSurplusPercent) = 0; jmasa@3732: virtual Chunk* find_largest_dict() const = 0; duke@435: // verify that the given chunk is in the dictionary. jmasa@3732: virtual bool verify_chunk_in_free_list(Chunk* tc) const = 0; duke@435: duke@435: // Sigma_{all_free_blocks} (block_size^2) duke@435: virtual double sum_of_squared_block_sizes() const = 0; duke@435: jmasa@3730: virtual Chunk* find_chunk_ends_at(HeapWord* target) const = 0; jmasa@3732: virtual void inc_total_size(size_t v) = 0; jmasa@3732: virtual void dec_total_size(size_t v) = 0; duke@435: duke@435: NOT_PRODUCT ( jmasa@3732: virtual size_t sum_dict_returned_bytes() = 0; jmasa@3732: virtual void initialize_dict_returned_bytes() = 0; jmasa@3732: virtual size_t total_count() = 0; duke@435: ) duke@435: jmasa@3732: virtual void report_statistics() const { duke@435: gclog_or_tty->print("No statistics available"); duke@435: } duke@435: jmasa@3732: virtual void print_dict_census() const = 0; ysr@1580: virtual void print_free_lists(outputStream* st) const = 0; duke@435: duke@435: virtual void verify() const = 0; duke@435: duke@435: Mutex* par_lock() const PRODUCT_RETURN0; duke@435: void set_par_lock(Mutex* lock) PRODUCT_RETURN; duke@435: void verify_par_locked() const PRODUCT_RETURN; duke@435: }; stefank@2314: jmasa@3730: #endif // SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP