--- /dev/null 2015-02-26 11:35:21.495574995 +0100 +++ new/src/share/vm/gc_implementation/g1/g1EvacStats.hpp 2015-03-05 15:35:48.194751317 +0100 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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 www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1EVACSTATS_HPP +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1EVACSTATS_HPP + +#include "gc_implementation/shared/parGCAllocBuffer.hpp" + +// Records various memory allocation statistics gathered during evacuation. +class G1EvacStats : public PLABStats { + private: + size_t _undo_waste; // Number of words wasted within PLABs due to allocation undos. + size_t _region_end_waste; // Number of words wasted due to skipping to the next region. + uint _regions_filled; // Number of regions filled completely. + size_t _inline_allocated; // Number of words allocated directly into the regions. + + // Number of words allocated during evacuation failure in the regions that failed evacuation. + size_t _failure_used; + // Number of words wasted during evacuation failure in the regions that failed evacuation. + size_t _failure_waste; + + virtual void reset() { + PLABStats::reset(); + _undo_waste = 0; + _region_end_waste = 0; + _regions_filled = 0; + _inline_allocated = 0; + _failure_used = 0; + _failure_waste = 0; + } + + public: + G1EvacStats(size_t desired_plab_sz_, unsigned wt) : PLABStats(desired_plab_sz_, wt), + _undo_waste(0), _region_end_waste(0), _regions_filled(0), _inline_allocated(0), + _failure_used(0), _failure_waste(0) { + } + + virtual void adjust_desired_plab_sz(uint no_of_gc_workers); + + size_t allocated() const { return _allocated; } + size_t wasted() const { return _wasted; } + size_t unused() const { return _unused; } + size_t used() const { return allocated() - (wasted() + unused()); } + size_t undo_waste() const { return _undo_waste; } + uint regions_refilled() const { return _regions_filled; } + size_t region_end_waste() const { return _region_end_waste; } + size_t inline_allocated() const { return _inline_allocated; } + + size_t failure_used() const { return _failure_used; } + size_t failure_waste() const { return _failure_waste; } + + void add_inline_allocated(size_t value) { + Atomic::add_ptr(value, &_inline_allocated); + } + + void add_undo_waste(size_t value) { + Atomic::add_ptr(value, &_undo_waste); + } + + void add_region_end_waste(size_t value) { + Atomic::add_ptr(value, &_region_end_waste); + Atomic::add_ptr(1, &_regions_filled); + } + + void add_failure_used_and_waste(size_t used, size_t waste) { + Atomic::add_ptr(used, &_failure_used); + Atomic::add_ptr(waste, &_failure_waste); + } +}; + +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1EVACSTATS_HPP