Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_interface/gcCause.hpp
32285 views
/*1* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_GC_INTERFACE_GCCAUSE_HPP25#define SHARE_VM_GC_INTERFACE_GCCAUSE_HPP2627#include "memory/allocation.hpp"2829//30// This class exposes implementation details of the various31// collector(s), and we need to be very careful with it. If32// use of this class grows, we should split it into public33// and implemenation-private "causes".34//3536class GCCause : public AllStatic {37public:38enum Cause {39/* public */40_java_lang_system_gc,41_full_gc_alot,42_scavenge_alot,43_allocation_profiler,44_jvmti_force_gc,45_gc_locker,46_heap_inspection,47_heap_dump,48_wb_young_gc,49_wb_conc_mark,50_update_allocation_context_stats_inc,51_update_allocation_context_stats_full,5253/* implementation independent, but reserved for GC use */54_no_gc,55_no_cause_specified,56_allocation_failure,5758/* implementation specific */5960_tenured_generation_full,61_metadata_GC_threshold,6263_cms_generation_full,64_cms_initial_mark,65_cms_final_remark,66_cms_concurrent_mark,6768_old_generation_expanded_on_last_scavenge,69_old_generation_too_full_to_scavenge,70_adaptive_size_policy,7172_g1_inc_collection_pause,73_g1_humongous_allocation,7475_shenandoah_stop_vm,76_shenandoah_metadata_gc_clear_softrefs,77_shenandoah_allocation_failure_evac,78_shenandoah_concurrent_gc,79_shenandoah_upgrade_to_full_gc,8081_last_ditch_collection,82_last_gc_cause83};8485inline static bool is_user_requested_gc(GCCause::Cause cause) {86return (cause == GCCause::_java_lang_system_gc ||87cause == GCCause::_jvmti_force_gc);88}8990inline static bool is_serviceability_requested_gc(GCCause::Cause91cause) {92return (cause == GCCause::_jvmti_force_gc ||93cause == GCCause::_heap_inspection ||94cause == GCCause::_heap_dump);95}9697// Return a string describing the GCCause.98static const char* to_string(GCCause::Cause cause);99};100101// Helper class for doing logging that includes the GC Cause102// as a string.103class GCCauseString : StackObj {104private:105static const int _length = 128;106char _buffer[_length];107int _position;108109public:110GCCauseString(const char* prefix, GCCause::Cause cause) {111if (PrintGCCause) {112_position = jio_snprintf(_buffer, _length, "%s (%s) ", prefix, GCCause::to_string(cause));113} else {114_position = jio_snprintf(_buffer, _length, "%s ", prefix);115}116assert(_position >= 0 && _position <= _length,117err_msg("Need to increase the buffer size in GCCauseString? %d", _position));118}119120GCCauseString& append(const char* str) {121int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str);122_position += res;123assert(res >= 0 && _position <= _length,124err_msg("Need to increase the buffer size in GCCauseString? %d", res));125return *this;126}127128operator const char*() {129return _buffer;130}131};132133#endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP134135136