Skip to content

Commit 7121d71

Browse files
committedJul 31, 2024
8337421: RISC-V: client VM build failure after JDK-8335191
Reviewed-by: fyang, mli
1 parent 61386c1 commit 7121d71

File tree

3 files changed

+107
-104
lines changed

3 files changed

+107
-104
lines changed
 

‎src/hotspot/cpu/riscv/stubGenerator_riscv.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -5936,7 +5936,6 @@ static const int64_t right_3_bits = right_n_bits(3);
59365936
}
59375937

59385938
void generate_compiler_stubs() {
5939-
#if COMPILER2_OR_JVMCI
59405939
#ifdef COMPILER2
59415940
if (UseMulAddIntrinsic) {
59425941
StubRoutines::_mulAdd = generate_mulAdd();
@@ -5970,7 +5969,6 @@ static const int64_t right_3_bits = right_n_bits(3);
59705969
StubRoutines::_bigIntegerLeftShiftWorker = generate_bigIntegerLeftShift();
59715970
StubRoutines::_bigIntegerRightShiftWorker = generate_bigIntegerRightShift();
59725971
}
5973-
#endif // COMPILER2
59745972

59755973
if (UseSHA256Intrinsics) {
59765974
Sha2Generator sha2(_masm, this);
@@ -5984,10 +5982,6 @@ static const int64_t right_3_bits = right_n_bits(3);
59845982
StubRoutines::_sha512_implCompressMB = sha2.generate_sha512_implCompress(true);
59855983
}
59865984

5987-
generate_compare_long_strings();
5988-
5989-
generate_string_indexof_stubs();
5990-
59915985
if (UseMD5Intrinsics) {
59925986
StubRoutines::_md5_implCompress = generate_md5_implCompress(false, "md5_implCompress");
59935987
StubRoutines::_md5_implCompressMB = generate_md5_implCompress(true, "md5_implCompressMB");
@@ -6006,7 +6000,11 @@ static const int64_t right_3_bits = right_n_bits(3);
60066000
StubRoutines::_updateBytesAdler32 = generate_updateBytesAdler32();
60076001
}
60086002

6009-
#endif // COMPILER2_OR_JVMCI
6003+
generate_compare_long_strings();
6004+
6005+
generate_string_indexof_stubs();
6006+
6007+
#endif // COMPILER2
60106008
}
60116009

60126010
public:

‎src/hotspot/cpu/riscv/vm_version_riscv.cpp

+100-97
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ void VM_Version::useRVA23U64Profile() {
5858
}
5959

6060
void VM_Version::initialize() {
61+
common_initialize();
62+
#ifdef COMPILER2
63+
c2_initialize();
64+
#endif // COMPILER2
65+
}
66+
67+
void VM_Version::common_initialize() {
6168
_supports_atomic_getset4 = true;
6269
_supports_atomic_getadd4 = true;
6370
_supports_atomic_getset8 = true;
@@ -152,10 +159,6 @@ void VM_Version::initialize() {
152159
FLAG_SET_DEFAULT(UseVectorizedMismatchIntrinsic, false);
153160
}
154161

155-
if (FLAG_IS_DEFAULT(UseMD5Intrinsics)) {
156-
FLAG_SET_DEFAULT(UseMD5Intrinsics, true);
157-
}
158-
159162
if (FLAG_IS_DEFAULT(UsePoly1305Intrinsics)) {
160163
FLAG_SET_DEFAULT(UsePoly1305Intrinsics, true);
161164
}
@@ -230,15 +233,105 @@ void VM_Version::initialize() {
230233
_initial_vector_length = cpu_vector_length();
231234
}
232235
}
236+
}
233237

