Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/memory/freeBlockDictionary.hpp
32285 views
/*1* Copyright (c) 2001, 2012, 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_VM_MEMORY_FREEBLOCKDICTIONARY_HPP25#define SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP2627#include "memory/allocation.hpp"28#include "runtime/mutex.hpp"29#include "utilities/debug.hpp"30#include "utilities/globalDefinitions.hpp"31#include "utilities/ostream.hpp"3233// A FreeBlockDictionary is an abstract superclass that will allow34// a number of alternative implementations in the future.35template <class Chunk>36class FreeBlockDictionary: public CHeapObj<mtGC> {37public:38enum Dither {39atLeast,40exactly,41roughly42};43enum DictionaryChoice {44dictionaryBinaryTree = 0,45dictionarySplayTree = 1,46dictionarySkipList = 247};4849private:50// This field is added and can be set to point to the51// the Mutex used to synchronize access to the52// dictionary so that assertion checking can be done.53// For example it is set to point to _parDictionaryAllocLock.54NOT_PRODUCT(Mutex* _lock;)5556public:57virtual void remove_chunk(Chunk* fc) = 0;58virtual Chunk* get_chunk(size_t size, Dither dither = atLeast) = 0;59virtual void return_chunk(Chunk* chunk) = 0;60virtual size_t total_chunk_size(debug_only(const Mutex* lock)) const = 0;61virtual size_t max_chunk_size() const = 0;62virtual size_t min_size() const = 0;63// Reset the dictionary to the initial conditions for a single64// block.65virtual void reset(HeapWord* addr, size_t size) = 0;66virtual void reset() = 0;6768virtual void dict_census_update(size_t size, bool split, bool birth) = 0;69virtual bool coal_dict_over_populated(size_t size) = 0;70virtual void begin_sweep_dict_census(double coalSurplusPercent,71float inter_sweep_current, float inter_sweep_estimate,72float intra__sweep_current) = 0;73virtual void end_sweep_dict_census(double splitSurplusPercent) = 0;74virtual Chunk* find_largest_dict() const = 0;75// verify that the given chunk is in the dictionary.76virtual bool verify_chunk_in_free_list(Chunk* tc) const = 0;7778// Sigma_{all_free_blocks} (block_size^2)79virtual double sum_of_squared_block_sizes() const = 0;8081virtual Chunk* find_chunk_ends_at(HeapWord* target) const = 0;82virtual void inc_total_size(size_t v) = 0;83virtual void dec_total_size(size_t v) = 0;8485NOT_PRODUCT (86virtual size_t sum_dict_returned_bytes() = 0;87virtual void initialize_dict_returned_bytes() = 0;88virtual size_t total_count() = 0;89)9091virtual void report_statistics() const {92gclog_or_tty->print("No statistics available");93}9495virtual void print_dict_census() const = 0;96virtual void print_free_lists(outputStream* st) const = 0;9798virtual void verify() const = 0;99100Mutex* par_lock() const PRODUCT_RETURN0;101void set_par_lock(Mutex* lock) PRODUCT_RETURN;102void verify_par_locked() const PRODUCT_RETURN;103};104105#endif // SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP106107108