[riscv-port] RFR: 8277391: riscv: implement tls function MacroAssembler::get_thread() by using tls.ie

Fei Yang fyang at openjdk.java.net
Fri Nov 19 04:01:21 UTC 2021


On Thu, 18 Nov 2021 12:36:31 GMT, zhengxiaolinX <duke at openjdk.java.net> wrote:

> Hi team,
> 
> This patch fixes the unimplemented assembly version of `__ get_thread()`, bringing some performance improvement by directly using the x4 register to refer to the variable `Thread::_thr_current`. Tested tests under hotspot/ and jdk/. [Original patch](https://github.com/riscv-collab/riscv-openjdk/pull/4)
> 
> Thanks,
> Xiaolin

Changes requested by fyang (Lead).

src/hotspot/os_cpu/linux_riscv/threadLS_linux_riscv.S line 31:

> 29:     .type   _ZN10JavaThread25riscv64_get_thread_helperEv, %function
> 30: 
> 31: _ZN10JavaThread25riscv64_get_thread_helperEv:

For maximum flexibility, I would suggest we switch to use the global-dynamic TLS model here if you don't have a strong reason to use the initial-exec TLS model. That's the default TLS model used by the host GCC compiler and I don't want to affected by the limits of the initial-exec TLS model some day.
---------------
        la.tls.gd       a0, _ZN6Thread12_thr_currentE
        addi    sp, sp, -16
        sd      ra, 8(sp)
        call    __tls_get_addr at plt
        ld      ra, 8(sp)
        ld      a0, 0(a0)
        addi    sp, sp, 16
        ret
---------------

-------------

PR: https://git.openjdk.java.net/riscv-port/pull/7


More information about the riscv-port-dev mailing list