Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackAlignmentInBytes问题修复 #381

Open
DingliZhang opened this issue Apr 25, 2022 · 2 comments
Open

StackAlignmentInBytes问题修复 #381

DingliZhang opened this issue Apr 25, 2022 · 2 comments

Comments

@DingliZhang
Copy link

DingliZhang commented Apr 25, 2022

问题描述

来源于 #126 (comment) ,源码位于:

const int StackAlignmentInBytes = 8;

但其实其中引用的 https://github.com/riscv/riscv-eabi-spec/blob/master/EABI.adoc#eabi-stack-alignment 为嵌入式ABI,不会用于 Linux,而后者将继续使用Unix ABI (UABI)。

https://github.com/riscv/riscv-isa-manual/releases/download/draft-20220424-f5f9c27/riscv-spec.pdf 中提到:
image

相关的讨论:

riscv-non-isa/riscv-elf-psabi-doc#21

测试结果

将这里的8 revert为16,在core release模式下可以通过 https://github.com/openjdk-riscv/testcase-jdk11u-rv32g 测试:

image

c2下对当前结果没有影响。

也许我们可以在未来根据嵌入式设备/Linux系统设备来设定这里的栈对齐,当前的话我认为修改为16字节对齐是正确的。

@DingliZhang
Copy link
Author

#262 (comment) 这里对RV64将zr放入栈中的操作解释为为了16字节对齐是有问题的。
查看jvm11规范:https://docs.oracle.com/javase/specs/jvms/se11/jvms11.pdf
image

规范中指出long和double都需要两个本地变量槽(slot)来存储,因此在rv64中的 push_l 以及 push_d 都会执行 addi(esp, esp, -2 * wordSize); 来开辟128位空间,每个slot为64位,也就是两个本地变量槽;而rv32中每个slot大小为32位,long/double需要分高低32位来存储,也正好是需要两个本地变量槽。

@DingliZhang
Copy link
Author

#397 中将 #153 修改的 StackAlignmentInBytes 回退为了16,,但是同时修改的 #254 的结果并没有进行改动,将这些改动一并回退:DingliZhang@b76aef3

对当前结果没有影响:
image

@DingliZhang DingliZhang reopened this Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant