src/share/vm/runtime/virtualspace.hpp

Thu, 24 May 2018 20:03:11 +0800

author
aoqi
date
Thu, 24 May 2018 20:03:11 +0800
changeset 8868
91ddc23482a4
parent 7994
04ff2f6cd0eb
permissions
-rw-r--r--

Increase MaxHeapSize for better performance on MIPS

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_RUNTIME_VIRTUALSPACE_HPP
aoqi@0 26 #define SHARE_VM_RUNTIME_VIRTUALSPACE_HPP
aoqi@0 27
aoqi@0 28 #include "memory/allocation.hpp"
aoqi@0 29
aoqi@0 30 // ReservedSpace is a data structure for reserving a contiguous address range.
aoqi@0 31
aoqi@0 32 class ReservedSpace VALUE_OBJ_CLASS_SPEC {
aoqi@0 33 friend class VMStructs;
aoqi@0 34 private:
aoqi@0 35 char* _base;
aoqi@0 36 size_t _size;
aoqi@0 37 size_t _noaccess_prefix;
aoqi@0 38 size_t _alignment;
aoqi@0 39 bool _special;
aoqi@0 40 bool _executable;
aoqi@0 41
aoqi@0 42 // ReservedSpace
aoqi@0 43 ReservedSpace(char* base, size_t size, size_t alignment, bool special,
aoqi@0 44 bool executable);
aoqi@0 45 void initialize(size_t size, size_t alignment, bool large,
aoqi@0 46 char* requested_address,
aoqi@0 47 const size_t noaccess_prefix,
aoqi@0 48 bool executable);
aoqi@0 49
aoqi@0 50 protected:
aoqi@0 51 // Create protection page at the beginning of the space.
aoqi@0 52 void protect_noaccess_prefix(const size_t size);
aoqi@0 53
aoqi@0 54 public:
aoqi@0 55 // Constructor
aoqi@0 56 ReservedSpace();
tschatzl@7782 57 // Initialize the reserved space with the given size. If preferred_page_size
tschatzl@7782 58 // is set, use this as minimum page size/alignment. This may waste some space
tschatzl@7782 59 // if the given size is not aligned to that value, as the reservation will be
tschatzl@7782 60 // aligned up to the final alignment in this case.
tschatzl@7782 61 ReservedSpace(size_t size, size_t preferred_page_size = 0);
aoqi@0 62 ReservedSpace(size_t size, size_t alignment, bool large,
aoqi@0 63 char* requested_address = NULL,
aoqi@0 64 const size_t noaccess_prefix = 0);
aoqi@0 65 ReservedSpace(size_t size, size_t alignment, bool large, bool executable);
aoqi@0 66
aoqi@0 67 // Accessors
aoqi@0 68 char* base() const { return _base; }
aoqi@0 69 size_t size() const { return _size; }
aoqi@0 70 size_t alignment() const { return _alignment; }
aoqi@0 71 bool special() const { return _special; }
aoqi@0 72 bool executable() const { return _executable; }
aoqi@0 73 size_t noaccess_prefix() const { return _noaccess_prefix; }
aoqi@0 74 bool is_reserved() const { return _base != NULL; }
aoqi@0 75 void release();
aoqi@0 76
aoqi@0 77 // Splitting
aoqi@0 78 ReservedSpace first_part(size_t partition_size, size_t alignment,
aoqi@0 79 bool split = false, bool realloc = true);
aoqi@0 80 ReservedSpace last_part (size_t partition_size, size_t alignment);
aoqi@0 81
aoqi@0 82 // These simply call the above using the default alignment.
aoqi@0 83 inline ReservedSpace first_part(size_t partition_size,
aoqi@0 84 bool split = false, bool realloc = true);
aoqi@0 85 inline ReservedSpace last_part (size_t partition_size);
aoqi@0 86
aoqi@0 87 // Alignment
aoqi@0 88 static size_t page_align_size_up(size_t size);
aoqi@0 89 static size_t page_align_size_down(size_t size);
aoqi@0 90 static size_t allocation_align_size_up(size_t size);
aoqi@0 91 static size_t allocation_align_size_down(size_t size);
aoqi@0 92 };
aoqi@0 93
aoqi@0 94 ReservedSpace
aoqi@0 95 ReservedSpace::first_part(size_t partition_size, bool split, bool realloc)
aoqi@0 96 {
aoqi@0 97 return first_part(partition_size, alignment(), split, realloc);
aoqi@0 98 }
aoqi@0 99
aoqi@0 100 ReservedSpace ReservedSpace::last_part(size_t partition_size)
aoqi@0 101 {
aoqi@0 102 return last_part(partition_size, alignment());
aoqi@0 103 }
aoqi@0 104
aoqi@0 105 // Class encapsulating behavior specific of memory space reserved for Java heap
aoqi@0 106 class ReservedHeapSpace : public ReservedSpace {
aoqi@0 107 public:
aoqi@0 108 // Constructor
aoqi@0 109 ReservedHeapSpace(size_t size, size_t forced_base_alignment,
aoqi@0 110 bool large, char* requested_address);
aoqi@0 111 };
aoqi@0 112
aoqi@0 113 // Class encapsulating behavior specific memory space for Code
aoqi@0 114 class ReservedCodeSpace : public ReservedSpace {
aoqi@0 115 public:
aoqi@0 116 // Constructor
aoqi@0 117 ReservedCodeSpace(size_t r_size, size_t rs_align, bool large);
aoqi@0 118 };
aoqi@0 119
aoqi@0 120 // VirtualSpace is data structure for committing a previously reserved address range in smaller chunks.
aoqi@0 121
aoqi@0 122 class VirtualSpace VALUE_OBJ_CLASS_SPEC {
aoqi@0 123 friend class VMStructs;
aoqi@0 124 private:
aoqi@0 125 // Reserved area
aoqi@0 126 char* _low_boundary;
aoqi@0 127 char* _high_boundary;
aoqi@0 128
aoqi@0 129 // Committed area
aoqi@0 130 char* _low;
aoqi@0 131 char* _high;
aoqi@0 132
aoqi@0 133 // The entire space has been committed and pinned in memory, no
aoqi@0 134 // os::commit_memory() or os::uncommit_memory().
aoqi@0 135 bool _special;
aoqi@0 136
aoqi@0 137 // Need to know if commit should be executable.
aoqi@0 138 bool _executable;
aoqi@0 139
aoqi@0 140 // MPSS Support
aoqi@0 141 // Each virtualspace region has a lower, middle, and upper region.
aoqi@0 142 // Each region has an end boundary and a high pointer which is the
aoqi@0 143 // high water mark for the last allocated byte.
aoqi@0 144 // The lower and upper unaligned to LargePageSizeInBytes uses default page.
aoqi@0 145 // size. The middle region uses large page size.
aoqi@0 146 char* _lower_high;
aoqi@0 147 char* _middle_high;
aoqi@0 148 char* _upper_high;
aoqi@0 149
aoqi@0 150 char* _lower_high_boundary;
aoqi@0 151 char* _middle_high_boundary;
aoqi@0 152 char* _upper_high_boundary;
aoqi@0 153
aoqi@0 154 size_t _lower_alignment;
aoqi@0 155 size_t _middle_alignment;
aoqi@0 156 size_t _upper_alignment;
aoqi@0 157
aoqi@0 158 // MPSS Accessors
aoqi@0 159 char* lower_high() const { return _lower_high; }
aoqi@0 160 char* middle_high() const { return _middle_high; }
aoqi@0 161 char* upper_high() const { return _upper_high; }
aoqi@0 162
aoqi@0 163 char* lower_high_boundary() const { return _lower_high_boundary; }
aoqi@0 164 char* middle_high_boundary() const { return _middle_high_boundary; }
aoqi@0 165 char* upper_high_boundary() const { return _upper_high_boundary; }
aoqi@0 166
aoqi@0 167 size_t lower_alignment() const { return _lower_alignment; }
aoqi@0 168 size_t middle_alignment() const { return _middle_alignment; }
aoqi@0 169 size_t upper_alignment() const { return _upper_alignment; }
aoqi@0 170
aoqi@0 171 public:
aoqi@0 172 // Committed area
aoqi@0 173 char* low() const { return _low; }
aoqi@0 174 char* high() const { return _high; }
aoqi@0 175
aoqi@0 176 // Reserved area
aoqi@0 177 char* low_boundary() const { return _low_boundary; }
aoqi@0 178 char* high_boundary() const { return _high_boundary; }
aoqi@0 179
aoqi@0 180 bool special() const { return _special; }
aoqi@0 181
aoqi@0 182 public:
aoqi@0 183 // Initialization
aoqi@0 184 VirtualSpace();
aoqi@0 185 bool initialize_with_granularity(ReservedSpace rs, size_t committed_byte_size, size_t max_commit_ganularity);
aoqi@0 186 bool initialize(ReservedSpace rs, size_t committed_byte_size);
aoqi@0 187
aoqi@0 188 // Destruction
aoqi@0 189 ~VirtualSpace();
aoqi@0 190
aoqi@0 191 // Reserved memory
aoqi@0 192 size_t reserved_size() const;
aoqi@0 193 // Actually committed OS memory
aoqi@0 194 size_t actual_committed_size() const;
aoqi@0 195 // Memory used/expanded in this virtual space
aoqi@0 196 size_t committed_size() const;
aoqi@0 197 // Memory left to use/expand in this virtual space
aoqi@0 198 size_t uncommitted_size() const;
aoqi@0 199
aoqi@0 200 bool contains(const void* p) const;
aoqi@0 201
aoqi@0 202 // Operations
aoqi@0 203 // returns true on success, false otherwise
aoqi@0 204 bool expand_by(size_t bytes, bool pre_touch = false);
aoqi@0 205 void shrink_by(size_t bytes);
aoqi@0 206 void release();
aoqi@0 207
aoqi@0 208 void check_for_contiguity() PRODUCT_RETURN;
aoqi@0 209
aoqi@0 210 // Debugging
aoqi@0 211 void print_on(outputStream* out) PRODUCT_RETURN;
aoqi@0 212 void print();
aoqi@0 213 };
aoqi@0 214
aoqi@0 215 #endif // SHARE_VM_RUNTIME_VIRTUALSPACE_HPP

mercurial