src/share/vm/memory/freeBlockDictionary.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/memory/freeBlockDictionary.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,106 @@
     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<mtGC> {
    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 +  // This field is added and can be set to point to the
    1.55 +  // the Mutex used to synchronize access to the
    1.56 +  // dictionary so that assertion checking can be done.
    1.57 +  // For example it is set to point to _parDictionaryAllocLock.
    1.58 +  NOT_PRODUCT(Mutex* _lock;)
    1.59 +
    1.60 + public:
    1.61 +  virtual void       remove_chunk(Chunk* fc) = 0;
    1.62 +  virtual Chunk*     get_chunk(size_t size, Dither dither = atLeast) = 0;
    1.63 +  virtual void       return_chunk(Chunk* chunk) = 0;
    1.64 +  virtual size_t     total_chunk_size(debug_only(const Mutex* lock)) const = 0;
    1.65 +  virtual size_t     max_chunk_size()   const = 0;
    1.66 +  virtual size_t     min_size()        const = 0;
    1.67 +  // Reset the dictionary to the initial conditions for a single
    1.68 +  // block.
    1.69 +  virtual void       reset(HeapWord* addr, size_t size) = 0;
    1.70 +  virtual void       reset() = 0;
    1.71 +
    1.72 +  virtual void       dict_census_update(size_t size, bool split, bool birth) = 0;
    1.73 +  virtual bool       coal_dict_over_populated(size_t size) = 0;
    1.74 +  virtual void       begin_sweep_dict_census(double coalSurplusPercent,
    1.75 +                       float inter_sweep_current, float inter_sweep_estimate,
    1.76 +                       float intra__sweep_current) = 0;
    1.77 +  virtual void       end_sweep_dict_census(double splitSurplusPercent) = 0;
    1.78 +  virtual Chunk*     find_largest_dict() const = 0;
    1.79 +  // verify that the given chunk is in the dictionary.
    1.80 +  virtual bool verify_chunk_in_free_list(Chunk* tc) const = 0;
    1.81 +
    1.82 +  // Sigma_{all_free_blocks} (block_size^2)
    1.83 +  virtual double sum_of_squared_block_sizes() const = 0;
    1.84 +
    1.85 +  virtual Chunk* find_chunk_ends_at(HeapWord* target) const = 0;
    1.86 +  virtual void inc_total_size(size_t v) = 0;
    1.87 +  virtual void dec_total_size(size_t v) = 0;
    1.88 +
    1.89 +  NOT_PRODUCT (
    1.90 +    virtual size_t   sum_dict_returned_bytes() = 0;
    1.91 +    virtual void     initialize_dict_returned_bytes() = 0;
    1.92 +    virtual size_t   total_count() = 0;
    1.93 +  )
    1.94 +
    1.95 +  virtual void       report_statistics() const {
    1.96 +    gclog_or_tty->print("No statistics available");
    1.97 +  }
    1.98 +
    1.99 +  virtual void       print_dict_census() const = 0;
   1.100 +  virtual void       print_free_lists(outputStream* st) const = 0;
   1.101 +
   1.102 +  virtual void       verify()         const = 0;
   1.103 +
   1.104 +  Mutex* par_lock()                const PRODUCT_RETURN0;
   1.105 +  void   set_par_lock(Mutex* lock)       PRODUCT_RETURN;
   1.106 +  void   verify_par_locked()       const PRODUCT_RETURN;
   1.107 +};
   1.108 +
   1.109 +#endif // SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP

mercurial