So here it is, the first method from the all new Shark, String.hashCode()
. And the same method from old Shark for comparison. Some highlights:
- The inner loop for the actual calculation is 18 instructions (down from 53)
- A complete pass through the method when fetching a cached hashcode is 39 instructions (down from 66)
All in all I’m pretty pleased with myself.
i am reading this blog, but what is Shark anyway? maybe you should put a small explanation.. maybe i missed it?
Shark is a platform-independent JIT for HotSpot, to complement the zero-assembler interpreter we’ve been using. I wrote a tiny bit about it here.
That’s great !!! So we already have the ubiquitous “all architectures” interpreter, and next we also will have it’s brother the ubiquitous “all architectures” JIT compiler. Porting Java to new architectures will become simple !!!!
hmm, i had already updated the Hotpost and IcedTea articles of wikipedia with informations about zero. Now i’ve done the same for Shark ;-)
Porting Java to new architectures should be not so much “simple” as “not required”, though you will only have the interpreter unless LLVM supports your CPU.
Also, a minor nit, I saw you used the term “platform independent” in the Wikipedia articles, but “platform” to me suggests the combination of CPU and OS, and Zero and Shark are CPU-independent but Linux-specific.
I fixed the article: “This port is intended to allow the interpreter part of HotSpot to be very easily adapted to any Linux processor architecture”, and “Achievement of this work would made the Java Virtual Machine independent of the CPU architecture.” That said, again great work !!
Thank you :)