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

Sat, 27 Sep 2008 00:33:13 -0700

author
iveresov
date
Sat, 27 Sep 2008 00:33:13 -0700
changeset 808
06df86c2ec37
parent 704
850fdf70db2b
child 970
4e400c36026f
permissions
-rw-r--r--

6740923: NUMA allocator: Ensure the progress of adaptive chunk resizing
Summary: Treat a chuck where the allocation has failed as fully used.
Reviewed-by: ysr

duke@435 1 /*
xdono@631 2 * Copyright 2001-2008 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
duke@435 28 // an assumption.
duke@435 29 //
duke@435 30 // Invariant: (ImmutableSpace +) bottom() <= top() <= end()
duke@435 31 // top() is inclusive and end() is exclusive.
duke@435 32
jmasa@698 33 class MutableSpaceMangler;
jmasa@698 34
duke@435 35 class MutableSpace: public ImmutableSpace {
duke@435 36 friend class VMStructs;
jmasa@698 37
jmasa@698 38 // Helper for mangling unused space in debug builds
jmasa@698 39 MutableSpaceMangler* _mangler;
jmasa@698 40
duke@435 41 protected:
duke@435 42 HeapWord* _top;
duke@435 43
jmasa@698 44 MutableSpaceMangler* mangler() { return _mangler; }
jmasa@698 45
duke@435 46 public:
jmasa@698 47 virtual ~MutableSpace();
jmasa@698 48 MutableSpace();
jmasa@698 49
duke@435 50 // Accessors
duke@435 51 HeapWord* top() const { return _top; }
duke@435 52 virtual void set_top(HeapWord* value) { _top = value; }
duke@435 53
duke@435 54 HeapWord** top_addr() { return &_top; }
duke@435 55 HeapWord** end_addr() { return &_end; }
duke@435 56
duke@435 57 virtual void set_bottom(HeapWord* value) { _bottom = value; }
duke@435 58 virtual void set_end(HeapWord* value) { _end = value; }
duke@435 59
duke@435 60 // Returns a subregion containing all objects in this space.
duke@435 61 MemRegion used_region() { return MemRegion(bottom(), top()); }
duke@435 62
duke@435 63 // Initialization
jmasa@698 64 virtual void initialize(MemRegion mr,
jmasa@698 65 bool clear_space,
jmasa@698 66 bool mangle_space);
jmasa@698 67 virtual void clear(bool mangle_space);
jmasa@698 68 // Does the usual initialization but optionally resets top to bottom.
jmasa@698 69 #if 0 // MANGLE_SPACE
jmasa@698 70 void initialize(MemRegion mr, bool clear_space, bool reset_top);
jmasa@698 71 #endif
duke@435 72 virtual void update() { }
duke@435 73 virtual void accumulate_statistics() { }
duke@435 74
jmasa@698 75 // Methods used in mangling. See descriptions under SpaceMangler.
jmasa@698 76 virtual void mangle_unused_area() PRODUCT_RETURN;
jmasa@698 77 virtual void mangle_unused_area_complete() PRODUCT_RETURN;
jmasa@698 78 virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
jmasa@698 79 virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
jmasa@698 80 virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
jmasa@698 81
jmasa@698 82 // Used to save the space's current top for later use during mangling.
jmasa@698 83 virtual void set_top_for_allocations() PRODUCT_RETURN;
jmasa@698 84
duke@435 85 virtual void ensure_parsability() { }
duke@435 86
jmasa@698 87 virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
duke@435 88
duke@435 89 // Boolean querries.
duke@435 90 bool is_empty() const { return used_in_words() == 0; }
duke@435 91 bool not_empty() const { return used_in_words() > 0; }
duke@435 92 bool contains(const void* p) const { return _bottom <= p && p < _end; }
duke@435 93
duke@435 94 // Size computations. Sizes are in bytes.
duke@435 95 size_t used_in_bytes() const { return used_in_words() * HeapWordSize; }
duke@435 96 size_t free_in_bytes() const { return free_in_words() * HeapWordSize; }
duke@435 97
duke@435 98 // Size computations. Sizes are in heapwords.
duke@435 99 virtual size_t used_in_words() const { return pointer_delta(top(), bottom()); }
duke@435 100 virtual size_t free_in_words() const { return pointer_delta(end(), top()); }
duke@435 101 virtual size_t tlab_capacity(Thread* thr) const { return capacity_in_bytes(); }
duke@435 102 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const { return free_in_bytes(); }
duke@435 103
duke@435 104 // Allocation (return NULL if full)
duke@435 105 virtual HeapWord* allocate(size_t word_size);
duke@435 106 virtual HeapWord* cas_allocate(size_t word_size);
duke@435 107 // Optional deallocation. Used in NUMA-allocator.
duke@435 108 bool cas_deallocate(HeapWord *obj, size_t size);
duke@435 109
duke@435 110 // Iteration.
duke@435 111 void oop_iterate(OopClosure* cl);
duke@435 112 void object_iterate(ObjectClosure* cl);
duke@435 113
duke@435 114 // Debugging
duke@435 115 virtual void print() const;
duke@435 116 virtual void print_on(outputStream* st) const;
duke@435 117 virtual void print_short() const;
duke@435 118 virtual void print_short_on(outputStream* st) const;
iveresov@625 119 virtual void verify(bool allow_dirty);
duke@435 120 };

mercurial