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

changeset 435
a61af66fc99e
child 625
d1635bf93939
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/shared/mutableSpace.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,102 @@
     1.4 +/*
     1.5 + * Copyright 2001-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +// A MutableSpace is a subtype of ImmutableSpace that supports the
    1.29 +// concept of allocation. This includes the concepts that a space may
    1.30 +// be only partially full, and the querry methods that go with such
    1.31 +// an assumption.
    1.32 +//
    1.33 +// Invariant: (ImmutableSpace +) bottom() <= top() <= end()
    1.34 +// top() is inclusive and end() is exclusive.
    1.35 +
    1.36 +class MutableSpace: public ImmutableSpace {
    1.37 +  friend class VMStructs;
    1.38 + protected:
    1.39 +  HeapWord* _top;
    1.40 +
    1.41 + public:
    1.42 +  virtual ~MutableSpace()                  {}
    1.43 +  MutableSpace()                           { _top = NULL;    }
    1.44 +  // Accessors
    1.45 +  HeapWord* top() const                    { return _top;    }
    1.46 +  virtual void set_top(HeapWord* value)    { _top = value;   }
    1.47 +
    1.48 +  HeapWord** top_addr()                    { return &_top; }
    1.49 +  HeapWord** end_addr()                    { return &_end; }
    1.50 +
    1.51 +  virtual void set_bottom(HeapWord* value) { _bottom = value; }
    1.52 +  virtual void set_end(HeapWord* value)    { _end = value; }
    1.53 +
    1.54 +  // Returns a subregion containing all objects in this space.
    1.55 +  MemRegion used_region() { return MemRegion(bottom(), top()); }
    1.56 +
    1.57 +  // Initialization
    1.58 +  virtual void initialize(MemRegion mr, bool clear_space);
    1.59 +  virtual void clear();
    1.60 +  virtual void update() { }
    1.61 +  virtual void accumulate_statistics() { }
    1.62 +
    1.63 +  // Overwrites the unused portion of this space. Note that some collectors
    1.64 +  // may use this "scratch" space during collections.
    1.65 +  virtual void mangle_unused_area() {
    1.66 +    mangle_region(MemRegion(_top, _end));
    1.67 +  }
    1.68 +  virtual void ensure_parsability() { }
    1.69 +
    1.70 +  void mangle_region(MemRegion mr) {
    1.71 +    debug_only(Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord));
    1.72 +  }
    1.73 +
    1.74 +  // Boolean querries.
    1.75 +  bool is_empty() const              { return used_in_words() == 0; }
    1.76 +  bool not_empty() const             { return used_in_words() > 0; }
    1.77 +  bool contains(const void* p) const { return _bottom <= p && p < _end; }
    1.78 +
    1.79 +  // Size computations.  Sizes are in bytes.
    1.80 +  size_t used_in_bytes() const                { return used_in_words() * HeapWordSize; }
    1.81 +  size_t free_in_bytes() const                { return free_in_words() * HeapWordSize; }
    1.82 +
    1.83 +  // Size computations.  Sizes are in heapwords.
    1.84 +  virtual size_t used_in_words() const                    { return pointer_delta(top(), bottom()); }
    1.85 +  virtual size_t free_in_words() const                    { return pointer_delta(end(),    top()); }
    1.86 +  virtual size_t tlab_capacity(Thread* thr) const         { return capacity_in_bytes();            }
    1.87 +  virtual size_t unsafe_max_tlab_alloc(Thread* thr) const { return free_in_bytes();                }
    1.88 +
    1.89 +  // Allocation (return NULL if full)
    1.90 +  virtual HeapWord* allocate(size_t word_size);
    1.91 +  virtual HeapWord* cas_allocate(size_t word_size);
    1.92 +  // Optional deallocation. Used in NUMA-allocator.
    1.93 +  bool cas_deallocate(HeapWord *obj, size_t size);
    1.94 +
    1.95 +  // Iteration.
    1.96 +  void oop_iterate(OopClosure* cl);
    1.97 +  void object_iterate(ObjectClosure* cl);
    1.98 +
    1.99 +  // Debugging
   1.100 +  virtual void print() const;
   1.101 +  virtual void print_on(outputStream* st) const;
   1.102 +  virtual void print_short() const;
   1.103 +  virtual void print_short_on(outputStream* st) const;
   1.104 +  virtual void verify(bool allow_dirty) const;
   1.105 +};

mercurial