src/share/vm/memory/freeBlockDictionary.hpp

changeset 3730
9f059abe8cf2
parent 2314
f95d63e2154a
child 3732
f69a5d43dc19
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/memory/freeBlockDictionary.hpp	Thu Mar 29 19:46:24 2012 -0700
     1.3 @@ -0,0 +1,102 @@
     1.4 +/*
     1.5 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP
    1.29 +#define SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP
    1.30 +
    1.31 +#include "memory/allocation.hpp"
    1.32 +#include "runtime/mutex.hpp"
    1.33 +#include "utilities/debug.hpp"
    1.34 +#include "utilities/globalDefinitions.hpp"
    1.35 +#include "utilities/ostream.hpp"
    1.36 +
    1.37 +// A FreeBlockDictionary is an abstract superclass that will allow
    1.38 +// a number of alternative implementations in the future.
    1.39 +template <class Chunk>
    1.40 +class FreeBlockDictionary: public CHeapObj {
    1.41 + public:
    1.42 +  enum Dither {
    1.43 +    atLeast,
    1.44 +    exactly,
    1.45 +    roughly
    1.46 +  };
    1.47 +  enum DictionaryChoice {
    1.48 +    dictionaryBinaryTree = 0,
    1.49 +    dictionarySplayTree  = 1,
    1.50 +    dictionarySkipList   = 2
    1.51 +  };
    1.52 +
    1.53 + private:
    1.54 +  NOT_PRODUCT(Mutex* _lock;)
    1.55 +
    1.56 + public:
    1.57 +  virtual void       removeChunk(Chunk* fc) = 0;
    1.58 +  virtual Chunk*     getChunk(size_t size, Dither dither = atLeast) = 0;
    1.59 +  virtual void       returnChunk(Chunk* chunk) = 0;
    1.60 +  virtual size_t     totalChunkSize(debug_only(const Mutex* lock)) const = 0;
    1.61 +  virtual size_t     maxChunkSize()   const = 0;
    1.62 +  virtual size_t     minSize()        const = 0;
    1.63 +  // Reset the dictionary to the initial conditions for a single
    1.64 +  // block.
    1.65 +  virtual void       reset(HeapWord* addr, size_t size) = 0;
    1.66 +  virtual void       reset() = 0;
    1.67 +
    1.68 +  virtual void       dictCensusUpdate(size_t size, bool split, bool birth) = 0;
    1.69 +  virtual bool       coalDictOverPopulated(size_t size) = 0;
    1.70 +  virtual void       beginSweepDictCensus(double coalSurplusPercent,
    1.71 +                       float inter_sweep_current, float inter_sweep_estimate,
    1.72 +                       float intra__sweep_current) = 0;
    1.73 +  virtual void       endSweepDictCensus(double splitSurplusPercent) = 0;
    1.74 +  virtual Chunk*     findLargestDict() const = 0;
    1.75 +  // verify that the given chunk is in the dictionary.
    1.76 +  virtual bool verifyChunkInFreeLists(Chunk* tc) const = 0;
    1.77 +
    1.78 +  // Sigma_{all_free_blocks} (block_size^2)
    1.79 +  virtual double sum_of_squared_block_sizes() const = 0;
    1.80 +
    1.81 +  virtual Chunk* find_chunk_ends_at(HeapWord* target) const = 0;
    1.82 +  virtual void inc_totalSize(size_t v) = 0;
    1.83 +  virtual void dec_totalSize(size_t v) = 0;
    1.84 +
    1.85 +  NOT_PRODUCT (
    1.86 +    virtual size_t   sumDictReturnedBytes() = 0;
    1.87 +    virtual void     initializeDictReturnedBytes() = 0;
    1.88 +    virtual size_t   totalCount() = 0;
    1.89 +  )
    1.90 +
    1.91 +  virtual void       reportStatistics() const {
    1.92 +    gclog_or_tty->print("No statistics available");
    1.93 +  }
    1.94 +
    1.95 +  virtual void       printDictCensus() const = 0;
    1.96 +  virtual void       print_free_lists(outputStream* st) const = 0;
    1.97 +
    1.98 +  virtual void       verify()         const = 0;
    1.99 +
   1.100 +  Mutex* par_lock()                const PRODUCT_RETURN0;
   1.101 +  void   set_par_lock(Mutex* lock)       PRODUCT_RETURN;
   1.102 +  void   verify_par_locked()       const PRODUCT_RETURN;
   1.103 +};
   1.104 +
   1.105 +#endif // SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP

mercurial