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

Fri, 10 Oct 2014 15:51:58 +0200

author
tschatzl
date
Fri, 10 Oct 2014 15:51:58 +0200
changeset 7257
e7d0505c8a30
parent 7051
1f1d373cd044
child 7509
ae52ee069062
permissions
-rw-r--r--

8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
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@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
tschatzl@7051 52 // Indicates that the entire space has been committed and pinned in memory,
tschatzl@7051 53 // os::commit_memory() or os::uncommit_memory() have no function.
tschatzl@7051 54 bool _special;
tschatzl@7051 55
tschatzl@7051 56 // Indicates whether the committed space should be executable.
tschatzl@7051 57 bool _executable;
tschatzl@7051 58
tschatzl@7051 59 // Returns the index of the page which contains the given address.
tschatzl@7051 60 uintptr_t addr_to_page_index(char* addr) const;
tschatzl@7051 61 // Returns the address of the given page index.
tschatzl@7051 62 char* page_start(uintptr_t index);
tschatzl@7051 63 // Returns the byte size of the given number of pages.
tschatzl@7051 64 size_t byte_size_for_pages(size_t num);
tschatzl@7051 65
tschatzl@7051 66 // Returns true if the entire area is backed by committed memory.
tschatzl@7051 67 bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
tschatzl@7051 68 // Returns true if the entire area is not backed by committed memory.
tschatzl@7051 69 bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
tschatzl@7051 70
tschatzl@7051 71 public:
tschatzl@7051 72
tschatzl@7051 73 // Commit the given area of pages starting at start being size_in_pages large.
tschatzl@7051 74 MemRegion commit(uintptr_t start, size_t size_in_pages);
tschatzl@7051 75
tschatzl@7051 76 // Uncommit the given area of pages starting at start being size_in_pages large.
tschatzl@7051 77 MemRegion uncommit(uintptr_t start, size_t size_in_pages);
tschatzl@7051 78
tschatzl@7051 79 bool special() const { return _special; }
tschatzl@7051 80
tschatzl@7051 81 // Initialization
tschatzl@7051 82 G1PageBasedVirtualSpace();
tschatzl@7051 83 bool initialize_with_granularity(ReservedSpace rs, size_t page_size);
tschatzl@7051 84
tschatzl@7051 85 // Destruction
tschatzl@7051 86 ~G1PageBasedVirtualSpace();
tschatzl@7051 87
tschatzl@7051 88 // Amount of reserved memory.
tschatzl@7051 89 size_t reserved_size() const;
tschatzl@7051 90 // Memory used in this virtual space.
tschatzl@7051 91 size_t committed_size() const;
tschatzl@7051 92 // Memory left to use/expand in this virtual space.
tschatzl@7051 93 size_t uncommitted_size() const;
tschatzl@7051 94
tschatzl@7051 95 bool contains(const void* p) const;
tschatzl@7051 96
tschatzl@7051 97 MemRegion reserved() {
tschatzl@7051 98 MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
tschatzl@7051 99 return x;
tschatzl@7051 100 }
tschatzl@7051 101
tschatzl@7051 102 void release();
tschatzl@7051 103
tschatzl@7051 104 void check_for_contiguity() PRODUCT_RETURN;
tschatzl@7051 105
tschatzl@7051 106 // Debugging
tschatzl@7051 107 void print_on(outputStream* out) PRODUCT_RETURN;
tschatzl@7051 108 void print();
tschatzl@7051 109 };
tschatzl@7051 110
tschatzl@7051 111 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP

mercurial