无用的测试指令? [英] Useless test instruction?
问题描述
我得到了以下程序集列表,作为Java程序的JIT编译的结果.
I got the below assembly list as result for JIT compilation for my java program.
mov 0x14(%rsp),%r10d
inc %r10d
mov 0x1c(%rsp),%r8d
inc %r8d
test %eax,(%r11) ; <--- this instruction
mov (%rsp),%r9
mov 0x40(%rsp),%r14d
mov 0x18(%rsp),%r11d
mov %ebp,%r13d
mov 0x8(%rsp),%rbx
mov 0x20(%rsp),%rbp
mov 0x10(%rsp),%ecx
mov 0x28(%rsp),%rax
movzbl 0x18(%r9),%edi
movslq %r8d,%rsi
cmp 0x30(%rsp),%rsi
jge 0x00007fd3d27c4f17
我对test
指令的理解在这里没有用,因为测试的主要思想是
My understanding the test
instruction is useless here because the main idea of the test is
标志SF,ZF,PF被修改,而AND的结果被丢弃.
The flags SF, ZF, PF are modified while the result of the AND is discarded.
,这里我们不使用这些结果标志.
and here we don't use these result flags.
这是JIT中的错误还是我错过了什么? 如果是,最好的报告地点在哪里? 谢谢!
Is it a bug in JIT or do I miss something? If it is, where the best place for reporting it? Thanks!
推荐答案
必须为线程本地握手投票.
查看从中读取%r11
的位置.如果从%r15
(线程本地存储)的某个偏移量读取它,那就好了.请参见此处的示例:
That must be the thread-local handshake poll.
Look where %r11
is read from. If it is read from some offset off the %r15
(thread-local storage), that's the guy. See the example here:
0.31% ↗ ...70: movzbl 0x94(%r9),%r10d
0.19% │ ...78: mov 0x108(%r15),%r11 ; read the thread-local page addr
25.62% │ ...7f: add $0x1,%rbp
35.10% │ ...83: test %eax,(%r11) ; thread-local handshake poll
34.91% │ ...86: test %r10d,%r10d
╰ ...89: je ...70
这不是没有用的,一旦保护页面被标记为不可读,它将导致SEGV,并将控制权转移到JVM的SEGV处理程序.这是JVM安全点Java线程机制的一部分,例如用于GC.
It is not useless, it would cause SEGV once the guard page is marked non-readable, and that would transfer control to JVM's SEGV handler. This is part of JVM's mechanics to safepoint Java threads, e.g. for GC.
UPD:希望在此处.
这篇关于无用的测试指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!