Skip to content

Commit 309291f

Browse files
kuaiweizhengxiaolinX
authored andcommitted
8276799: Implementation of JEP 422: Linux/RISC-V Port
8283737: riscv: MacroAssembler::stop() should emit fixed-length instruction sequence 8285437: riscv: Fix MachNode size mismatch for MacroAssembler::verify_oops* 8287418: riscv: Fix correctness issue of MacroAssembler::movptr 8293100: RISC-V: Need to save and restore callee-saved FloatRegisters in StubGenerator::generate_call_stub 8295926: RISC-V: C1: Fix LIRGenerator::do_LibmIntrinsic 8291952: riscv: Remove PRAGMA_NONNULL_IGNORED 8308277: RISC-V: Improve vectorization of Match.sqrt() on floats 8282306: os::is_first_C_frame(frame*) crashes on invalid link access Co-authored-by: Xiaolin Zheng <xlinzheng@openjdk.org> Reviewed-by: fyang Backport-of: 5905b02c0e2643ae8d097562f181953f6c88fc89
1 parent 89c9bff commit 309291f

File tree

175 files changed

+54994
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+54994
-188
lines changed

make/autoconf/hotspot.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
370370
AC_MSG_CHECKING([if shenandoah can be built])
371371
if HOTSPOT_CHECK_JVM_FEATURE(shenandoahgc); then
372372
if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86" || \
373-
test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
373+
test "x$OPENJDK_TARGET_CPU" = "xaarch64" || \
374+
test "x$OPENJDK_TARGET_CPU" = "xriscv64"; then
374375
AC_MSG_RESULT([yes])
375376
else
376377
DISABLED_JVM_FEATURES="$DISABLED_JVM_FEATURES shenandoahgc"

make/autoconf/libraries.m4

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2022, 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
@@ -130,6 +130,12 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
130130
BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lthread"
131131
fi
132132
133+
# Because RISC-V only has word-sized atomics, it requries libatomic where
134+
# other common architectures do not. So link libatomic by default.
135+
if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xriscv64; then
136+
BASIC_JVM_LIBS="$BASIC_JVM_LIBS -latomic"
137+
fi
138+
133139
# perfstat lib
134140
if test "x$OPENJDK_TARGET_OS" = xaix; then
135141
BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lperfstat"

make/autoconf/platform.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 2022, 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
@@ -554,6 +554,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
554554
HOTSPOT_$1_CPU_DEFINE=PPC64
555555
elif test "x$OPENJDK_$1_CPU" = xppc64le; then
556556
HOTSPOT_$1_CPU_DEFINE=PPC64
557+
elif test "x$OPENJDK_$1_CPU" = xriscv64; then
558+
HOTSPOT_$1_CPU_DEFINE=RISCV64
557559
558560
# The cpu defines below are for zero, we don't support them directly.
559561
elif test "x$OPENJDK_$1_CPU" = xsparc; then

make/hotspot/gensrc/GensrcAdlc.gmk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2013, 2022, 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
@@ -150,6 +150,12 @@ ifeq ($(call check-jvm-feature, compiler2), true)
150150
$d/os_cpu/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_OS)_$(HOTSPOT_TARGET_CPU_ARCH).ad \
151151
)))
152152

153+
ifeq ($(HOTSPOT_TARGET_CPU_ARCH), riscv)
154+
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
155+
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/$(HOTSPOT_TARGET_CPU_ARCH)_b.ad \
156+
)))
157+
endif
158+
153159
ifeq ($(call check-jvm-feature, shenandoahgc), true)
154160
AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \
155161
$d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/shenandoah/shenandoah_$(HOTSPOT_TARGET_CPU).ad \

src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -1593,7 +1593,9 @@ void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
15931593
}
15941594

15951595

