author | eosterlund |
Tue, 12 Nov 2019 20:01:23 +0000 | |
changeset 59038 | b9a42ca342db |
parent 58066 | 8407928b9fe5 |
child 58679 | 9c3209ff7550 |
permissions | -rw-r--r-- |
57850 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
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 |
* |
|
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 |
#include "precompiled.hpp" |
|
57851
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
25 |
#include "gc/z/zThreadLocalData.hpp" |
57850 | 26 |
#include "gc/z/zObjArrayAllocator.hpp" |
27 |
#include "gc/z/zUtils.inline.hpp" |
|
28 |
#include "oops/arrayKlass.hpp" |
|
29 |
#include "runtime/interfaceSupport.inline.hpp" |
|
30 |
||
31 |
ZObjArrayAllocator::ZObjArrayAllocator(Klass* klass, size_t word_size, int length, Thread* thread) : |
|
58066
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
32 |
ObjArrayAllocator(klass, word_size, length, false /* do_zero */, thread) {} |
57850 | 33 |
|
34 |
oop ZObjArrayAllocator::finish(HeapWord* mem) const { |
|
58066
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
35 |
// Initialize object header and length field |
57851
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
36 |
ObjArrayAllocator::finish(mem); |
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
37 |
|
58066
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
38 |
// Keep the array alive across safepoints through an invisible |
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
39 |
// root. Invisible roots are not visited by the heap itarator |
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
40 |
// and the marking logic will not attempt to follow its elements. |
57851
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
41 |
ZThreadLocalData::set_invisible_root(_thread, (oop*)&mem); |
57850 | 42 |
|
58066
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
43 |
// A max segment size of 64K was chosen because microbenchmarking |
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
44 |
// suggested that it offered a good trade-off between allocation |
8407928b9fe5
8230566: ZGC: Don't substitute klass pointer during array clearing
pliden
parents:
57851
diff
changeset
|
45 |
// time and time-to-safepoint |
57850 | 46 |
const size_t segment_max = ZUtils::bytes_to_words(64 * K); |
47 |
const size_t skip = arrayOopDesc::header_size(ArrayKlass::cast(_klass)->element_type()); |
|
48 |
size_t remaining = _word_size - skip; |
|
49 |
||
50 |
while (remaining > 0) { |
|
51 |
// Clear segment |
|
52 |
const size_t segment = MIN2(remaining, segment_max); |
|
57851
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
53 |
Copy::zero_to_words(mem + (_word_size - remaining), segment); |
57850 | 54 |
remaining -= segment; |
55 |
||
56 |
if (remaining > 0) { |
|
57 |
// Safepoint |
|
58 |
ThreadBlockInVM tbivm((JavaThread*)_thread); |
|
59 |
} |
|
60 |
} |
|
61 |
||
57851
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
62 |
ZThreadLocalData::clear_invisible_root(_thread); |
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
63 |
|
6728c41f2a08
8229451: ZGC: Make some roots invisible to the heap iterator
pliden
parents:
57850
diff
changeset
|
64 |
return oop(mem); |
57850 | 65 |
} |