Tue, 24 Dec 2013 11:48:39 -0800
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
Summary: Copyright year updated for files modified during 2013
Reviewed-by: twisti, iveresov
stefank@5515 | 1 | /* |
stefank@5515 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
stefank@5515 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
stefank@5515 | 4 | * |
stefank@5515 | 5 | * This code is free software; you can redistribute it and/or modify it |
stefank@5515 | 6 | * under the terms of the GNU General Public License version 2 only, as |
stefank@5515 | 7 | * published by the Free Software Foundation. |
stefank@5515 | 8 | * |
stefank@5515 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
stefank@5515 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
stefank@5515 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
stefank@5515 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
stefank@5515 | 13 | * accompanied this code). |
stefank@5515 | 14 | * |
stefank@5515 | 15 | * You should have received a copy of the GNU General Public License version |
stefank@5515 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
stefank@5515 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
stefank@5515 | 18 | * |
stefank@5515 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
stefank@5515 | 20 | * or visit www.oracle.com if you need additional information or have any |
stefank@5515 | 21 | * questions. |
stefank@5515 | 22 | * |
stefank@5515 | 23 | */ |
stefank@5515 | 24 | |
stefank@5515 | 25 | #include "memory/allocation.inline.hpp" |
stefank@5515 | 26 | #include "memory/padded.hpp" |
stefank@5515 | 27 | #include "utilities/debug.hpp" |
stefank@5515 | 28 | #include "utilities/globalDefinitions.hpp" |
stefank@5515 | 29 | |
stefank@5515 | 30 | // Creates an aligned padded array. |
stefank@5515 | 31 | // The memory can't be deleted since the raw memory chunk is not returned. |
stefank@5515 | 32 | template <class T, MEMFLAGS flags, size_t alignment> |
stefank@5515 | 33 | PaddedEnd<T>* PaddedArray<T, flags, alignment>::create_unfreeable(uint length) { |
stefank@5515 | 34 | // Check that the PaddedEnd class works as intended. |
stefank@5515 | 35 | STATIC_ASSERT(is_size_aligned_(sizeof(PaddedEnd<T>), alignment)); |
stefank@5515 | 36 | |
stefank@5515 | 37 | // Allocate a chunk of memory large enough to allow for some alignment. |
stefank@5515 | 38 | void* chunk = AllocateHeap(length * sizeof(PaddedEnd<T, alignment>) + alignment, flags); |
stefank@5515 | 39 | |
stefank@5515 | 40 | // Make the initial alignment. |
stefank@5515 | 41 | PaddedEnd<T>* aligned_padded_array = (PaddedEnd<T>*)align_pointer_up(chunk, alignment); |
stefank@5515 | 42 | |
stefank@5515 | 43 | // Call the default constructor for each element. |
stefank@5515 | 44 | for (uint i = 0; i < length; i++) { |
stefank@5515 | 45 | ::new (&aligned_padded_array[i]) T(); |
stefank@5515 | 46 | } |
stefank@5515 | 47 | |
stefank@5515 | 48 | return aligned_padded_array; |
stefank@5515 | 49 | } |