Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shared/gSpaceCounters.hpp
38921 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_IMPLEMENTATION_SHARED_GSPACECOUNTERS_HPP25#define SHARE_VM_GC_IMPLEMENTATION_SHARED_GSPACECOUNTERS_HPP2627#include "utilities/macros.hpp"28#if INCLUDE_ALL_GCS29#include "gc_implementation/shared/generationCounters.hpp"30#include "memory/generation.hpp"31#include "runtime/perfData.hpp"32#endif // INCLUDE_ALL_GCS3334// A GSpaceCounter is a holder class for performance counters35// that track a space;3637class GSpaceCounters: public CHeapObj<mtGC> {38friend class VMStructs;3940private:41PerfVariable* _capacity;42PerfVariable* _used;4344// Constant PerfData types don't need to retain a reference.45// However, it's a good idea to document them here.46// PerfConstant* _size;4748Generation* _gen;49char* _name_space;5051public:5253GSpaceCounters(const char* name, int ordinal, size_t max_size, Generation* g,54GenerationCounters* gc, bool sampled=true);5556~GSpaceCounters() {57if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space, mtGC);58}5960inline void update_capacity() {61_capacity->set_value(_gen->capacity());62}6364inline void update_used() {65_used->set_value(_gen->used_stable());66}6768// special version of update_used() to allow the used value to be69// passed as a parameter. This method can can be used in cases were70// the utilization is already known and/or when the _gen->used()71// method is known to be expensive and we want to avoid unnecessary72// calls to it.73//74inline void update_used(size_t used) {75_used->set_value(used);76}7778inline void inc_used(size_t size) {79_used->inc(size);80}8182debug_only(83// for security reasons, we do not allow arbitrary reads from84// the counters as they may live in shared memory.85jlong used() {86return _used->get_value();87}88jlong capacity() {89return _used->get_value();90}91)9293inline void update_all() {94update_used();95update_capacity();96}9798const char* name_space() const { return _name_space; }99};100101class GenerationUsedHelper : public PerfLongSampleHelper {102private:103Generation* _gen;104105public:106GenerationUsedHelper(Generation* g) : _gen(g) { }107108inline jlong take_sample() {109return _gen->used_stable();110}111};112113#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GSPACECOUNTERS_HPP114115116