Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp
38920 views
/*1* Copyright (c) 2011, 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_G1_G1ALLOCREGION_INLINE_HPP25#define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP2627#include "gc_implementation/g1/g1AllocRegion.hpp"28#include "gc_implementation/g1/heapRegion.inline.hpp"2930inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,31size_t word_size,32bool bot_updates) {33assert(alloc_region != NULL, err_msg("pre-condition"));3435if (!bot_updates) {36return alloc_region->allocate_no_bot_updates(word_size);37} else {38return alloc_region->allocate(word_size);39}40}4142inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,43size_t word_size,44bool bot_updates) {45assert(alloc_region != NULL, err_msg("pre-condition"));46assert(!alloc_region->is_empty(), err_msg("pre-condition"));4748if (!bot_updates) {49return alloc_region->par_allocate_no_bot_updates(word_size);50} else {51return alloc_region->par_allocate(word_size);52}53}5455inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size,56bool bot_updates) {57assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));5859HeapRegion* alloc_region = _alloc_region;60assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));6162HeapWord* result = par_allocate(alloc_region, word_size, bot_updates);63if (result != NULL) {64trace("alloc", word_size, result);65return result;66}67trace("alloc failed", word_size);68return NULL;69}7071inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size,72bool bot_updates) {73// First we have to tedo the allocation, assuming we're holding the74// appropriate lock, in case another thread changed the region while75// we were waiting to get the lock.76HeapWord* result = attempt_allocation(word_size, bot_updates);77if (result != NULL) {78return result;79}8081retire(true /* fill_up */);82result = new_alloc_region_and_allocate(word_size, false /* force */);83if (result != NULL) {84trace("alloc locked (second attempt)", word_size, result);85return result;86}87trace("alloc locked failed", word_size);88return NULL;89}9091inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,92bool bot_updates) {93assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));94assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));9596trace("forcing alloc");97HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);98if (result != NULL) {99trace("alloc forced", word_size, result);100return result;101}102trace("alloc forced failed", word_size);103return NULL;104}105106#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP107108109