hotspot/src/share/vm/gc/g1/g1HeapVerifier.hpp
author mgerdin
Mon, 07 Mar 2016 17:23:59 +0100
changeset 37039 79f62b89a7a6
parent 35943 e726308008c0
child 39698 4016de4e596b
permissions -rw-r--r--
8151178: Move the collection set out of the G1 collector policy Summary: Create a G1CollectionSet class Reviewed-by: jwilhelm, tbenson, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     1
/*
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
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
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1HEAPVERIFIER_HPP
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    26
#define SHARE_VM_GC_G1_G1HEAPVERIFIER_HPP
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"
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    29
#include "memory/allocation.hpp"
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    30
#include "memory/universe.hpp"
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    31
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    32
class G1CollectedHeap;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    33
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    34
class G1HeapVerifier : public CHeapObj<mtGC> {
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    35
private:
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    36
  G1CollectedHeap* _g1h;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    37
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    38
  // verify_region_sets() performs verification over the region
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    39
  // lists. It will be compiled in the product code to be used when
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    40
  // necessary (i.e., during heap verification).
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:
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    44
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    45
  G1HeapVerifier(G1CollectedHeap* heap) : _g1h(heap) { }
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    46
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    47
  // Perform verification.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    48
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    49
  // vo == UsePrevMarking  -> use "prev" marking information,
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    50
  // vo == UseNextMarking -> use "next" marking information
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    51
  // vo == UseMarkWord    -> use the mark word in the object header
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    52
  //
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    53
  // NOTE: Only the "prev" marking information is guaranteed to be
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    54
  // consistent most of the time, so most calls to this should use
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    55
  // vo == UsePrevMarking.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    56
  // Currently, there is only one case where this is called with
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    57
  // vo == UseNextMarking, which is to verify the "next" marking
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    58
  // information at the end of remark.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    59
  // Currently there is only one place where this is called with
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    60
  // vo == UseMarkWord, which is to verify the marking during a
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    61
  // full GC.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    62
  void verify(VerifyOption vo);
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    63
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    64
  // verify_region_sets_optional() is planted in the code for
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    65
  // list verification in non-product builds (and it can be enabled in
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    66
  // product builds by defining HEAP_REGION_SET_FORCE_VERIFY to be 1).
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    67
#if HEAP_REGION_SET_FORCE_VERIFY
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    68
  void verify_region_sets_optional() {
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    69
    verify_region_sets();
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    70
  }
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    71
#else // HEAP_REGION_SET_FORCE_VERIFY
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    72
  void verify_region_sets_optional() { }
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    73
#endif // HEAP_REGION_SET_FORCE_VERIFY
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    74
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    75
  void prepare_for_verify();
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    76
  double verify(bool guard, const char* msg);
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    77
  void verify_before_gc();
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    78
  void verify_after_gc();
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
#ifndef PRODUCT
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    81
  // Make sure that the given bitmap has no marked objects in the
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    82
  // range [from,limit). If it does, print an error message and return
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    83
  // false. Otherwise, just return true. bitmap_name should be "prev"
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    84
  // or "next".
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35851
diff changeset
    85
  bool verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap,
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    86
                                HeapWord* from, HeapWord* limit);
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    87
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    88
  // Verify that the prev / next bitmap range [tams,end) for the given
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    89
  // 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
    90
  // are detected.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    91
  bool verify_bitmaps(const char* caller, HeapRegion* hr);
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    92
#endif // PRODUCT
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    93
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    94
  // If G1VerifyBitmaps is set, verify that the marking bitmaps for
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    95
  // the given region do not have any spurious marks. If errors are
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    96
  // detected, print appropriate error messages and crash.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
    97
  void check_bitmaps(const char* caller, HeapRegion* hr) PRODUCT_RETURN;
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 do not
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   100
  // have any spurious marks. If errors are detected, print
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   101
  // appropriate error messages and crash.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   102
  void check_bitmaps(const char* caller) 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
  // Do sanity check on the contents of the in-cset fast test table.
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   105
  bool check_cset_fast_test() PRODUCT_RETURN_( return true; );
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   106
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   107
  void verify_card_table_cleanup() 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
  void verify_not_dirty_region(HeapRegion* hr) PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   110
  void verify_dirty_region(HeapRegion* hr) PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   111
  void verify_dirty_young_list(HeapRegion* head) PRODUCT_RETURN;
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   112
  void verify_dirty_young_regions() 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
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents:
diff changeset
   115
#endif // SHARE_VM_GC_G1_G1HEAPVERIFIER_HPP