3 ms·
Can't you use function overloading? or function pointers? Why do you need to recompile the code? Can someone give an example of where this should be used?
by samfisher83 10y ago
Can't you use function overloading? or function pointers? Why do you need to recompile the code? Can someone give an example of where this should be used?
- bedatadriven 10y agoThis is precisely a strategy for optimizing away the cost of function calls and other indirection. You basically really want this in any case where you're applying a dynamic expression to a large dataset. We use the technique in Renjin, an R interpreter built on the JVM, for vectorized expressions such as sqrt(x^2+y^2) where x and y are long arrays. You can implement this with function pointers, or interfaces in Java, but if you're evaluating the expression millions of times, then the cost of the indirection is huge, and worse yet, it gets in the way of the processor's branch prediction and pipelining. If you can compile the same dynamic expression down to straightline machine code, the impact is pretty fantastic: http://www.renjin.org/blog/2015-06-28-renjin-at-rsummit-2015.html http://www.renjin.org/blog/2015-06-28-renjin-at-rsummit-2015...