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

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 970
4e400c36026f
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

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

mercurial