Mercurial > hg > truffle
annotate src/share/vm/memory/padded.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 #ifndef SHARE_VM_MEMORY_PADDED_HPP |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
26 #define SHARE_VM_MEMORY_PADDED_HPP |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
27 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
28 #include "memory/allocation.hpp" |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
29 #include "utilities/globalDefinitions.hpp" |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
30 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
31 // Bytes needed to pad type to avoid cache-line sharing; alignment should be the |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
32 // expected cache line size (a power of two). The first addend avoids sharing |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
33 // when the start address is not a multiple of alignment; the second maintains |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
34 // alignment of starting addresses that happen to be a multiple. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
35 #define PADDING_SIZE(type, alignment) \ |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
36 ((alignment) + align_size_up_(sizeof(type), alignment)) |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
37 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
38 // Templates to create a subclass padded to avoid cache line sharing. These are |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
39 // effective only when applied to derived-most (leaf) classes. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
40 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
41 // When no args are passed to the base ctor. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
42 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE> |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
43 class Padded : public T { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
44 private: |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
45 char _pad_buf_[PADDING_SIZE(T, alignment)]; |
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 // When either 0 or 1 args may be passed to the base ctor. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
49 template <class T, typename Arg1T, size_t alignment = DEFAULT_CACHE_LINE_SIZE> |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
50 class Padded01 : public T { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
51 public: |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
52 Padded01(): T() { } |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
53 Padded01(Arg1T arg1): T(arg1) { } |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
54 private: |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
55 char _pad_buf_[PADDING_SIZE(T, alignment)]; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
56 }; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
57 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
58 // Super class of PaddedEnd when pad_size != 0. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
59 template <class T, size_t pad_size> |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
60 class PaddedEndImpl : public T { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
61 private: |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
62 char _pad_buf[pad_size]; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
63 }; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
64 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
65 // Super class of PaddedEnd when pad_size == 0. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
66 template <class T> |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
67 class PaddedEndImpl<T, /*pad_size*/ 0> : public T { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
68 // No padding. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
69 }; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
70 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
71 #define PADDED_END_SIZE(type, alignment) (align_size_up_(sizeof(type), alignment) - sizeof(type)) |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
72 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
73 // More memory conservative implementation of Padded. The subclass adds the |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
74 // minimal amount of padding needed to make the size of the objects be aligned. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
75 // This will help reducing false sharing, |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
76 // if the start address is a multiple of alignment. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
77 template <class T, size_t alignment = DEFAULT_CACHE_LINE_SIZE> |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
78 class PaddedEnd : public PaddedEndImpl<T, PADDED_END_SIZE(T, alignment)> { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
79 // C++ don't allow zero-length arrays. The padding is put in a |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
80 // super class that is specialized for the pad_size == 0 case. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
81 }; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
82 |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
83 // Helper class to create an array of PaddedEnd<T> objects. All elements will |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
84 // start at a multiple of alignment and the size will be aligned to alignment. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
85 template <class T, MEMFLAGS flags, size_t alignment = DEFAULT_CACHE_LINE_SIZE> |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
86 class PaddedArray { |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
87 public: |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
88 // Creates an aligned padded array. |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
89 // 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
|
90 static PaddedEnd<T>* create_unfreeable(uint length); |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
91 }; |
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
92 |
17754
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
93 // Helper class to create an array of references to arrays of primitive types |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
94 // Both the array of references and the data arrays are aligned to the given |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
95 // alignment. The allocated memory is zero-filled. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
96 template <class T, MEMFLAGS flags, size_t alignment = DEFAULT_CACHE_LINE_SIZE> |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
97 class Padded2DArray { |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
98 public: |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
99 // Creates an aligned padded 2D array. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
100 // The memory cannot be deleted since the raw memory chunk is not returned. |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
101 static T** create_unfreeable(uint rows, uint columns, size_t* allocation_size = NULL); |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
102 }; |
d7070f371770
8035815: Cache-align and pad the from card cache
tschatzl
parents:
12029
diff
changeset
|
103 |
17760
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
104 // Helper class to create an array of T objects. The array as a whole will |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
105 // start at a multiple of alignment and its size will be aligned to alignment. |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
106 template <class T, MEMFLAGS flags, size_t alignment = DEFAULT_CACHE_LINE_SIZE> |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
107 class PaddedPrimitiveArray { |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
108 public: |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
109 static T* create_unfreeable(size_t length); |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
110 }; |
5479cb006184
8036860: Pad and cache-align the BiasedMappedArray
tschatzl
parents:
17754
diff
changeset
|
111 |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
diff
changeset
|
112 #endif // SHARE_VM_MEMORY_PADDED_HPP |