Mercurial > hg > truffle
annotate src/share/vm/memory/padded.inline.hpp @ 21282:93215cb4a2f9
include duringCall and rethrowException for BytecodeFrames in disassembly comments
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 11 May 2015 12:22:49 +0200 |
parents | 5479cb006184 |
children |
rev | line source |
---|---|
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
1 /* |
17754
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
4 * |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
8 * |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
13 * accompanied this code). |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
14 * |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
18 * |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
21 * questions. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
22 * |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
23 */ |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
24 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
25 #include "memory/allocation.inline.hpp" |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
26 #include "memory/padded.hpp" |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
27 #include "utilities/debug.hpp" |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
28 #include "utilities/globalDefinitions.hpp" |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
29 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
30 // Creates an aligned padded array. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
31 // The memory can't be deleted since the raw memory chunk is not returned. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
32 template <class T, MEMFLAGS flags, size_t alignment> |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
33 PaddedEnd<T>* PaddedArray<T, flags, alignment>::create_unfreeable(uint length) { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
34 // Check that the PaddedEnd class works as intended. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
35 STATIC_ASSERT(is_size_aligned_(sizeof(PaddedEnd<T>), alignment)); |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
36 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
37 // Allocate a chunk of memory large enough to allow for some alignment. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
38 void* chunk = AllocateHeap(length * sizeof(PaddedEnd<T, alignment>) + alignment, flags); |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
39 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
40 // Make the initial alignment. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
41 PaddedEnd<T>* aligned_padded_array = (PaddedEnd<T>*)align_pointer_up(chunk, alignment); |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
42 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
43 // Call the default constructor for each element. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
44 for (uint i = 0; i < length; i++) { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
45 ::new (&aligned_padded_array[i]) T(); |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
46 } |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
47 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
48 return aligned_padded_array; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
49 } |
17754
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
50 |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
51 template <class T, MEMFLAGS flags, size_t alignment> |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
52 T** Padded2DArray<T, flags, alignment>::create_unfreeable(uint rows, uint columns, size_t* allocation_size) { |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
53 // Calculate and align the size of the first dimension's table. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
54 size_t table_size = align_size_up_(rows * sizeof(T*), alignment); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
55 // The size of the separate rows. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
56 size_t row_size = align_size_up_(columns * sizeof(T), alignment); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
57 // Total size consists of the indirection table plus the rows. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
58 size_t total_size = table_size + rows * row_size + alignment; |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
59 |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
60 // Allocate a chunk of memory large enough to allow alignment of the chunk. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
61 void* chunk = AllocateHeap(total_size, flags); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
62 // Clear the allocated memory. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
63 memset(chunk, 0, total_size); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
64 // Align the chunk of memory. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
65 T** result = (T**)align_pointer_up(chunk, alignment); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
66 void* data_start = (void*)((uintptr_t)result + table_size); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
67 |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
68 // Fill in the row table. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
69 for (size_t i = 0; i < rows; i++) { |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
70 result[i] = (T*)((uintptr_t)data_start + i * row_size); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
71 } |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
72 |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
73 if (allocation_size != NULL) { |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
74 *allocation_size = total_size; |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
75 } |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
76 |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
77 return result; |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
78 } |
17760
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
79 |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
80 template <class T, MEMFLAGS flags, size_t alignment> |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
81 T* PaddedPrimitiveArray<T, flags, alignment>::create_unfreeable(size_t length) { |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
82 // Allocate a chunk of memory large enough to allow for some alignment. |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
83 void* chunk = AllocateHeap(length * sizeof(T) + alignment, flags); |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
84 |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
85 memset(chunk, 0, length * sizeof(T) + alignment); |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
86 |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
87 return (T*)align_pointer_up(chunk, alignment); |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
88 } |