psPromotionLAB.inline.hpp revision 13249:a2753984d2c1
1/* 2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25#ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP 26#define SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP 27 28#include "gc/parallel/psPromotionLAB.hpp" 29#include "gc/shared/collectedHeap.inline.hpp" 30#include "utilities/align.hpp" 31 32HeapWord* PSYoungPromotionLAB::allocate(size_t size) { 33 // Can't assert this, when young fills, we keep the LAB around, but flushed. 34 // assert(_state != flushed, "Sanity"); 35 HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end(), SurvivorAlignmentInBytes); 36 if (obj == NULL) { 37 return NULL; 38 } 39 40 HeapWord* new_top = obj + size; 41 // The 'new_top>obj' check is needed to detect overflow of obj+size. 42 if (new_top > obj && new_top <= end()) { 43 set_top(new_top); 44 assert(is_aligned(obj, SurvivorAlignmentInBytes) && is_object_aligned(new_top), 45 "checking alignment"); 46 return obj; 47 } else { 48 set_top(obj); 49 return NULL; 50 } 51} 52 53#endif // SHARE_VM_GC_PARALLEL_PSPROMOTIONLAB_INLINE_HPP 54