src/share/vm/memory/freeBlockDictionary.hpp

Mon, 29 Apr 2013 16:13:57 -0400

author
hseigel
date
Mon, 29 Apr 2013 16:13:57 -0400
changeset 4987
f258c5828eb8
parent 4196
685df3c6f84b
child 6876
710a3c8b516e
permissions
-rw-r--r--

8011773: Some tests on Interned String crashed JVM with OOM
Summary: Instead of terminating the VM, throw OutOfMemoryError exceptions.
Reviewed-by: coleenp, dholmes

duke@435 1 /*
jmasa@3730 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
jmasa@3730 25 #ifndef SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP
jmasa@3730 26 #define SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "runtime/mutex.hpp"
stefank@2314 30 #include "utilities/debug.hpp"
stefank@2314 31 #include "utilities/globalDefinitions.hpp"
stefank@2314 32 #include "utilities/ostream.hpp"
stefank@2314 33
duke@435 34 // A FreeBlockDictionary is an abstract superclass that will allow
duke@435 35 // a number of alternative implementations in the future.
jmasa@3730 36 template <class Chunk>
zgu@3900 37 class FreeBlockDictionary: public CHeapObj<mtGC> {
duke@435 38 public:
duke@435 39 enum Dither {
duke@435 40 atLeast,
duke@435 41 exactly,
duke@435 42 roughly
duke@435 43 };
duke@435 44 enum DictionaryChoice {
duke@435 45 dictionaryBinaryTree = 0,
duke@435 46 dictionarySplayTree = 1,
duke@435 47 dictionarySkipList = 2
duke@435 48 };
duke@435 49
duke@435 50 private:
coleenp@4037 51 // This field is added and can be set to point to the
coleenp@4037 52 // the Mutex used to synchronize access to the
coleenp@4037 53 // dictionary so that assertion checking can be done.
coleenp@4037 54 // For example it is set to point to _parDictionaryAllocLock.
duke@435 55 NOT_PRODUCT(Mutex* _lock;)
duke@435 56
duke@435 57 public:
jmasa@3732 58 virtual void remove_chunk(Chunk* fc) = 0;
jmasa@3732 59 virtual Chunk* get_chunk(size_t size, Dither dither = atLeast) = 0;
jmasa@3732 60 virtual void return_chunk(Chunk* chunk) = 0;
jmasa@3732 61 virtual size_t total_chunk_size(debug_only(const Mutex* lock)) const = 0;
jmasa@3732 62 virtual size_t max_chunk_size() const = 0;
jmasa@3732 63 virtual size_t min_size() const = 0;
duke@435 64 // Reset the dictionary to the initial conditions for a single
duke@435 65 // block.
duke@435 66 virtual void reset(HeapWord* addr, size_t size) = 0;
duke@435 67 virtual void reset() = 0;
duke@435 68
jmasa@4196 69 virtual void dict_census_update(size_t size, bool split, bool birth) = 0;
jmasa@3732 70 virtual bool coal_dict_over_populated(size_t size) = 0;
jmasa@3732 71 virtual void begin_sweep_dict_census(double coalSurplusPercent,
ysr@1580 72 float inter_sweep_current, float inter_sweep_estimate,
ysr@1580 73 float intra__sweep_current) = 0;
jmasa@3732 74 virtual void end_sweep_dict_census(double splitSurplusPercent) = 0;
jmasa@3732 75 virtual Chunk* find_largest_dict() const = 0;
duke@435 76 // verify that the given chunk is in the dictionary.
jmasa@3732 77 virtual bool verify_chunk_in_free_list(Chunk* tc) const = 0;
duke@435 78
duke@435 79 // Sigma_{all_free_blocks} (block_size^2)
duke@435 80 virtual double sum_of_squared_block_sizes() const = 0;
duke@435 81
jmasa@3730 82 virtual Chunk* find_chunk_ends_at(HeapWord* target) const = 0;
jmasa@3732 83 virtual void inc_total_size(size_t v) = 0;
jmasa@3732 84 virtual void dec_total_size(size_t v) = 0;
duke@435 85
duke@435 86 NOT_PRODUCT (
jmasa@3732 87 virtual size_t sum_dict_returned_bytes() = 0;
jmasa@3732 88 virtual void initialize_dict_returned_bytes() = 0;
jmasa@3732 89 virtual size_t total_count() = 0;
duke@435 90 )
duke@435 91
jmasa@3732 92 virtual void report_statistics() const {
duke@435 93 gclog_or_tty->print("No statistics available");
duke@435 94 }
duke@435 95
jmasa@3732 96 virtual void print_dict_census() const = 0;
ysr@1580 97 virtual void print_free_lists(outputStream* st) const = 0;
duke@435 98
duke@435 99 virtual void verify() const = 0;
duke@435 100
duke@435 101 Mutex* par_lock() const PRODUCT_RETURN0;
duke@435 102 void set_par_lock(Mutex* lock) PRODUCT_RETURN;
duke@435 103 void verify_par_locked() const PRODUCT_RETURN;
duke@435 104 };
stefank@2314 105
jmasa@3730 106 #endif // SHARE_VM_MEMORY_FREEBLOCKDICTIONARY_HPP

mercurial