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.

Reply via email to