Skip to content

Commit 65a0a19

Browse files
stefankplidenalbertnetymkfiskxmas92
committed
ZGC: Generational
Co-authored-by: Stefan Karlsson <stefank@openjdk.org> Co-authored-by: Per Liden <pliden@openjdk.org> Co-authored-by: Albert Mingkun Yang <ayang@openjdk.org> Co-authored-by: Erik Österlund <eosterlund@openjdk.org> Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org> Co-authored-by: Stefan Johansson <kstefanj@openjdk.org>
1 parent c52cac9 commit 65a0a19

File tree

321 files changed

+25982
-7688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+25982
-7688
lines changed

src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,10 +1010,7 @@ void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch
10101010
__ decode_heap_oop(dest->as_register());
10111011
}
10121012

1013-
if (!UseZGC) {
1014-
// Load barrier has not yet been applied, so ZGC can't verify the oop here
1015-
__ verify_oop(dest->as_register());
1016-
}
1013+
__ verify_oop(dest->as_register());
10171014
}
10181015
}
10191016

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright (c) 2017, 2021, 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"
25+
#include "gc/shared/gcLogPrecious.hpp"
26+
#include "gc/shared/gc_globals.hpp"
27+
#include "gc/z/zAddress.hpp"
28+
#include "gc/z/zBarrierSetAssembler.hpp"
29+
#include "gc/z/zGlobals.hpp"
30+
#include "runtime/globals.hpp"
31+
#include "runtime/os.hpp"
32+
#include "utilities/globalDefinitions.hpp"
33+
#include "utilities/powerOfTwo.hpp"
34+
35+
#ifdef LINUX
36+
#include <sys/mman.h>
37+
#endif // LINUX
38+
39+
// Default value if probing is not implemented for a certain platform: 128TB
40+
static const size_t DEFAULT_MAX_ADDRESS_BIT = 47;
41+
// Minimum value returned, if probing fails: 64GB
42+
static const size_t MINIMUM_MAX_ADDRESS_BIT = 36;
43+
44+
static size_t probe_valid_max_address_bit() {
45+
#ifdef LINUX
46+
size_t max_address_bit = 0;
47+
const size_t page_size = os::vm_page_size();
48+
for (size_t i = DEFAULT_MAX_ADDRESS_BIT; i > MINIMUM_MAX_ADDRESS_BIT; --i) {
49+
const uintptr_t base_addr = ((uintptr_t) 1U) << i;
50+
if (msync((void*)base_addr, page_size, MS_ASYNC) == 0) {
51+
// msync suceeded, the address is valid, and maybe even already mapped.
52+
max_address_bit = i;
53+
break;
54+
}
55+
if (errno != ENOMEM) {
56+
// Some error occured. This should never happen, but msync
57+
// has some undefined behavior, hence ignore this bit.
58+
#ifdef ASSERT
59+
fatal("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno));
60+
#else // ASSERT
61+
log_warning_p(gc)("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno));
62+
#endif // ASSERT
63+
continue;
64+
}
65+
// Since msync failed with ENOMEM, the page might not be mapped.
66+
// Try to map it, to see if the address is valid.
67+
void* const result_addr = mmap((void*) base_addr, page_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
68+
if (result_addr != MAP_FAILED) {
69+
munmap(result_addr, page_size);
70+
}
71+
if ((uintptr_t) result_addr == base_addr) {
72+
// address is valid
73+
max_address_bit = i;
74+
break;
75+
}
76+
}
77+
if (max_address_bit == 0) {
78+
// probing failed, allocate a very high page and take that bit as the maximum
79+
const uintptr_t high_addr = ((uintptr_t) 1U) << DEFAULT_MAX_ADDRESS_BIT;
80+
void* const result_addr = mmap((void*) high_addr, page_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
81+
if (result_addr != MAP_FAILED) {
82+
max_address_bit = BitsPerSize_t - count_leading_zeros((size_t) result_addr) - 1;
83+
munmap(result_addr, page_size);
84+
}
85+
}
86+
log_info_p(gc, init)("Probing address space for the highest valid bit: " SIZE_FORMAT, max_address_bit);
87+
return MAX2(max_address_bit, MINIMUM_MAX_ADDRESS_BIT);
88+
#else // LINUX
89+
return DEFAULT_MAX_ADDRESS_BIT;
90+
#endif // LINUX
91+
}
92+
93+
size_t ZPlatformAddressOffsetBits() {
94+
const static size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1;
95+
const size_t max_address_offset_bits = valid_max_address_offset_bits - 3;
96+
const size_t min_address_offset_bits = max_address_offset_bits - 2;
97+
const size_t address_offset = round_up_power_of_2(MaxHeapSize * ZVirtualToPhysicalRatio);
98+
const size_t address_offset_bits = log2i_exact(address_offset);
99+
return clamp(address_offset_bits, min_address_offset_bits, max_address_offset_bits);
100+
}
101+
102+
size_t ZPlatformAddressHeapBaseShift() {
103+
return ZPlatformAddressOffsetBits();
104+
}
105+
106+
void ZGlobalsPointers::pd_set_good_masks() {
107+
BarrierSetAssembler::clear_patching_epoch();
108+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2015, 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+
#ifndef CPU_AARCH64_GC_Z_ZADDRESS_AARCH64_HPP
25+
#define CPU_AARCH64_GC_Z_ZADDRESS_AARCH64_HPP
26+
27+
#include "utilities/globalDefinitions.hpp"
28+
29+
const size_t ZPointerLoadShift = 16;
30+
31+
size_t ZPlatformAddressOffsetBits();
32+
size_t ZPlatformAddressHeapBaseShift();
33+
34+
#endif // CPU_AARCH64_GC_Z_ZADDRESS_AARCH64_HPP
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
#ifndef CPU_AARCH64_GC_Z_ZADDRESS_AARCH64_INLINE_HPP
25+
#define CPU_AARCH64_GC_Z_ZADDRESS_AARCH64_INLINE_HPP
26+
27+
#include "utilities/globalDefinitions.hpp"
28+
29+
inline uintptr_t ZPointer::remap_bits(uintptr_t colored) {
30+
return (colored ^ ZPointerRemappedMask) & ZPointerRemappedMask;
31+
}
32+
33+
inline constexpr int ZPointer::load_shift_lookup(uintptr_t value) {
34+
return ZPointerLoadShift;
35+
}
36+
37+
#endif // CPU_AARCH64_GC_Z_ZADDRESS_AARCH64_INLINE_HPP

0 commit comments

Comments
 (0)