--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp Wed Nov 02 08:04:23 2011 +0100
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp Mon Nov 07 22:11:12 2011 -0500
@@ -47,8 +47,18 @@
class hrs_ext_msg;
+typedef enum {
+ HRSPhaseNone,
+ HRSPhaseEvacuation,
+ HRSPhaseCleanup,
+ HRSPhaseFullGC
+} HRSPhase;
+
+class HRSPhaseSetter;
+
class HeapRegionSetBase VALUE_OBJ_CLASS_SPEC {
friend class hrs_ext_msg;
+ friend class HRSPhaseSetter;
protected:
static size_t calculate_region_num(HeapRegion* hr);
@@ -80,6 +90,15 @@
size_t _calc_total_capacity_bytes;
size_t _calc_total_used_bytes;
+ // This is here so that it can be used in the subclasses to assert
+ // something different depending on which phase the GC is in. This
+ // can be particularly helpful in the check_mt_safety() methods.
+ static HRSPhase _phase;
+
+ // Only used by HRSPhaseSetter.
+ static void clear_phase();
+ static void set_phase(HRSPhase phase);
+
// verify_region() is used to ensure that the contents of a region
// added to / removed from a set are consistent. Different sets
// make different assumptions about the regions added to them. So
@@ -177,6 +196,16 @@
}
};
+class HRSPhaseSetter {
+public:
+ HRSPhaseSetter(HRSPhase phase) {
+ HeapRegionSetBase::set_phase(phase);
+ }
+ ~HRSPhaseSetter() {
+ HeapRegionSetBase::clear_phase();
+ }
+};
+
// These two macros are provided for convenience, to keep the uses of
// these two asserts a bit more concise.