Funny coincidence, I mention this in todays' "Java Specialists'
Newsletter": https://www.javaspecialists.eu/archive/Issue254.html
And I believe they improved this in Java 9 :-)
Regards
Heinz
--
Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java™ Specialists' Newsletter" - www.javaspecialists.eu
Java Champion - www.javachampions.org
Oracle Developer Champion - www.twitter.com/dev_champions
JavaOne Rock Star - www.oracle.com/javaone/rock-star-wall-of-fame.html
Tel: +30 69 75 595 262
Skype: kabutz
John Hening wrote:
Hello!
I have the very simple Utils function:
public static Unsafe getUnsafe(){
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
return (Unsafe) f.get(null);
}
And, as it turned out from my analysis with perf it is a bottleneck in
my "scheme" of the program. That funciton is called in main loop. It is
a scheme so it wasn't optimized (I know that I should do it better).
Nevertheless, perf points that `String::intern` is
cpu-cylcle-consuming.
I cannot understand why that method wasn't compiled to something like
that:
("theUnsafe" was placed in permgen)
and now:
load string_theUnsafe_from_permgen
call Unsafe.class.getDeclaredField
..
instead of
public static getUnsafe()Lsun/misc/Unsafe;
...
L0
LDC Lsun/misc/Unsafe;.class
LDC "theUnsafe"
INVOKEVIRTUAL java/lang/Class.getDeclaredField
(Ljava/lang/String;)Ljava/lang/reflect/Field;
...
}
Especially, I don't see where method
String.intern
is called? I suppose that it is called by interpreter on
LDC "theUnsafe"
Explain me that, please.
Greetings,
John
--
You received this message because you are subscribed to the Google
Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to mechanical-sympathy+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-sympathy+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.