[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DotGNU]callvirt change to cscc
From: |
Rhys Weatherley |
Subject: |
Re: [DotGNU]callvirt change to cscc |
Date: |
Fri, 15 Nov 2002 21:06:41 +1000 |
Gopal V wrote:
> this totally destroys the efficency of using non-virtual methods ...
> Because if we're going to lookup each and every method .... It's just
> one lookup per method for every call . IMHO we should try to optimise
> rather than correct non-existent bugs for non-existent compatibility..
Actually, the runtime impact isn't as big as you think. The verifier
notices that "callvirt" is being used on a non-virtual method and
inserts a normal CVM "call" opcode, rather than CVM's "call_virtual".
The only runtime change is to do a "cknull" before the "call".
It doesn't have to do a virtual method lookup for every call - it
can call the destination method directly.
> The correct NullReferenceException will be thrown when the called
> method accesses 'this' anyway...
>
> Sorry, I don't like this change ... This is neither good or bad ..
> it's UGLY ...
I agree with you. Unfortunately, compatibility trumps efficiency
in this case. Under MS'es compiler/runtime, the following throws
a NullReferenceException even though "this" is never touched by
the "DoNothing" method:
using System;
public class Test
{
public void DoNothing()
{
}
public static void Main()
{
((Test)null).DoNothing();
}
}
Cheers,
Rhys.