src/share/vm/gc_implementation/shared/spaceDecorator.hpp

Thu, 13 Feb 2014 17:44:39 +0100

author
stefank
date
Thu, 13 Feb 2014 17:44:39 +0100
changeset 6971
7426d8d76305
parent 4153
b9a9ed0f8eeb
child 6876
710a3c8b516e
permissions
-rw-r--r--

8034761: Remove the do_code_roots parameter from process_strong_roots
Reviewed-by: tschatzl, mgerdin, jmasa

jmasa@698 1 /*
mikael@4153 2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. 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 *
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.
jmasa@698 22 *
jmasa@698 23 */
jmasa@698 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_SPACEDECORATOR_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_SPACEDECORATOR_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/shared/mutableSpace.hpp"
stefank@2314 29 #include "memory/space.hpp"
stefank@2314 30 #include "utilities/globalDefinitions.hpp"
stefank@2314 31
jmasa@698 32 class SpaceDecorator: public AllStatic {
jmasa@698 33 public:
jmasa@698 34 // Initialization flags.
jmasa@698 35 static const bool Clear = true;
jmasa@698 36 static const bool DontClear = false;
jmasa@698 37 static const bool Mangle = true;
jmasa@698 38 static const bool DontMangle = false;
jmasa@698 39 };
jmasa@698 40
jmasa@698 41 // Functionality for use with class Space and class MutableSpace.
jmasa@698 42 // The approach taken with the mangling is to mangle all
jmasa@698 43 // the space initially and then to mangle areas that have
jmasa@698 44 // been allocated since the last collection. Mangling is
jmasa@698 45 // done in the context of a generation and in the context
jmasa@698 46 // of a space.
jmasa@698 47 // The space in a generation is mangled when it is first
jmasa@698 48 // initialized and when the generation grows. The spaces
jmasa@698 49 // are not necessarily up-to-date when this mangling occurs
jmasa@698 50 // and the method mangle_region() is used.
jmasa@698 51 // After allocations have been done in a space, the space generally
jmasa@698 52 // need to be remangled. Remangling is only done on the
jmasa@698 53 // recently allocated regions in the space. Typically, that is
jmasa@698 54 // the region between the new top and the top just before a
jmasa@698 55 // garbage collection.
jmasa@698 56 // An exception to the usual mangling in a space is done when the
jmasa@698 57 // space is used for an extraordinary purpose. Specifically, when
jmasa@698 58 // to-space is used as scratch space for a mark-sweep-compact
jmasa@698 59 // collection.
jmasa@698 60 // Spaces are mangled after a collection. If the generation
jmasa@698 61 // grows after a collection, the added space is mangled as part of
jmasa@698 62 // the growth of the generation. No additional mangling is needed when the
jmasa@698 63 // spaces are resized after an expansion.
jmasa@698 64 // The class SpaceMangler keeps a pointer to the top of the allocated
jmasa@698 65 // area and provides the methods for doing the piece meal mangling.
jmasa@698 66 // Methods for doing sparces and full checking of the mangling are
jmasa@698 67 // included. The full checking is done if DEBUG_MANGLING is defined.
jmasa@698 68 // GenSpaceMangler is used with the GenCollectedHeap collectors and
jmasa@698 69 // MutableSpaceMangler is used with the ParallelScavengeHeap collectors.
jmasa@698 70 // These subclasses abstract the differences in the types of spaces used
jmasa@698 71 // by each heap.
jmasa@698 72
zgu@3900 73 class SpaceMangler: public CHeapObj<mtGC> {
jmasa@698 74 friend class VMStructs;
jmasa@698 75
jmasa@698 76 // High water mark for allocations. Typically, the space above
jmasa@698 77 // this point have been mangle previously and don't need to be
jmasa@698 78 // touched again. Space belows this point has been allocated
jmasa@698 79 // and remangling is needed between the current top and this
jmasa@698 80 // high water mark.
jmasa@698 81 HeapWord* _top_for_allocations;
jmasa@698 82 HeapWord* top_for_allocations() { return _top_for_allocations; }
jmasa@698 83
jmasa@698 84 public:
jmasa@698 85
jmasa@698 86 // Setting _top_for_allocations to NULL at initialization
jmasa@698 87 // makes it always below top so that mangling done as part
jmasa@698 88 // of the initialize() call of a space does nothing (as it
jmasa@698 89 // should since the mangling is done as part of the constructor
jmasa@698 90 // for the space.
jmasa@698 91 SpaceMangler() : _top_for_allocations(NULL) {}
jmasa@698 92
jmasa@698 93 // Methods for top and end that delegate to the specific
jmasa@698 94 // space type.
jmasa@698 95 virtual HeapWord* top() const = 0;
jmasa@698 96 virtual HeapWord* end() const = 0;
jmasa@698 97
jmasa@698 98 // Return true if q matches the mangled pattern.
jmasa@698 99 static bool is_mangled(HeapWord* q) PRODUCT_RETURN0;
jmasa@698 100
jmasa@698 101 // Used to save the an address in a space for later use during mangling.
jmasa@698 102 void set_top_for_allocations(HeapWord* v);
jmasa@698 103
jmasa@698 104 // Overwrites the unused portion of this space.
jmasa@698 105 // Mangle only the region not previously mangled [top, top_previously_mangled)
jmasa@698 106 void mangle_unused_area();
jmasa@698 107 // Mangle all the unused region [top, end)
jmasa@698 108 void mangle_unused_area_complete();
jmasa@698 109 // Do some sparse checking on the area that should have been mangled.
jmasa@698 110 void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
jmasa@698 111 // Do a complete check of the area that should be mangled.
jmasa@698 112 void check_mangled_unused_area_complete() PRODUCT_RETURN;
jmasa@698 113
jmasa@698 114 // Mangle the MemRegion. This is a non-space specific mangler. It
jmasa@698 115 // is used during the initial mangling of a space before the space
jmasa@698 116 // is fully constructed. Also is used when a generation is expanded
jmasa@698 117 // and possibly before the spaces have been reshaped to to the new
jmasa@698 118 // size of the generation.
jcoomes@1902 119 static void mangle_region(MemRegion mr) PRODUCT_RETURN;
jmasa@698 120 };
jmasa@698 121
jmasa@698 122 class ContiguousSpace;
jmasa@698 123
jmasa@698 124 // For use with GenCollectedHeap's
jmasa@698 125 class GenSpaceMangler: public SpaceMangler {
jmasa@698 126 ContiguousSpace* _sp;
jmasa@698 127
jmasa@698 128 ContiguousSpace* sp() { return _sp; }
jmasa@698 129
jmasa@698 130 HeapWord* top() const { return _sp->top(); }
jmasa@698 131 HeapWord* end() const { return _sp->end(); }
jmasa@698 132
jmasa@698 133 public:
jmasa@698 134 GenSpaceMangler(ContiguousSpace* sp) : SpaceMangler(), _sp(sp) {}
jmasa@698 135 };
jmasa@698 136
jmasa@698 137 // For use with ParallelScavengeHeap's.
jmasa@698 138 class MutableSpaceMangler: public SpaceMangler {
jmasa@698 139 MutableSpace* _sp;
jmasa@698 140
jmasa@698 141 MutableSpace* sp() { return _sp; }
jmasa@698 142
jmasa@698 143 HeapWord* top() const { return _sp->top(); }
jmasa@698 144 HeapWord* end() const { return _sp->end(); }
jmasa@698 145
jmasa@698 146 public:
jmasa@698 147 MutableSpaceMangler(MutableSpace* sp) : SpaceMangler(), _sp(sp) {}
jmasa@698 148 };
stefank@2314 149
stefank@2314 150 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_SPACEDECORATOR_HPP

mercurial