author | eosterlund |
Thu, 28 Jun 2018 14:22:28 +0200 | |
changeset 50882 | 80abf702eed8 |
parent 50578 | e2a7f431f65c |
child 53191 | a257992e1e4d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49593
4dd58ecc9912
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents:
47779
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
30764 | 25 |
#ifndef SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP |
26 |
#define SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP |
|
7397 | 27 |
|
30764 | 28 |
#include "gc/shared/collectedHeap.hpp" |
35862
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
33105
diff
changeset
|
29 |
#include "oops/oop.inline.hpp" |
46625 | 30 |
#include "utilities/align.hpp" |
10566
630c177ec580
7081933: Use zeroing elimination optimization for large array
kvn
parents:
10565
diff
changeset
|
31 |
|
25905
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
32 |
inline HeapWord* CollectedHeap::align_allocation_or_fail(HeapWord* addr, |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
33 |
HeapWord* end, |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
34 |
unsigned short alignment_in_bytes) { |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
35 |
if (alignment_in_bytes <= ObjectAlignmentInBytes) { |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
36 |
return addr; |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
37 |
} |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
38 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
39 |
assert(is_aligned(addr, HeapWordSize), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
40 |
"Address " PTR_FORMAT " is not properly aligned.", p2i(addr)); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
41 |
assert(is_aligned(alignment_in_bytes, HeapWordSize), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
42 |
"Alignment size %u is incorrect.", alignment_in_bytes); |
25905
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
43 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
44 |
HeapWord* new_addr = align_up(addr, alignment_in_bytes); |
25905
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
45 |
size_t padding = pointer_delta(new_addr, addr); |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
46 |
|
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
47 |
if (padding == 0) { |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
48 |
return addr; |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
49 |
} |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
50 |
|
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
51 |
if (padding < CollectedHeap::min_fill_size()) { |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
52 |
padding += alignment_in_bytes / HeapWordSize; |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
53 |
assert(padding >= CollectedHeap::min_fill_size(), |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
54 |
"alignment_in_bytes %u is expect to be larger " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
55 |
"than the minimum object size", alignment_in_bytes); |
25905
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
56 |
new_addr = addr + padding; |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
57 |
} |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
58 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
59 |
assert(new_addr > addr, "Unexpected arithmetic overflow " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
30764
diff
changeset
|
60 |
PTR_FORMAT " not greater than " PTR_FORMAT, p2i(new_addr), p2i(addr)); |
25905
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
61 |
if(new_addr < end) { |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
62 |
CollectedHeap::fill_with_object(addr, padding); |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
63 |
return new_addr; |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
64 |
} else { |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
65 |
return NULL; |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
66 |
} |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
67 |
} |
04a3d83cc752
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
23995
diff
changeset
|
68 |
|
30764 | 69 |
#endif // SHARE_VM_GC_SHARED_COLLECTEDHEAP_INLINE_HPP |