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 SHARE_GC_Z_ZGLOBALS_HPP |
25 | #define SHARE_GC_Z_ZGLOBALS_HPP |
26 | |
27 | #include "utilities/globalDefinitions.hpp" |
28 | #include "utilities/macros.hpp" |
29 | #include OS_CPU_HEADER(gc/z/zGlobals) |
30 | |
31 | // Collector name |
32 | const char* const ZName = "The Z Garbage Collector" ; |
33 | |
34 | // Global phase state |
35 | extern uint32_t ZGlobalPhase; |
36 | const uint32_t ZPhaseMark = 0; |
37 | const uint32_t ZPhaseMarkCompleted = 1; |
38 | const uint32_t ZPhaseRelocate = 2; |
39 | |
40 | // Global sequence number |
41 | extern uint32_t ZGlobalSeqNum; |
42 | |
43 | // Granule shift/size |
44 | const size_t ZGranuleSizeShift = ZPlatformGranuleSizeShift; |
45 | const size_t ZGranuleSize = (size_t)1 << ZGranuleSizeShift; |
46 | |
47 | // Max heap size shift/size |
48 | const size_t ZMaxHeapSizeShift = ZPlatformMaxHeapSizeShift; |
49 | const size_t ZMaxHeapSize = (size_t)1 << ZMaxHeapSizeShift; |
50 | |
51 | // Page types |
52 | const uint8_t ZPageTypeSmall = 0; |
53 | const uint8_t ZPageTypeMedium = 1; |
54 | const uint8_t ZPageTypeLarge = 2; |
55 | |
56 | // Page size shifts |
57 | const size_t ZPageSizeSmallShift = ZGranuleSizeShift; |
58 | const size_t ZPageSizeMediumShift = ZPageSizeSmallShift + 4; |
59 | |
60 | // Page sizes |
61 | const size_t ZPageSizeSmall = (size_t)1 << ZPageSizeSmallShift; |
62 | const size_t ZPageSizeMedium = (size_t)1 << ZPageSizeMediumShift; |
63 | |
64 | // Object size limits |
65 | const size_t ZObjectSizeLimitSmall = (ZPageSizeSmall / 8); // Allow 12.5% waste |
66 | const size_t ZObjectSizeLimitMedium = (ZPageSizeMedium / 8); // Allow 12.5% waste |
67 | |
68 | // Object alignment shifts |
69 | extern const int& ZObjectAlignmentSmallShift; |
70 | const int ZObjectAlignmentMediumShift = ZPageSizeMediumShift - 13; // 8192 objects per page |
71 | const int ZObjectAlignmentLargeShift = ZPageSizeSmallShift; |
72 | |
73 | // Object alignments |
74 | extern const int& ZObjectAlignmentSmall; |
75 | const int ZObjectAlignmentMedium = 1 << ZObjectAlignmentMediumShift; |
76 | const int ZObjectAlignmentLarge = 1 << ZObjectAlignmentLargeShift; |
77 | |
78 | // |
79 | // Good/Bad mask states |
80 | // -------------------- |
81 | // |
82 | // GoodMask BadMask WeakGoodMask WeakBadMask |
83 | // -------------------------------------------------------------- |
84 | // Marked0 001 110 101 010 |
85 | // Marked1 010 101 110 001 |
86 | // Remapped 100 011 100 011 |
87 | // |
88 | |
89 | // Good/bad masks |
90 | extern uintptr_t ZAddressGoodMask; |
91 | extern uintptr_t ZAddressBadMask; |
92 | extern uintptr_t ZAddressWeakBadMask; |
93 | |
94 | // Pointer base address |
95 | extern uintptr_t ZAddressBase; |
96 | |
97 | // Pointer part of address |
98 | extern size_t ZAddressOffsetBits; |
99 | const size_t ZAddressOffsetShift = 0; |
100 | extern uintptr_t ZAddressOffsetMask; |
101 | extern size_t ZAddressOffsetMax; |
102 | |
103 | // Metadata part of address |
104 | const size_t ZAddressMetadataBits = 4; |
105 | extern size_t ZAddressMetadataShift; |
106 | extern uintptr_t ZAddressMetadataMask; |
107 | |
108 | // Metadata types |
109 | extern uintptr_t ZAddressMetadataMarked; |
110 | extern uintptr_t ZAddressMetadataMarked0; |
111 | extern uintptr_t ZAddressMetadataMarked1; |
112 | extern uintptr_t ZAddressMetadataRemapped; |
113 | extern uintptr_t ZAddressMetadataFinalizable; |
114 | |
115 | // Address space start/end/size |
116 | extern uintptr_t ZAddressSpaceStart; |
117 | extern uintptr_t ZAddressSpaceEnd; |
118 | extern size_t ZAddressSpaceSize; |
119 | |
120 | // Reserved space start/end |
121 | extern uintptr_t ZAddressReservedStart; |
122 | extern uintptr_t ZAddressReservedEnd; |
123 | extern size_t ZAddressReservedSize; |
124 | |
125 | // NMethod entry barrier |
126 | const size_t ZNMethodDisarmedOffset = ZPlatformNMethodDisarmedOffset; |
127 | |
128 | // Cache line size |
129 | const size_t ZCacheLineSize = ZPlatformCacheLineSize; |
130 | |
131 | // Mark stack space |
132 | extern uintptr_t ZMarkStackSpaceStart; |
133 | const size_t ZMarkStackSpaceExpandSize = (size_t)1 << 25; // 32M |
134 | |
135 | // Mark stack and magazine sizes |
136 | const size_t ZMarkStackSizeShift = 11; // 2K |
137 | const size_t ZMarkStackSize = (size_t)1 << ZMarkStackSizeShift; |
138 | const size_t = (size_t)1 << 4; // 16B |
139 | const size_t ZMarkStackSlots = (ZMarkStackSize - ZMarkStackHeaderSize) / sizeof(uintptr_t); |
140 | const size_t ZMarkStackMagazineSize = (size_t)1 << 15; // 32K |
141 | const size_t ZMarkStackMagazineSlots = (ZMarkStackMagazineSize / ZMarkStackSize) - 1; |
142 | |
143 | // Mark stripe size |
144 | const size_t ZMarkStripeShift = ZGranuleSizeShift; |
145 | |
146 | // Max number of mark stripes |
147 | const size_t ZMarkStripesMax = 16; // Must be a power of two |
148 | |
149 | // Mark cache size |
150 | const size_t ZMarkCacheSize = 1024; // Must be a power of two |
151 | |
152 | // Partial array minimum size |
153 | const size_t ZMarkPartialArrayMinSizeShift = 12; // 4K |
154 | const size_t ZMarkPartialArrayMinSize = (size_t)1 << ZMarkPartialArrayMinSizeShift; |
155 | |
156 | // Max number of proactive/terminate flush attempts |
157 | const size_t ZMarkProactiveFlushMax = 10; |
158 | const size_t ZMarkTerminateFlushMax = 3; |
159 | |
160 | // Try complete mark timeout |
161 | const uint64_t ZMarkCompleteTimeout = 1; // ms |
162 | |
163 | #endif // SHARE_GC_Z_ZGLOBALS_HPP |
164 | |