1596-
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
1596+
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type,
1597+
LIR_Opr cmp_opr1, LIR_Opr cmp_opr2) {
1598+
assert(cmp_opr1 == LIR_OprFact::illegalOpr && cmp_opr2 == LIR_OprFact::illegalOpr, "unnecessary cmp oprs on aarch64");
15971599

15981600
Assembler::Condition acond, ncond;
15991601
switch (condition) {

src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2022, 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
@@ -1824,7 +1824,10 @@ void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
18241824
}
18251825

18261826

1827-
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
1827+
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type,
1828+
LIR_Opr cmp_opr1, LIR_Opr cmp_opr2) {
1829+
assert(cmp_opr1 == LIR_OprFact::illegalOpr && cmp_opr2 == LIR_OprFact::illegalOpr, "unnecessary cmp oprs on arm");
1830+
18281831
AsmCondition acond = al;
18291832
AsmCondition ncond = nv;
18301833
if (opr1 != opr2) {

src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2019, SAP SE. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2012, 2021 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
@@ -1553,8 +1553,10 @@ inline void load_to_reg(LIR_Assembler *lasm, LIR_Opr src, LIR_Opr dst) {
15531553
}
15541554
}
15551555

1556+
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type,
1557+
LIR_Opr cmp_opr1, LIR_Opr cmp_opr2) {
1558+
assert(cmp_opr1 == LIR_OprFact::illegalOpr && cmp_opr2 == LIR_OprFact::illegalOpr, "unnecessary cmp oprs on ppc");
15561559

1557-
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
15581560
if (opr1->is_equal(opr2) || opr1->is_same_register(opr2)) {
15591561
load_to_reg(this, opr1, result); // Condition doesn't matter.
15601562
return;
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/*
2+
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4+
* Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved.
5+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6+
*
7+
* This code is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU General Public License version 2 only, as
9+
* published by the Free Software Foundation.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*
25+
*/
26+
27+
#include "precompiled.hpp"
28+
#include "interpreter/interpreter.hpp"
29+
#include "oops/constMethod.hpp"
30+
#include "oops/klass.inline.hpp"
31+
#include "oops/method.hpp"
32+
#include "runtime/frame.inline.hpp"
33+
#include "utilities/align.hpp"
34+
#include "utilities/debug.hpp"
35+
#include "utilities/macros.hpp"
36+
37+
int AbstractInterpreter::BasicType_as_index(BasicType type) {
38+
int i = 0;
39+
switch (type) {
40+
case T_BOOLEAN: i = 0; break;
41+
case T_CHAR : i = 1; break;
42+
case T_BYTE : i = 2; break;
43+
case T_SHORT : i = 3; break;
44+
case T_INT : i = 4; break;
45+
case T_LONG : i = 5; break;
46+
case T_VOID : i = 6; break;
47+
case T_FLOAT : i = 7; break;
48+
case T_DOUBLE : i = 8; break;
49+
case T_OBJECT : i = 9; break;
50+
case T_ARRAY : i = 9; break;
51+
default : ShouldNotReachHere();
52+
}
53+
assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
54+
"index out of bounds");
55+
return i;
56+
}
57+
58+
// How much stack a method activation needs in words.
59+
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
60+
const int entry_size = frame::interpreter_frame_monitor_size();
61+
62+
// total overhead size: entry_size + (saved fp thru expr stack
63+
// bottom). be sure to change this if you add/subtract anything
64+
// to/from the overhead area
65+
const int overhead_size =
66+
-(frame::interpreter_frame_initial_sp_offset) + entry_size;
67+
68+
const int stub_code = frame::entry_frame_after_call_words;
69+
assert_cond(method != NULL);
70+
const int method_stack = (method->max_locals() + method->max_stack()) *
71+
Interpreter::stackElementWords;
72+
return (overhead_size + method_stack + stub_code);
73+
}
74+
75+
// asm based interpreter deoptimization helpers
76+
int AbstractInterpreter::size_activation(int max_stack,
77+
int temps,
78+
int extra_args,
79+
int monitors,
80+
int callee_params,
81+
int callee_locals,
82+
bool is_top_frame) {
83+
// Note: This calculation must exactly parallel the frame setup
84+
// in TemplateInterpreterGenerator::generate_method_entry.
85+
86+
// fixed size of an interpreter frame:
87+
int overhead = frame::sender_sp_offset -
88+
frame::interpreter_frame_initial_sp_offset;
89+
// Our locals were accounted for by the caller (or last_frame_adjust
90+
// on the transistion) Since the callee parameters already account
91+
// for the callee's params we only need to account for the extra
92+
// locals.
93+
int size = overhead +
94+
(callee_locals - callee_params) +
95+
monitors * frame::interpreter_frame_monitor_size() +
96+
// On the top frame, at all times SP <= ESP, and SP is
97+
// 16-aligned. We ensure this by adjusting SP on method
98+
// entry and re-entry to allow room for the maximum size of
99+
// the expression stack. When we call another method we bump
100+
// SP so that no stack space is wasted. So, only on the top
101+
// frame do we need to allow max_stack words.
102+
(is_top_frame ? max_stack : temps + extra_args);
103+
104+
// On riscv we always keep the stack pointer 16-aligned, so we
105+
// must round up here.
106+
size = align_up(size, 2);
107+
108+
return size;
109+
}
110+
111+
void AbstractInterpreter::layout_activation(Method* method,
112+
int tempcount,
113+
int popframe_extra_args,
114+
int moncount,
115+
int caller_actual_parameters,
116+
int callee_param_count,
117+
int callee_locals,
118+
frame* caller,
119+
frame* interpreter_frame,
120+
bool is_top_frame,
121+
bool is_bottom_frame) {
122+
// The frame interpreter_frame is guaranteed to be the right size,
123+
// as determined by a previous call to the size_activation() method.
124+
// It is also guaranteed to be walkable even though it is in a
125+
// skeletal state
126+
assert_cond(method != NULL && caller != NULL && interpreter_frame != NULL);
127+
int max_locals = method->max_locals() * Interpreter::stackElementWords;
128+
int extra_locals = (method->max_locals() - method->size_of_parameters()) *
129+
Interpreter::stackElementWords;
130+
131+
#ifdef ASSERT
132+
assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");
133+
#endif
134+
135+
interpreter_frame->interpreter_frame_set_method(method);
136+
// NOTE the difference in using sender_sp and interpreter_frame_sender_sp
137+
// interpreter_frame_sender_sp is the original sp of the caller (the unextended_sp)
138+
// and sender_sp is fp
139+
intptr_t* locals = NULL;
140+
if (caller->is_interpreted_frame()) {
141+
locals = caller->interpreter_frame_last_sp() + caller_actual_parameters - 1;
142+
} else {
143+
locals = interpreter_frame->sender_sp() + max_locals - 1;
144+
}
145+
146+
#ifdef ASSERT
147+
if (caller->is_interpreted_frame()) {
148+
assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
149+
}
150+
#endif
151+
152+
interpreter_frame->interpreter_frame_set_locals(locals);
153+
BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
154+
BasicObjectLock* monbot = montop - moncount;
155+
interpreter_frame->interpreter_frame_set_monitor_end(monbot);
156+
157+
// Set last_sp
158+
intptr_t* last_sp = (intptr_t*) monbot -
159+
tempcount*Interpreter::stackElementWords -
160+
popframe_extra_args;
161+
interpreter_frame->interpreter_frame_set_last_sp(last_sp);
162+
163+
// All frames but the initial (oldest) interpreter frame we fill in have
164+
// a value for sender_sp that allows walking the stack but isn't
165+
// truly correct. Correct the value here.
166+
if (extra_locals != 0 &&
167+
interpreter_frame->sender_sp() ==
168+
interpreter_frame->interpreter_frame_sender_sp()) {
169+
interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
170+
extra_locals);
171+
}
172+
173+
*interpreter_frame->interpreter_frame_cache_addr() =
174+
method->constants()->cache();
175+
*interpreter_frame->interpreter_frame_mirror_addr() =
176+
method->method_holder()->java_mirror();
177+
}

0 commit comments

Comments
 (0)