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

     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP
    28 #include "memory/allocation.hpp"
    29 #include "memory/memRegion.hpp"
    30 #include "runtime/virtualspace.hpp"
    31 #include "utilities/bitMap.hpp"
    33 // Virtual space management helper for a virtual space with an OS page allocation
    34 // granularity.
    35 // (De-)Allocation requests are always OS page aligned by passing a page index
    36 // and multiples of pages.
    37 // The implementation gives an error when trying to commit or uncommit pages that
    38 // have already been committed or uncommitted.
    39 class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC {
    40   friend class VMStructs;
    41  private:
    42   // Reserved area addresses.
    43   char* _low_boundary;
    44   char* _high_boundary;
    46   // The commit/uncommit granularity in bytes.
    47   size_t _page_size;
    49   // Bitmap used for verification of commit/uncommit operations.
    50   BitMap _committed;
    52   // Indicates that the entire space has been committed and pinned in memory,
    53   // os::commit_memory() or os::uncommit_memory() have no function.
    54   bool _special;
    56   // Indicates whether the committed space should be executable.
    57   bool _executable;
    59   // Returns the index of the page which contains the given address.
    60   uintptr_t  addr_to_page_index(char* addr) const;
    61   // Returns the address of the given page index.
    62   char*  page_start(uintptr_t index);
    63   // Returns the byte size of the given number of pages.
    64   size_t byte_size_for_pages(size_t num);
    66   // Returns true if the entire area is backed by committed memory.
    67   bool is_area_committed(uintptr_t start, size_t size_in_pages) const;
    68   // Returns true if the entire area is not backed by committed memory.
    69   bool is_area_uncommitted(uintptr_t start, size_t size_in_pages) const;
    71  public:
    73   // Commit the given area of pages starting at start being size_in_pages large.
    74   MemRegion commit(uintptr_t start, size_t size_in_pages);
    76   // Uncommit the given area of pages starting at start being size_in_pages large.
    77   MemRegion uncommit(uintptr_t start, size_t size_in_pages);
    79   bool special() const { return _special; }
    81   // Initialization
    82   G1PageBasedVirtualSpace();
    83   bool initialize_with_granularity(ReservedSpace rs, size_t page_size);
    85   // Destruction
    86   ~G1PageBasedVirtualSpace();
    88   // Amount of reserved memory.
    89   size_t reserved_size() const;
    90   // Memory used in this virtual space.
    91   size_t committed_size() const;
    92   // Memory left to use/expand in this virtual space.
    93   size_t uncommitted_size() const;
    95   bool contains(const void* p) const;
    97   MemRegion reserved() {
    98     MemRegion x((HeapWord*)_low_boundary, reserved_size() / HeapWordSize);
    99     return x;
   100   }
   102   void release();
   104   void check_for_contiguity() PRODUCT_RETURN;
   106   // Debugging
   107   void print_on(outputStream* out) PRODUCT_RETURN;
   108   void print();
   109 };
   111 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1PAGEBASEDVIRTUALSPACE_HPP

mercurial