Hi StefanK,
Looks good!
Bengt
On 2016-03-23 11:28, Stefan Karlsson wrote:
Hi all,
Please, review this patch to optimize the log_is_enabled check in the
Unified Logging framework.
http://cr.openjdk.java.net/~stefank/8152538/webrev.01/
https://bugs.openjdk.java.net/browse/JDK-8152538
The following code:
void logLine() {
log_debug(gc)("logLine");
}
expands into:
(!log_is_enabled(Debug, __VA_ARGS__)) ? ... : ... )
The log_is_enabled macro further expands and inlines functions, but
then end up calling LogTagSet::is_level.
Currently, the generated code looks like this:
(gdb) disass logLine
Dump of assembler code for function logLine():
0x0000000000ae3bc0 <+0>: push %rbp
0x0000000000ae3bc1 <+1>: lea 0x755fb8(%rip),%rdi # 0x1239b80
<_ZN16LogTagSetMappingILN6LogTag4typeE22ELS1_0ELS1_0ELS1_0ELS1_0EE7_tagsetE>
0x0000000000ae3bc8 <+8>: mov $0x2,%esi
0x0000000000ae3bcd <+13>: mov %rsp,%rbp
0x0000000000ae3bd0 <+16>: callq 0x969c30
<LogTagSet::is_level(LogLevel::type) const>
0x0000000000ae3bd5 <+21>: test %al,%al
0x0000000000ae3bd7 <+23>: jne 0xae3be0 <logLine()+32>
0x0000000000ae3bd9 <+25>: pop %rbp
0x0000000000ae3bda <+26>: retq
0x0000000000ae3bdb <+27>: nopl 0x0(%rax,%rax,1)
0x0000000000ae3be0 <+32>: pop %rbp
0x0000000000ae3be1 <+33>: lea 0x265133(%rip),%rdi # 0xd48d1b
0x0000000000ae3be8 <+40>: xor %eax,%eax
0x0000000000ae3bea <+42>:
jmpq 0x5d9e00 <LogImpl<(LogTag::type)22, (LogTag::type)0,
(LogTag::type)0, (LogTag::type)0, (LogTag::type)0,
(LogTag::type)0>::write<(LogLevel::type)2>(char const*, ...)>
By making LogTagSet::is_level inlinable, we get:
(gdb) disass logLine
Dump of assembler code for function logLine():
0x0000000000ae1690 <+0>: cmpq $0x0,0x756520(%rip) # 0x1237bb8
<_ZN16LogTagSetMappingILN6LogTag4typeE22ELS1_0ELS1_0ELS1_0ELS1_0EE7_tagsetE+56>
0x0000000000ae1698 <+8>: push %rbp
0x0000000000ae1699 <+9>: mov %rsp,%rbp
0x0000000000ae169c <+12>: je 0xae16b0 <logLine()+32>
0x0000000000ae169e <+14>: pop %rbp
0x0000000000ae169f <+15>: lea 0x264d75(%rip),%rdi # 0xd4641b
0x0000000000ae16a6 <+22>: xor %eax,%eax
0x0000000000ae16a8 <+24>:
jmpq 0x5d8f60 <LogImpl<(LogTag::type)22, (LogTag::type)0,
(LogTag::type)0, (LogTag::type)0, (LogTag::type)0,
(LogTag::type)0>::write<(LogLevel::type)2>(char const*, ...)>
0x0000000000ae16ad <+29>: nopl (%rax)
0x0000000000ae16b0 <+32>: pop %rbp
0x0000000000ae16b1 <+33>: retq
End of assembler dump.
Thanks,
StefanK