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

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

author
tschatzl
date
Fri, 10 Oct 2014 15:51:58 +0200
changeset 7257
e7d0505c8a30
parent 7195
c02ec279b062
child 9861
a248d0be1309
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_HEAPREGIONTYPE_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP
    28 #include "memory/allocation.hpp"
    30 #define hrt_assert_is_valid(tag) \
    31   assert(is_valid((tag)), err_msg("invalid HR type: %u", (uint) (tag)))
    33 class HeapRegionType VALUE_OBJ_CLASS_SPEC {
    34 private:
    35   // We encode the value of the heap region type so the generation can be
    36   // determined quickly. The tag is split into two parts:
    37   //
    38   //   major type (young, humongous)                         : top N-1 bits
    39   //   minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit
    40   //
    41   // If there's need to increase the number of minor types in the
    42   // future, we'll have to increase the size of the latter and hence
    43   // decrease the size of the former.
    44   //
    45   // 0000 0 [ 0] Free
    46   //
    47   // 0001 0      Young Mask
    48   // 0001 0 [ 2] Eden
    49   // 0001 1 [ 3] Survivor
    50   //
    51   // 0010 0      Humongous Mask
    52   // 0010 0 [ 4] Humongous Starts
    53   // 0010 1 [ 5] Humongous Continues
    54   //
    55   // 01000 [ 8] Old
    56   typedef enum {
    57     FreeTag       = 0,
    59     YoungMask     = 2,
    60     EdenTag       = YoungMask,
    61     SurvTag       = YoungMask + 1,
    63     HumMask       = 4,
    64     HumStartsTag  = HumMask,
    65     HumContTag    = HumMask + 1,
    67     OldTag        = 8
    68   } Tag;
    70   volatile Tag _tag;
    72   static bool is_valid(Tag tag);
    74   Tag get() const {
    75     hrt_assert_is_valid(_tag);
    76     return _tag;
    77   }
    79   // Sets the type to 'tag'.
    80   void set(Tag tag) {
    81     hrt_assert_is_valid(tag);
    82     hrt_assert_is_valid(_tag);
    83     _tag = tag;
    84   }
    86   // Sets the type to 'tag', expecting the type to be 'before'. This
    87   // is available for when we want to add sanity checking to the type
    88   // transition.
    89   void set_from(Tag tag, Tag before) {
    90     hrt_assert_is_valid(tag);
    91     hrt_assert_is_valid(before);
    92     hrt_assert_is_valid(_tag);
    93     assert(_tag == before,
    94            err_msg("HR tag: %u, expected: %u new tag; %u", _tag, before, tag));
    95     _tag = tag;
    96   }
    98 public:
    99   // Queries
   101   bool is_free() const { return get() == FreeTag; }
   103   bool is_young()    const { return (get() & YoungMask) != 0; }
   104   bool is_eden()     const { return get() == EdenTag;  }
   105   bool is_survivor() const { return get() == SurvTag;  }
   107   bool is_humongous()           const { return (get() & HumMask) != 0; }
   108   bool is_starts_humongous()    const { return get() == HumStartsTag;  }
   109   bool is_continues_humongous() const { return get() == HumContTag;    }
   111   bool is_old() const { return get() == OldTag; }
   113   // Setters
   115   void set_free() { set(FreeTag); }
   117   void set_eden()        { set_from(EdenTag, FreeTag); }
   118   void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
   119   void set_survivor()    { set_from(SurvTag, FreeTag); }
   121   void set_starts_humongous()    { set_from(HumStartsTag, FreeTag); }
   122   void set_continues_humongous() { set_from(HumContTag,   FreeTag); }
   124   void set_old() { set(OldTag); }
   126   // Misc
   128   const char* get_str() const;
   129   const char* get_short_str() const;
   131   HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
   132 };
   134 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP

mercurial