Walter Bright:

On 4/10/2013 4:00 AM, Manu wrote:
It doesn't have all sources. It could load a library. That can never be guaranteed.

Currently, a virtual call is done with:

   (*vtbl[i])(args...)

It makes me wonder if the following would be faster:

   method_fp = vtbl[i];
   if (method_fp == &method)
       method(args...)
   else
       (*method_fp)(args...)

Anyone care to dummy this up and run a benchmark?

It's important to repeat experiments, but I think it's also interesting to take a look at the very extensive amount of experiments already done on such matters since Self virtual machines. The relevant part of the source code of open source JavaVM is worth looking at.

http://en.wikipedia.org/wiki/Inline_caching

http://www.azulsystems.com/blog/cliff/2010-04-08-inline-caches-and-call-site-optimization

http://extras.springer.com/2000/978-3-540-67660-7/papers/1628/16280258.pdf

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.3108&rep=rep1&type=pdf

The benchmarking should be done with a both few different little synthetic programs, and one largish program that used virtual calls a lot.

Bye,
bearophile

Reply via email to