Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp
40957 views
1
/*
2
* Copyright (c) 2015, 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
25
#include "precompiled.hpp"
26
#include "runtime/flags/jvmFlag.hpp"
27
#include "runtime/flags/jvmFlagLimit.hpp"
28
#include "runtime/flags/jvmFlagConstraintsRuntime.hpp"
29
#include "runtime/globals.hpp"
30
#include "runtime/os.hpp"
31
#include "runtime/safepointMechanism.hpp"
32
#include "runtime/task.hpp"
33
#include "utilities/powerOfTwo.hpp"
34
35
JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) {
36
if (!is_power_of_2(value)) {
37
JVMFlag::printError(verbose,
38
"ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
39
"power of 2\n",
40
value);
41
return JVMFlag::VIOLATES_CONSTRAINT;
42
}
43
// In case page size is very small.
44
if (value >= (intx)os::vm_page_size()) {
45
JVMFlag::printError(verbose,
46
"ObjectAlignmentInBytes (" INTX_FORMAT ") must be "
47
"less than page size (%d)\n",
48
value, os::vm_page_size());
49
return JVMFlag::VIOLATES_CONSTRAINT;
50
}
51
return JVMFlag::SUCCESS;
52
}
53
54
// Need to enforce the padding not to break the existing field alignments.
55
// It is sufficient to check against the largest type size.
56
JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) {
57
if ((value % BytesPerLong) != 0) {
58
JVMFlag::printError(verbose,
59
"ContendedPaddingWidth (" INTX_FORMAT ") must be "
60
"a multiple of %d\n",
61
value, BytesPerLong);
62
return JVMFlag::VIOLATES_CONSTRAINT;
63
} else {
64
return JVMFlag::SUCCESS;
65
}
66
}
67
68
JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) {
69
if (value > BiasedLockingBulkRevokeThreshold) {
70
JVMFlag::printError(verbose,
71
"BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be "
72
"less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n",
73
value, BiasedLockingBulkRevokeThreshold);
74
return JVMFlag::VIOLATES_CONSTRAINT;
75
} else {
76
return JVMFlag::SUCCESS;
77
}
78
}
79
80
JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) {
81
if ((value % PeriodicTask::interval_gran) != 0) {
82
JVMFlag::printError(verbose,
83
"BiasedLockingStartupDelay (" INTX_FORMAT ") must be "
84
"evenly divisible by PeriodicTask::interval_gran (%d)\n",
85
value, PeriodicTask::interval_gran);
86
return JVMFlag::VIOLATES_CONSTRAINT;
87
} else {
88
return JVMFlag::SUCCESS;
89
}
90
}
91
92
JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) {
93
if (value < BiasedLockingBulkRebiasThreshold) {
94
JVMFlag::printError(verbose,
95
"BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be "
96
"greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n",
97
value, BiasedLockingBulkRebiasThreshold);
98
return JVMFlag::VIOLATES_CONSTRAINT;
99
} else if ((double)value/(double)BiasedLockingDecayTime > 0.1) {
100
JVMFlag::printError(verbose,
101
"The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")"
102
" to BiasedLockingDecayTime (" INTX_FORMAT ") must be "
103
"less than or equal to 0.1\n",
104
value, BiasedLockingBulkRebiasThreshold);
105
return JVMFlag::VIOLATES_CONSTRAINT;
106
} else {
107
return JVMFlag::SUCCESS;
108
}
109
}
110
111
JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) {
112
if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) {
113
JVMFlag::printError(verbose,
114
"The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")"
115
" to BiasedLockingDecayTime (" INTX_FORMAT ") must be "
116
"less than or equal to 0.1\n",
117
BiasedLockingBulkRebiasThreshold, value);
118
return JVMFlag::VIOLATES_CONSTRAINT;
119
} else {
120
return JVMFlag::SUCCESS;
121
}
122
}
123
124
JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) {
125
if ((value % PeriodicTask::interval_gran != 0)) {
126
JVMFlag::printError(verbose,
127
"PerfDataSamplingInterval (" INTX_FORMAT ") must be "
128
"evenly divisible by PeriodicTask::interval_gran (%d)\n",
129
value, PeriodicTask::interval_gran);
130
return JVMFlag::VIOLATES_CONSTRAINT;
131
} else {
132
return JVMFlag::SUCCESS;
133
}
134
}
135
136
JVMFlag::Error VMPageSizeConstraintFunc(uintx value, bool verbose) {
137
uintx min = (uintx)os::vm_page_size();
138
if (value < min) {
139
JVMFlag::printError(verbose,
140
"%s %s=" UINTX_FORMAT " is outside the allowed range [ " UINTX_FORMAT
141
" ... " UINTX_FORMAT " ]\n",
142
JVMFlagLimit::last_checked_flag()->type_string(),
143
JVMFlagLimit::last_checked_flag()->name(),
144
value, min, max_uintx);
145
return JVMFlag::VIOLATES_CONSTRAINT;
146
}
147
148
return JVMFlag::SUCCESS;
149
}
150
151
JVMFlag::Error NUMAInterleaveGranularityConstraintFunc(size_t value, bool verbose) {
152
size_t min = os::vm_allocation_granularity();
153
size_t max = NOT_LP64(2*G) LP64_ONLY(8192*G);
154
155
if (value < min || value > max) {
156
JVMFlag::printError(verbose,
157
"size_t NUMAInterleaveGranularity=" UINTX_FORMAT " is outside the allowed range [ " UINTX_FORMAT
158
" ... " UINTX_FORMAT " ]\n", value, min, max);
159
return JVMFlag::VIOLATES_CONSTRAINT;
160
}
161
162
return JVMFlag::SUCCESS;
163
}
164
165