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

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

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

mercurial