Merge: Guard call
authorJean Privat <jean@pryen.org>
Thu, 26 Feb 2015 02:23:36 +0000 (09:23 +0700)
committerJean Privat <jean@pryen.org>
Thu, 26 Feb 2015 02:23:36 +0000 (09:23 +0700)
Add option `--guard-call` as an alternative implementation of the link-time optimization `--substitute-monomorph`

The idea is to have the standard VFT call guarded by a symbol when the call is monomorphic.
So the sequence is independent of any client and is roughly

~~~
if SYMBOL != null then
   SYMBOL(ARGS)
else
   (SELF->VFT[COLOR])(ARGS)
end
~~~

where the value of the SYMBOL is set for each specific program at link-time: null when the call is polymorphic and the address of the single target when the call is monomorphic.

Benches show that, on my computer, there is from 0% to 10% in loss so this alternative implementation is pure overcost :)
Still keep it because, I coded it and works, and it may worth something on other architectures.

The benchs shows some quick results:

* first (sc, red) is default
* second (sl, green) is `--substitute-monomorph`, the previous impl
* third (gc, blue) is `--guard-call``, the new one
* last (cd, purple) is `--direct-call-monomorph0`, the optimal with direct calls directly inserted in a global way

![bench_linkboost](https://cloud.githubusercontent.com/assets/135828/6342973/794b2a92-bc13-11e4-9b22-cc43e6cda473.png)

Even if the result is deceiving, the PR does some cleanup and refactorization, so we got that goin for us,  which is nice.

Pull-Request: #1173
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

1  2 
benchmarks/bench_engines.sh

Simple merge