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

Thu, 19 Jun 2014 13:31:14 +0200

author
brutisso
date
Thu, 19 Jun 2014 13:31:14 +0200
changeset 6904
0982ec23da03
parent 6376
cfd4aac53239
child 6876
710a3c8b516e
permissions
-rw-r--r--

8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
Reviewed-by: jwilhelm, ehelin, tschatzl

duke@435 1 /*
brutisso@3711 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
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_MUTABLESPACE_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_MUTABLESPACE_HPP
stefank@2314 27
stefank@2314 28 #include "gc_implementation/shared/immutableSpace.hpp"
stefank@2314 29 #include "memory/memRegion.hpp"
stefank@2314 30 #include "utilities/copy.hpp"
stefank@2314 31
duke@435 32 // A MutableSpace is a subtype of ImmutableSpace that supports the
duke@435 33 // concept of allocation. This includes the concepts that a space may
duke@435 34 // be only partially full, and the querry methods that go with such
iveresov@970 35 // an assumption. MutableSpace is also responsible for minimizing the
iveresov@970 36 // page allocation time by having the memory pretouched (with
iveresov@970 37 // AlwaysPretouch) and for optimizing page placement on NUMA systems
iveresov@970 38 // by make the underlying region interleaved (with UseNUMA).
duke@435 39 //
duke@435 40 // Invariant: (ImmutableSpace +) bottom() <= top() <= end()
duke@435 41 // top() is inclusive and end() is exclusive.
duke@435 42
jmasa@698 43 class MutableSpaceMangler;
jmasa@698 44
duke@435 45 class MutableSpace: public ImmutableSpace {
duke@435 46 friend class VMStructs;
jmasa@698 47
jmasa@698 48 // Helper for mangling unused space in debug builds
jmasa@698 49 MutableSpaceMangler* _mangler;
iveresov@970 50 // The last region which page had been setup to be interleaved.
iveresov@970 51 MemRegion _last_setup_region;
iveresov@970 52 size_t _alignment;
duke@435 53 protected:
duke@435 54 HeapWord* _top;
duke@435 55
jmasa@698 56 MutableSpaceMangler* mangler() { return _mangler; }
jmasa@698 57
iveresov@970 58 void numa_setup_pages(MemRegion mr, bool clear_space);
iveresov@970 59 void pretouch_pages(MemRegion mr);
iveresov@970 60
iveresov@970 61 void set_last_setup_region(MemRegion mr) { _last_setup_region = mr; }
iveresov@970 62 MemRegion last_setup_region() const { return _last_setup_region; }
iveresov@970 63
duke@435 64 public:
jmasa@698 65 virtual ~MutableSpace();
iveresov@970 66 MutableSpace(size_t page_size);
jmasa@698 67
duke@435 68 // Accessors
duke@435 69 HeapWord* top() const { return _top; }
duke@435 70 virtual void set_top(HeapWord* value) { _top = value; }
duke@435 71
duke@435 72 HeapWord** top_addr() { return &_top; }
duke@435 73 HeapWord** end_addr() { return &_end; }
duke@435 74
duke@435 75 virtual void set_bottom(HeapWord* value) { _bottom = value; }
duke@435 76 virtual void set_end(HeapWord* value) { _end = value; }
duke@435 77
iveresov@970 78 size_t alignment() { return _alignment; }
iveresov@970 79
duke@435 80 // Returns a subregion containing all objects in this space.
duke@435 81 MemRegion used_region() { return MemRegion(bottom(), top()); }
duke@435 82
iveresov@970 83 static const bool SetupPages = true;
iveresov@970 84 static const bool DontSetupPages = false;
iveresov@970 85
duke@435 86 // Initialization
jmasa@698 87 virtual void initialize(MemRegion mr,
jmasa@698 88 bool clear_space,
iveresov@970 89 bool mangle_space,
iveresov@970 90 bool setup_pages = SetupPages);
iveresov@970 91
jmasa@698 92 virtual void clear(bool mangle_space);
jmasa@698 93 // Does the usual initialization but optionally resets top to bottom.
jmasa@698 94 #if 0 // MANGLE_SPACE
jmasa@698 95 void initialize(MemRegion mr, bool clear_space, bool reset_top);
jmasa@698 96 #endif
duke@435 97 virtual void update() { }
duke@435 98 virtual void accumulate_statistics() { }
duke@435 99
jmasa@698 100 // Methods used in mangling. See descriptions under SpaceMangler.
jmasa@698 101 virtual void mangle_unused_area() PRODUCT_RETURN;
jmasa@698 102 virtual void mangle_unused_area_complete() PRODUCT_RETURN;
jmasa@698 103 virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
jmasa@698 104 virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
jmasa@698 105 virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
jmasa@698 106
jmasa@698 107 // Used to save the space's current top for later use during mangling.
jmasa@698 108 virtual void set_top_for_allocations() PRODUCT_RETURN;
jmasa@698 109
duke@435 110 virtual void ensure_parsability() { }
duke@435 111
jmasa@698 112 virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
duke@435 113
duke@435 114 // Boolean querries.
duke@435 115 bool is_empty() const { return used_in_words() == 0; }
duke@435 116 bool not_empty() const { return used_in_words() > 0; }
duke@435 117 bool contains(const void* p) const { return _bottom <= p && p < _end; }
duke@435 118
duke@435 119 // Size computations. Sizes are in bytes.
duke@435 120 size_t used_in_bytes() const { return used_in_words() * HeapWordSize; }
duke@435 121 size_t free_in_bytes() const { return free_in_words() * HeapWordSize; }
duke@435 122
duke@435 123 // Size computations. Sizes are in heapwords.
duke@435 124 virtual size_t used_in_words() const { return pointer_delta(top(), bottom()); }
duke@435 125 virtual size_t free_in_words() const { return pointer_delta(end(), top()); }
duke@435 126 virtual size_t tlab_capacity(Thread* thr) const { return capacity_in_bytes(); }
brutisso@6376 127 virtual size_t tlab_used(Thread* thr) const { return used_in_bytes(); }
duke@435 128 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const { return free_in_bytes(); }
duke@435 129
duke@435 130 // Allocation (return NULL if full)
duke@435 131 virtual HeapWord* allocate(size_t word_size);
duke@435 132 virtual HeapWord* cas_allocate(size_t word_size);
duke@435 133 // Optional deallocation. Used in NUMA-allocator.
duke@435 134 bool cas_deallocate(HeapWord *obj, size_t size);
duke@435 135
duke@435 136 // Iteration.
coleenp@4037 137 void oop_iterate(ExtendedOopClosure* cl);
coleenp@4037 138 void oop_iterate_no_header(OopClosure* cl);
duke@435 139 void object_iterate(ObjectClosure* cl);
duke@435 140
duke@435 141 // Debugging
duke@435 142 virtual void print() const;
duke@435 143 virtual void print_on(outputStream* st) const;
duke@435 144 virtual void print_short() const;
duke@435 145 virtual void print_short_on(outputStream* st) const;
brutisso@3711 146 virtual void verify();
duke@435 147 };
stefank@2314 148
stefank@2314 149 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_MUTABLESPACE_HPP

mercurial