view hotspot/src/share/vm/gc/shared/gcCause.hpp @ 37103:79c0f8e4b7b7

8062506: Java GCCause enum is out of sync with C++ GCCause enum Reviewed-by: stefank, tschatzl
author pliden
date Tue, 15 Mar 2016 08:01:50 +0100
parents be6025ebffea
children f025738bbada
line wrap: on
line source
 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit if you need additional information or have any
 * questions.


#include "memory/allocation.hpp"

// This class exposes implementation details of the various
// collector(s), and we need to be very careful with it. If
// use of this class grows, we should split it into public
// and implementation-private "causes".
// The definitions in the SA code should be kept in sync
// with the definitions here.

class GCCause : public AllStatic {
  enum Cause {
    /* public */

    /* implementation independent, but reserved for GC use */

    /* implementation specific */








  inline static bool is_user_requested_gc(GCCause::Cause cause) {
    return (cause == GCCause::_java_lang_system_gc ||
            cause == GCCause::_dcmd_gc_run);

  inline static bool is_serviceability_requested_gc(GCCause::Cause
                                                             cause) {
    return (cause == GCCause::_jvmti_force_gc ||
            cause == GCCause::_heap_inspection ||
            cause == GCCause::_heap_dump);

  // Causes for collection of the tenured gernation
  inline static bool is_tenured_allocation_failure_gc(GCCause::Cause cause) {
    assert(cause != GCCause::_old_generation_too_full_to_scavenge &&
           cause != GCCause::_old_generation_expanded_on_last_scavenge,
           "This GCCause may be correct but is not expected yet: %s",
    // _tenured_generation_full or _cms_generation_full for full tenured generations
    // _adaptive_size_policy for a full collection after a young GC
    // _allocation_failure is the generic cause a collection which could result
    // in the collection of the tenured generation if there is not enough space
    // in the tenured generation to support a young GC.
    // _last_ditch_collection is a collection done to include SoftReferences.
    return (cause == GCCause::_tenured_generation_full ||
            cause == GCCause::_cms_generation_full ||
            cause == GCCause::_adaptive_size_policy ||
            cause == GCCause::_allocation_failure ||
            cause == GCCause::_last_ditch_collection);

  // Causes for collection of the young generation
  inline static bool is_allocation_failure_gc(GCCause::Cause cause) {
    // _allocation_failure is the generic cause a collection for allocation failure
    // _adaptive_size_policy is for a collecton done before a full GC
    // _last_ditch_collection is a collection done to include SoftReferences.
    return (cause == GCCause::_allocation_failure ||
            cause == GCCause::_adaptive_size_policy ||
            cause == GCCause::_last_ditch_collection);

  // Return a string describing the GCCause.
  static const char* to_string(GCCause::Cause cause);