Tue, 22 Sep 2009 14:06:10 -0700
6884624: Update copyright year
Summary: Update copyright for files that have been modified in 2009 through Septermber
Reviewed-by: tbell, ohair
jmasa@698 | 1 | /* |
xdono@772 | 2 | * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. |
jmasa@698 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jmasa@698 | 4 | * |
jmasa@698 | 5 | * This code is free software; you can redistribute it and/or modify it |
jmasa@698 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jmasa@698 | 7 | * published by the Free Software Foundation. |
jmasa@698 | 8 | * |
jmasa@698 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jmasa@698 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jmasa@698 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jmasa@698 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jmasa@698 | 13 | * accompanied this code). |
jmasa@698 | 14 | * |
jmasa@698 | 15 | * You should have received a copy of the GNU General Public License version |
jmasa@698 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jmasa@698 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jmasa@698 | 18 | * |
jmasa@698 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
jmasa@698 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
jmasa@698 | 21 | * have any questions. |
jmasa@698 | 22 | * |
jmasa@698 | 23 | */ |
jmasa@698 | 24 | |
jmasa@698 | 25 | class SpaceDecorator: public AllStatic { |
jmasa@698 | 26 | public: |
jmasa@698 | 27 | // Initialization flags. |
jmasa@698 | 28 | static const bool Clear = true; |
jmasa@698 | 29 | static const bool DontClear = false; |
jmasa@698 | 30 | static const bool Mangle = true; |
jmasa@698 | 31 | static const bool DontMangle = false; |
jmasa@698 | 32 | }; |
jmasa@698 | 33 | |
jmasa@698 | 34 | // Functionality for use with class Space and class MutableSpace. |
jmasa@698 | 35 | // The approach taken with the mangling is to mangle all |
jmasa@698 | 36 | // the space initially and then to mangle areas that have |
jmasa@698 | 37 | // been allocated since the last collection. Mangling is |
jmasa@698 | 38 | // done in the context of a generation and in the context |
jmasa@698 | 39 | // of a space. |
jmasa@698 | 40 | // The space in a generation is mangled when it is first |
jmasa@698 | 41 | // initialized and when the generation grows. The spaces |
jmasa@698 | 42 | // are not necessarily up-to-date when this mangling occurs |
jmasa@698 | 43 | // and the method mangle_region() is used. |
jmasa@698 | 44 | // After allocations have been done in a space, the space generally |
jmasa@698 | 45 | // need to be remangled. Remangling is only done on the |
jmasa@698 | 46 | // recently allocated regions in the space. Typically, that is |
jmasa@698 | 47 | // the region between the new top and the top just before a |
jmasa@698 | 48 | // garbage collection. |
jmasa@698 | 49 | // An exception to the usual mangling in a space is done when the |
jmasa@698 | 50 | // space is used for an extraordinary purpose. Specifically, when |
jmasa@698 | 51 | // to-space is used as scratch space for a mark-sweep-compact |
jmasa@698 | 52 | // collection. |
jmasa@698 | 53 | // Spaces are mangled after a collection. If the generation |
jmasa@698 | 54 | // grows after a collection, the added space is mangled as part of |
jmasa@698 | 55 | // the growth of the generation. No additional mangling is needed when the |
jmasa@698 | 56 | // spaces are resized after an expansion. |
jmasa@698 | 57 | // The class SpaceMangler keeps a pointer to the top of the allocated |
jmasa@698 | 58 | // area and provides the methods for doing the piece meal mangling. |
jmasa@698 | 59 | // Methods for doing sparces and full checking of the mangling are |
jmasa@698 | 60 | // included. The full checking is done if DEBUG_MANGLING is defined. |
jmasa@698 | 61 | // GenSpaceMangler is used with the GenCollectedHeap collectors and |
jmasa@698 | 62 | // MutableSpaceMangler is used with the ParallelScavengeHeap collectors. |
jmasa@698 | 63 | // These subclasses abstract the differences in the types of spaces used |
jmasa@698 | 64 | // by each heap. |
jmasa@698 | 65 | |
jmasa@698 | 66 | class SpaceMangler: public CHeapObj { |
jmasa@698 | 67 | friend class VMStructs; |
jmasa@698 | 68 | |
jmasa@698 | 69 | // High water mark for allocations. Typically, the space above |
jmasa@698 | 70 | // this point have been mangle previously and don't need to be |
jmasa@698 | 71 | // touched again. Space belows this point has been allocated |
jmasa@698 | 72 | // and remangling is needed between the current top and this |
jmasa@698 | 73 | // high water mark. |
jmasa@698 | 74 | HeapWord* _top_for_allocations; |
jmasa@698 | 75 | HeapWord* top_for_allocations() { return _top_for_allocations; } |
jmasa@698 | 76 | |
jmasa@698 | 77 | public: |
jmasa@698 | 78 | |
jmasa@698 | 79 | // Setting _top_for_allocations to NULL at initialization |
jmasa@698 | 80 | // makes it always below top so that mangling done as part |
jmasa@698 | 81 | // of the initialize() call of a space does nothing (as it |
jmasa@698 | 82 | // should since the mangling is done as part of the constructor |
jmasa@698 | 83 | // for the space. |
jmasa@698 | 84 | SpaceMangler() : _top_for_allocations(NULL) {} |
jmasa@698 | 85 | |
jmasa@698 | 86 | // Methods for top and end that delegate to the specific |
jmasa@698 | 87 | // space type. |
jmasa@698 | 88 | virtual HeapWord* top() const = 0; |
jmasa@698 | 89 | virtual HeapWord* end() const = 0; |
jmasa@698 | 90 | |
jmasa@698 | 91 | // Return true if q matches the mangled pattern. |
jmasa@698 | 92 | static bool is_mangled(HeapWord* q) PRODUCT_RETURN0; |
jmasa@698 | 93 | |
jmasa@698 | 94 | // Used to save the an address in a space for later use during mangling. |
jmasa@698 | 95 | void set_top_for_allocations(HeapWord* v); |
jmasa@698 | 96 | |
jmasa@698 | 97 | // Overwrites the unused portion of this space. |
jmasa@698 | 98 | // Mangle only the region not previously mangled [top, top_previously_mangled) |
jmasa@698 | 99 | void mangle_unused_area(); |
jmasa@698 | 100 | // Mangle all the unused region [top, end) |
jmasa@698 | 101 | void mangle_unused_area_complete(); |
jmasa@698 | 102 | // Do some sparse checking on the area that should have been mangled. |
jmasa@698 | 103 | void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN; |
jmasa@698 | 104 | // Do a complete check of the area that should be mangled. |
jmasa@698 | 105 | void check_mangled_unused_area_complete() PRODUCT_RETURN; |
jmasa@698 | 106 | |
jmasa@698 | 107 | // Mangle the MemRegion. This is a non-space specific mangler. It |
jmasa@698 | 108 | // is used during the initial mangling of a space before the space |
jmasa@698 | 109 | // is fully constructed. Also is used when a generation is expanded |
jmasa@698 | 110 | // and possibly before the spaces have been reshaped to to the new |
jmasa@698 | 111 | // size of the generation. |
jmasa@698 | 112 | static void mangle_region(MemRegion mr); |
jmasa@698 | 113 | }; |
jmasa@698 | 114 | |
jmasa@698 | 115 | class ContiguousSpace; |
jmasa@698 | 116 | |
jmasa@698 | 117 | // For use with GenCollectedHeap's |
jmasa@698 | 118 | class GenSpaceMangler: public SpaceMangler { |
jmasa@698 | 119 | ContiguousSpace* _sp; |
jmasa@698 | 120 | |
jmasa@698 | 121 | ContiguousSpace* sp() { return _sp; } |
jmasa@698 | 122 | |
jmasa@698 | 123 | HeapWord* top() const { return _sp->top(); } |
jmasa@698 | 124 | HeapWord* end() const { return _sp->end(); } |
jmasa@698 | 125 | |
jmasa@698 | 126 | public: |
jmasa@698 | 127 | GenSpaceMangler(ContiguousSpace* sp) : SpaceMangler(), _sp(sp) {} |
jmasa@698 | 128 | }; |
jmasa@698 | 129 | |
jmasa@698 | 130 | // For use with ParallelScavengeHeap's. |
jmasa@698 | 131 | class MutableSpaceMangler: public SpaceMangler { |
jmasa@698 | 132 | MutableSpace* _sp; |
jmasa@698 | 133 | |
jmasa@698 | 134 | MutableSpace* sp() { return _sp; } |
jmasa@698 | 135 | |
jmasa@698 | 136 | HeapWord* top() const { return _sp->top(); } |
jmasa@698 | 137 | HeapWord* end() const { return _sp->end(); } |
jmasa@698 | 138 | |
jmasa@698 | 139 | public: |
jmasa@698 | 140 | MutableSpaceMangler(MutableSpace* sp) : SpaceMangler(), _sp(sp) {} |
jmasa@698 | 141 | }; |