4 ms·
Dynamic typing means you pay the cost of trace recording or profiling to collect the type info. The actual code performance should ultimately be the same. JIT c
by jashmatthews 7y ago
Dynamic typing means you pay the cost of trace recording or profiling to collect the type info. The actual code performance should ultimately be the same. JIT can remove the overhead of dynamic dispatch and replace it with a fixed call and a guard, for example. This isn’t possible with dynamically loading C libraries.
- deleted 7y ago[deleted]
- saagarjha 7y ago> JIT can remove the overhead of dynamic dispatch and replace it with a fixed call and a guard, for example. Only when the guard isn’t triggered constantly. With an actual type system you can remove many of these guards altogether instead of having them everywhere and falling back to the slow case when you get something unexpected.
- jashmatthews 7y agoThere are actually two problems here: How to handle things being re-defined and how to handle an unexpected type after speculation. In real high performance VMs the guard for redefinition is effectively a single instruction which is a CPU can easily branch predict and handle with out of order execution: https://chrisseaton.com/truffleruby/low-overhead-polling/ https://chrisseaton.com/truffleruby/low-overhead-polling/ With unexpected types we can use LuaJIT as an example: The type speculation guard will be turned into a conditional branch to a side trace. The slow path quickly becomes another fast path.