Path: blob/master/src/hotspot/share/gc/shared/copyFailedInfo.hpp
40957 views
/*1* Copyright (c) 2012, 2019, 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_GC_SHARED_COPYFAILEDINFO_HPP25#define SHARE_GC_SHARED_COPYFAILEDINFO_HPP2627#include "jfr/support/jfrThreadId.hpp"28#include "runtime/thread.hpp"29#include "utilities/globalDefinitions.hpp"3031class CopyFailedInfo : public CHeapObj<mtGC> {32size_t _first_size;33size_t _smallest_size;34size_t _total_size;35uint _count;3637public:38CopyFailedInfo() : _first_size(0), _smallest_size(0), _total_size(0), _count(0) {}3940virtual void register_copy_failure(size_t size) {41if (_first_size == 0) {42_first_size = size;43_smallest_size = size;44} else if (size < _smallest_size) {45_smallest_size = size;46}47_total_size += size;48_count++;49}5051virtual void reset() {52_first_size = 0;53_smallest_size = 0;54_total_size = 0;55_count = 0;56}5758bool has_failed() const { return _count != 0; }59size_t first_size() const { return _first_size; }60size_t smallest_size() const { return _smallest_size; }61size_t total_size() const { return _total_size; }62uint failed_count() const { return _count; }63};6465class PromotionFailedInfo : public CopyFailedInfo {66traceid _thread_trace_id;6768public:69PromotionFailedInfo() : CopyFailedInfo(), _thread_trace_id(0) {}7071void register_copy_failure(size_t size) {72CopyFailedInfo::register_copy_failure(size);73if (_thread_trace_id == 0) {74_thread_trace_id = JFR_THREAD_ID(Thread::current());75} else {76assert(JFR_THREAD_ID(Thread::current()) == _thread_trace_id,77"The PromotionFailedInfo should be thread local.");78}79}8081void reset() {82CopyFailedInfo::reset();83_thread_trace_id = 0;84}8586traceid thread_trace_id() const { return _thread_trace_id; }8788};8990class EvacuationFailedInfo : public CopyFailedInfo {};9192#endif // SHARE_GC_SHARED_COPYFAILEDINFO_HPP939495