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_MEMORY_PADDED_INLINE_HPP
26 #define SHARE_VM_MEMORY_PADDED_INLINE_HPP
27
28 #include "memory/allocation.inline.hpp"
29 #include "memory/padded.hpp"
30 #include "utilities/debug.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 // Creates an aligned padded array.
34 // The memory can't be deleted since the raw memory chunk is not returned.
35 template <class T, MEMFLAGS flags, size_t alignment>
36 PaddedEnd<T>* PaddedArray<T, flags, alignment>::create_unfreeable(uint length) {
37 // Check that the PaddedEnd class works as intended.
38 STATIC_ASSERT(is_aligned_(sizeof(PaddedEnd<T>), alignment));
39
40 // Allocate a chunk of memory large enough to allow for some alignment.
41 void* chunk = AllocateHeap(length * sizeof(PaddedEnd<T, alignment>) + alignment, flags);
42
43 // Make the initial alignment.
44 PaddedEnd<T>* aligned_padded_array = (PaddedEnd<T>*)align_up(chunk, alignment);
45
46 // Call the default constructor for each element.
47 for (uint i = 0; i < length; i++) {
48 ::new (&aligned_padded_array[i]) T();
49 }
|
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_MEMORY_PADDED_INLINE_HPP
26 #define SHARE_VM_MEMORY_PADDED_INLINE_HPP
27
28 #include "memory/allocation.inline.hpp"
29 #include "memory/padded.hpp"
30 #include "utilities/align.hpp"
31 #include "utilities/debug.hpp"
32 #include "utilities/globalDefinitions.hpp"
33
34 // Creates an aligned padded array.
35 // The memory can't be deleted since the raw memory chunk is not returned.
36 template <class T, MEMFLAGS flags, size_t alignment>
37 PaddedEnd<T>* PaddedArray<T, flags, alignment>::create_unfreeable(uint length) {
38 // Check that the PaddedEnd class works as intended.
39 STATIC_ASSERT(is_aligned_(sizeof(PaddedEnd<T>), alignment));
40
41 // Allocate a chunk of memory large enough to allow for some alignment.
42 void* chunk = AllocateHeap(length * sizeof(PaddedEnd<T, alignment>) + alignment, flags);
43
44 // Make the initial alignment.
45 PaddedEnd<T>* aligned_padded_array = (PaddedEnd<T>*)align_up(chunk, alignment);
46
47 // Call the default constructor for each element.
48 for (uint i = 0; i < length; i++) {
49 ::new (&aligned_padded_array[i]) T();
50 }
|