Hi again,
as expected not much of a difference on the test I was using (a small
cost on the startup/warmup numbers due replacing a boolean check with a
method call), but on a test that adds in a few extended PrintStreams
and mixes those with use of System.out I can get a ~3-4% statistical
improvement with your idea - so I think it's better to peel off
the PrintStream.class check like this:
http://cr.openjdk.java.net/~redestad/8215412/jdk.03/
Thanks!
/Claes
On 2019-01-02 13:29, Claes Redestad wrote:
Hi Rémi,
On 2019-01-02 13:05, Remi Forax wrote:
Hi Claes,
did you try instead of having a field 'internal' to inline the class
check (this.getClass() == PrintStream.class) at every call site you
are reading that field ?
for a method like println(), the VM has to do a class check (if CHA is
defeated) before entering the method println so the JIT might be able
to remove the check this.getClass() == PrintStream.class because it
already know at that point that the current class is PrintStream.
interesting idea - I'll try it out. I don't expect it to make much of a
difference in my current (trivial) tests, but perhaps in a slightly more
contrived setup.
happy new year!
/Claes