On the 0x20B day of Apache Harmony Armand Navabi wrote:
> I am trying to become more familiar with the jit code. I ran the
> following to see what all was compiled when running Hello World.
> "java -Xtrace:compile Hello". I was very surprised to see the number of
> methods that seem to be loaded. I think there are about 1079 methods
> that get compiled for Hello World.
>
> Does harmony just load all the classes in the classlib and compile every
> method? If not, then why would there be so many methods compiled for a
> simple hello world program?
my 2c:
first time methods are compiled "just before execution". So, you have
to execute a method in your app to see it compiled.
> Right now I am trying to write a simple profiling tool that counts the
> number of certain instructions in a program for a given input (i.e. I
> want to run the program, and for every instruction that ends up running,
> collect information). So, since it seems that the jit not only compiles
> every instruction in the program (not only the ones that end up
> running), but also a bunch of other classes, I thought perhaps I would
> be more interested in the interpreter.
Do you mean bytecode instructions? or CPU instructions? For bytecode
you better use the interpreter. For IA-32 we have a special profiling
utility in JIT CG ("iprof") that allows to count how many instructions
of a certain kind were executed, what are the hottest basicblocks,
etc. Feel free to ask on "iprof" in the mailing list. (I think, "we
should document this" :P, but it is not the first priority)
> Running "java -Xint -Xtrace:interpreter Hello" then also gave me way
> more output then I expected. For example
>
> ...
> interpreter: java/lang/String indexOf(II)I
> interpreter: java/lang/String startsWith(Ljava/lang/String;)Z
> interpreter: java/lang/String startsWith(Ljava/lang/String;I)Z
> interpreter: java/lang/String regionMatches(ILjava/lang/String;II)Z
> interpreter: java/net/URI
> access$1002(Ljava/net/URI;Ljava/lang/String;)Ljava/lang/String;
> interpreter: java/net/URI access$1000(Ljava/net/URI;)Ljava/lang/String;
> interpreter: java/net/URI$Helper
> validatePath(Ljava/lang/String;Ljava/lang/String;I)V
> interpreter: java/net/URIEncoderDecoder
> validate(Ljava/lang/String;Ljava/lang/String;)V
> interpreter: java/lang/String length()I
> interpreter: java/lang/String charAt(I)C
> interpreter: java/lang/String indexOf(I)I
> interpreter: java/lang/String indexOf(II)I
> interpreter: java/lang/String length()I
> ...
>
> I'm not sure why all of this is being interpreted for a simple hello
> world program. My understanding was that the interpreter traverses the
> byte code for the given input and then handles the executed byte codes.
> It seems like a lot more is going on here.
>
> Also, I am trying to become familiar with the jit and interpreter by
> reading the DRL Developer's Guide. Are there any other resources other
> than the Developer's Guide and this mailing list?
>
>
> Thanks
> Armand
>
--
Egor Pasko, Intel Managed Runtime Division