Fri, 15 Jun 2018 17:25:38 +0800
#7167 disable UseSHA, UseSHA1Intrinsics, UseSHA256Intrinsics and UseSHA512Intrinsics on MIPS
Reviewed-by: aoqi
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
26 #include "precompiled.hpp"
27 #include "asm/macroAssembler.hpp"
28 #include "asm/macroAssembler.inline.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "runtime/java.hpp"
31 #include "runtime/stubCodeGenerator.hpp"
32 #include "vm_version_mips.hpp"
33 #ifdef TARGET_OS_FAMILY_linux
34 # include "os_linux.inline.hpp"
35 #endif
36 #ifdef TARGET_OS_FAMILY_solaris
37 # include "os_solaris.inline.hpp"
38 #endif
39 #ifdef TARGET_OS_FAMILY_windows
40 # include "os_windows.inline.hpp"
41 #endif
42 #ifdef TARGET_OS_FAMILY_bsd
43 # include "os_bsd.inline.hpp"
44 #endif
45 /*
46 int VM_Version::_cpu;
47 int VM_Version::_model;
48 int VM_Version::_stepping;
49 int VM_Version::_cpuFeatures;
50 const char* VM_Version::_features_str = "";
51 VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, };
53 static BufferBlob* stub_blob;
54 static const int stub_size = 300;
56 extern "C" {
57 typedef void (*getPsrInfo_stub_t)(void*);
58 }
59 static getPsrInfo_stub_t getPsrInfo_stub = NULL;
60 */
61 int VM_Version::_features = VM_Version::unknown_m;
62 const char* VM_Version::_features_str = "";
63 /*
64 class VM_Version_StubGenerator: public StubCodeGenerator {
65 public:
67 VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
69 address generate_getPsrInfo() {
70 };
71 };
74 void VM_Version::get_processor_features() {
75 }
76 */
77 void VM_Version::initialize() {
79 _features = determine_features();
80 //no need, Abstract_VM_Version already define it as false
81 _supports_cx8 = true;
83 //////////////////////add some other feature here//////////////////
85 if (UseG1GC && FLAG_IS_DEFAULT(MaxGCPauseMillis)) {
86 FLAG_SET_CMDLINE(uintx, MaxGCPauseMillis, 650);
87 }
89 #ifdef COMPILER2
90 if (MaxVectorSize > 0) {
91 if (!is_power_of_2(MaxVectorSize)) {
92 warning("MaxVectorSize must be a power of 2");
93 MaxVectorSize = 8;
94 }
95 if (MaxVectorSize > 0 && supports_ps()) {
96 MaxVectorSize = 8;
97 }
98 }
99 /*
100 *
101 * 2017/5/17:
102 * Vector optimization of MIPS works in most cases, but cannot pass hotspot/test/compiler/6340864/TestFloatVect.java.
103 * Vector optimization was closed by default.
104 * The reasons:
105 * 1. The kernel does not have emulation of PS instructions yet, so the emulation of PS instructions must be done in JVM, see JVM_handle_linux_signal.
106 * 2. It seems the gcc4.4.7 had some bug related to ucontext_t, which is used in signal handler to emulate PS instructions.
107 */
108 if (FLAG_IS_DEFAULT(MaxVectorSize)) {
109 MaxVectorSize = 0;
110 }
112 if (is_gs464e()) {
113 if (FLAG_IS_DEFAULT(UseCountTrailingZerosInstruction)) {
114 FLAG_SET_DEFAULT(UseCountTrailingZerosInstruction, 1);
115 }
116 } else if (UseCountTrailingZerosInstruction) {
117 if (!FLAG_IS_DEFAULT(UseCountTrailingZerosInstruction))
118 warning("Only 3A2000/3000 CPUs support UseCountTrailingZerosInstruction");
119 FLAG_SET_DEFAULT(UseCountTrailingZerosInstruction, 0);
120 }
121 #endif
122 UseSSE = 0; // Only on x86 and x64
124 if (is_loongson()) {
125 if (FLAG_IS_DEFAULT(UseLoongsonISA)) {
126 FLAG_SET_DEFAULT(UseLoongsonISA, 1);
127 }
128 } else if (UseLoongsonISA) {
129 if (!FLAG_IS_DEFAULT(UseLoongsonISA))
130 warning("Only Loongson CPUs support LoongISA");
131 FLAG_SET_DEFAULT(UseLoongsonISA, 0);
132 }
134 if (is_gs464e()) {
135 if (FLAG_IS_DEFAULT(Use3A2000)) {
136 FLAG_SET_DEFAULT(Use3A2000, 1);
137 }
138 } else if (Use3A2000) {
139 if (!FLAG_IS_DEFAULT(Use3A2000))
140 warning("Only 3A2000/3000 CPUs support this option");
141 FLAG_SET_DEFAULT(Use3A2000, 0);
142 }
144 if (is_gs464()) {
145 if (FLAG_IS_DEFAULT(UseSyncLevel)) {
146 FLAG_SET_DEFAULT(UseSyncLevel, 1000);
147 }
148 }
150 if (is_gs464e()) {
151 if (FLAG_IS_DEFAULT(UseSyncLevel)) {
152 FLAG_SET_DEFAULT(UseSyncLevel, 2000);
153 }
154 }
156 if (TieredCompilation) {
157 if (!FLAG_IS_DEFAULT(TieredCompilation))
158 warning("TieredCompilation not supported");
159 FLAG_SET_DEFAULT(TieredCompilation, false);
160 }
162 char buf[256];
163 jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
164 (has_l2_cache() ? ", has_l2_cache" : ""),
165 (has_16k_page() ? ", has_16k_page" : ""),
166 (is_loongson() ? ", on_loongson" : ""),
167 (is_gs464() ? ", 3A1000/3B1500" : ""),
168 (is_gs464e() ? ", 3A2000/3A3000/3B2000/3B3000" : ""),
169 (is_gs264() ? ", 2K1000" : ""),
170 (UseLoongsonISA ? ", UseLoongsonISA" : ""),
171 (UseCountTrailingZerosInstruction ? ", UseCountTrailingZerosInstruction" : ""),
172 (Use3A2000 ? ", Use3A2000" : ""));
174 // buf is started with ", " or is empty
175 _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf);
177 if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
178 FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
179 }
181 if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) {
182 FLAG_SET_DEFAULT(AllocatePrefetchLines, 1);
183 }
185 if (FLAG_IS_DEFAULT(AllocatePrefetchStepSize)) {
186 FLAG_SET_DEFAULT(AllocatePrefetchStepSize, 64);
187 }
189 if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
190 FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64);
191 }
193 if (FLAG_IS_DEFAULT(AllocateInstancePrefetchLines)) {
194 FLAG_SET_DEFAULT(AllocateInstancePrefetchLines, 1);
195 }
197 if (UseSHA) {
198 warning("SHA instructions are not available on this CPU");
199 FLAG_SET_DEFAULT(UseSHA, false);
200 }
202 if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) {
203 warning("SHA intrinsics are not available on this CPU");
204 FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
205 FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
206 FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
207 }
209 NOT_PRODUCT( if (PrintMiscellaneous && Verbose) print_features(); );
210 }
212 void VM_Version::print_features() {
213 tty->print_cr("Version:%s", cpu_features());
214 }
216 int VM_Version::determine_features() {
217 //////////////////////add some other feature here//////////////////
218 int features = platform_features(unknown_m);
219 //spt_16k_page_m;
220 return features;
221 }
223 static int saved_features = 0;
225 void VM_Version::allow_all() {
226 saved_features = _features;
227 _features = all_features_m;
228 }
230 void VM_Version::revert() {
231 _features = saved_features;
232 }