Open axiangyushanhaijing opened 1 year ago
新建C2开发分支,基于当前解释器下 rv-JDK8-dev 开发; C2-dev
基于C2-dev分支下开发两个独立分支 一个保持部分多余节点-- 1114_c2_keep_CompareAndSwapB
一个删除多余节点--- 1114_c2_dev_test
本地开发调试分支为 ---c2_temp_1117
临时代码提交分支--c2-temp.
JDK8中不存在FmF/FmD
C2编译遇到的头文件递归问题
基于 commit下,继续调试
修复 一些 符号表未定义的问题
diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp
index aee078038b..5b443b0377 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp
@@ -67,7 +67,7 @@ FloatRegister LIR_OprDesc::as_double_reg() const {
#endif
-#if defined(ARM) || defined(AARCH64)
+#if defined(ARM) || defined(AARCH64) || defined(RISCV64)
FloatRegister LIR_OprDesc::as_float_reg() const {
return as_FloatRegister(fpu_regnr());
@@ -359,7 +359,22 @@ void LIR_OpBranch::change_ublock(BlockBegin* b) {
assert(_ublock != NULL, "must have old block");
_ublock = b;
}
-
+#ifdef NO_FLAG_REG
+void LIR_Op4::emit_code(LIR_Assembler* masm) {
+ masm->emit_op4(this);
+}
+#endif
+#ifdef NO_FLAG_REG
+// LIR_Op4
+void LIR_Op4::print_instr(outputStream* out) const {
+ print_condition(out, cond()); out->print(" ");
+ in_opr1()->print(out); out->print(" ");
+ in_opr2()->print(out); out->print(" ");
+ in_opr3()->print(out); out->print(" ");
+ in_opr4()->print(out); out->print(" ");
+ result_opr()->print(out);
+}
+#endif
void LIR_OpBranch::negate_cond() {
switch (_cond) {
case lir_cond_equal: _cond = lir_cond_notEqual; break;
diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp
index f56133ce15..e18ddd64f3 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp
@@ -886,6 +886,7 @@ class LIR_OpTypeCheck;
class LIR_OpCompareAndSwap;
class LIR_OpProfileCall;
class LIR_OpProfileType;
+NO_FLAGREG_ONLY(class LIR_Op4;)
#ifdef ASSERT
class LIR_OpAssert;
#endif
@@ -1152,6 +1153,7 @@ class LIR_Op: public CompilationResourceObj {
virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
virtual LIR_OpProfileType* as_OpProfileType() { return NULL; }
+ NO_FLAGREG_ONLY(virtual LIR_Op4* as_Op4() { return NULL; })
#ifdef ASSERT
virtual LIR_OpAssert* as_OpAssert() { return NULL; }
#endif
c2第一次报错记录:
0x400bdd6ab4: slli a1,a1,0x5
0x400bdd6ab8: addi a1,a1,16
0x400bdd6abc: mv a2,sp
0x400bdd6ac0: lui a3,0x400
0x400bdd6ac4: addi a3,a3,798
0x400bdd6ac8: slli a3,a3,0xb
0x400bdd6acc: addi a3,a3,761
0x400bdd6ad0: slli a3,a3,0x5
0x400bdd6ad4: addi a3,a3,6
0x400bdd6ad8: jalr a3
=> 0x400bdd6adc: ebreak
0x400bdd6ae0: sw a1,28(s1)
0x400bdd6ae2: sw a1,28(s1)
0x400bdd6ae4: sw a1,28(s1)
0x400bdd6ae6: sw a1,28(s1)
0x400bdd6ae8: sw a1,28(s1)
0x400bdd6aea: sw a1,28(s1)
0x400bdd6aec: sw a1,28(s1)
0x400bdd6aee: sw a1,28(s1)
zhangxiang@k9-plct:~/jdk8u/c2_jdk8u/jdk8u$ qemu64 -g 1234 ./build/linux-riscv64-normal-server-slowdebug/jdk/bin/java -version =============== DEBUG MESSAGE: illegal bytecode sequence - method not verified ================
qemu-riscv64: QEMU: Terminated via GDBstub
基于 #201 本地开发分支 c2-temp
zhangxiang@k9-plct:~/jdk8u/c2_jdk8u/jdk8u/build/linux-riscv64-normal-server-slowdebug/jdk/bin$ qemu64 ./java -version
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/c1_LinearScan.cpp:1256
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hotspot/src/share/vm/c1/c1_LinearScan.cpp:1256), pid=2302312, tid=0x00000041815821e0
# assert(op->as_Op2() != NULL) failed: lir_cmove must be LIR_Op2
#
# JRE version: OpenJDK Runtime Environment (8.0_352) (build 1.8.0_352-internal-debug-zhangxiang_2022_11_24_11_02-b00)
# Java VM: OpenJDK 64-Bit Server VM (25.352-b00-debug mixed mode linux-riscv64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/build/linux-riscv64-normal-server-slowdebug/jdk/bin/hs_err_pid2302312.log
[thread 281479229920 also had an error]
[thread 281070272992 also had an error]
[thread 281206591968 also had an error]
[thread 281615548896 also had an error]
openjdk version "1.8.0_352-internal-debug"
OpenJDK Runtime Environment (build 1.8.0_352-internal-debug-zhangxiang_2022_11_24_11_02-b00)
OpenJDK 64-Bit Server VM (build 25.352-b00-debug, mixed mode)
#
# Compiler replay data is saved as:
# /home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/build/linux-riscv64-normal-server-slowdebug/jdk/bin/replay_pid2302312.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Current thread is 281342910944
Dumping core ...
Aborted
提交 #204 已解决问题
# To suppress the following error report, specify this argument# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=
# after -XX: or in .hotspotrc: SuppressErrorAt=/c1_LIR.hpp/c1_LIR.hpp:431
:431
[thread 281342902752 also had an error]
[thread 281206583776 also had an error]
[thread 281615540704 also had an error]
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hotspot/src/share/vm/c1/c1_LIR.hpp:431), pid=2776001, tid=0x00000041897811e0
# assert(is_pointer()) failed: type check
#
提交 #pr205解决问题
zhangxiang@k9-plct:~/jdk8u/c2_jdk8u/jdk8u$ qemu64 ./build/linux-riscv64-normal-server-slowdebug/jdk/bin/java -version
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/c1_LIR.cpp:211
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hotspot/src/share/vm/c1/c1_LIR.cpp:211), pid=2778656, tid=0x00000041919821e0
# assert((kindfield == fpu_register || kindfield == stack_value ARM_ONLY(|| kindfield == cpu_register) PPC_ONLY(|| kindfield == cpu_register) ) && size_field() == single_size) failed: must match
#
# JRE version: OpenJDK Runtime Environment (8.0_352) (build 1.8.0_352-internal-debug-zhangxiang_2022_11_24_11_02-b00)
查看报错log:
tive frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0xb25f68] VMError::report_and_die()+0x4f6
V [libjvm.so+0x4a0ca8] report_vm_error(char const*, int, char const*, char const*)+0x7c
V [libjvm.so+0x2de858] LIR_OprDesc::validate_type() const+0x13e
V [libjvm.so+0x2a926a] LIR_OprDesc::is_cpu_register() const+0x14
V [libjvm.so+0x2a91ca] LIR_OprDesc::is_register() const+0x14
V [libjvm.so+0x2a9582] LIR_OpVisitState::append(LIR_OprDesc*&, LIR_OpVisitState::OprMode)+0xae
V [libjvm.so+0x2a9a20] LIR_OpVisitState::do_temp(LIR_OprDesc*&)+0x1e
V [libjvm.so+0x2dfc0c] LIR_OpVisitState::visit(LIR_Op*)+0x520
V [libjvm.so+0x3185c4] LinearScan::compute_local_live_sets()+0x386
V [libjvm.so+0x321d16] LinearScan::do_linear_scan()+0x3c
V [libjvm.so+0x2aafc0] Compilation::emit_lir()+0xd6
V [libjvm.so+0x2ab56a] Compilation::compile_java_method()+0x188
V [libjvm.so+0x2ab848] Compilation::compile_method()+0xae
V [libjvm.so+0x2abd8a] Compilation::Compilation(AbstractCompiler*, ciEnv*, ciMethod*, int, BufferBlob*)+0x1b4
V [libjvm.so+0x2aef86] Compiler::compile_method(ciEnv*, ciMethod*, int)+0x88
V [libjvm.so+0x43cdf0] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x3fa
V [libjvm.so+0x43c282] CompileBroker::compiler_thread_loop()+0x290
V [libjvm.so+0xac68b4] compiler_thread_entry(JavaThread*, Thread*)+0x66
V [libjvm.so+0xac1f7a] JavaThread::thread_main_inner()+0x13c
V [libjvm.so+0xac1e32] JavaThread::run()+0x130
V [libjvm.so+0x952462] java_start(Thread*)+0x1a0
C [libpthread.so.0+0x6dae] start_thread+0x96
C [libc.so.6+0xa179a] __thread_start+0x6
在 LIR_OpVisitState::visit(LIR_Op*)函数中发现case lir_convert: 添加了关于riscv64的条件,但是jdk11中不需要添加
diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp
index 6ece4f8aff..ae8236b8fd 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp
@@ -639,7 +639,7 @@ void LIR_OpVisitState::visit(LIR_Op* op) {
assert(opConvert->_info == NULL, "must be");
if (opConvert->_opr->is_valid()) do_input(opConvert->_opr);
if (opConvert->_result->is_valid()) do_output(opConvert->_result);
-#if defined(PPC) || defined(AARCH64) || defined(RISCV64)
+#if defined(PPC) || defined(AARCH64)
if (opConvert->_tmp1->is_valid()) do_temp(opConvert->_tmp1);
if (opConvert->_tmp2->is_valid()) do_temp(opConvert->_tmp2);
#endif
提交 #pr216 此时当前报错:
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/c1_LinearScan.cpp:6261
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hotspot/src/share/vm/c1/c1_LinearScan.cpp:6261), pid=425234, tid=0x000000417117e1e0
# assert(prev_cmp != NULL) failed: should have found comp instruction for branch
#
# JRE version: OpenJDK Runtime Environment (8.0_352) (build 1.8.0_352-internal-debug-zhangxiang_2022_11_28_16_33-b00)
# Java VM: OpenJDK 64-Bit Server VM (25.352-b00-debug mixed mode linux-riscv64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hs_err_pid425234.log
提交 #pr217解决该问题,此时报错同 type check
当前报错log:
Stack: [0x0000004189582000,0x0000004189782000], sp=0x000000418977f950, free space=2038k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0xb25daa] VMError::report_and_die()+0x4f6
V [libjvm.so+0x4a0aea] report_vm_error(char const*, int, char const*, char const*)+0x7c
V [libjvm.so+0x2a9322] LIR_OprDesc::pointer() const+0x44
V [libjvm.so+0x2a934c] LIR_OprDesc::as_constant_ptr() const+0x14
V [libjvm.so+0x2a6f42] CounterOverflowStub::emit_code(LIR_Assembler*)+0x38
V [libjvm.so+0x2e9ea6] LIR_Assembler::emit_stubs(CodeStubList*)+0xf0
V [libjvm.so+0x2e9ee2] LIR_Assembler::emit_slow_case_stubs()+0x1c
V [libjvm.so+0x2ab0b6] Compilation::emit_code_epilog(LIR_Assembler*)+0x34
V [libjvm.so+0x2ab36a] Compilation::emit_code_body()+0x10c
V [libjvm.so+0x2ab598] Compilation::compile_java_method()+0x1b6
V [libjvm.so+0x2ab848] Compilation::compile_method()+0xae
V [libjvm.so+0x2abd8a] Compilation::Compilation(AbstractCompiler*, ciEnv*, ciMethod*, int, BufferBlob*)+0x1b4
V [libjvm.so+0x2aef86] Compiler::compile_method(ciEnv*, ciMethod*, int)+0x88
V [libjvm.so+0x43cc32] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x3fa
V [libjvm.so+0x43c0c4] CompileBroker::compiler_thread_loop()+0x290
V [libjvm.so+0xac66f6] compiler_thread_entry(JavaThread*, Thread*)+0x66
V [libjvm.so+0xac1dbc] JavaThread::thread_main_inner()+0x13c
V [libjvm.so+0xac1c74] JavaThread::run()+0x130
V [libjvm.so+0x9522a4] java_start(Thread*)+0x1a0
C [libpthread.so.0+0x6dae] start_thread+0x96
C [libc.so.6+0xa179a] __thread_start+0x6
已提 #pr218
zhangxiang@k9-plct:~/jdk8u/c2_jdk8u/jdk8u$ qemu64 ./build/linux-riscv64-normal-server-slowdebug/jdk/bin/java ~/rv-jdk8u/jdk8u/c1_diff/Hello
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGILL (0x4) at pc=0x000000400c232340, pid=569520, tid=0x0000004003caf1e0
#
# JRE version: OpenJDK Runtime Environment (8.0_352) (build 1.8.0_352-internal-debug-zhangxiang_2022_11_28_16_33-b00)
# Java VM: OpenJDK 64-Bit Server VM (25.352-b00-debug mixed mode linux-riscv64 compressed oops)
# Problematic frame:
# J 4 C1 java.lang.Object.<init>()V (1 bytes) @ 0x000000400c232340 [0x000000400c232300+0x40]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hs_err_pid569520.log
Compiled method (c1) 5342 4 3 java.lang.Object::<init> (1 bytes)
total in heap [0x000000400c232190,0x000000400c2325d8] = 1096
relocation [0x000000400c2322c0,0x000000400c2322e0] = 32
main code [0x000000400c232300,0x000000400c232440] = 320
stub code [0x000000400c232440,0x000000400c232540] = 256
metadata [0x000000400c232540,0x000000400c232550] = 16
scopes data [0x000000400c232550,0x000000400c232570] = 32
scopes pcs [0x000000400c232570,0x000000400c2325d0] = 96
dependencies [0x000000400c2325d0,0x000000400c2325d8] = 8
Compiled method (c1) 5344 4 3 java.lang.Object::<init> (1 bytes)
total in heap [0x000000400c232190,0x000000400c2325d8] = 1096
relocation [0x000000400c2322c0,0x000000400c2322e0] = 32
main code [0x000000400c232300,0x000000400c232440] = 320
stub code [0x000000400c232440,0x000000400c232540] = 256
metadata [0x000000400c232540,0x000000400c232550] = 16
scopes data [0x000000400c232550,0x000000400c232570] = 32
scopes pcs [0x000000400c232570,0x000000400c2325d0] = 96
dependencies [0x000000400c2325d0,0x000000400c2325d8] = 8
#
# If you would like to submit a bug report, please visit:
zhangxiang@k9-plct:~/jdk8u/c2_jdk8u/jdk8u$ qemu64 ./build/linux-riscv64-normal-server-slowdebug/jdk/bin/java -XX:+LogCompilation -XX:LogFile=/home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/1205.log
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc: SuppressErrorAt=/safepoint.cpp:413
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hotspot/src/share/vm/runtime/safepoint.cpp:413), pid=743977, tid=0x00000040ff0031e0
# assert(iterations < (uint)max_jint) failed: We have been iterating in the safepoint loop too long
#
# JRE version: OpenJDK Runtime Environment (8.0_352) (build 1.8.0_352-internal-debug-zhangxiang_2022_11_28_16_33-b00)
# Java VM: OpenJDK 64-Bit Server VM (25.352-b00-debug mixed mode linux-riscv64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/zhangxiang/jdk8u/c2_jdk8u/jdk8u/hs_err_pid743977.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Current thread is 279156109792
Dumping core ...
Aborted
提交 #226 ,修改了delete_unnecessary_jumps的实现。
提交 #227 , 在c1_LIRGenerator.hpp中增加了
+#ifndef NO_FLAG_REG
void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info);
void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info);
-
+#endif
原理同 #227 提交 pr228
参考jdk11提交 pr229,增加了ideal_reg关于riscv64的支持。
参考jdk11提交 pr230,修改了LIR_Op2::verify()中lir_cmove关于riscv64的支持。
参考jdk11提交 pr232,修改了调用__ branch中关于riscv64的支持。
关于 #184 需要重新review修改
针对release版本出现的问题,重新提交 #279
在GraphKit::write_barrier_post添加riscv64的支持。同时由于GraphKit::post_barrier调用write_barrier_post,进一步追溯发现post_barrier在C1中多处被调用,后续还需要补充这些地方关于riscv64的支持。
#ifdef CC_INTERP
define_pd_global(bool, ProfileInterpreter, false);
#else
define_pd_global(bool, ProfileInterpreter, true);
#endif //
修改后当前报错
Replace flags_offset with header_offset.
Replace zr with x15.
Fix generate_code_for.
1、在JDK8中部分节点是否需要保留
2、新增TEMP_DEF属性