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" /> <invokespecial> <call class="System.Object name="GetHashCode" /> </invokespecial> <invokevirtual> <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" /> </invokevirtual> </method>
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.
1:53:35 PM Comments
|