-
Notifications
You must be signed in to change notification settings - Fork 822
Why is alwayscallvirt the default? #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Edit: Found root cause of why base class constructors use |
I guess this is my fault :) Back in 2010 I've submitted this issue and AFAIR we've adopted |
Could the reason be the same as in C#, that is An article going into detail of this looks like being .NET Type Internals - From a Microsoft CLR Perspective. Interesting blog on observing null this is Jarepar's Observing a null this value. <edit: Plus the blog by @vladima. :) |
@veikkoeeva The C# compiler does use |
Oh I see, So a proper fix would require reviewing everywhere in the code generator that currently specifies a |
@latkin yes, that is correct |
The performance difference could be huge between the direct and indirect calls. I have (re)created a small benchmark [1] in F# to measure the call overhead in different cases. The benchmark is far from perfect, but it will provide some valuable information. https://gist.github.com/zpodlovics/73deb8b7a06d7d5ec374 Some benchmark result: Windows Vista, .NET 4.0.30319.34209, Intel Core2 7200 (2GHz)
Ubuntu 14.04, Mono 4.0, AMD Kaveri 7850 (3.7GHz)
[1] https://programmers.stackexchange.com/questions/234473/how-are-virtual-methods-slower-in-c |
My question was answered, so I'll close this out. |
By default, the F# compiler always uses the
callvirt
instruction, even when the fastercall
instruction is safe/appropriate. Default is set in build.fs.You can override this with the undocumented
--alwayscallvirt-
flag.Why is this the default? Should we consider changing it?
The text was updated successfully, but these errors were encountered: