Skip to content

Commit 99b79fb

Browse files
committed
Backport 29e1ee2eccd59e665827e0d42c490261002cf99e
1 parent 847c59b commit 99b79fb

5 files changed

Lines changed: 476 additions & 14 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2026 SAP SE. 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+
25+
#include "runtime/registerMap.hpp"
26+
27+
address RegisterMap::pd_location(VMReg base_reg, int slot_idx) const {
28+
if (base_reg->is_VectorSRegister()) {
29+
// Not all physical slots belonging to a VectorRegister have corresponding
30+
// valid VMReg locations in the RegisterMap.
31+
// (See RegisterSaver::push_frame_reg_args_and_save_live_registers.)
32+
// However, the slots are always saved to the stack in a contiguous region
33+
// of memory so we can calculate the address of the upper slots by
34+
// offsetting from the base address.
35+
assert(base_reg->is_concrete(), "must pass base reg");
36+
address base_location = location(base_reg);
37+
if (base_location != nullptr) {
38+
intptr_t offset_in_bytes = slot_idx * VMRegImpl::stack_slot_size;
39+
return base_location + offset_in_bytes;
40+
} else {
41+
return nullptr;
42+
}
43+
} else {
44+
return location(base_reg->next(slot_idx));
45+
}
46+
}

src/hotspot/cpu/ppc/registerMap_ppc.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
2+
* Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2012, 2026 SAP SE. 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
@@ -35,9 +35,7 @@
3535
// Since there is none, we just return NULL.
3636
address pd_location(VMReg reg) const { return NULL; }
3737

38-
address pd_location(VMReg base_reg, int slot_idx) const {
39-
return location(base_reg->next(slot_idx));
40-
}
38+
address pd_location(VMReg base_reg, int slot_idx) const;
4139

4240
// no PD state to clear or copy:
4341
void pd_clear() {}

src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class RegisterSaver {
100100

101101
// During deoptimization only the result registers need to be restored
102102
// all the other values have already been extracted.
103-
static void restore_result_registers(MacroAssembler* masm, int frame_size_in_bytes);
103+
static void restore_result_registers(MacroAssembler* masm, int frame_size_in_bytes, bool save_vectors);
104104

105105
// Constants and data structures:
106106

@@ -350,6 +350,7 @@ OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssemble
350350
__ li(R30, offset);
351351
__ stxvd2x(as_VectorSRegister(reg_num), R30, R1_SP);
352352

353+
// RegisterMap::pd_location only uses the first VMReg for each VectorRegister.
353354
if (generate_oop_map) {
354355
map->set_callee_saved(VMRegImpl::stack2reg(offset>>2),
355356
RegisterSaver_LiveVSRegs[i].vmreg);
@@ -523,10 +524,14 @@ void RegisterSaver::restore_argument_registers_and_pop_frame(MacroAssembler*masm
523524
}
524525

525526
// Restore the registers that might be holding a result.
526-
void RegisterSaver::restore_result_registers(MacroAssembler* masm, int frame_size_in_bytes) {
527+
void RegisterSaver::restore_result_registers(MacroAssembler* masm, int frame_size_in_bytes, bool save_vectors) {
527528
const int regstosave_num = sizeof(RegisterSaver_LiveRegs) /
528529
sizeof(RegisterSaver::LiveRegType);
529-
const int register_save_size = regstosave_num * reg_size; // VS registers not relevant here.
530+
const int vecregstosave_num = save_vectors ? (sizeof(RegisterSaver_LiveVSRegs) /
531+
sizeof(RegisterSaver::LiveRegType))
532+
: 0;
533+
const int register_save_size = regstosave_num * reg_size + vecregstosave_num * vs_reg_size;
534+
530535
const int register_save_offset = frame_size_in_bytes - register_save_size;
531536

532537
// restore all result registers (ints and floats)
@@ -555,7 +560,7 @@ void RegisterSaver::restore_result_registers(MacroAssembler* masm, int frame_siz
555560
offset += reg_size;
556561
}
557562

558-
assert(offset == frame_size_in_bytes, "consistency check");
563+
assert(offset == frame_size_in_bytes - (save_vectors ? vecregstosave_num * vs_reg_size : 0), "consistency check");
559564
}
560565

561566
// Is vector's size (in bytes) bigger than a size saved by default?
@@ -2701,7 +2706,8 @@ void SharedRuntime::generate_deopt_blob() {
27012706
&first_frame_size_in_bytes,
27022707
/*generate_oop_map=*/ true,
27032708
return_pc_adjustment_no_exception,
2704-
RegisterSaver::return_pc_is_lr);
2709+
RegisterSaver::return_pc_is_lr,
2710+
/*save_vectors*/ SuperwordUseVSX);
27052711
assert(map != NULL, "OopMap must have been created");
27062712

27072713
__ li(exec_mode_reg, Deoptimization::Unpack_deopt);
@@ -2736,7 +2742,8 @@ void SharedRuntime::generate_deopt_blob() {
27362742
&first_frame_size_in_bytes,
27372743
/*generate_oop_map=*/ false,
27382744
/*return_pc_adjustment_exception=*/ 0,
2739-
RegisterSaver::return_pc_is_pre_saved);
2745+
RegisterSaver::return_pc_is_pre_saved,
2746+
/*save_vectors*/ SuperwordUseVSX);
27402747

27412748
// Deopt during an exception. Save exec mode for unpack_frames.
27422749
__ li(exec_mode_reg, Deoptimization::Unpack_exception);
@@ -2754,7 +2761,8 @@ void SharedRuntime::generate_deopt_blob() {
27542761
&first_frame_size_in_bytes,
27552762
/*generate_oop_map=*/ false,
27562763
/*return_pc_adjustment_reexecute=*/ 0,
2757-
RegisterSaver::return_pc_is_pre_saved);
2764+
RegisterSaver::return_pc_is_pre_saved,
2765+
/*save_vectors*/ SuperwordUseVSX);
27582766
__ li(exec_mode_reg, Deoptimization::Unpack_reexecute);
27592767
#endif
27602768

@@ -2781,7 +2789,7 @@ void SharedRuntime::generate_deopt_blob() {
27812789

27822790
// Restore only the result registers that have been saved
27832791
// by save_volatile_registers(...).
2784-
RegisterSaver::restore_result_registers(masm, first_frame_size_in_bytes);
2792+
RegisterSaver::restore_result_registers(masm, first_frame_size_in_bytes, /*save_vectors*/ SuperwordUseVSX);
27852793

27862794
// reload the exec mode from the UnrollBlock (it might have changed)
27872795
__ lwz(exec_mode_reg, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes(), unroll_block_reg);

src/hotspot/cpu/ppc/vm_version_ppc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "jvm.h"
2828
#include "asm/assembler.inline.hpp"
2929
#include "asm/macroAssembler.inline.hpp"
30+
#include "compiler/compilerDefinitions.hpp"
3031
#include "compiler/disassembler.hpp"
3132
#include "memory/resourceArea.hpp"
3233
#include "runtime/globals_extension.hpp"
@@ -129,7 +130,7 @@ void VM_Version::initialize() {
129130
}
130131

131132
if (PowerArchitecturePPC64 >= 8) {
132-
if (FLAG_IS_DEFAULT(SuperwordUseVSX)) {
133+
if (FLAG_IS_DEFAULT(SuperwordUseVSX) && CompilerConfig::is_c2_enabled()) {
133134
FLAG_SET_ERGO(SuperwordUseVSX, true);
134135
}
135136
} else {

0 commit comments

Comments
 (0)