# Monday, 19 August 2002
« No Title | Main | No Title »
No Title
I changed the XML remapping language to support Object.hashCode() & Object.toString() twiddling (see this previous posting for more info). It is now possible to specify which CIL code sequence should be substituted for a call to a method. Here is how Object.hashCode() looks:

<method type="instance" name="hashCode" sig="()I" access="public">
<override name="GetHashCode" />
<call class="System.Object name="GetHashCode" />
<dup />
<isinst class="System.String" />
<brfalse name="skip" />
<call class="StringHelper" name="hashCode" />
<br name="end" />
<label name="skip" />
<callvirt class="System.Object name="GetHashCode" />
<label name="end" />

Every virtual call (the invokevirtual bytecode) is converted into a test to see if the call is being done on a string, if so it calls StringHelper.hashCode(), if not, it calls System.Object.GetHashCode(). This isn't yet how it should be, because when it is known at compile time that the reference that hashCode() is called on isn't a string, then this test shouldn't be emitted. I still have to figure out a way to support this optimization.

Updated the binaries and source snaphots.

Monday, 19 August 2002 14:53:35 (W. Europe Daylight Time, UTC+02:00)  #    Comments [1]
Wednesday, 21 August 2002 08:25:20 (W. Europe Daylight Time, UTC+02:00)

You can also optimize the test away (in the other direction) if it's known at compile time that the object *is* a string. Or is that unnecessary since String provides its own GetHashCode implementation that will be invokespecialed already since it's a final class (or whatever the CLR equivalent of final is)?
Home page

I apologize for the lameness of this, but the comment spam was driving me nuts. In order to be able to post a comment, you need to answer a simple question. Hopefully this question is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.

Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)

Comment (HTML not allowed)  

Live Comment Preview