/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
#include "gc_implementation/shared/gcUtil.hpp"
#include "oops/typeArrayOop.hpp"
#include "runtime/perfData.hpp"
class GlobalTLABStats;
// ThreadLocalAllocBuffer: a descriptor for thread-local storage used by
// the threads for allocation.
// It is thread-private at any time, but maybe multiplexed over
// time across multiple threads. The park()/unpark() pair is
// used to make it avaiable for such multiplexing.
friend class VMStructs;
private:
unsigned _number_of_refills;
unsigned _fast_refill_waste;
unsigned _slow_refill_waste;
unsigned _gc_waste;
unsigned _slow_allocations;
void accumulate_statistics();
void initialize_statistics();
// Make parsable and release it.
void reset();
// Resize based on amount of allocation, etc.
void resize();
void print_stats(const char* tag);
// statistics
public:
// do nothing. tlabs must be inited by initialize() calls
}
// Don't discard tlab if remaining space is larger than this.
// Allocate size HeapWords. The memory is NOT initialized to zero.
// Reserve space at the end of TLAB
}
// Return tlab size or remaining space in eden such that the
// space is large enough to hold obj_size and necessary fill space.
// Otherwise return 0;
// Record slow allocation
// Initialization at startup
static void startup_initialization();
// Make an in-use tlab parsable, optionally also retiring it.
void make_parsable(bool retire);
// Retire in-use tlab before allocation of a new tlab
void clear_before_allocation();
// Accumulate statistics across all tlabs before gc
static void accumulate_statistics_before_gc();
// Resize tlabs for all threads
static void resize_all_tlabs();
void initialize();
// Code generation support
static ByteSize refill_waste_limit_offset() { return byte_offset_of(ThreadLocalAllocBuffer, _refill_waste_limit ); }
static ByteSize number_of_refills_offset() { return byte_offset_of(ThreadLocalAllocBuffer, _number_of_refills ); }
static ByteSize fast_refill_waste_offset() { return byte_offset_of(ThreadLocalAllocBuffer, _fast_refill_waste ); }
static ByteSize slow_allocations_offset() { return byte_offset_of(ThreadLocalAllocBuffer, _slow_allocations ); }
void verify();
};
private:
// Accumulate perfdata in private variables because
// PerfData should be write-only for security reasons
// (see perfData.hpp)
unsigned _allocating_threads;
unsigned _total_refills;
unsigned _max_refills;
unsigned _total_slow_allocations;
unsigned _max_slow_allocations;
public:
// Initialize all counters
void initialize();
// Write all perf counters to the perf_counters
void publish();
void print();
// Accessors
unsigned allocating_threads_avg() {
}
return _total_allocation;
}
// Update methods
void update_allocating_threads() {
}
_total_refills += value;
}
}
_total_gc_waste += value;
}
}
}
}
};
#endif // SHARE_VM_MEMORY_THREADLOCALALLOCBUFFER_HPP