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

Mon, 19 Aug 2019 10:11:31 +0200

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 7195
c02ec279b062
permissions
-rw-r--r--

8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com

     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"
    29 #include "gc_implementation/g1/g1HeapRegionTraceType.hpp"
    31 #define hrt_assert_is_valid(tag) \
    32   assert(is_valid((tag)), err_msg("invalid HR type: %u", (uint) (tag)))
    34 class HeapRegionType VALUE_OBJ_CLASS_SPEC {
    35 private:
    36   // We encode the value of the heap region type so the generation can be
    37   // determined quickly. The tag is split into two parts:
    38   //
    39   //   major type (young, humongous)                         : top N-1 bits
    40   //   minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit
    41   //
    42   // If there's need to increase the number of minor types in the
    43   // future, we'll have to increase the size of the latter and hence
    44   // decrease the size of the former.
    45   //
    46   // 0000 0 [ 0] Free
    47   //
    48   // 0001 0      Young Mask
    49   // 0001 0 [ 2] Eden
    50   // 0001 1 [ 3] Survivor
    51   //
    52   // 0010 0      Humongous Mask
    53   // 0010 0 [ 4] Humongous Starts
    54   // 0010 1 [ 5] Humongous Continues
    55   //
    56   // 01000 [ 8] Old
    57   typedef enum {
    58     FreeTag       = 0,
    60     YoungMask     = 2,
    61     EdenTag       = YoungMask,
    62     SurvTag       = YoungMask + 1,
    64     HumMask       = 4,
    65     HumStartsTag  = HumMask,
    66     HumContTag    = HumMask + 1,
    68     OldTag        = 8
    69   } Tag;
    71   volatile Tag _tag;
    73   static bool is_valid(Tag tag);
    75   Tag get() const {
    76     hrt_assert_is_valid(_tag);
    77     return _tag;
    78   }
    80   // Sets the type to 'tag'.
    81   void set(Tag tag) {
    82     hrt_assert_is_valid(tag);
    83     hrt_assert_is_valid(_tag);
    84     _tag = tag;
    85   }
    87   // Sets the type to 'tag', expecting the type to be 'before'. This
    88   // is available for when we want to add sanity checking to the type
    89   // transition.
    90   void set_from(Tag tag, Tag before) {
    91     hrt_assert_is_valid(tag);
    92     hrt_assert_is_valid(before);
    93     hrt_assert_is_valid(_tag);
    94     assert(_tag == before,
    95            err_msg("HR tag: %u, expected: %u new tag; %u", _tag, before, tag));
    96     _tag = tag;
    97   }
    99 public:
   100   // Queries
   102   bool is_free() const { return get() == FreeTag; }
   104   bool is_young()    const { return (get() & YoungMask) != 0; }
   105   bool is_eden()     const { return get() == EdenTag;  }
   106   bool is_survivor() const { return get() == SurvTag;  }
   108   bool is_humongous()           const { return (get() & HumMask) != 0; }
   109   bool is_starts_humongous()    const { return get() == HumStartsTag;  }
   110   bool is_continues_humongous() const { return get() == HumContTag;    }
   112   bool is_old() const { return get() == OldTag; }
   114   // Setters
   116   void set_free() { set(FreeTag); }
   118   void set_eden()        { set_from(EdenTag, FreeTag); }
   119   void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
   120   void set_survivor()    { set_from(SurvTag, FreeTag); }
   122   void set_starts_humongous()    { set_from(HumStartsTag, FreeTag); }
   123   void set_continues_humongous() { set_from(HumContTag,   FreeTag); }
   125   void set_old() { set(OldTag); }
   127   // Misc
   129   const char* get_str() const;
   130   const char* get_short_str() const;
   131   G1HeapRegionTraceType::Type get_trace_type();
   133   HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
   134 };
   136 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONTYPE_HPP

mercurial