src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 3900
d2a62e0f25eb
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSVIRTUALSPACE_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSVIRTUALSPACE_HPP
stefank@2314 27
stefank@2314 28 #include "runtime/virtualspace.hpp"
stefank@2314 29
duke@435 30 // VirtualSpace for the parallel scavenge collector.
duke@435 31 //
duke@435 32 // VirtualSpace is data structure for committing a previously reserved address
duke@435 33 // range in smaller chunks.
duke@435 34
duke@435 35 class PSVirtualSpace : public CHeapObj {
duke@435 36 friend class VMStructs;
duke@435 37 protected:
duke@435 38 // The space is committed/uncommited in chunks of size _alignment. The
duke@435 39 // ReservedSpace passed to initialize() must be aligned to this value.
duke@435 40 const size_t _alignment;
duke@435 41
duke@435 42 // Reserved area
duke@435 43 char* _reserved_low_addr;
duke@435 44 char* _reserved_high_addr;
duke@435 45
duke@435 46 // Committed area
duke@435 47 char* _committed_low_addr;
duke@435 48 char* _committed_high_addr;
duke@435 49
duke@435 50 // The entire space has been committed and pinned in memory, no
duke@435 51 // os::commit_memory() or os::uncommit_memory().
duke@435 52 bool _special;
duke@435 53
duke@435 54 // Convenience wrapper.
duke@435 55 inline static size_t pointer_delta(const char* left, const char* right);
duke@435 56
duke@435 57 public:
duke@435 58 PSVirtualSpace(ReservedSpace rs, size_t alignment);
duke@435 59 PSVirtualSpace(ReservedSpace rs);
duke@435 60
duke@435 61 ~PSVirtualSpace();
duke@435 62
duke@435 63 // Eventually all instances should be created with the above 1- or 2-arg
duke@435 64 // constructors. Then the 1st constructor below should become protected and
duke@435 65 // the 2nd ctor and initialize() removed.
duke@435 66 PSVirtualSpace(size_t alignment): _alignment(alignment) { }
duke@435 67 PSVirtualSpace();
duke@435 68 bool initialize(ReservedSpace rs, size_t commit_size);
duke@435 69
duke@435 70 bool contains(void* p) const;
duke@435 71
duke@435 72 // Accessors (all sizes are bytes).
duke@435 73 size_t alignment() const { return _alignment; }
duke@435 74 char* reserved_low_addr() const { return _reserved_low_addr; }
duke@435 75 char* reserved_high_addr() const { return _reserved_high_addr; }
duke@435 76 char* committed_low_addr() const { return _committed_low_addr; }
duke@435 77 char* committed_high_addr() const { return _committed_high_addr; }
duke@435 78 bool special() const { return _special; }
duke@435 79
duke@435 80 inline size_t committed_size() const;
duke@435 81 inline size_t reserved_size() const;
duke@435 82 inline size_t uncommitted_size() const;
duke@435 83
duke@435 84 // Operations.
duke@435 85 inline void set_reserved(char* low_addr, char* high_addr, bool special);
duke@435 86 inline void set_reserved(ReservedSpace rs);
duke@435 87 inline void set_committed(char* low_addr, char* high_addr);
iveresov@970 88 virtual bool expand_by(size_t bytes);
duke@435 89 virtual bool shrink_by(size_t bytes);
duke@435 90 virtual size_t expand_into(PSVirtualSpace* space, size_t bytes);
duke@435 91 void release();
duke@435 92
duke@435 93 #ifndef PRODUCT
duke@435 94 // Debugging
duke@435 95 static bool is_aligned(size_t val, size_t align);
duke@435 96 bool is_aligned(size_t val) const;
duke@435 97 bool is_aligned(char* val) const;
duke@435 98 void verify() const;
duke@435 99 void print() const;
duke@435 100 virtual bool grows_up() const { return true; }
duke@435 101 bool grows_down() const { return !grows_up(); }
duke@435 102
duke@435 103 // Helper class to verify a space when entering/leaving a block.
duke@435 104 class PSVirtualSpaceVerifier: public StackObj {
duke@435 105 private:
duke@435 106 const PSVirtualSpace* const _space;
duke@435 107 public:
duke@435 108 PSVirtualSpaceVerifier(PSVirtualSpace* space): _space(space) {
duke@435 109 _space->verify();
duke@435 110 }
duke@435 111 ~PSVirtualSpaceVerifier() { _space->verify(); }
duke@435 112 };
duke@435 113 #endif
duke@435 114
duke@435 115 virtual void print_space_boundaries_on(outputStream* st) const;
duke@435 116
duke@435 117 // Included for compatibility with the original VirtualSpace.
duke@435 118 public:
duke@435 119 // Committed area
duke@435 120 char* low() const { return committed_low_addr(); }
duke@435 121 char* high() const { return committed_high_addr(); }
duke@435 122
duke@435 123 // Reserved area
duke@435 124 char* low_boundary() const { return reserved_low_addr(); }
duke@435 125 char* high_boundary() const { return reserved_high_addr(); }
duke@435 126 };
duke@435 127
duke@435 128 // A virtual space that grows from high addresses to low addresses.
duke@435 129 class PSVirtualSpaceHighToLow : public PSVirtualSpace {
duke@435 130 friend class VMStructs;
duke@435 131 public:
duke@435 132 PSVirtualSpaceHighToLow(ReservedSpace rs, size_t alignment);
duke@435 133 PSVirtualSpaceHighToLow(ReservedSpace rs);
duke@435 134
iveresov@970 135 virtual bool expand_by(size_t bytes);
duke@435 136 virtual bool shrink_by(size_t bytes);
duke@435 137 virtual size_t expand_into(PSVirtualSpace* space, size_t bytes);
duke@435 138
duke@435 139 virtual void print_space_boundaries_on(outputStream* st) const;
duke@435 140
duke@435 141 #ifndef PRODUCT
duke@435 142 // Debugging
duke@435 143 virtual bool grows_up() const { return false; }
duke@435 144 #endif
duke@435 145 };
duke@435 146
duke@435 147 //
duke@435 148 // PSVirtualSpace inlines.
duke@435 149 //
duke@435 150 inline size_t
duke@435 151 PSVirtualSpace::pointer_delta(const char* left, const char* right) {
duke@435 152 return ::pointer_delta((void *)left, (void*)right, sizeof(char));
duke@435 153 }
duke@435 154
duke@435 155 inline size_t PSVirtualSpace::committed_size() const {
duke@435 156 return pointer_delta(committed_high_addr(), committed_low_addr());
duke@435 157 }
duke@435 158
duke@435 159 inline size_t PSVirtualSpace::reserved_size() const {
duke@435 160 return pointer_delta(reserved_high_addr(), reserved_low_addr());
duke@435 161 }
duke@435 162
duke@435 163 inline size_t PSVirtualSpace::uncommitted_size() const {
duke@435 164 return reserved_size() - committed_size();
duke@435 165 }
duke@435 166
duke@435 167 inline void PSVirtualSpace::set_reserved(char* low_addr, char* high_addr, bool special) {
duke@435 168 _reserved_low_addr = low_addr;
duke@435 169 _reserved_high_addr = high_addr;
duke@435 170 _special = special;
duke@435 171 }
duke@435 172
duke@435 173 inline void PSVirtualSpace::set_reserved(ReservedSpace rs) {
duke@435 174 set_reserved(rs.base(), rs.base() + rs.size(), rs.special());
duke@435 175 }
duke@435 176
duke@435 177 inline void PSVirtualSpace::set_committed(char* low_addr, char* high_addr) {
duke@435 178 _committed_low_addr = low_addr;
duke@435 179 _committed_high_addr = high_addr;
duke@435 180 }
stefank@2314 181
stefank@2314 182 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSVIRTUALSPACE_HPP

mercurial