[riscv-port] RFR: 8277391: riscv: implement tls function MacroAssembler::get_thread() by using tls.gd [v2]
fyang at openjdk.java.net
Tue Nov 23 01:30:35 UTC 2021
On Mon, 22 Nov 2021 02:40:18 GMT, zhengxiaolinX <duke at openjdk.java.net> wrote:
>> Hi Felix -
>> Quite sorry for the late reply - it takes me some time to look up some references. This code looks great without any problem and I totally agree with your point - so it is hard to make me not think you have implemented one version already in your codebase :-) And `__tls_get_addr`'s implementation could found itself at [this link](https://sources.debian.org/src/glibc/2.31-13/sysdeps/riscv/libc-tls.c/) with [macros defined](https://sources.debian.org/src/glibc/2.31-13/sysdeps/riscv/nptl/tls.h/), which is a C function. With this respect, it seems that I also need to save and restore all volatile registers pessimistically in `MacroAssembler::get_thread`, same as the current implementation on the master branch. I think it might be hard to keep the saved registers the same as AArch64's implementation that only clobbers x1 - please correct me if I missed something. But this seems much cheaper than calling a [pthread_getspecific](https://sources.debian.org/src/glibc/2.32-4/nptl/pthread_g
etspecific.c/?hl=24#L24). In fact, the first version of this patch is written in a similar way as yours - for better performance I chose to use tls.ie - but I think you hold a very reasonable point.
>> It's Friday night so please feel free to move the discussion to weekdays.
>> Thanks -
> Seems `get_thread()` is only used in debug code on AArch64 and RISCV -- I have pushed revised code and now hotspot and jdk tier1 are under testing. I will ping this thread when tests are done.
Updated changes looks good. Let's see when you have the test result.
More information about the riscv-port-dev