hotspot/src/share/vm/gc/shared/gcId.hpp
author mlarsson
Mon, 04 Jan 2016 11:27:02 +0100
changeset 35227 176e593eb364
parent 35061 be6025ebffea
permissions -rw-r--r--
8065331: Add trace events for failed allocations Reviewed-by: brutisso, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25350
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     1
/*
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25350
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
25350
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     4
 *
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     8
 *
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    13
 * accompanied this code).
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    14
 *
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    18
 *
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    21
 * questions.
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    22
 *
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    23
 */
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25350
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_GCID_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25350
diff changeset
    26
#define SHARE_VM_GC_SHARED_GCID_HPP
25350
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    27
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    28
#include "memory/allocation.hpp"
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    29
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    30
class GCId : public AllStatic {
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    31
  friend class GCIdMark;
33146
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    32
  friend class GCIdMarkAndRestore;
25350
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    33
  static uint _next_id;
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    34
  static const uint UNDEFINED = (uint)-1;
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    35
  static const uint create();
25350
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    36
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    37
 public:
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    38
  // Returns the currently active GC id. Asserts that there is an active GC id.
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    39
  static const uint current();
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    40
  // Same as current() but can return undefined() if no GC id is currently active
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    41
  static const uint current_raw();
35227
176e593eb364 8065331: Add trace events for failed allocations
mlarsson
parents: 35061
diff changeset
    42
  // Returns the next expected GCId.
176e593eb364 8065331: Add trace events for failed allocations
mlarsson
parents: 35061
diff changeset
    43
  static const uint peek();
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    44
  static const uint undefined() { return UNDEFINED; }
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33152
diff changeset
    45
  static size_t print_prefix(char* buf, size_t len);
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    46
};
25350
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    47
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    48
class GCIdMark : public StackObj {
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    49
  uint _gc_id;
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    50
 public:
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    51
  GCIdMark();
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    52
  GCIdMark(uint gc_id);
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 30764
diff changeset
    53
  ~GCIdMark();
25350
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    54
};
6423a57e5451 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
brutisso
parents:
diff changeset
    55
33146
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    56
class GCIdMarkAndRestore : public StackObj {
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    57
  uint _gc_id;
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    58
  uint _previous_gc_id;
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    59
 public:
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    60
  GCIdMarkAndRestore();
33152
6ad7fe735042 8139293: TestGCEventMixedWithG1ConcurrentMark.java fails after JDK-8134953
brutisso
parents: 33146
diff changeset
    61
  GCIdMarkAndRestore(uint gc_id);
33146
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    62
  ~GCIdMarkAndRestore();
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    63
};
77349b58b4c0 8138717: TestGCEventMixedWithG1ConcurrentMark.java fails
brutisso
parents: 33107
diff changeset
    64
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 25350
diff changeset
    65
#endif // SHARE_VM_GC_SHARED_GCID_HPP