[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-i18n-dev
Subject:    Re: <i18n dev> RFR: 8304245: Speed up CharacterData.of by avoiding bit shifting in the latin1 fast-p
From:       Eirik Bjorsnos <duke () openjdk ! org>
Date:       2023-03-18 17:48:20
Message-ID: aIvFD53PL8vFsGb4kuot0F1rvmCY7waESfefHR5GJFE=.2514bafa-08c1-4e54-8e01-5442dd04e263 () github ! com
[Download RAW message or body]

On Sat, 18 Mar 2023 17:06:52 GMT, jmehrens <duke@openjdk.org> wrote:

> > We could, but benchmarks show no performance improvements over the current PR. I \
> > think the current code is perhaps slightly more readable.
> 
> Does non-short-circuit logical AND operator perform similar to baseline?  In this \
> very specific case there is no risk of side effects due to method calls, no risk of \
> null pointer exception because of primitives, and there is not an excessive amount \
> of conditions.  Therefore, I would think either `&` or `&&` are viable options. 
> `if (ch >= 0 & ch <= 0xFF) {`
> 
> I ask just for the sake of my own learning on this topic as it relates to \
> performance as opposed to code readability preferences.

Both choices of operators en up with identical generated code on my Intel Mac.

For reference, I did a comparison between the generated code for the current code, \
and the one in this PR:

Current generated code start like this:


movl		%eax, -0x14000(%rsp)
pushq		%rbp
subq		$0x20, %rsp
cmpl		$1, 0x20(%r15)
jne		0x119cae072
movl		%esi, %r11d
shrl		$8, %r11d
testl		%r11d, %r11d
jne		0x119cae043
movabsq		$0x70fe03c90, %rax  ;   {oop(a \
'java/lang/CharacterDataLatin1'{0x000000070fe03c90})} ``` 

While the PR generated code starts like this:


movl		%eax, -0x14000(%rsp)
pushq		%rbp
subq		$0x20, %rsp
cmpl		$1, 0x20(%r15)
jne		0x1171d41f2
nopw		(%rax, %rax)
cmpl		$0x100, %esi
jae		0x1171d41c5
movabsq		$0x70fe03c90, %rax  ;   {oop(a \
'java/lang/CharacterDataLatin1'{0x000000070fe03c90})}


The rest of the code seems identical.

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

PR: https://git.openjdk.org/jdk/pull/13040


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic