RFR: 8263718: unused-result warning happens at os_linux.cpp
Thomas Stuefe
stuefe at openjdk.java.net
Fri Mar 19 17:36:40 UTC 2021
On Fri, 19 Mar 2021 12:51:07 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:
>>> > I modified the code as following, it seems to work - we cannot see `alloca()`, however the stack is expanded.
>>>
>>> Sorry but I'm not seeing where the stack actually gets expanded?
>>
>> 0x00007ffff7154d87 <+87>: sub %rax,%rsp
>>
>> I guess `%rax` seems to contain the result of `((pid ^ counter++) & 7) * 128`, then `alloca()` is replaced to `sub` for `%RSP`.
>> I saw the warning for this issue as `void* __builtin_alloca(long unsigned int)`. It might be it. We can just expand `%RSP` if we want to allocate buffer on the stack.
>
> I objdump'ed libjvm.so in JDK 16 Linux x64 from jdk.java.net , it also does not seem to expand the stack:
>
> 0000000000bd8500 <thread_native_entry(Thread*)>:
> bd8500: 55 push %rbp
> bd8501: 48 89 e5 mov %rsp,%rbp
> bd8504: 41 56 push %r14
> bd8506: 41 55 push %r13
> bd8508: 49 89 fd mov %rdi,%r13
> bd850b: 41 54 push %r12
> bd850d: 53 push %rbx
> bd850e: e8 ad 1e 1a 00 callq d7a3c0 <Thread::record_stack_base_and_size()>
> bd8513: e8 08 27 66 ff callq 23ac20 <getpid at plt>
> bd8518: 4c 89 ef mov %r13,%rdi
> bd851b: 83 05 e6 a3 64 00 01 addl $0x1,0x64a3e6(%rip) # 1222908 <thread_native_entry(Thread*)::counter>
> bd8522: e8 39 1e 1a 00 callq d7a360 <Thread::initialize_thread_current()>
> bd8527: 49 8b 9d 70 02 00 00 mov 0x270(%r13),%rbx
> bd852e: 31 c0 xor %eax,%eax
>
> Result from `getpid()` will be stored into `%RAX`, however it is not used until `xor` at bd852e.
> And also I could not find out both `alloca()` call and manipulating `%RSP` at here.
Writing to the *end* of the allocated area may do the trick.
..Thomas
-------------
PR: https://git.openjdk.java.net/jdk/pull/3042
More information about the hotspot-dev
mailing list