hotspot/src/share/vm/gc/g1/heapRegionType.hpp
author david
Tue, 29 Sep 2015 11:02:08 +0200
changeset 33105 294e48b4f704
parent 32623 390a27af5657
child 36098 e056a98ac7ca
permissions -rw-r--r--
8080775: Better argument formatting for assert() and friends Reviewed-by: kbarrett, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26846
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     4
 *
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     8
 *
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    13
 * accompanied this code).
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    14
 *
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    18
 *
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    21
 * questions.
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    22
 *
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    23
 */
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26846
diff changeset
    25
#ifndef SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26846
diff changeset
    26
#define SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    27
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    28
#include "memory/allocation.hpp"
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    29
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    30
#define hrt_assert_is_valid(tag) \
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
    31
  assert(is_valid((tag)), "invalid HR type: %u", (uint) (tag))
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    32
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    33
class HeapRegionType VALUE_OBJ_CLASS_SPEC {
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    34
private:
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    35
  // We encode the value of the heap region type so the generation can be
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    36
  // determined quickly. The tag is split into two parts:
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    37
  //
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31346
diff changeset
    38
  //   major type (young, old, humongous, archive)           : top N-1 bits
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    39
  //   minor type (eden / survivor, starts / cont hum, etc.) : bottom 1 bit
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    40
  //
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    41
  // If there's need to increase the number of minor types in the
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    42
  // future, we'll have to increase the size of the latter and hence
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    43
  // decrease the size of the former.
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    44
  //
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    45
  // 0000 0 [ 0] Free
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    46
  //
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    47
  // 0001 0 [ 2] Young Mask
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    48
  // 0001 0 [ 2] Eden
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    49
  // 0001 1 [ 3] Survivor
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    50
  //
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    51
  // 0010 0 [ 4] Humongous Mask
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    52
  // 0100 0 [ 8] Pinned Mask
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    53
  // 0110 0 [12] Starts Humongous
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    54
  // 0110 1 [13] Continues Humongous
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    55
  //
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    56
  // 1000 0 [16] Old Mask
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    57
  //
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    58
  // 1100 0 [24] Archive
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    59
  typedef enum {
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
    60
    FreeTag               = 0,
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    61
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
    62
    YoungMask             = 2,
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
    63
    EdenTag               = YoungMask,
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
    64
    SurvTag               = YoungMask + 1,
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    65
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
    66
    HumongousMask         = 4,
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    67
    PinnedMask            = 8,
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    68
    StartsHumongousTag    = HumongousMask | PinnedMask,
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    69
    ContinuesHumongousTag = HumongousMask | PinnedMask + 1,
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    70
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    71
    OldMask               = 16,
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    72
    OldTag                = OldMask,
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    73
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
    74
    ArchiveTag            = PinnedMask | OldMask
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    75
  } Tag;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    76
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    77
  volatile Tag _tag;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    78
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    79
  static bool is_valid(Tag tag);
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    80
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    81
  Tag get() const {
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    82
    hrt_assert_is_valid(_tag);
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    83
    return _tag;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    84
  }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    85
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    86
  // Sets the type to 'tag'.
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    87
  void set(Tag tag) {
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    88
    hrt_assert_is_valid(tag);
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    89
    hrt_assert_is_valid(_tag);
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    90
    _tag = tag;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    91
  }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    92
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    93
  // Sets the type to 'tag', expecting the type to be 'before'. This
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    94
  // is available for when we want to add sanity checking to the type
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    95
  // transition.
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    96
  void set_from(Tag tag, Tag before) {
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    97
    hrt_assert_is_valid(tag);
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    98
    hrt_assert_is_valid(before);
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
    99
    hrt_assert_is_valid(_tag);
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32623
diff changeset
   100
    assert(_tag == before, "HR tag: %u, expected: %u new tag; %u", _tag, before, tag);
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   101
    _tag = tag;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   102
  }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   103
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   104
public:
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   105
  // Queries
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   106
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   107
  bool is_free() const { return get() == FreeTag; }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   108
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   109
  bool is_young()    const { return (get() & YoungMask) != 0; }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   110
  bool is_eden()     const { return get() == EdenTag;  }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   111
  bool is_survivor() const { return get() == SurvTag;  }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   112
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
   113
  bool is_humongous()           const { return (get() & HumongousMask) != 0;   }
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
   114
  bool is_starts_humongous()    const { return get() == StartsHumongousTag;    }
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
   115
  bool is_continues_humongous() const { return get() == ContinuesHumongousTag; }
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   116
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   117
  bool is_archive() const { return get() == ArchiveTag; }
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   118
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   119
  // is_old regions may or may not also be pinned
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   120
  bool is_old() const { return (get() & OldMask) != 0; }
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   121
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   122
  // is_pinned regions may be archive or humongous
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   123
  bool is_pinned() const { return (get() & PinnedMask) != 0; }
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   124
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   125
  // Setters
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   126
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   127
  void set_free() { set(FreeTag); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   128
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   129
  void set_eden()        { set_from(EdenTag, FreeTag); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   130
  void set_eden_pre_gc() { set_from(EdenTag, SurvTag); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   131
  void set_survivor()    { set_from(SurvTag, FreeTag); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   132
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
   133
  void set_starts_humongous()    { set_from(StartsHumongousTag,    FreeTag); }
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26696
diff changeset
   134
  void set_continues_humongous() { set_from(ContinuesHumongousTag, FreeTag); }
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   135
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   136
  void set_old() { set(OldTag); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   137
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   138
  void set_archive() { set_from(ArchiveTag, FreeTag); }
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   139
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   140
  // Misc
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   141
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   142
  const char* get_str() const;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   143
  const char* get_short_str() const;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   144
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   145
  HeapRegionType() : _tag(FreeTag) { hrt_assert_is_valid(_tag); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   146
};
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents:
diff changeset
   147
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 26846
diff changeset
   148
#endif // SHARE_VM_GC_G1_HEAPREGIONTYPE_HPP