duke@435: /* xdono@631: * Copyright 2001-2008 Sun Microsystems, Inc. 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: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: // A FreeBlockDictionary is an abstract superclass that will allow duke@435: // a number of alternative implementations in the future. duke@435: 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: duke@435: NOT_PRODUCT(Mutex* _lock;) duke@435: duke@435: public: duke@435: virtual void removeChunk(FreeChunk* fc) = 0; duke@435: virtual FreeChunk* getChunk(size_t size, Dither dither = atLeast) = 0; duke@435: virtual void returnChunk(FreeChunk* chunk) = 0; duke@435: virtual size_t totalChunkSize(debug_only(const Mutex* lock)) const = 0; duke@435: virtual size_t maxChunkSize() const = 0; duke@435: virtual size_t minSize() 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: duke@435: virtual void dictCensusUpdate(size_t size, bool split, bool birth) = 0; duke@435: virtual bool coalDictOverPopulated(size_t size) = 0; duke@435: virtual void beginSweepDictCensus(double coalSurplusPercent, ysr@1580: float inter_sweep_current, float inter_sweep_estimate, ysr@1580: float intra__sweep_current) = 0; duke@435: virtual void endSweepDictCensus(double splitSurplusPercent) = 0; duke@435: virtual FreeChunk* findLargestDict() const = 0; duke@435: // verify that the given chunk is in the dictionary. duke@435: virtual bool verifyChunkInFreeLists(FreeChunk* 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: duke@435: virtual FreeChunk* find_chunk_ends_at(HeapWord* target) const = 0; duke@435: virtual void inc_totalSize(size_t v) = 0; duke@435: virtual void dec_totalSize(size_t v) = 0; duke@435: duke@435: NOT_PRODUCT ( duke@435: virtual size_t sumDictReturnedBytes() = 0; duke@435: virtual void initializeDictReturnedBytes() = 0; duke@435: virtual size_t totalCount() = 0; duke@435: ) duke@435: duke@435: virtual void reportStatistics() const { duke@435: gclog_or_tty->print("No statistics available"); duke@435: } duke@435: duke@435: virtual void printDictCensus() 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: };