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