234238
#ifdef COMPILER2
235-
c2_initialize();
236-
#endif // COMPILER2
239+
void VM_Version::c2_initialize() {
240+
if (UseCMoveUnconditionally) {
241+
FLAG_SET_DEFAULT(UseCMoveUnconditionally, false);
242+
}
243+
244+
if (ConditionalMoveLimit > 0) {
245+
FLAG_SET_DEFAULT(ConditionalMoveLimit, 0);
246+
}
237247

238-
// NOTE: Make sure codes dependent on UseRVV are put after c2_initialize(),
248+
if (!UseRVV) {
249+
FLAG_SET_DEFAULT(MaxVectorSize, 0);
250+
FLAG_SET_DEFAULT(UseRVVForBigIntegerShiftIntrinsics, false);
251+
} else {
252+
if (!FLAG_IS_DEFAULT(MaxVectorSize) && MaxVectorSize != _initial_vector_length) {
253+
warning("Current system does not support RVV vector length for MaxVectorSize %d. Set MaxVectorSize to %d",
254+
(int)MaxVectorSize, _initial_vector_length);
255+
}
256+
MaxVectorSize = _initial_vector_length;
257+
if (MaxVectorSize < 16) {
258+
warning("RVV does not support vector length less than 16 bytes. Disabling RVV.");
259+
UseRVV = false;
260+
FLAG_SET_DEFAULT(MaxVectorSize, 0);
261+
}
262+
}
263+
264+
// NOTE: Make sure codes dependent on UseRVV are put after MaxVectorSize initialize,
239265
// as there are extra checks inside it which could disable UseRVV
240266
// in some situations.
241267

268+
if (FLAG_IS_DEFAULT(UseVectorizedHashCodeIntrinsic)) {
269+
FLAG_SET_DEFAULT(UseVectorizedHashCodeIntrinsic, true);
270+
}
271+
272+
if (!UseZicbop) {
273+
if (!FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
274+
warning("Zicbop is not available on this CPU");
275+
}
276+
FLAG_SET_DEFAULT(AllocatePrefetchStyle, 0);
277+
} else {
278+
// Limit AllocatePrefetchDistance so that it does not exceed the
279+
// static constraint of 512 defined in runtime/globals.hpp.
280+
if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
281+
FLAG_SET_DEFAULT(AllocatePrefetchDistance, MIN2(512, 3 * (int)CacheLineSize));
282+
}
283+
if (FLAG_IS_DEFAULT(AllocatePrefetchStepSize)) {
284+
FLAG_SET_DEFAULT(AllocatePrefetchStepSize, (int)CacheLineSize);
285+
}
286+
if (FLAG_IS_DEFAULT(PrefetchScanIntervalInBytes)) {
287+
FLAG_SET_DEFAULT(PrefetchScanIntervalInBytes, 3 * (int)CacheLineSize);
288+
}
289+
if (FLAG_IS_DEFAULT(PrefetchCopyIntervalInBytes)) {
290+
FLAG_SET_DEFAULT(PrefetchCopyIntervalInBytes, 3 * (int)CacheLineSize);
291+
}
292+
293+
if (PrefetchCopyIntervalInBytes != -1 &&
294+
((PrefetchCopyIntervalInBytes & 7) || (PrefetchCopyIntervalInBytes >= 32768))) {
295+
warning("PrefetchCopyIntervalInBytes must be -1, or a multiple of 8 and < 32768");
296+
PrefetchCopyIntervalInBytes &= ~7;
297+
if (PrefetchCopyIntervalInBytes >= 32768) {
298+
PrefetchCopyIntervalInBytes = 32760;
299+
}
300+
}
301+
if (AllocatePrefetchDistance !=-1 && (AllocatePrefetchDistance & 7)) {
302+
warning("AllocatePrefetchDistance must be multiple of 8");
303+
AllocatePrefetchDistance &= ~7;
304+
}
305+
if (AllocatePrefetchStepSize & 7) {
306+
warning("AllocatePrefetchStepSize must be multiple of 8");
307+
AllocatePrefetchStepSize &= ~7;
308+
}
309+
}
310+
311+
if (FLAG_IS_DEFAULT(UseMulAddIntrinsic)) {
312+
FLAG_SET_DEFAULT(UseMulAddIntrinsic, true);
313+
}
314+
315+
if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
316+
FLAG_SET_DEFAULT(UseMultiplyToLenIntrinsic, true);
317+
}
318+
319+
if (FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) {
320+
FLAG_SET_DEFAULT(UseSquareToLenIntrinsic, true);
321+
}
322+
323+
if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
324+
FLAG_SET_DEFAULT(UseMontgomeryMultiplyIntrinsic, true);
325+
}
326+
327+
if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) {
328+
FLAG_SET_DEFAULT(UseMontgomerySquareIntrinsic, true);
329+
}
330+
331+
if (FLAG_IS_DEFAULT(UseMD5Intrinsics)) {
332+
FLAG_SET_DEFAULT(UseMD5Intrinsics, true);
333+
}
334+
242335
// Adler32
243336
if (UseRVV) {
244337
if (FLAG_IS_DEFAULT(UseAdler32Intrinsics)) {
@@ -332,96 +425,6 @@ void VM_Version::initialize() {
332425
FLAG_SET_DEFAULT(UseSHA, false);
333426
}
334427
}
335-
336-
#ifdef COMPILER2
337-
void VM_Version::c2_initialize() {
338-
if (UseCMoveUnconditionally) {
339-
FLAG_SET_DEFAULT(UseCMoveUnconditionally, false);
340-
}
341-
342-
if (ConditionalMoveLimit > 0) {
343-
FLAG_SET_DEFAULT(ConditionalMoveLimit, 0);
344-
}
345-
346-
if (!UseRVV) {
347-
FLAG_SET_DEFAULT(MaxVectorSize, 0);
348-
FLAG_SET_DEFAULT(UseRVVForBigIntegerShiftIntrinsics, false);
349-
} else {
350-
if (!FLAG_IS_DEFAULT(MaxVectorSize) && MaxVectorSize != _initial_vector_length) {
351-
warning("Current system does not support RVV vector length for MaxVectorSize %d. Set MaxVectorSize to %d",
352-
(int)MaxVectorSize, _initial_vector_length);
353-
}
354-
MaxVectorSize = _initial_vector_length;
355-
if (MaxVectorSize < 16) {
356-
warning("RVV does not support vector length less than 16 bytes. Disabling RVV.");
357-
UseRVV = false;
358-
FLAG_SET_DEFAULT(MaxVectorSize, 0);
359-
}
360-
}
361-
362-
if (FLAG_IS_DEFAULT(UseVectorizedHashCodeIntrinsic)) {
363-
FLAG_SET_DEFAULT(UseVectorizedHashCodeIntrinsic, true);
364-
}
365-
366-
if (!UseZicbop) {
367-
if (!FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
368-
warning("Zicbop is not available on this CPU");
369-
}
370-
FLAG_SET_DEFAULT(AllocatePrefetchStyle, 0);
371-
} else {
372-
// Limit AllocatePrefetchDistance so that it does not exceed the
373-
// static constraint of 512 defined in runtime/globals.hpp.
374-
if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
375-
FLAG_SET_DEFAULT(AllocatePrefetchDistance, MIN2(512, 3 * (int)CacheLineSize));
376-
}
377-
if (FLAG_IS_DEFAULT(AllocatePrefetchStepSize)) {
378-
FLAG_SET_DEFAULT(AllocatePrefetchStepSize, (int)CacheLineSize);
379-
}
380-
if (FLAG_IS_DEFAULT(PrefetchScanIntervalInBytes)) {
381-
FLAG_SET_DEFAULT(PrefetchScanIntervalInBytes, 3 * (int)CacheLineSize);
382-
}
383-
if (FLAG_IS_DEFAULT(PrefetchCopyIntervalInBytes)) {
384-
FLAG_SET_DEFAULT(PrefetchCopyIntervalInBytes, 3 * (int)CacheLineSize);
385-
}
386-
387-
if (PrefetchCopyIntervalInBytes != -1 &&
388-
((PrefetchCopyIntervalInBytes & 7) || (PrefetchCopyIntervalInBytes >= 32768))) {
389-
warning("PrefetchCopyIntervalInBytes must be -1, or a multiple of 8 and < 32768");
390-
PrefetchCopyIntervalInBytes &= ~7;
391-
if (PrefetchCopyIntervalInBytes >= 32768) {
392-
PrefetchCopyIntervalInBytes = 32760;
393-
}
394-
}
395-
if (AllocatePrefetchDistance !=-1 && (AllocatePrefetchDistance & 7)) {
396-
warning("AllocatePrefetchDistance must be multiple of 8");
397-
AllocatePrefetchDistance &= ~7;
398-
}
399-
if (AllocatePrefetchStepSize & 7) {
400-
warning("AllocatePrefetchStepSize must be multiple of 8");
401-
AllocatePrefetchStepSize &= ~7;
402-
}
403-
}
404-
405-
if (FLAG_IS_DEFAULT(UseMulAddIntrinsic)) {
406-
FLAG_SET_DEFAULT(UseMulAddIntrinsic, true);
407-
}
408-
409-
if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
410-
FLAG_SET_DEFAULT(UseMultiplyToLenIntrinsic, true);
411-
}
412-
413-
if (FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) {
414-
FLAG_SET_DEFAULT(UseSquareToLenIntrinsic, true);
415-
}
416-
417-
if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
418-
FLAG_SET_DEFAULT(UseMontgomeryMultiplyIntrinsic, true);
419-
}
420-
421-
if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) {
422-
FLAG_SET_DEFAULT(UseMontgomerySquareIntrinsic, true);
423-
}
424-
}
425428
#endif // COMPILER2
426429

427430
void VM_Version::initialize_cpu_information(void) {

‎src/hotspot/cpu/riscv/vm_version_riscv.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ class VM_Version : public Abstract_VM_Version {
264264
static uint32_t cpu_vector_length();
265265
static uint32_t _initial_vector_length;
266266

267+
static void common_initialize();
268+
267269
#ifdef COMPILER2
268270
static void c2_initialize();
269271
#endif // COMPILER2

0 commit comments

Comments
 (0)
Please sign in to comment.