author | stefank |
Tue, 11 Apr 2017 23:45:37 +0200 | |
changeset 46565 | 8dcbf532ea00 |
parent 30764 | fec48bf5a827 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
10676
diff
changeset
|
2 |
* Copyright (c) 2002, 2015, 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:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
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:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/parallel/mutableSpace.hpp" |
27 |
#include "gc/parallel/parallelScavengeHeap.hpp" |
|
28 |
#include "gc/parallel/psPromotionLAB.hpp" |
|
7397 | 29 |
#include "oops/oop.inline.hpp" |
1 | 30 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
31 |
size_t PSPromotionLAB::filler_header_size; |
1 | 32 |
|
33 |
// This is the shared initialization code. It sets up the basic pointers, |
|
34 |
// and allows enough extra space for a filler object. We call a virtual |
|
35 |
// method, "lab_is_valid()" to handle the different asserts the old/young |
|
36 |
// labs require. |
|
37 |
void PSPromotionLAB::initialize(MemRegion lab) { |
|
38 |
assert(lab_is_valid(lab), "Sanity"); |
|
39 |
||
40 |
HeapWord* bottom = lab.start(); |
|
41 |
HeapWord* end = lab.end(); |
|
42 |
||
43 |
set_bottom(bottom); |
|
44 |
set_end(end); |
|
45 |
set_top(bottom); |
|
46 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
47 |
// Initialize after VM starts up because header_size depends on compressed |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
48 |
// oops. |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
49 |
filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT)); |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
50 |
|
1 | 51 |
// We can be initialized to a zero size! |
52 |
if (free() > 0) { |
|
53 |
if (ZapUnusedHeapArea) { |
|
54 |
debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord)); |
|
55 |
} |
|
56 |
||
57 |
// NOTE! We need to allow space for a filler object. |
|
58 |
assert(lab.word_size() >= filler_header_size, "lab is too small"); |
|
59 |
end = end - filler_header_size; |
|
60 |
set_end(end); |
|
61 |
||
62 |
_state = needs_flush; |
|
63 |
} else { |
|
64 |
_state = zero_size; |
|
65 |
} |
|
66 |
||
67 |
assert(this->top() <= this->end(), "pointers out of order"); |
|
68 |
} |
|
69 |
||
70 |
// Fill all remaining lab space with an unreachable object. |
|
71 |
// The goal is to leave a contiguous parseable span of objects. |
|
72 |
void PSPromotionLAB::flush() { |
|
73 |
assert(_state != flushed, "Attempt to flush PLAB twice"); |
|
74 |
assert(top() <= end(), "pointers out of order"); |
|
75 |
||
76 |
// If we were initialized to a zero sized lab, there is |
|
77 |
// nothing to flush |
|
78 |
if (_state == zero_size) |
|
79 |
return; |
|
80 |
||
81 |
// PLAB's never allocate the last aligned_header_size |
|
82 |
// so they can always fill with an array. |
|
83 |
HeapWord* tlab_end = end() + filler_header_size; |
|
84 |
typeArrayOop filler_oop = (typeArrayOop) top(); |
|
85 |
filler_oop->set_mark(markOopDesc::prototype()); |
|
86 |
filler_oop->set_klass(Universe::intArrayKlassObj()); |
|
87 |
const size_t array_length = |
|
88 |
pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT); |
|
89 |
assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB"); |
|
90 |
filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint)))); |
|
91 |
||
92 |
#ifdef ASSERT |
|
93 |
// Note that we actually DO NOT want to use the aligned header size! |
|
94 |
HeapWord* elt_words = ((HeapWord*)filler_oop) + typeArrayOopDesc::header_size(T_INT); |
|
95 |
Copy::fill_to_words(elt_words, array_length, 0xDEAABABE); |
|
96 |
#endif |
|
97 |
||
98 |
set_bottom(NULL); |
|
99 |
set_end(NULL); |
|
100 |
set_top(NULL); |
|
101 |
||
102 |
_state = flushed; |
|
103 |
} |
|
104 |
||
10676
1e1510b8031a
7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents:
7397
diff
changeset
|
105 |
bool PSPromotionLAB::unallocate_object(HeapWord* obj, size_t obj_size) { |
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
10676
diff
changeset
|
106 |
assert(ParallelScavengeHeap::heap()->is_in(obj), "Object outside heap"); |
1 | 107 |
|
108 |
if (contains(obj)) { |
|
10676
1e1510b8031a
7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents:
7397
diff
changeset
|
109 |
HeapWord* object_end = obj + obj_size; |
1e1510b8031a
7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents:
7397
diff
changeset
|
110 |
assert(object_end == top(), "Not matching last allocation"); |
1 | 111 |
|
10676
1e1510b8031a
7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents:
7397
diff
changeset
|
112 |
set_top(obj); |
1e1510b8031a
7021322: assert(object_end <= top()) failed: Object crosses promotion LAB boundary
stefank
parents:
7397
diff
changeset
|
113 |
return true; |
1 | 114 |
} |
115 |
||
116 |
return false; |
|
117 |
} |
|
118 |
||
119 |
// Fill all remaining lab space with an unreachable object. |
|
120 |
// The goal is to leave a contiguous parseable span of objects. |
|
121 |
void PSOldPromotionLAB::flush() { |
|
122 |
assert(_state != flushed, "Attempt to flush PLAB twice"); |
|
123 |
assert(top() <= end(), "pointers out of order"); |
|
124 |
||
125 |
if (_state == zero_size) |
|
126 |
return; |
|
127 |
||
128 |
HeapWord* obj = top(); |
|
129 |
||
130 |
PSPromotionLAB::flush(); |
|
131 |
||
132 |
assert(_start_array != NULL, "Sanity"); |
|
133 |
||
134 |
_start_array->allocate_block(obj); |
|
135 |
} |
|
136 |
||
137 |
#ifdef ASSERT |
|
138 |
||
139 |
bool PSYoungPromotionLAB::lab_is_valid(MemRegion lab) { |
|
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
10676
diff
changeset
|
140 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 141 |
MutableSpace* to_space = heap->young_gen()->to_space(); |
142 |
MemRegion used = to_space->used_region(); |
|
143 |
if (used.contains(lab)) { |
|
144 |
return true; |
|
145 |
} |
|
146 |
||
147 |
return false; |
|
148 |
} |
|
149 |
||
150 |
bool PSOldPromotionLAB::lab_is_valid(MemRegion lab) { |
|
151 |
assert(_start_array->covered_region().contains(lab), "Sanity"); |
|
152 |
||
30173
13cf7580b000
8077413: Avoid use of Universe::heap() inside collectors
pliden
parents:
10676
diff
changeset
|
153 |
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); |
1 | 154 |
PSOldGen* old_gen = heap->old_gen(); |
155 |
MemRegion used = old_gen->object_space()->used_region(); |
|
156 |
||
157 |
if (used.contains(lab)) { |
|
158 |
return true; |
|
159 |
} |
|
160 |
||
161 |
return false; |
|
162 |
} |
|
163 |
||
164 |
#endif /* ASSERT */ |