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

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial