Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/shenandoahAllocRequest.hpp
38920 views
/*1* Copyright (c) 2018, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/2223#ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHALLOCREQUEST_HPP24#define SHARE_VM_GC_SHENANDOAH_SHENANDOAHALLOCREQUEST_HPP2526#include "memory/allocation.hpp"2728class ShenandoahAllocRequest : public StackObj {29public:30enum Type {31_alloc_shared, // Allocate common, outside of TLAB32_alloc_shared_gc, // Allocate common, outside of GCLAB33_alloc_tlab, // Allocate TLAB34_alloc_gclab, // Allocate GCLAB35_ALLOC_LIMIT36};3738static const char* alloc_type_to_string(Type type) {39switch (type) {40case _alloc_shared:41return "Shared";42case _alloc_shared_gc:43return "Shared GC";44case _alloc_tlab:45return "TLAB";46case _alloc_gclab:47return "GCLAB";48default:49ShouldNotReachHere();50return "";51}52}5354private:55size_t _min_size;56size_t _requested_size;57size_t _actual_size;58Type _alloc_type;59#ifdef ASSERT60bool _actual_size_set;61#endif6263ShenandoahAllocRequest(size_t _min_size, size_t _requested_size, Type _alloc_type) :64_min_size(_min_size), _requested_size(_requested_size),65_actual_size(0), _alloc_type(_alloc_type)66#ifdef ASSERT67, _actual_size_set(false)68#endif69{}7071public:72static inline ShenandoahAllocRequest for_tlab(size_t requested_size) {73return ShenandoahAllocRequest(requested_size, requested_size, _alloc_tlab);74}7576static inline ShenandoahAllocRequest for_gclab(size_t min_size, size_t requested_size) {77return ShenandoahAllocRequest(min_size, requested_size, _alloc_gclab);78}7980static inline ShenandoahAllocRequest for_shared_gc(size_t requested_size) {81return ShenandoahAllocRequest(0, requested_size, _alloc_shared_gc);82}8384static inline ShenandoahAllocRequest for_shared(size_t requested_size) {85return ShenandoahAllocRequest(0, requested_size, _alloc_shared);86}8788inline size_t size() {89return _requested_size;90}9192inline Type type() {93return _alloc_type;94}9596inline const char* type_string() {97return alloc_type_to_string(_alloc_type);98}99100inline size_t min_size() {101assert (is_lab_alloc(), "Only access for LAB allocs");102return _min_size;103}104105inline size_t actual_size() {106assert (_actual_size_set, "Should be set");107return _actual_size;108}109110inline void set_actual_size(size_t v) {111#ifdef ASSERT112assert (!_actual_size_set, "Should not be set");113_actual_size_set = true;114#endif115_actual_size = v;116}117118inline bool is_mutator_alloc() {119switch (_alloc_type) {120case _alloc_tlab:121case _alloc_shared:122return true;123case _alloc_gclab:124case _alloc_shared_gc:125return false;126default:127ShouldNotReachHere();128return false;129}130}131132inline bool is_gc_alloc() {133switch (_alloc_type) {134case _alloc_tlab:135case _alloc_shared:136return false;137case _alloc_gclab:138case _alloc_shared_gc:139return true;140default:141ShouldNotReachHere();142return false;143}144}145146inline bool is_lab_alloc() {147switch (_alloc_type) {148case _alloc_tlab:149case _alloc_gclab:150return true;151case _alloc_shared:152case _alloc_shared_gc:153return false;154default:155ShouldNotReachHere();156return false;157}158}159};160161#endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHALLOCREQUEST_HPP162163164