Skip to content
This repository was archived by the owner on Sep 2, 2022. It is now read-only.

Commit a7e5da2

Browse files
author
Ningsheng Jian
committed
8258384: AArch64: SVE verify_ptrue fails on some tests
Reviewed-by: adinn, ngasson
1 parent 2cb271e commit a7e5da2

6 files changed

+45
-43
lines changed

src/hotspot/cpu/aarch64/aarch64.ad

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
2-
// Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
3-
// Copyright (c) 2014, 2020, Red Hat, Inc. All rights reserved.
2+
// Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
3+
// Copyright (c) 2014, 2021, Red Hat, Inc. All rights reserved.
44
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
//
66
// This code is free software; you can redistribute it and/or modify it
@@ -1911,7 +1911,7 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
19111911
__ bind(L_skip_barrier);
19121912
}
19131913

1914-
if (UseSVE > 0 && C->max_vector_size() >= 16) {
1914+
if (C->max_vector_size() >= 16) {
19151915
__ reinitialize_ptrue();
19161916
}
19171917

@@ -3793,11 +3793,9 @@ encode %{
37933793
}
37943794
}
37953795

3796-
if (UseSVE > 0 && Compile::current()->max_vector_size() >= 16) {
3797-
// Only non uncommon_trap calls need to reinitialize ptrue.
3798-
if (uncommon_trap_request() == 0) {
3799-
__ reinitialize_ptrue();
3800-
}
3796+
// Only non uncommon_trap calls need to reinitialize ptrue.
3797+
if (Compile::current()->max_vector_size() >= 16 && uncommon_trap_request() == 0) {
3798+
__ reinitialize_ptrue();
38013799
}
38023800
%}
38033801

@@ -3808,7 +3806,7 @@ encode %{
38083806
if (call == NULL) {
38093807
ciEnv::current()->record_failure("CodeCache is full");
38103808
return;
3811-
} else if (UseSVE > 0 && Compile::current()->max_vector_size() >= 16) {
3809+
} else if (Compile::current()->max_vector_size() >= 16) {
38123810
__ reinitialize_ptrue();
38133811
}
38143812
%}
@@ -3846,7 +3844,7 @@ encode %{
38463844
__ bind(retaddr);
38473845
__ add(sp, sp, 2 * wordSize);
38483846
}
3849-
if (UseSVE > 0 && Compile::current()->max_vector_size() >= 16) {
3847+
if (Compile::current()->max_vector_size() >= 16) {
38503848
__ reinitialize_ptrue();
38513849
}
38523850
%}
@@ -3859,7 +3857,7 @@ encode %{
38593857
enc_class aarch64_enc_ret() %{
38603858
C2_MacroAssembler _masm(&cbuf);
38613859
#ifdef ASSERT
3862-
if (UseSVE > 0 && Compile::current()->max_vector_size() >= 16) {
3860+
if (Compile::current()->max_vector_size() >= 16) {
38633861
__ verify_ptrue();
38643862
}
38653863
#endif

src/hotspot/cpu/aarch64/gc/z/zBarrierSetAssembler_aarch64.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -354,6 +354,10 @@ class ZSaveLiveRegisters {
354354
~ZSaveLiveRegisters() {
355355
// Restore registers
356356
__ pop_fp(_fp_regs, sp);
357+
358+
// External runtime call may clobber ptrue reg
359+
__ reinitialize_ptrue();
360+
357361
__ pop(_gp_regs, sp);
358362
}
359363
};
@@ -428,11 +432,6 @@ void ZBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, Z
428432
ZSetupArguments setup_arguments(masm, stub);
429433
__ mov(rscratch1, stub->slow_path());
430434
__ blr(rscratch1);
431-
if (UseSVE > 0) {
432-
// Reinitialize the ptrue predicate register, in case the external runtime
433-
// call clobbers ptrue reg, as we may return to SVE compiled code.
434-
__ reinitialize_ptrue();
435-
}
436435
}
437436
// Stub exit
438437
__ b(*stub->continuation());

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -2659,6 +2659,8 @@ void MacroAssembler::pop_call_clobbered_registers_except(RegSet exclude) {
26592659
as_FloatRegister(i+3), T1D, Address(post(sp, 4 * wordSize)));
26602660
}
26612661

2662+
reinitialize_ptrue();
2663+
26622664
pop(call_clobbered_registers() - exclude, sp);
26632665
}
26642666

