src/hotspot/share/gc/g1/g1HeapVerifier.hpp
author tschatzl
Sat, 18 May 2019 22:11:25 +0200
changeset 54934 39814e0a8964
parent 54923 23837d614c17
permissions -rw-r--r--
8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated Summary: Filter out cards from the current collection set during evacuation increments. Reviewed-by: kbarrett, sangheki
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52811
diff changeset
     2
 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     4
 *
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     8
 *
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    13
 * accompanied this code).
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    14
 *
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    18
 *
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    21
 * questions.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    22
 *
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    23
 */
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52811
diff changeset
    25
#ifndef SHARE_GC_G1_G1HEAPVERIFIER_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52811
diff changeset
    26
#define SHARE_GC_G1_G1HEAPVERIFIER_HPP
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    27
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    28
#include "gc/g1/heapRegionSet.hpp"
54781
f3f07c76d3d1 8223619: Move VerifyOption out of Universe
stefank
parents: 53244
diff changeset
    29
#include "gc/shared/verifyOption.hpp"
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    30
#include "memory/allocation.hpp"
49725
e740e1a38c96 8200550: Xcode 9.3 produce warning -Wexpansion-to-defined
kbarrett
parents: 49602
diff changeset
    31
#include "utilities/macros.hpp"
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    32
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    33
class G1CollectedHeap;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    34
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    35
class G1HeapVerifier : public CHeapObj<mtGC> {
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    36
private:
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 48179
diff changeset
    37
  static int _enabled_verification_types;
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 48179
diff changeset
    38
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    39
  G1CollectedHeap* _g1h;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    40
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    41
  void verify_region_sets();
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    42
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    43
public:
48179
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 47885
diff changeset
    44
  enum G1VerifyType {
50787
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 49725
diff changeset
    45
    G1VerifyYoungNormal     =  1, // -XX:VerifyGCType=young-normal
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 49725
diff changeset
    46
    G1VerifyConcurrentStart =  2, // -XX:VerifyGCType=concurrent-start
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 49725
diff changeset
    47
    G1VerifyMixed           =  4, // -XX:VerifyGCType=mixed
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 49725
diff changeset
    48
    G1VerifyRemark          =  8, // -XX:VerifyGCType=remark
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 49725
diff changeset
    49
    G1VerifyCleanup         = 16, // -XX:VerifyGCType=cleanup
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 49725
diff changeset
    50
    G1VerifyFull            = 32, // -XX:VerifyGCType=full
5f0266d16543 8204082: Make names of Young GCs more uniform in logs
tschatzl
parents: 49725
diff changeset
    51
    G1VerifyAll             = -1
48179
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 47885
diff changeset
    52
  };
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    53
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 48179
diff changeset
    54
  G1HeapVerifier(G1CollectedHeap* heap) : _g1h(heap) {}
48179
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 47885
diff changeset
    55
49602
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 48179
diff changeset
    56
  static void enable_verification_type(G1VerifyType type);
db050c11c3b5 8199850: Move parsing of VerifyGCType to G1
pliden
parents: 48179
diff changeset
    57
  static bool should_verify(G1VerifyType type);
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    58
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    59
  // Perform verification.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    60
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    61
  // vo == UsePrevMarking -> use "prev" marking information,
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    62
  // vo == UseNextMarking -> use "next" marking information
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    63
  // vo == UseFullMarking -> use "next" marking bitmap but no TAMS
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    64
  //
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    65
  // NOTE: Only the "prev" marking information is guaranteed to be
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    66
  // consistent most of the time, so most calls to this should use
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    67
  // vo == UsePrevMarking.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    68
  // Currently, there is only one case where this is called with
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    69
  // vo == UseNextMarking, which is to verify the "next" marking
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    70
  // information at the end of remark.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    71
  // Currently there is only one place where this is called with
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    72
  // vo == UseFullMarking, which is to verify the marking during a
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    73
  // full GC.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    74
  void verify(VerifyOption vo);
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    75
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    76
  // verify_region_sets_optional() is planted in the code for
49725
e740e1a38c96 8200550: Xcode 9.3 produce warning -Wexpansion-to-defined
kbarrett
parents: 49602
diff changeset
    77
  // list verification in debug builds.
e740e1a38c96 8200550: Xcode 9.3 produce warning -Wexpansion-to-defined
kbarrett
parents: 49602
diff changeset
    78
  void verify_region_sets_optional() { DEBUG_ONLY(verify_region_sets();) }
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    79
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    80
  void prepare_for_verify();
48179
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 47885
diff changeset
    81
  double verify(G1VerifyType type, VerifyOption vo, const char* msg);
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 47885
diff changeset
    82
  void verify_before_gc(G1VerifyType type);
34fe70d22e9c 8191821: Finer granularity for GC verification
sjohanss
parents: 47885
diff changeset
    83
  void verify_after_gc(G1VerifyType type);
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    84
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    85
#ifndef PRODUCT
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    86
  // Make sure that the given bitmap has no marked objects in the
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    87
  // range [from,limit). If it does, print an error message and return
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    88
  // false. Otherwise, just return true. bitmap_name should be "prev"
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    89
  // or "next".
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 39698
diff changeset
    90
  bool verify_no_bits_over_tams(const char* bitmap_name, const G1CMBitMap* const bitmap,
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    91
                                HeapWord* from, HeapWord* limit);
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    92
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    93
  // Verify that the prev / next bitmap range [tams,end) for the given
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    94
  // region has no marks. Return true if all is well, false if errors
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    95
  // are detected.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    96
  bool verify_bitmaps(const char* caller, HeapRegion* hr);
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    97
#endif // PRODUCT
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    98
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    99
  // If G1VerifyBitmaps is set, verify that the marking bitmaps for
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   100
  // the given region do not have any spurious marks. If errors are
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   101
  // detected, print appropriate error messages and crash.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   102
  void check_bitmaps(const char* caller, HeapRegion* hr) PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   103
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   104
  // If G1VerifyBitmaps is set, verify that the marking bitmaps do not
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   105
  // have any spurious marks. If errors are detected, print
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   106
  // appropriate error messages and crash.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   107
  void check_bitmaps(const char* caller) PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   108
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   109
  // Do sanity check on the contents of the in-cset fast test table.
54923
23837d614c17 8224038: Fix remaining InCSetState mentions
tschatzl
parents: 54786
diff changeset
   110
  bool check_region_attr_table() PRODUCT_RETURN_( return true; );
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   111
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   112
  void verify_card_table_cleanup() PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   113
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   114
  void verify_not_dirty_region(HeapRegion* hr) PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   115
  void verify_dirty_region(HeapRegion* hr) PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   116
  void verify_dirty_young_regions() PRODUCT_RETURN;
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   117
52811
ff04b71bf6f1 8214388: CDS dumping fails with java heap fragmentation
iklam
parents: 50787
diff changeset
   118
  static void verify_ready_for_archiving();
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   119
  static void verify_archive_regions();
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   120
};
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   121
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52811
diff changeset
   122
#endif // SHARE_GC_G1_G1HEAPVERIFIER_HPP