1 /* |
|
2 * Copyright (c) 2017, 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" |
|
25 #include "gc/z/zGlobals.hpp" |
|
26 #include "gc/z/zUtils.inline.hpp" |
|
27 #include "runtime/globals.hpp" |
|
28 #include "utilities/globalDefinitions.hpp" |
|
29 |
|
30 // |
|
31 // The heap can have three different layouts, depending on the max heap size. |
|
32 // |
|
33 // Address Space & Pointer Layout 1 |
|
34 // -------------------------------- |
|
35 // |
|
36 // +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) |
|
37 // . . |
|
38 // . . |
|
39 // . . |
|
40 // +--------------------------------+ 0x0000014000000000 (20TB) |
|
41 // | Remapped View | |
|
42 // +--------------------------------+ 0x0000010000000000 (16TB) |
|
43 // | (Reserved, but unused) | |
|
44 // +--------------------------------+ 0x00000c0000000000 (12TB) |
|
45 // | Marked1 View | |
|
46 // +--------------------------------+ 0x0000080000000000 (8TB) |
|
47 // | Marked0 View | |
|
48 // +--------------------------------+ 0x0000040000000000 (4TB) |
|
49 // . . |
|
50 // +--------------------------------+ 0x0000000000000000 |
|
51 // |
|
52 // 6 4 4 4 4 |
|
53 // 3 6 5 2 1 0 |
|
54 // +--------------------+----+-----------------------------------------------+ |
|
55 // |00000000 00000000 00|1111|11 11111111 11111111 11111111 11111111 11111111| |
|
56 // +--------------------+----+-----------------------------------------------+ |
|
57 // | | | |
|
58 // | | * 41-0 Object Offset (42-bits, 4TB address space) |
|
59 // | | |
|
60 // | * 45-42 Metadata Bits (4-bits) 0001 = Marked0 (Address view 4-8TB) |
|
61 // | 0010 = Marked1 (Address view 8-12TB) |
|
62 // | 0100 = Remapped (Address view 16-20TB) |
|
63 // | 1000 = Finalizable (Address view N/A) |
|
64 // | |
|
65 // * 63-46 Fixed (18-bits, always zero) |
|
66 // |
|
67 // |
|
68 // Address Space & Pointer Layout 2 |
|
69 // -------------------------------- |
|
70 // |
|
71 // +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) |
|
72 // . . |
|
73 // . . |
|
74 // . . |
|
75 // +--------------------------------+ 0x0000280000000000 (40TB) |
|
76 // | Remapped View | |
|
77 // +--------------------------------+ 0x0000200000000000 (32TB) |
|
78 // | (Reserved, but unused) | |
|
79 // +--------------------------------+ 0x0000180000000000 (24TB) |
|
80 // | Marked1 View | |
|
81 // +--------------------------------+ 0x0000100000000000 (16TB) |
|
82 // | Marked0 View | |
|
83 // +--------------------------------+ 0x0000080000000000 (8TB) |
|
84 // . . |
|
85 // +--------------------------------+ 0x0000000000000000 |
|
86 // |
|
87 // 6 4 4 4 4 |
|
88 // 3 7 6 3 2 0 |
|
89 // +------------------+-----+------------------------------------------------+ |
|
90 // |00000000 00000000 0|1111|111 11111111 11111111 11111111 11111111 11111111| |
|
91 // +-------------------+----+------------------------------------------------+ |
|
92 // | | | |
|
93 // | | * 42-0 Object Offset (43-bits, 8TB address space) |
|
94 // | | |
|
95 // | * 46-43 Metadata Bits (4-bits) 0001 = Marked0 (Address view 8-16TB) |
|
96 // | 0010 = Marked1 (Address view 16-24TB) |
|
97 // | 0100 = Remapped (Address view 32-40TB) |
|
98 // | 1000 = Finalizable (Address view N/A) |
|
99 // | |
|
100 // * 63-47 Fixed (17-bits, always zero) |
|
101 // |
|
102 // |
|
103 // Address Space & Pointer Layout 3 |
|
104 // -------------------------------- |
|
105 // |
|
106 // +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) |
|
107 // . . |
|
108 // . . |
|
109 // . . |
|
110 // +--------------------------------+ 0x0000500000000000 (80TB) |
|
111 // | Remapped View | |
|
112 // +--------------------------------+ 0x0000400000000000 (64TB) |
|
113 // | (Reserved, but unused) | |
|
114 // +--------------------------------+ 0x0000300000000000 (48TB) |
|
115 // | Marked1 View | |
|
116 // +--------------------------------+ 0x0000200000000000 (32TB) |
|
117 // | Marked0 View | |
|
118 // +--------------------------------+ 0x0000100000000000 (16TB) |
|
119 // . . |
|
120 // +--------------------------------+ 0x0000000000000000 |
|
121 // |
|
122 // 6 4 4 4 4 |
|
123 // 3 8 7 4 3 0 |
|
124 // +------------------+----+-------------------------------------------------+ |
|
125 // |00000000 00000000 |1111|1111 11111111 11111111 11111111 11111111 11111111| |
|
126 // +------------------+----+-------------------------------------------------+ |
|
127 // | | | |
|
128 // | | * 43-0 Object Offset (44-bits, 16TB address space) |
|
129 // | | |
|
130 // | * 47-44 Metadata Bits (4-bits) 0001 = Marked0 (Address view 16-32TB) |
|
131 // | 0010 = Marked1 (Address view 32-48TB) |
|
132 // | 0100 = Remapped (Address view 64-80TB) |
|
133 // | 1000 = Finalizable (Address view N/A) |
|
134 // | |
|
135 // * 63-48 Fixed (16-bits, always zero) |
|
136 // |
|
137 |
|
138 uintptr_t ZPlatformAddressSpaceStart() { |
|
139 const uintptr_t first_heap_view_address = (uintptr_t)1 << (ZPlatformAddressMetadataShift() + 0); |
|
140 const size_t min_address_offset = 0; |
|
141 return first_heap_view_address + min_address_offset; |
|
142 } |
|
143 |
|
144 uintptr_t ZPlatformAddressSpaceEnd() { |
|
145 const uintptr_t last_heap_view_address = (uintptr_t)1 << (ZPlatformAddressMetadataShift() + 2); |
|
146 const size_t max_address_offset = (size_t)1 << ZPlatformAddressOffsetBits(); |
|
147 return last_heap_view_address + max_address_offset; |
|
148 } |
|
149 |
|
150 uintptr_t ZPlatformAddressReservedStart() { |
|
151 return ZPlatformAddressSpaceStart(); |
|
152 } |
|
153 |
|
154 uintptr_t ZPlatformAddressReservedEnd() { |
|
155 return ZPlatformAddressSpaceEnd(); |
|
156 } |
|
157 |
|
158 uintptr_t ZPlatformAddressBase() { |
|
159 return 0; |
|
160 } |
|
161 |
|
162 size_t ZPlatformAddressOffsetBits() { |
|
163 const size_t min_address_offset_bits = 42; // 4TB |
|
164 const size_t max_address_offset_bits = 44; // 16TB |
|
165 const size_t virtual_to_physical_ratio = 7; // 7:1 |
|
166 const size_t address_offset = ZUtils::round_up_power_of_2(MaxHeapSize * virtual_to_physical_ratio); |
|
167 const size_t address_offset_bits = log2_intptr(address_offset); |
|
168 return MIN2(MAX2(address_offset_bits, min_address_offset_bits), max_address_offset_bits); |
|
169 } |
|
170 |
|
171 size_t ZPlatformAddressMetadataShift() { |
|
172 return ZPlatformAddressOffsetBits(); |
|
173 } |
|