Fri, 21 Feb 2014 10:01:20 +0100
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
Reviewed-by: tschatzl, coleenp
stefank@5515 | 1 | /* |
tschatzl@6403 | 2 | * Copyright (c) 2013, 2014, 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 | } |
tschatzl@6403 | 50 | |
tschatzl@6403 | 51 | template <class T, MEMFLAGS flags, size_t alignment> |
tschatzl@6403 | 52 | T** Padded2DArray<T, flags, alignment>::create_unfreeable(uint rows, uint columns, size_t* allocation_size) { |
tschatzl@6403 | 53 | // Calculate and align the size of the first dimension's table. |
tschatzl@6403 | 54 | size_t table_size = align_size_up_(rows * sizeof(T*), alignment); |
tschatzl@6403 | 55 | // The size of the separate rows. |
tschatzl@6403 | 56 | size_t row_size = align_size_up_(columns * sizeof(T), alignment); |
tschatzl@6403 | 57 | // Total size consists of the indirection table plus the rows. |
tschatzl@6403 | 58 | size_t total_size = table_size + rows * row_size + alignment; |
tschatzl@6403 | 59 | |
tschatzl@6403 | 60 | // Allocate a chunk of memory large enough to allow alignment of the chunk. |
tschatzl@6403 | 61 | void* chunk = AllocateHeap(total_size, flags); |
tschatzl@6403 | 62 | // Clear the allocated memory. |
tschatzl@6403 | 63 | memset(chunk, 0, total_size); |
tschatzl@6403 | 64 | // Align the chunk of memory. |
tschatzl@6403 | 65 | T** result = (T**)align_pointer_up(chunk, alignment); |
tschatzl@6403 | 66 | void* data_start = (void*)((uintptr_t)result + table_size); |
tschatzl@6403 | 67 | |
tschatzl@6403 | 68 | // Fill in the row table. |
tschatzl@6403 | 69 | for (size_t i = 0; i < rows; i++) { |
tschatzl@6403 | 70 | result[i] = (T*)((uintptr_t)data_start + i * row_size); |
tschatzl@6403 | 71 | } |
tschatzl@6403 | 72 | |
tschatzl@6403 | 73 | if (allocation_size != NULL) { |
tschatzl@6403 | 74 | *allocation_size = total_size; |
tschatzl@6403 | 75 | } |
tschatzl@6403 | 76 | |
tschatzl@6403 | 77 | return result; |
tschatzl@6403 | 78 | } |
tschatzl@6409 | 79 | |
tschatzl@6409 | 80 | template <class T, MEMFLAGS flags, size_t alignment> |
tschatzl@6409 | 81 | T* PaddedPrimitiveArray<T, flags, alignment>::create_unfreeable(size_t length) { |
tschatzl@6409 | 82 | // Allocate a chunk of memory large enough to allow for some alignment. |
tschatzl@6409 | 83 | void* chunk = AllocateHeap(length * sizeof(T) + alignment, flags); |
tschatzl@6409 | 84 | |
tschatzl@6409 | 85 | memset(chunk, 0, length * sizeof(T) + alignment); |
tschatzl@6409 | 86 | |
tschatzl@6409 | 87 | return (T*)align_pointer_up(chunk, alignment); |
tschatzl@6409 | 88 | } |