2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2008-07-02 12:55:16 -07:00
|
|
|
* Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
|
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
|
|
* have any questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// A MutableSpace is a subtype of ImmutableSpace that supports the
|
|
|
|
// concept of allocation. This includes the concepts that a space may
|
|
|
|
// be only partially full, and the querry methods that go with such
|
|
|
|
// an assumption.
|
|
|
|
//
|
|
|
|
// Invariant: (ImmutableSpace +) bottom() <= top() <= end()
|
|
|
|
// top() is inclusive and end() is exclusive.
|
|
|
|
|
2008-07-09 15:08:55 -07:00
|
|
|
class MutableSpaceMangler;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
class MutableSpace: public ImmutableSpace {
|
|
|
|
friend class VMStructs;
|
2008-07-09 15:08:55 -07:00
|
|
|
|
|
|
|
// Helper for mangling unused space in debug builds
|
|
|
|
MutableSpaceMangler* _mangler;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
protected:
|
|
|
|
HeapWord* _top;
|
|
|
|
|
2008-07-09 15:08:55 -07:00
|
|
|
MutableSpaceMangler* mangler() { return _mangler; }
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
public:
|
2008-07-09 15:08:55 -07:00
|
|
|
virtual ~MutableSpace();
|
|
|
|
MutableSpace();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Accessors
|
|
|
|
HeapWord* top() const { return _top; }
|
|
|
|
virtual void set_top(HeapWord* value) { _top = value; }
|
|
|
|
|
|
|
|
HeapWord** top_addr() { return &_top; }
|
|
|
|
HeapWord** end_addr() { return &_end; }
|
|
|
|
|
|
|
|
virtual void set_bottom(HeapWord* value) { _bottom = value; }
|
|
|
|
virtual void set_end(HeapWord* value) { _end = value; }
|
|
|
|
|
|
|
|
// Returns a subregion containing all objects in this space.
|
|
|
|
MemRegion used_region() { return MemRegion(bottom(), top()); }
|
|
|
|
|
|
|
|
// Initialization
|
2008-07-09 15:08:55 -07:00
|
|
|
virtual void initialize(MemRegion mr,
|
|
|
|
bool clear_space,
|
|
|
|
bool mangle_space);
|
|
|
|
virtual void clear(bool mangle_space);
|
|
|
|
// Does the usual initialization but optionally resets top to bottom.
|
|
|
|
#if 0 // MANGLE_SPACE
|
|
|
|
void initialize(MemRegion mr, bool clear_space, bool reset_top);
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
virtual void update() { }
|
|
|
|
virtual void accumulate_statistics() { }
|
|
|
|
|
2008-07-09 15:08:55 -07:00
|
|
|
// Methods used in mangling. See descriptions under SpaceMangler.
|
|
|
|
virtual void mangle_unused_area() PRODUCT_RETURN;
|
|
|
|
virtual void mangle_unused_area_complete() PRODUCT_RETURN;
|
|
|
|
virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
|
|
|
|
virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
|
|
|
|
virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
|
|
|
|
|
|
|
|
// Used to save the space's current top for later use during mangling.
|
|
|
|
virtual void set_top_for_allocations() PRODUCT_RETURN;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
virtual void ensure_parsability() { }
|
|
|
|
|
2008-07-09 15:08:55 -07:00
|
|
|
virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Boolean querries.
|
|
|
|
bool is_empty() const { return used_in_words() == 0; }
|
|
|
|
bool not_empty() const { return used_in_words() > 0; }
|
|
|
|
bool contains(const void* p) const { return _bottom <= p && p < _end; }
|
|
|
|
|
|
|
|
// Size computations. Sizes are in bytes.
|
|
|
|
size_t used_in_bytes() const { return used_in_words() * HeapWordSize; }
|
|
|
|
size_t free_in_bytes() const { return free_in_words() * HeapWordSize; }
|
|
|
|
|
|
|
|
// Size computations. Sizes are in heapwords.
|
|
|
|
virtual size_t used_in_words() const { return pointer_delta(top(), bottom()); }
|
|
|
|
virtual size_t free_in_words() const { return pointer_delta(end(), top()); }
|
|
|
|
virtual size_t tlab_capacity(Thread* thr) const { return capacity_in_bytes(); }
|
|
|
|
virtual size_t unsafe_max_tlab_alloc(Thread* thr) const { return free_in_bytes(); }
|
|
|
|
|
|
|
|
// Allocation (return NULL if full)
|
|
|
|
virtual HeapWord* allocate(size_t word_size);
|
|
|
|
virtual HeapWord* cas_allocate(size_t word_size);
|
|
|
|
// Optional deallocation. Used in NUMA-allocator.
|
|
|
|
bool cas_deallocate(HeapWord *obj, size_t size);
|
|
|
|
|
|
|
|
// Iteration.
|
|
|
|
void oop_iterate(OopClosure* cl);
|
|
|
|
void object_iterate(ObjectClosure* cl);
|
|
|
|
|
|
|
|
// Debugging
|
|
|
|
virtual void print() const;
|
|
|
|
virtual void print_on(outputStream* st) const;
|
|
|
|
virtual void print_short() const;
|
|
|
|
virtual void print_short_on(outputStream* st) const;
|
2008-06-09 07:18:59 -07:00
|
|
|
virtual void verify(bool allow_dirty);
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|