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

Fri, 29 Apr 2016 00:06:10 +0800

author
aoqi
date
Fri, 29 Apr 2016 00:06:10 +0800
changeset 1
2d8a650513c2
parent 0
f90c822e73f8
child 25
873fd82b133d
permissions
-rw-r--r--

Added MIPS 64-bit port.

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

mercurial