1 | /* |
2 | * Copyright (c) 2015, 2018, 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/arguments.hpp" |
27 | #include "runtime/flags/jvmFlag.hpp" |
28 | #include "runtime/flags/jvmFlagConstraintsRuntime.hpp" |
29 | #include "runtime/globals.hpp" |
30 | #include "runtime/safepointMechanism.hpp" |
31 | #include "runtime/task.hpp" |
32 | |
33 | JVMFlag::Error ObjectAlignmentInBytesConstraintFunc(intx value, bool verbose) { |
34 | if (!is_power_of_2(value)) { |
35 | JVMFlag::printError(verbose, |
36 | "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " |
37 | "power of 2\n" , |
38 | value); |
39 | return JVMFlag::VIOLATES_CONSTRAINT; |
40 | } |
41 | // In case page size is very small. |
42 | if (value >= (intx)os::vm_page_size()) { |
43 | JVMFlag::printError(verbose, |
44 | "ObjectAlignmentInBytes (" INTX_FORMAT ") must be " |
45 | "less than page size (%d)\n" , |
46 | value, os::vm_page_size()); |
47 | return JVMFlag::VIOLATES_CONSTRAINT; |
48 | } |
49 | return JVMFlag::SUCCESS; |
50 | } |
51 | |
52 | // Need to enforce the padding not to break the existing field alignments. |
53 | // It is sufficient to check against the largest type size. |
54 | JVMFlag::Error ContendedPaddingWidthConstraintFunc(intx value, bool verbose) { |
55 | if ((value % BytesPerLong) != 0) { |
56 | JVMFlag::printError(verbose, |
57 | "ContendedPaddingWidth (" INTX_FORMAT ") must be " |
58 | "a multiple of %d\n" , |
59 | value, BytesPerLong); |
60 | return JVMFlag::VIOLATES_CONSTRAINT; |
61 | } else { |
62 | return JVMFlag::SUCCESS; |
63 | } |
64 | } |
65 | |
66 | JVMFlag::Error BiasedLockingBulkRebiasThresholdFunc(intx value, bool verbose) { |
67 | if (value > BiasedLockingBulkRevokeThreshold) { |
68 | JVMFlag::printError(verbose, |
69 | "BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ") must be " |
70 | "less than or equal to BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")\n" , |
71 | value, BiasedLockingBulkRevokeThreshold); |
72 | return JVMFlag::VIOLATES_CONSTRAINT; |
73 | } else { |
74 | return JVMFlag::SUCCESS; |
75 | } |
76 | } |
77 | |
78 | JVMFlag::Error BiasedLockingStartupDelayFunc(intx value, bool verbose) { |
79 | if ((value % PeriodicTask::interval_gran) != 0) { |
80 | JVMFlag::printError(verbose, |
81 | "BiasedLockingStartupDelay (" INTX_FORMAT ") must be " |
82 | "evenly divisible by PeriodicTask::interval_gran (%d)\n" , |
83 | value, PeriodicTask::interval_gran); |
84 | return JVMFlag::VIOLATES_CONSTRAINT; |
85 | } else { |
86 | return JVMFlag::SUCCESS; |
87 | } |
88 | } |
89 | |
90 | JVMFlag::Error BiasedLockingBulkRevokeThresholdFunc(intx value, bool verbose) { |
91 | if (value < BiasedLockingBulkRebiasThreshold) { |
92 | JVMFlag::printError(verbose, |
93 | "BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ") must be " |
94 | "greater than or equal to BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")\n" , |
95 | value, BiasedLockingBulkRebiasThreshold); |
96 | return JVMFlag::VIOLATES_CONSTRAINT; |
97 | } else if ((double)value/(double)BiasedLockingDecayTime > 0.1) { |
98 | JVMFlag::printError(verbose, |
99 | "The ratio of BiasedLockingBulkRevokeThreshold (" INTX_FORMAT ")" |
100 | " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " |
101 | "less than or equal to 0.1\n" , |
102 | value, BiasedLockingBulkRebiasThreshold); |
103 | return JVMFlag::VIOLATES_CONSTRAINT; |
104 | } else { |
105 | return JVMFlag::SUCCESS; |
106 | } |
107 | } |
108 | |
109 | JVMFlag::Error BiasedLockingDecayTimeFunc(intx value, bool verbose) { |
110 | if (BiasedLockingBulkRebiasThreshold/(double)value > 0.1) { |
111 | JVMFlag::printError(verbose, |
112 | "The ratio of BiasedLockingBulkRebiasThreshold (" INTX_FORMAT ")" |
113 | " to BiasedLockingDecayTime (" INTX_FORMAT ") must be " |
114 | "less than or equal to 0.1\n" , |
115 | BiasedLockingBulkRebiasThreshold, value); |
116 | return JVMFlag::VIOLATES_CONSTRAINT; |
117 | } else { |
118 | return JVMFlag::SUCCESS; |
119 | } |
120 | } |
121 | |
122 | JVMFlag::Error PerfDataSamplingIntervalFunc(intx value, bool verbose) { |
123 | if ((value % PeriodicTask::interval_gran != 0)) { |
124 | JVMFlag::printError(verbose, |
125 | "PerfDataSamplingInterval (" INTX_FORMAT ") must be " |
126 | "evenly divisible by PeriodicTask::interval_gran (%d)\n" , |
127 | value, PeriodicTask::interval_gran); |
128 | return JVMFlag::VIOLATES_CONSTRAINT; |
129 | } else { |
130 | return JVMFlag::SUCCESS; |
131 | } |
132 | } |
133 | |
134 | JVMFlag::Error ThreadLocalHandshakesConstraintFunc(bool value, bool verbose) { |
135 | if (value) { |
136 | if (!SafepointMechanism::supports_thread_local_poll()) { |
137 | JVMFlag::printError(verbose, "ThreadLocalHandshakes not yet supported on this platform\n" ); |
138 | return JVMFlag::VIOLATES_CONSTRAINT; |
139 | } |
140 | } |
141 | return JVMFlag::SUCCESS; |
142 | } |
143 | |