Skip to content

Commit 8d8bb09

Browse files
committed
s390x port
1 parent 1d29010 commit 8d8bb09

File tree

5 files changed

+64
-20
lines changed

5 files changed

+64
-20
lines changed
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 IBM Corp. 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_VectorRegister()) {
29+
// Not all physical slots belonging to a VectorRegister have corresponding
30+
// valid VMReg locations in the RegisterMap.
31+
// (See RegisterSaver::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/s390/registerMap_s390.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2016 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -36,9 +36,7 @@
3636
// Since there is none, we just return null.
3737
address pd_location(VMReg reg) const {return nullptr;}
3838

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

4341
// No PD state to clear or copy.
4442
void pd_clear() {}

src/hotspot/cpu/s390/registerSaver_s390.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2016 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -58,7 +58,7 @@ class RegisterSaver {
5858

5959
// During deoptimization only the result register need to be restored
6060
// all the other values have already been extracted.
61-
static void restore_result_registers(MacroAssembler* masm);
61+
static void restore_result_registers(MacroAssembler* masm, bool save_vectors);
6262

6363
// Constants and data structures:
6464

src/hotspot/cpu/s390/sharedRuntime_s390.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, RegisterSet reg
402402
break;
403403
}
404404

405-
// Second set_callee_saved is really a waste but we'll keep things as they were for now
406405
map->set_callee_saved(VMRegImpl::stack2reg(offset >> 2), live_regs[i].vmreg);
407-
map->set_callee_saved(VMRegImpl::stack2reg((offset + half_reg_size) >> 2), live_regs[i].vmreg->next());
408406
}
409407
assert(first != noreg, "Should spill at least one int reg.");
410408
__ z_stmg(first, last, first_offset, Z_SP);
@@ -473,7 +471,6 @@ OopMap* RegisterSaver::generate_oop_map(MacroAssembler* masm, RegisterSet reg_se
473471
for (int i = 0; i < regstosave_num; i++) {
474472
if (live_regs[i].reg_type < RegisterSaver::excluded_reg) {
475473
map->set_callee_saved(VMRegImpl::stack2reg(offset>>2), live_regs[i].vmreg);
476-
map->set_callee_saved(VMRegImpl::stack2reg((offset + half_reg_size)>>2), live_regs[i].vmreg->next());
477474
}
478475
offset += reg_size;
479476
}
@@ -580,10 +577,12 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, RegisterSet reg
580577

581578

582579
// Pop the current frame and restore the registers that might be holding a result.
583-
void RegisterSaver::restore_result_registers(MacroAssembler* masm) {
580+
void RegisterSaver::restore_result_registers(MacroAssembler* masm, bool save_vectors) {
584581
const int regstosave_num = sizeof(RegisterSaver_LiveRegs) /
585582
sizeof(RegisterSaver::LiveRegType);
586-
const int register_save_offset = live_reg_frame_size(all_registers) - live_reg_save_size(all_registers);
583+
const int vecregstosave_num = save_vectors ? calculate_vregstosave_num() : 0;
584+
const int vreg_save_size = vecregstosave_num * v_reg_size;
585+
const int register_save_offset = live_reg_frame_size(all_registers, save_vectors) - (live_reg_save_size(all_registers) + vreg_save_size);
587586

588587
// Restore all result registers (ints and floats).
589588
int offset = register_save_offset;
@@ -609,7 +608,7 @@ void RegisterSaver::restore_result_registers(MacroAssembler* masm) {
609608
ShouldNotReachHere();
610609
}
611610
}
612-
assert(offset == live_reg_frame_size(all_registers), "consistency check");
611+
assert(offset == live_reg_frame_size(all_registers, save_vectors) - (save_vectors ? vreg_save_size : 0) , "consistency check");
613612
}
614613

615614
// ---------------------------------------------------------------------------
@@ -2557,7 +2556,7 @@ void SharedRuntime::generate_deopt_blob() {
25572556
// nmethod that was valid just before the nmethod was deoptimized.
25582557
// save R14 into the deoptee frame. the `fetch_unroll_info'
25592558
// procedure called below will read it from there.
2560-
map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
2559+
map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers, Z_R14, /* save_vectors= */ SuperwordUseVX);
25612560

25622561
// note the entry point.
25632562
__ load_const_optimized(exec_mode_reg, Deoptimization::Unpack_deopt);
@@ -2573,7 +2572,7 @@ void SharedRuntime::generate_deopt_blob() {
25732572
int reexecute_offset = __ offset() - start_off;
25742573

25752574
// No need to update map as each call to save_live_registers will produce identical oopmap
2576-
(void) RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
2575+
(void) RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers, Z_R14, /* save_vectors= */ SuperwordUseVX);
25772576

25782577
__ load_const_optimized(exec_mode_reg, Deoptimization::Unpack_reexecute);
25792578
__ z_bru(exec_mode_initialized);
@@ -2611,7 +2610,7 @@ void SharedRuntime::generate_deopt_blob() {
26112610
__ z_lg(Z_R1_scratch, Address(Z_thread, JavaThread::exception_pc_offset()));
26122611

26132612
// Save everything in sight.
2614-
(void) RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers, Z_R1_scratch);
2613+
(void) RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers, Z_R1_scratch, /* save_vectors= */ SuperwordUseVX);
26152614

26162615
// Now it is safe to overwrite any register
26172616

@@ -2661,7 +2660,7 @@ void SharedRuntime::generate_deopt_blob() {
26612660
__ z_lgr(unroll_block_reg, Z_RET);
26622661
// restore the return registers that have been saved
26632662
// (among other registers) by save_live_registers(...).
2664-
RegisterSaver::restore_result_registers(masm);
2663+
RegisterSaver::restore_result_registers(masm, /*save_vectors*/ SuperwordUseVX);
26652664

26662665
// reload the exec mode from the UnrollBlock (it might have changed)
26672666
__ z_llgf(exec_mode_reg, Address(unroll_block_reg, Deoptimization::UnrollBlock::unpack_kind_offset()));
@@ -2737,7 +2736,7 @@ void SharedRuntime::generate_deopt_blob() {
27372736
// Make sure all code is generated
27382737
masm->flush();
27392738

2740-
_deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, RegisterSaver::live_reg_frame_size(RegisterSaver::all_registers)/wordSize);
2739+
_deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, RegisterSaver::live_reg_frame_size(RegisterSaver::all_registers, SuperwordUseVX)/wordSize);
27412740
_deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset);
27422741
}
27432742

src/hotspot/cpu/s390/vm_version_s390.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2016, 2024 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -24,8 +24,9 @@
2424
*/
2525

2626
#include "asm/assembler.inline.hpp"
27-
#include "compiler/disassembler.hpp"
2827
#include "code/compiledIC.hpp"
28+
#include "compiler/compilerDefinitions.inline.hpp"
29+
#include "compiler/disassembler.hpp"
2930
#include "jvm.h"
3031
#include "memory/resourceArea.hpp"
3132
#include "runtime/java.hpp"
@@ -105,7 +106,7 @@ void VM_Version::initialize() {
105106
int model_ix = get_model_index();
106107

107108
if ( model_ix >= 7 ) {
108-
if (FLAG_IS_DEFAULT(SuperwordUseVX)) {
109+
if (FLAG_IS_DEFAULT(SuperwordUseVX) && CompilerConfig::is_c2_enabled()) {
109110
FLAG_SET_ERGO(SuperwordUseVX, true);
110111
}
111112
if (model_ix > 7 && FLAG_IS_DEFAULT(UseSFPV) && SuperwordUseVX) {

0 commit comments

Comments
 (0)