<div class="__aliyun_email_body_block"><div  style="line-height:1.7;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><div  style="clear:both;">Hi <span >Vladimir,</span></div><div  style="clear:both;"><span ><br ></span></div><div  style="clear:both;"><span >Thank you for the update, and good to know all's right at last.</span></div><div  style="clear:both;"><span ><br ></span></div><div  style="clear:both;">Maybe we need support for unaligned addresses in the backend, and it seems RVC could trigger it without any effort, for its 2-byte nature.</div><div  style="clear:both;"><br ></div><div  style="clear:both;">As discussed in <span ><a  href="https://mail.openjdk.org/pipermail/riscv-port-dev/2022-July/000563.html" target="_blank">https://mail.openjdk.org/pipermail/riscv-port-dev/2022-July/000563.html</a> , the alignment issue is claimed by Yadong's team. So we can wait for their fixes then. During this gap maybe our fixes could help to workaround this issue (but may harm the performance a little).</span></div><div  style="clear:both;"><span ><br ></span></div><div  style="clear:both;"><span >Again good to know the root cause!</span></div><div  style="clear:both;"><span ><br ></span></div><div  style="clear:both;"><span >Best,</span></div><div  style="clear:both;"><span >Xiaolin</span></div><div  style="clear:both;"><br /></div><blockquote  style="margin-right:0;margin-top:0;margin-bottom:0;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><div  style="clear:both;">------------------------------------------------------------------</div><div  style="clear:both;">From:Vladimir Kempik <vladimir.kempik@gmail.com></div><div  style="clear:both;">Send Time:2022年9月16日(星期五) 19:49</div><div  style="clear:both;">To:郑孝林(云矅) <yunyao.zxl@alibaba-inc.com></div><div  style="clear:both;">Cc:riscv-port-dev <riscv-port-dev-retn@openjdk.org>; Aleksey Shipilev <shade@redhat.com>; riscv-port-dev@openjdk.org <riscv-port-dev@openjdk.org></div><div  style="clear:both;">Subject:Re: RVC by default?</div><div  style="clear:both;"><br /></div><head ></head><div  class="" style="word-wrap:break-word;-webkit-nbsp-mode:space;line-break:after-white-space;">Hello.<div  class="">I have applied your two fixes on top of jdk19 and tested - all issues have gone, thanks.</div><div  class="">Looks like the source of the issues is in my m-mode.</div><div  class=""><br  class=""></div><div  class="">Kinds Regards, Vladimir</div><div  class=""><div  class=""><div ><br  class=""><div  class="">16 сент. 2022 г., в 11:45, Xiaolin Zheng <<a  class="" href="mailto:yunyao.zxl@alibaba-inc.com" target="_blank">yunyao.zxl@alibaba-inc.com</a>> написал(а):</div><br  class="Apple-interchange-newline"><div  class=""><div  class="" style="line-height:1.7;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;"><div  class="" style="clear:both;"><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;">Hi <span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">Vladimir,</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><br  class=""></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">Thank you for the newly-added hs_err and further tests. I guess it might have some relationship with the discussed [misaligned issue](<span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><a  class="" href="https://mail.openjdk.org/pipermail/riscv-port-dev/2022-July/000559.html" target="_blank">https://mail.openjdk.org/pipermail/riscv-port-dev/2022-July/000559.html</a></span>) here. But just guessing. I have noticed one interesting thing that the crashed hs_err files are often like:</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><br  class=""></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">```</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">...</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">  0x0000003f7cc2f91e:   mv a0,s7</span><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;clear:both;">  0x0000003f7cc2f922:   auipc t0,0x10494</div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;clear:both;">  0x0000003f7cc2f926:   jalr 664(t0) # 0x0000003f8d0c3bba = AdapterHandlerEntry::print_adapter_on(outputStream*) const+470   <--- ??? Misaligned address: <span  class=" __aliyun_node_has_bgcolor" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;background-color:#ffffff;text-decoration-thickness:initial;float:none;display:inline;">0x0000003f7cc2f926</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;clear:both;">  0x0000003f7cc2f92a:   sd zero,704(s7)</div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">  0x0000003f7cc2f92e:   sd zero,712(s7)</span></div><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">...</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">```</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><br  class=""></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">With RVC, it is certainly <span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">legal</span> to locate at a 2-byte aligned address. But, this location is relocatable, which means it will be patched.</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><br  class=""></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">So, I might doubt something weird happened when performing the patching behavior. The patching logic, referencing the instruction segment, does not care about the alignment but only performs 4-byte memory load operations, such as <span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">Assembler::patch(). On machines having the misaligned address support, it would not go wrong of course; but it seems that our FPGA board discussed lacks this support. So I guess there might be an interesting chemical reaction happening here. I have written two patches to debug this issue and released one fastdebug build only for debugging purposes, and I put it at<span  class=""> </span><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><a  class="" href="https://github.com/zhengxiaolinX/jdk/releases/tag/test-unaligned" target="_blank">https://github.com/zhengxiaolinX/jdk/releases/tag/test-unaligned</a></span>. The two patches fix most of the misaligned accesses to the instruction segment. I was wondering if you could have a simple test of it when you are available, to see whether this issue still exists?</span></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><br  class=""></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">I am just guessing the problem here, hope it can reveal something to us.</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><br  class=""></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">Thank you very much.</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;"><br  class=""></span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">Best,</span></div><div  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;white-space:normal;word-spacing:.0px;text-decoration-thickness:initial;clear:both;"><span  class="" style="margin:.0px;padding:.0px;border:.0px;outline:.0px;">Xiaolin</span></div></div><div  class="" style="clear:both;"><br  class=""></div><div  class="" style="clear:both;">------------------------------------------------------------------</div><div  class="" style="clear:both;">From:Vladimir Kempik <<a  class="" href="mailto:vladimir.kempik@gmail.com" target="_blank">vladimir.kempik@gmail.com</a>></div><div  class="" style="clear:both;">Send Time:2022年9月15日(星期四) 23:25</div><div  class="" style="clear:both;">To:郑孝林(云矅) <<a  class="" href="mailto:yunyao.zxl@alibaba-inc.com" target="_blank">yunyao.zxl@alibaba-inc.com</a>></div><div  class="" style="clear:both;">Cc:riscv-port-dev <<a  class="" href="mailto:riscv-port-dev-retn@openjdk.org" target="_blank">riscv-port-dev-retn@openjdk.org</a>>; Aleksey Shipilev <<a  class="" href="mailto:shade@redhat.com" target="_blank">shade@redhat.com</a>>; <a  class="" href="mailto:riscv-port-dev@openjdk.org" target="_blank">riscv-port-dev@openjdk.org</a> <<a  class="" href="mailto:riscv-port-dev@openjdk.org" target="_blank">riscv-port-dev@openjdk.org</a>></div><div  class="" style="clear:both;">Subject:Re: RVC by default?</div><div  class="" style="clear:both;"><br  class=""></div><div  class="">Hello</div>Looks pretty similar to me.<div  class="">for me it was vanilla recent jdk19 <br  class=""><div  class="">But later, when I backported next patches to my jdk19 branch, the issue became different ( Arena alloc issue I have reported earlier):</div><div  class=""><br  class=""></div><div  class=""><div  class="">8290496: riscv: Fix build warnings-as-errors with GCC 11</div><div  class="">8290280: riscv: Clean up stack and register handling in interpreter</div><div  class="">8290137: riscv: small refactoring for add_memory_int32/64</div><div  class="">8290164: compiler/runtime/TestConstantsInError.java fails on riscv</div><div  class="">8291952: riscv: Remove PRAGMA_NONNULL_IGNORED</div><div  class="">8291947: riscv: fail to build after JDK-8290840</div><div  class="">8291893: riscv: remove fence.i used in user space Backport-of:...</div><div  class="">8292713: Unsafe.allocateInstance should be intrinsified without UseUnalignedAccesses</div><div  class="">8292867: RISC-V: Simplify weak CAS return value handling</div><div  class="">8292407: Improve Weak CAS VarHandle/Unsafe tests resilience under spurious failures</div><div  class="">8293100: RISC-V: Need to save and restore callee-saved FloatRegisters in...</div><div  class="">8293050: RISC-V: Remove redundant non-null assertions about macro-assembler</div><div  class="">8293474: RISC-V: Unify the way of moving function pointer</div><div  class="">8293524: RISC-V: Use macro-assembler functions as appropriate</div><div  class="">8293566: RISC-V: Clean up push and pop registers</div><div  class=""><br  class=""></div><div  class="">I’m gonna bisect this list and find what changed the behaviour.</div></div><div  class=""><br  class=""></div><div  class="">The workaround says - update to ubuntu 21.04, but its not clear - update runtime environment or build environment.</div><div  class="">For me the runtime is ubuntu 22.04, but I build the jdk with sysroot of ubuntu 20.04 ( for better compatibility) and gcc 11.2</div><div  class=""><br  class=""></div><div  class="">Regards, Vladimir<br  class=""><div  class="">15 сент. 2022 г., в 18:17, Xiaolin Zheng <<a  class="" href="mailto:yunyao.zxl@alibaba-inc.com" target="_blank">yunyao.zxl@alibaba-inc.com</a>> написал(а):</div><br  class="Apple-interchange-newline"><div  class=""><div  class="" style="line-height:1.7;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;"><div  class="" style="clear:both;">Hi Vladimir,</div><div  class="" style="clear:both;"><br  class=""></div><div  class="" style="clear:both;">The mailing list says my e-mail exceeds 40KB so I get rejected. But I want to send it out anyway before getting off today's work. So here is a work around:</div><div  class="" style="clear:both;">Please check:</div><div  class="" style="clear:both;"><span  class=""><a  class="" href="https://gist.github.com/zhengxiaolinX/25c32853690f7ac1c125d2fe1da19710" target="_blank">https://gist.github.com/zhengxiaolinX/25c32853690f7ac1c125d2fe1da19710</a></span></div><div  class="" style="clear:both;"><br  class=""></div><div  class="" style="clear:both;">Looking forward to your opinions.</div><div  class="" style="clear:both;"><br  class=""></div><div  class="" style="clear:both;">Best,</div><div  class="" style="clear:both;">Xiaolin</div></div></div></div><br  class=""></div></div></div></div><br  class=""></div></div></div></blockquote></div></div>