@@ -2695,6 +2697,11 @@ void MacroAssembler::pop_CPU_state(bool restore_vectors, bool use_sve,
26952697
ld1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
26962698
as_FloatRegister(i+3), restore_vectors ? T2D : T1D, Address(post(sp, step)));
26972699
}
2700+
2701+
if (restore_vectors) {
2702+
reinitialize_ptrue();
2703+
}
2704+
26982705
pop(0x3fffffff, sp); // integer registers except lr & sp
26992706
}
27002707

@@ -5304,7 +5311,9 @@ void MacroAssembler::verify_sve_vector_length() {
53045311

53055312
void MacroAssembler::verify_ptrue() {
53065313
Label verify_ok;
5307-
assert(UseSVE > 0, "should only be used for SVE");
5314+
if (!UseSVE) {
5315+
return;
5316+
}
53085317
sve_cntp(rscratch1, B, ptrue, ptrue); // get true elements count.
53095318
sve_dec(rscratch1, B);
53105319
cbz(rscratch1, verify_ok);

src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
2+
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -967,7 +967,9 @@ class MacroAssembler: public Assembler {
967967

968968
void verify_sve_vector_length();
969969
void reinitialize_ptrue() {
970-
sve_ptrue(ptrue, B);
970+
if (UseSVE > 0) {
971+
sve_ptrue(ptrue, B);
972+
}
971973
}
972974
void verify_ptrue();
973975

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -2791,12 +2791,6 @@ SafepointBlob* SharedRuntime::generate_handler_blob(address call_ptr, int poll_t
27912791

27922792
__ membar(Assembler::LoadLoad | Assembler::LoadStore);
27932793

2794-
if (UseSVE > 0 && save_vectors) {
2795-
// Reinitialize the ptrue predicate register, in case the external runtime
2796-
// call clobbers ptrue reg, as we may return to SVE compiled code.
2797-
__ reinitialize_ptrue();
2798-
}
2799-
28002794
__ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset()));
28012795
__ cbz(rscratch1, noException);
28022796

@@ -3019,6 +3013,9 @@ void OptoRuntime::generate_exception_blob() {
30193013
// handle_exception_C is a special VM call which does not require an explicit
30203014
// instruction sync afterwards.
30213015

3016+
// May jump to SVE compiled code
3017+
__ reinitialize_ptrue();
3018+
30223019
// Set an oopmap for the call site. This oopmap will only be used if we
30233020
// are unwinding the stack. Hence, all locations will be dead.
30243021
// Callee-saved registers will be the same as the frame above (i.e.,

src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -488,11 +488,10 @@ class StubGenerator: public StubCodeGenerator {
488488
__ call_VM_leaf(CAST_FROM_FN_PTR(address,
489489
SharedRuntime::exception_handler_for_return_address),
490490
rthread, c_rarg1);
491-
if (UseSVE > 0 ) {
492-
// Reinitialize the ptrue predicate register, in case the external runtime
493-
// call clobbers ptrue reg, as we may return to SVE compiled code.
494-
__ reinitialize_ptrue();
495-
}
491+
// Reinitialize the ptrue predicate register, in case the external runtime
492+
// call clobbers ptrue reg, as we may return to SVE compiled code.
493+
__ reinitialize_ptrue();
494+
496495
// we should not really care that lr is no longer the callee
497496
// address. we saved the value the handler needs in r19 so we can
498497
// just copy it to r3. however, the C2 handler will push its own
@@ -5653,11 +5652,9 @@ class StubGenerator: public StubCodeGenerator {
56535652

56545653
__ reset_last_Java_frame(true);
56555654

5656-
if (UseSVE > 0) {
5657-
// Reinitialize the ptrue predicate register, in case the external runtime
5658-
// call clobbers ptrue reg, as we may return to SVE compiled code.
5659-
__ reinitialize_ptrue();
5660-
}
5655+
// Reinitialize the ptrue predicate register, in case the external runtime
5656+
// call clobbers ptrue reg, as we may return to SVE compiled code.
5657+
__ reinitialize_ptrue();
56615658

56625659
__ leave();
56635660

0 commit comments

Comments
 (0)