Tue, 19 May 2015 15:49:27 +0200
8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
Summary: added WhiteBox methods to count regions and exact aux data sizes
Reviewed-by: jwilhelm, brutisso
tschatzl@7051 | 1 | /* |
tschatzl@7051 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
tschatzl@7051 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
tschatzl@7051 | 4 | * |
tschatzl@7051 | 5 | * This code is free software; you can redistribute it and/or modify it |
tschatzl@7051 | 6 | * under the terms of the GNU General Public License version 2 only, as |
tschatzl@7051 | 7 | * published by the Free Software Foundation. |
tschatzl@7051 | 8 | * |
tschatzl@7051 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
tschatzl@7051 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
tschatzl@7051 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
tschatzl@7051 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
tschatzl@7051 | 13 | * accompanied this code). |
tschatzl@7051 | 14 | * |
tschatzl@7051 | 15 | * You should have received a copy of the GNU General Public License version |
tschatzl@7051 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
tschatzl@7051 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
tschatzl@7051 | 18 | * |
tschatzl@7051 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
tschatzl@7051 | 20 | * or visit www.oracle.com if you need additional information or have any |
tschatzl@7051 | 21 | * questions. |
tschatzl@7051 | 22 | * |
tschatzl@7051 | 23 | */ |
tschatzl@7051 | 24 | |
tschatzl@7051 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP |
tschatzl@7051 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP |
tschatzl@7051 | 27 | |
tschatzl@7051 | 28 | #include "memory/allocation.hpp" |
tschatzl@7051 | 29 | #include "memory/memRegion.hpp" |
tschatzl@7051 | 30 | #include "runtime/virtualspace.hpp" |
tschatzl@7051 | 31 | #include "utilities/bitMap.hpp" |
tschatzl@7051 | 32 | |
tschatzl@7051 | 33 | // Virtual space management helper for a virtual space with an OS page allocation |
tschatzl@7051 | 34 | // granularity. |
tschatzl@7051 | 35 | // (De-)Allocation requests are always OS page aligned by passing a page index |
tschatzl@7051 | 36 | // and multiples of pages. |
tschatzl@7781 | 37 | // For systems that only commits of memory in a given size (always greater than |
tschatzl@7781 | 38 | // page size) the base address is required to be aligned to that page size. |
tschatzl@7781 | 39 | // The actual size requested need not be aligned to that page size, but the size |
tschatzl@7781 | 40 | // of the reservation passed may be rounded up to this page size. Any fragment |
tschatzl@7781 | 41 | // (less than the page size) of the actual size at the tail of the request will |
tschatzl@7781 | 42 | // be committed using OS small pages. |
tschatzl@7051 | 43 | // The implementation gives an error when trying to commit or uncommit pages that |
tschatzl@7051 | 44 | // have already been committed or uncommitted. |
tschatzl@7051 | 45 | class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC { |
tschatzl@7051 | 46 | friend class VMStructs; |
tschatzl@7051 | 47 | private: |
tschatzl@7051 | 48 | // Reserved area addresses. |
tschatzl@7051 | 49 | char* _low_boundary; |
tschatzl@7051 | 50 | char* _high_boundary; |
tschatzl@7051 | 51 | |
tschatzl@7781 | 52 | // The size of the tail in bytes of the handled space that needs to be committed |
tschatzl@7781 | 53 | // using small pages. |
tschatzl@7781 | 54 | size_t _tail_size; |
tschatzl@7781 | 55 | |
tschatzl@7781 | 56 | // The preferred page size used for commit/uncommit in bytes. |
tschatzl@7051 | 57 | size_t _page_size; |
tschatzl@7051 | 58 | |
tschatzl@7051 | 59 | // Bitmap used for verification of commit/uncommit operations. |
tschatzl@7051 | 60 | BitMap _committed; |
tschatzl@7051 | 61 | |
sjohanss@7509 | 62 | // Bitmap used to keep track of which pages are dirty or not for _special |
sjohanss@7509 | 63 | // spaces. This is needed because for those spaces the underlying memory |
sjohanss@7509 | 64 | // will only be zero filled the first time it is committed. Calls to commit |
sjohanss@7509 | 65 | // will use this bitmap and return whether or not the memory is zero filled. |
sjohanss@7509 | 66 | BitMap _dirty; |
sjohanss@7509 | 67 | |
tschatzl@7051 | 68 | // Indicates that the entire space has been committed and pinned in memory, |
tschatzl@7051 | 69 | // os::commit_memory() or os::uncommit_memory() have no function. |
tschatzl@7051 | 70 | bool _special; |
tschatzl@7051 | 71 | |
tschatzl@7051 | 72 | // Indicates whether the committed space should be executable. |
tschatzl@7051 | 73 | bool _executable; |
tschatzl@7051 | 74 | |
tschatzl@7781 | 75 | // Helper function for committing memory. Commit the given memory range by using |
tschatzl@7781 | 76 | // _page_size pages as much as possible and the remainder with small sized pages. |
tschatzl@7781 | 77 | void commit_internal(size_t start_page, size_t end_page); |
tschatzl@7781 | 78 | // Commit num_pages pages of _page_size size starting from start. All argument |
tschatzl@7781 | 79 | // checking has been performed. |
tschatzl@7781 | 80 | void commit_preferred_pages(size_t start_page, size_t end_page); |
tschatzl@7781 | 81 | // Commit space at the high end of the space that needs to be committed with small |
tschatzl@7781 | 82 | // sized pages. |
tschatzl@7781 | 83 | void commit_tail(); |
tschatzl@7781 | 84 | |
tschatzl@7781 | 85 | // Uncommit the given memory range. |
tschatzl@7781 | 86 | void uncommit_internal(size_t start_page, size_t end_page); |
tschatzl@7781 | 87 | |
tschatzl@7781 | 88 | // Pretouch the given memory range. |
tschatzl@7781 | 89 | void pretouch_internal(size_t start_page, size_t end_page); |
tschatzl@7781 | 90 | |
tschatzl@7051 | 91 | // Returns the index of the page which contains the given address. |
tschatzl@7051 | 92 | uintptr_t addr_to_page_index(char* addr) const; |
tschatzl@7051 | 93 | // Returns the address of the given page index. |
tschatzl@7781 | 94 | char* page_start(size_t index) const; |
tschatzl@7781 | 95 | |
tschatzl@7781 | 96 | // Is the given page index the last page? |
tschatzl@7781 | 97 | bool is_last_page(size_t index) const { return index == (_committed.size() - 1); } |
tschatzl@7781 | 98 | // Is the given page index the first after last page? |
tschatzl@7781 | 99 | bool is_after_last_page(size_t index) const; |
tschatzl@7781 | 100 | // Is the last page only partially covered by this space? |
tschatzl@7781 | 101 | bool is_last_page_partial() const { return !is_ptr_aligned(_high_boundary, _page_size); } |
tschatzl@7781 | 102 | // Returns the end address of the given page bounded by the reserved space. |
tschatzl@7781 | 103 | char* bounded_end_addr(size_t end_page) const; |
tschatzl@7051 | 104 | |
tschatzl@7051 | 105 | // Returns true if the entire area is backed by committed memory. |
tschatzl@7781 | 106 | bool is_area_committed(size_t start_page, size_t size_in_pages) const; |
tschatzl@7051 | 107 | // Returns true if the entire area is not backed by committed memory. |
tschatzl@7781 | 108 | bool is_area_uncommitted(size_t start_page, size_t size_in_pages) const; |
tschatzl@7051 | 109 | |
tschatzl@7781 | 110 | void initialize_with_page_size(ReservedSpace rs, size_t used_size, size_t page_size); |
tschatzl@7051 | 111 | public: |
tschatzl@7051 | 112 | |
tschatzl@7051 | 113 | // Commit the given area of pages starting at start being size_in_pages large. |
sjohanss@7509 | 114 | // Returns true if the given area is zero filled upon completion. |
tschatzl@7781 | 115 | bool commit(size_t start_page, size_t size_in_pages); |
tschatzl@7051 | 116 | |
tschatzl@7051 | 117 | // Uncommit the given area of pages starting at start being size_in_pages large. |
tschatzl@7781 | 118 | void uncommit(size_t start_page, size_t size_in_pages); |
tschatzl@7051 | 119 | |
tschatzl@7781 | 120 | // Initialize the given reserved space with the given base address and the size |
tschatzl@7781 | 121 | // actually used. |
tschatzl@7781 | 122 | // Prefer to commit in page_size chunks. |
tschatzl@7781 | 123 | G1PageBasedVirtualSpace(ReservedSpace rs, size_t used_size, size_t page_size); |
tschatzl@7051 | 124 | |
tschatzl@7051 | 125 | // Destruction |
tschatzl@7051 | 126 | ~G1PageBasedVirtualSpace(); |
tschatzl@7051 | 127 | |
tschatzl@7051 | 128 | // Amount of reserved memory. |
tschatzl@7051 | 129 | size_t reserved_size() const; |
tschatzl@7051 | 130 | // Memory used in this virtual space. |
tschatzl@7051 | 131 | size_t committed_size() const; |
tschatzl@7051 | 132 | // Memory left to use/expand in this virtual space. |
tschatzl@7051 | 133 | size_t uncommitted_size() const; |
tschatzl@7051 | 134 | |
tschatzl@7051 | 135 | bool contains(const void* p) const; |
tschatzl@7051 | 136 | |
tschatzl@7051 | 137 | MemRegion reserved() { |
tschatzl@7051 | 138 | MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize); |
tschatzl@7051 | 139 | return x; |
tschatzl@7051 | 140 | } |
tschatzl@7051 | 141 | |
tschatzl@7051 | 142 | void release(); |
tschatzl@7051 | 143 | |
tschatzl@7051 | 144 | void check_for_contiguity() PRODUCT_RETURN; |
tschatzl@7051 | 145 | |
tschatzl@7051 | 146 | // Debugging |
tschatzl@7051 | 147 | void print_on(outputStream* out) PRODUCT_RETURN; |
tschatzl@7051 | 148 | void print(); |
tschatzl@7051 | 149 | }; |
tschatzl@7051 | 150 | |
tschatzl@7051 | 151 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP |