Skip to content

Commit 14591b2

Browse files
committed
Backport 29e1ee2eccd59e665827e0d42c490261002cf99e
1 parent 4f9850a commit 14591b2

5 files changed

Lines changed: 481 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, nullptr);
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), nullptr);
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, 2023, 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 nullptr; }
3737

38-
address pd_location(VMReg base_reg, int slot_idx) const {
39-
return location(base_reg->next(slot_idx), nullptr);
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
@@ -105,7 +105,7 @@ class RegisterSaver {
105105

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

110110
// Constants and data structures:
111111

@@ -355,6 +355,7 @@ OopMap* RegisterSaver::push_frame_reg_args_and_save_live_registers(MacroAssemble
355355
__ li(R30, offset);
356356
__ stxvd2x(as_VectorSRegister(reg_num), R30, R1_SP);
357357

358+
// RegisterMap::pd_location only uses the first VMReg for each VectorRegister.
358359
if (generate_oop_map) {
359360
map->set_callee_saved(VMRegImpl::stack2reg(offset>>2),
360361
RegisterSaver_LiveVSRegs[i].vmreg);
@@ -528,10 +529,14 @@ void RegisterSaver::restore_argument_registers_and_pop_frame(MacroAssembler*masm
528529
}
529530

530531
// Restore the registers that might be holding a result.
531-
void RegisterSaver::restore_result_registers(MacroAssembler* masm, int frame_size_in_bytes) {
532+
void RegisterSaver::restore_result_registers(MacroAssembler* masm, int frame_size_in_bytes, bool save_vectors) {
532533
const int regstosave_num = sizeof(RegisterSaver_LiveRegs) /
533534
sizeof(RegisterSaver::LiveRegType);
534-
const int register_save_size = regstosave_num * reg_size; // VS registers not relevant here.
535+
const int vecregstosave_num = save_vectors ? (sizeof(RegisterSaver_LiveVSRegs) /
536+
sizeof(RegisterSaver::LiveRegType))
537+
: 0;
538+
const int register_save_size = regstosave_num * reg_size + vecregstosave_num * vs_reg_size;
539+
535540
const int register_save_offset = frame_size_in_bytes - register_save_size;
536541

537542
// restore all result registers (ints and floats)
@@ -560,7 +565,7 @@ void RegisterSaver::restore_result_registers(MacroAssembler* masm, int frame_siz
560565
offset += reg_size;
561566
}
562567

563-
assert(offset == frame_size_in_bytes, "consistency check");
568+
assert(offset == frame_size_in_bytes - (save_vectors ? vecregstosave_num * vs_reg_size : 0), "consistency check");
564569
}
565570

566571
// Is vector's size (in bytes) bigger than a size saved by default?
@@ -2984,7 +2989,8 @@ void SharedRuntime::generate_deopt_blob() {
29842989
&first_frame_size_in_bytes,
29852990
/*generate_oop_map=*/ true,
29862991
return_pc_adjustment_no_exception,
2987-
RegisterSaver::return_pc_is_lr);
2992+
RegisterSaver::return_pc_is_lr,
2993+
/*save_vectors*/ SuperwordUseVSX);
29882994
assert(map != nullptr, "OopMap must have been created");
29892995

29902996
__ li(exec_mode_reg, Deoptimization::Unpack_deopt);
@@ -3019,7 +3025,8 @@ void SharedRuntime::generate_deopt_blob() {
30193025
&first_frame_size_in_bytes,
30203026
/*generate_oop_map=*/ false,
30213027
/*return_pc_adjustment_exception=*/ 0,
3022-
RegisterSaver::return_pc_is_pre_saved);
3028+
RegisterSaver::return_pc_is_pre_saved,
3029+
/*save_vectors*/ SuperwordUseVSX);
30233030

30243031
// Deopt during an exception. Save exec mode for unpack_frames.
30253032
__ li(exec_mode_reg, Deoptimization::Unpack_exception);
@@ -3037,7 +3044,8 @@ void SharedRuntime::generate_deopt_blob() {
30373044
&first_frame_size_in_bytes,
30383045
/*generate_oop_map=*/ false,
30393046
/*return_pc_adjustment_reexecute=*/ 0,
3040-
RegisterSaver::return_pc_is_pre_saved);
3047+
RegisterSaver::return_pc_is_pre_saved,
3048+
/*save_vectors*/ SuperwordUseVSX);
30413049
__ li(exec_mode_reg, Deoptimization::Unpack_reexecute);
30423050
#endif
30433051

@@ -3063,7 +3071,7 @@ void SharedRuntime::generate_deopt_blob() {
30633071

30643072
// Restore only the result registers that have been saved
30653073
// by save_volatile_registers(...).
3066-
RegisterSaver::restore_result_registers(masm, first_frame_size_in_bytes);
3074+
RegisterSaver::restore_result_registers(masm, first_frame_size_in_bytes, /*save_vectors*/ SuperwordUseVSX);
30673075

30683076
// reload the exec mode from the UnrollBlock (it might have changed)
30693077
__ lwz(exec_mode_reg, in_bytes(Deoptimization::UnrollBlock::unpack_kind_offset()), 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
@@ -26,6 +26,7 @@
2626
#include "precompiled.hpp"
2727
#include "asm/assembler.inline.hpp"
2828
#include "asm/macroAssembler.inline.hpp"
29+
#include "compiler/compilerDefinitions.inline.hpp"
2930
#include "compiler/disassembler.hpp"
3031
#include "jvm.h"
3132
#include "memory/resourceArea.hpp"
@@ -130,7 +131,7 @@ void VM_Version::initialize() {
130131
}
131132

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

0 commit comments

Comments
 (0)