src/share/vm/runtime/virtualspace.hpp

Tue, 07 Apr 2015 10:53:51 +0200

author
tschatzl
date
Tue, 07 Apr 2015 10:53:51 +0200
changeset 7781
33e421924c67
parent 6198
55fb97c4c58d
child 7782
30e04eba9e29
permissions
-rw-r--r--

8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
Summary: Allow use of large pages for auxiliary data structures in G1. Clean up existing interfaces.
Reviewed-by: jmasa, pliden, stefank

duke@435 1 /*
mikael@6198 2 * Copyright (c) 1997, 2013, 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_RUNTIME_VIRTUALSPACE_HPP
stefank@2314 26 #define SHARE_VM_RUNTIME_VIRTUALSPACE_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29
duke@435 30 // ReservedSpace is a data structure for reserving a contiguous address range.
duke@435 31
duke@435 32 class ReservedSpace VALUE_OBJ_CLASS_SPEC {
duke@435 33 friend class VMStructs;
duke@435 34 private:
duke@435 35 char* _base;
duke@435 36 size_t _size;
coleenp@672 37 size_t _noaccess_prefix;
duke@435 38 size_t _alignment;
duke@435 39 bool _special;
coleenp@1091 40 bool _executable;
duke@435 41
duke@435 42 // ReservedSpace
coleenp@1091 43 ReservedSpace(char* base, size_t size, size_t alignment, bool special,
coleenp@1091 44 bool executable);
duke@435 45 void initialize(size_t size, size_t alignment, bool large,
coleenp@672 46 char* requested_address,
coleenp@1091 47 const size_t noaccess_prefix,
coleenp@1091 48 bool executable);
duke@435 49
coleenp@672 50 protected:
coleenp@672 51 // Create protection page at the beginning of the space.
coleenp@672 52 void protect_noaccess_prefix(const size_t size);
coleenp@672 53
duke@435 54 public:
duke@435 55 // Constructor
stefank@5578 56 ReservedSpace();
tschatzl@7781 57 // Initialize the reserved space with the given size. If prefer_large_pages is
tschatzl@7781 58 // set, if the given size warrants use of large pages, try to force them by
tschatzl@7781 59 // passing an alignment restriction further down. This may waste some space
tschatzl@7781 60 // if the given size is not aligned, as the reservation will be aligned up
tschatzl@7781 61 // to large page alignment.
tschatzl@7781 62 ReservedSpace(size_t size, bool prefer_large_pages = false);
duke@435 63 ReservedSpace(size_t size, size_t alignment, bool large,
coleenp@672 64 char* requested_address = NULL,
coleenp@672 65 const size_t noaccess_prefix = 0);
coleenp@1091 66 ReservedSpace(size_t size, size_t alignment, bool large, bool executable);
duke@435 67
duke@435 68 // Accessors
coleenp@1091 69 char* base() const { return _base; }
coleenp@1091 70 size_t size() const { return _size; }
coleenp@1091 71 size_t alignment() const { return _alignment; }
coleenp@1091 72 bool special() const { return _special; }
coleenp@1091 73 bool executable() const { return _executable; }
coleenp@1091 74 size_t noaccess_prefix() const { return _noaccess_prefix; }
coleenp@1091 75 bool is_reserved() const { return _base != NULL; }
duke@435 76 void release();
duke@435 77
duke@435 78 // Splitting
duke@435 79 ReservedSpace first_part(size_t partition_size, size_t alignment,
duke@435 80 bool split = false, bool realloc = true);
duke@435 81 ReservedSpace last_part (size_t partition_size, size_t alignment);
duke@435 82
duke@435 83 // These simply call the above using the default alignment.
duke@435 84 inline ReservedSpace first_part(size_t partition_size,
duke@435 85 bool split = false, bool realloc = true);
duke@435 86 inline ReservedSpace last_part (size_t partition_size);
duke@435 87
duke@435 88 // Alignment
duke@435 89 static size_t page_align_size_up(size_t size);
duke@435 90 static size_t page_align_size_down(size_t size);
duke@435 91 static size_t allocation_align_size_up(size_t size);
duke@435 92 static size_t allocation_align_size_down(size_t size);
duke@435 93 };
duke@435 94
duke@435 95 ReservedSpace
duke@435 96 ReservedSpace::first_part(size_t partition_size, bool split, bool realloc)
duke@435 97 {
duke@435 98 return first_part(partition_size, alignment(), split, realloc);
duke@435 99 }
duke@435 100
duke@435 101 ReservedSpace ReservedSpace::last_part(size_t partition_size)
duke@435 102 {
duke@435 103 return last_part(partition_size, alignment());
duke@435 104 }
duke@435 105
coleenp@672 106 // Class encapsulating behavior specific of memory space reserved for Java heap
coleenp@672 107 class ReservedHeapSpace : public ReservedSpace {
coleenp@672 108 public:
coleenp@672 109 // Constructor
coleenp@672 110 ReservedHeapSpace(size_t size, size_t forced_base_alignment,
coleenp@672 111 bool large, char* requested_address);
coleenp@672 112 };
coleenp@672 113
coleenp@1091 114 // Class encapsulating behavior specific memory space for Code
coleenp@1091 115 class ReservedCodeSpace : public ReservedSpace {
coleenp@1091 116 public:
coleenp@1091 117 // Constructor
coleenp@1091 118 ReservedCodeSpace(size_t r_size, size_t rs_align, bool large);
coleenp@1091 119 };
coleenp@1091 120
duke@435 121 // VirtualSpace is data structure for committing a previously reserved address range in smaller chunks.
duke@435 122
duke@435 123 class VirtualSpace VALUE_OBJ_CLASS_SPEC {
duke@435 124 friend class VMStructs;
duke@435 125 private:
duke@435 126 // Reserved area
duke@435 127 char* _low_boundary;
duke@435 128 char* _high_boundary;
duke@435 129
duke@435 130 // Committed area
duke@435 131 char* _low;
duke@435 132 char* _high;
duke@435 133
duke@435 134 // The entire space has been committed and pinned in memory, no
duke@435 135 // os::commit_memory() or os::uncommit_memory().
duke@435 136 bool _special;
duke@435 137
coleenp@1091 138 // Need to know if commit should be executable.
coleenp@1091 139 bool _executable;
coleenp@1091 140
duke@435 141 // MPSS Support
duke@435 142 // Each virtualspace region has a lower, middle, and upper region.
duke@435 143 // Each region has an end boundary and a high pointer which is the
duke@435 144 // high water mark for the last allocated byte.
duke@435 145 // The lower and upper unaligned to LargePageSizeInBytes uses default page.
duke@435 146 // size. The middle region uses large page size.
duke@435 147 char* _lower_high;
duke@435 148 char* _middle_high;
duke@435 149 char* _upper_high;
duke@435 150
duke@435 151 char* _lower_high_boundary;
duke@435 152 char* _middle_high_boundary;
duke@435 153 char* _upper_high_boundary;
duke@435 154
duke@435 155 size_t _lower_alignment;
duke@435 156 size_t _middle_alignment;
duke@435 157 size_t _upper_alignment;
duke@435 158
duke@435 159 // MPSS Accessors
duke@435 160 char* lower_high() const { return _lower_high; }
duke@435 161 char* middle_high() const { return _middle_high; }
duke@435 162 char* upper_high() const { return _upper_high; }
duke@435 163
duke@435 164 char* lower_high_boundary() const { return _lower_high_boundary; }
duke@435 165 char* middle_high_boundary() const { return _middle_high_boundary; }
duke@435 166 char* upper_high_boundary() const { return _upper_high_boundary; }
duke@435 167
duke@435 168 size_t lower_alignment() const { return _lower_alignment; }
duke@435 169 size_t middle_alignment() const { return _middle_alignment; }
duke@435 170 size_t upper_alignment() const { return _upper_alignment; }
duke@435 171
duke@435 172 public:
duke@435 173 // Committed area
duke@435 174 char* low() const { return _low; }
duke@435 175 char* high() const { return _high; }
duke@435 176
duke@435 177 // Reserved area
duke@435 178 char* low_boundary() const { return _low_boundary; }
duke@435 179 char* high_boundary() const { return _high_boundary; }
duke@435 180
duke@435 181 bool special() const { return _special; }
duke@435 182
duke@435 183 public:
duke@435 184 // Initialization
duke@435 185 VirtualSpace();
mgerdin@5859 186 bool initialize_with_granularity(ReservedSpace rs, size_t committed_byte_size, size_t max_commit_ganularity);
duke@435 187 bool initialize(ReservedSpace rs, size_t committed_byte_size);
duke@435 188
duke@435 189 // Destruction
duke@435 190 ~VirtualSpace();
duke@435 191
stefank@5704 192 // Reserved memory
stefank@5704 193 size_t reserved_size() const;
stefank@5704 194 // Actually committed OS memory
stefank@5704 195 size_t actual_committed_size() const;
stefank@5704 196 // Memory used/expanded in this virtual space
stefank@5704 197 size_t committed_size() const;
stefank@5704 198 // Memory left to use/expand in this virtual space
duke@435 199 size_t uncommitted_size() const;
stefank@5704 200
stefank@5704 201 bool contains(const void* p) const;
duke@435 202
duke@435 203 // Operations
duke@435 204 // returns true on success, false otherwise
duke@435 205 bool expand_by(size_t bytes, bool pre_touch = false);
duke@435 206 void shrink_by(size_t bytes);
duke@435 207 void release();
duke@435 208
duke@435 209 void check_for_contiguity() PRODUCT_RETURN;
duke@435 210
duke@435 211 // Debugging
stefank@5708 212 void print_on(outputStream* out) PRODUCT_RETURN;
stefank@5708 213 void print();
duke@435 214 };
stefank@2314 215
stefank@2314 216 #endif // SHARE_VM_RUNTIME_VIRTUALSPACE_HPP

mercurial