src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.hpp

Mon, 02 Feb 2015 10:38:39 +0100

author
tschatzl
date
Mon, 02 Feb 2015 10:38:39 +0100
changeset 7654
36c7518fd486
parent 7509
ae52ee069062
child 7781
33e421924c67
permissions
-rw-r--r--

8069760: When iterating over a card, G1 often iterates over much more references than are contained in the card
Summary: Properly bound the iteration work for objArray-oops.
Reviewed-by: mgerdin, kbarrett

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@7051 37 // The implementation gives an error when trying to commit or uncommit pages that
tschatzl@7051 38 // have already been committed or uncommitted.
tschatzl@7051 39 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
tschatzl@7051 40 friend class VMStructs;
tschatzl@7051 41 private:
tschatzl@7051 42 // Reserved area addresses.
tschatzl@7051 43 char* _low_boundary;
tschatzl@7051 44 char* _high_boundary;
tschatzl@7051 45
tschatzl@7051 46 // The commit/uncommit granularity in bytes.
tschatzl@7051 47 size_t _page_size;
tschatzl@7051 48
tschatzl@7051 49 // Bitmap used for verification of commit/uncommit operations.
tschatzl@7051 50 BitMap _committed;
tschatzl@7051 51
sjohanss@7509 52 // Bitmap used to keep track of which pages are dirty or not for _special
sjohanss@7509 53 // spaces. This is needed because for those spaces the underlying memory
sjohanss@7509 54 // will only be zero filled the first time it is committed. Calls to commit
sjohanss@7509 55 // will use this bitmap and return whether or not the memory is zero filled.
sjohanss@7509 56 BitMap _dirty;
sjohanss@7509 57
tschatzl@7051 58 // Indicates that the entire space has been committed and pinned in memory,
tschatzl@7051 59 // os::commit_memory() or os::uncommit_memory() have no function.
tschatzl@7051 60 bool _special;
tschatzl@7051 61
tschatzl@7051 62 // Indicates whether the committed space should be executable.
tschatzl@7051 63 bool _executable;
tschatzl@7051 64
tschatzl@7051 65 // Returns the index of the page which contains the given address.
tschatzl@7051 66 uintptr_t addr_to_page_index(char* addr) const;
tschatzl@7051 67 // Returns the address of the given page index.
tschatzl@7051 68 char* page_start(uintptr_t index);
tschatzl@7051 69 // Returns the byte size of the given number of pages.
tschatzl@7051 70 size_t byte_size_for_pages(size_t num);
tschatzl@7051 71
tschatzl@7051 72 // Returns true if the entire area is backed by committed memory.
tschatzl@7051 73 bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
tschatzl@7051 74 // Returns true if the entire area is not backed by committed memory.
tschatzl@7051 75 bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
tschatzl@7051 76
tschatzl@7051 77 public:
tschatzl@7051 78
tschatzl@7051 79 // Commit the given area of pages starting at start being size_in_pages large.
sjohanss@7509 80 // Returns true if the given area is zero filled upon completion.
sjohanss@7509 81 bool commit(uintptr_t start, size_t size_in_pages);
tschatzl@7051 82
tschatzl@7051 83 // Uncommit the given area of pages starting at start being size_in_pages large.
sjohanss@7509 84 void uncommit(uintptr_t start, size_t size_in_pages);
tschatzl@7051 85
tschatzl@7051 86 // Initialization
tschatzl@7051 87 G1PageBasedVirtualSpace();
tschatzl@7051 88 bool initialize_with_granularity(ReservedSpace rs, size_t page_size);
tschatzl@7051 89
tschatzl@7051 90 // Destruction
tschatzl@7051 91 ~G1PageBasedVirtualSpace();
tschatzl@7051 92
tschatzl@7051 93 // Amount of reserved memory.
tschatzl@7051 94 size_t reserved_size() const;
tschatzl@7051 95 // Memory used in this virtual space.
tschatzl@7051 96 size_t committed_size() const;
tschatzl@7051 97 // Memory left to use/expand in this virtual space.
tschatzl@7051 98 size_t uncommitted_size() const;
tschatzl@7051 99
tschatzl@7051 100 bool contains(const void* p) const;
tschatzl@7051 101
tschatzl@7051 102 MemRegion reserved() {
tschatzl@7051 103 MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
tschatzl@7051 104 return x;
tschatzl@7051 105 }
tschatzl@7051 106
tschatzl@7051 107 void release();
tschatzl@7051 108
tschatzl@7051 109 void check_for_contiguity() PRODUCT_RETURN;
tschatzl@7051 110
tschatzl@7051 111 // Debugging
tschatzl@7051 112 void print_on(outputStream* out) PRODUCT_RETURN;
tschatzl@7051 113 void print();
tschatzl@7051 114 };
tschatzl@7051 115
tschatzl@7051 116 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP

mercurial