Why Strings as Classes?

JAnderson ask at me.com
Tue Aug 26 19:04:32 PDT 2008


Walter Bright wrote:
> Jb wrote:
>> Walter said "the hardware cannot predict where a virtual call will go".
>>
>> It does in fact predict them, and speculatively execute them, and as 
>> pretty much any bechmark will show it gets it right the vast majority 
>> of the time. (On x86 anyway.)
>>
>> That's what I was saying. 
> 
> Looks like I keep falling behind on what modern CPUs are doing :-(
> 
> In any case, throughout all the revolutions in how CPUs work, there have 
> been a few invariants that hold true well enough as an optimization guide:
> 
> 1. fewer instructions ==> faster execution
> 2. fewer memory accesses ==> faster execution
> 3. fewer conditional branches ==> faster execution

Also you can't inline virtual calls (well a smart compiler could but 
that's another discussion).   That means the compiler can't optimize so 
well but removing unnecessary operations.

-Joel



More information about the Digitalmars-d mailing list