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

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 625
d1635bf93939
child 704
850fdf70db2b
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

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
duke@435 33 class MutableSpace: public ImmutableSpace {
duke@435 34 friend class VMStructs;
duke@435 35 protected:
duke@435 36 HeapWord* _top;
duke@435 37
duke@435 38 public:
duke@435 39 virtual ~MutableSpace() {}
duke@435 40 MutableSpace() { _top = NULL; }
duke@435 41 // Accessors
duke@435 42 HeapWord* top() const { return _top; }
duke@435 43 virtual void set_top(HeapWord* value) { _top = value; }
duke@435 44
duke@435 45 HeapWord** top_addr() { return &_top; }
duke@435 46 HeapWord** end_addr() { return &_end; }
duke@435 47
duke@435 48 virtual void set_bottom(HeapWord* value) { _bottom = value; }
duke@435 49 virtual void set_end(HeapWord* value) { _end = value; }
duke@435 50
duke@435 51 // Returns a subregion containing all objects in this space.
duke@435 52 MemRegion used_region() { return MemRegion(bottom(), top()); }
duke@435 53
duke@435 54 // Initialization
duke@435 55 virtual void initialize(MemRegion mr, bool clear_space);
duke@435 56 virtual void clear();
duke@435 57 virtual void update() { }
duke@435 58 virtual void accumulate_statistics() { }
duke@435 59
duke@435 60 // Overwrites the unused portion of this space. Note that some collectors
duke@435 61 // may use this "scratch" space during collections.
duke@435 62 virtual void mangle_unused_area() {
duke@435 63 mangle_region(MemRegion(_top, _end));
duke@435 64 }
duke@435 65 virtual void ensure_parsability() { }
duke@435 66
duke@435 67 void mangle_region(MemRegion mr) {
duke@435 68 debug_only(Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord));
duke@435 69 }
duke@435 70
duke@435 71 // Boolean querries.
duke@435 72 bool is_empty() const { return used_in_words() == 0; }
duke@435 73 bool not_empty() const { return used_in_words() > 0; }
duke@435 74 bool contains(const void* p) const { return _bottom <= p && p < _end; }
duke@435 75
duke@435 76 // Size computations. Sizes are in bytes.
duke@435 77 size_t used_in_bytes() const { return used_in_words() * HeapWordSize; }
duke@435 78 size_t free_in_bytes() const { return free_in_words() * HeapWordSize; }
duke@435 79
duke@435 80 // Size computations. Sizes are in heapwords.
duke@435 81 virtual size_t used_in_words() const { return pointer_delta(top(), bottom()); }
duke@435 82 virtual size_t free_in_words() const { return pointer_delta(end(), top()); }
duke@435 83 virtual size_t tlab_capacity(Thread* thr) const { return capacity_in_bytes(); }
duke@435 84 virtual size_t unsafe_max_tlab_alloc(Thread* thr) const { return free_in_bytes(); }
duke@435 85
duke@435 86 // Allocation (return NULL if full)
duke@435 87 virtual HeapWord* allocate(size_t word_size);
duke@435 88 virtual HeapWord* cas_allocate(size_t word_size);
duke@435 89 // Optional deallocation. Used in NUMA-allocator.
duke@435 90 bool cas_deallocate(HeapWord *obj, size_t size);
duke@435 91
duke@435 92 // Iteration.
duke@435 93 void oop_iterate(OopClosure* cl);
duke@435 94 void object_iterate(ObjectClosure* cl);
duke@435 95
duke@435 96 // Debugging
duke@435 97 virtual void print() const;
duke@435 98 virtual void print_on(outputStream* st) const;
duke@435 99 virtual void print_short() const;
duke@435 100 virtual void print_short_on(outputStream* st) const;
iveresov@625 101 virtual void verify(bool allow_dirty);
duke@435 102 };

mercurial