On 2011-05-16, at 11:13 PM, chevalma@iro.umontreal.ca wrote:
On my MacBook Pro, calling the handlers through the context gives a 10% performance boost for fib (and generates shorter code).
Calling them through the context as opposed to static linking?
Yes. Here are the measurements on my MacBook Pro:
bash-3.2$ ./js86 fib.js;fgrep -B 1 ".long 3 # fib" fib.js.S
real 0m1.599s user 0m1.595s sys 0m0.002s call jump_global_prop_handler .long 3 # fib -- call deoptimize_global_prop_handler .long 3 # fib -- call jump_global_prop_handler .long 3 # fib -- call jump_global_prop_handler .long 3 # fib bash-3.2$ ./js86 -ctx-handlers fib.js;fgrep -B 1 ".long 3 # fib" fib.js.S
real 0m1.448s user 0m1.446s sys 0m0.002s call *24(%ecx) .long 3 # fib -- call *20(%ecx) .long 3 # fib -- call *24(%ecx) .long 3 # fib -- call *24(%ecx) .long 3 # fib
Note that a direct call takes 5 bytes to encode, and a call through the context takes 3 bytes.
I'm not ready to generalize the performance to other programs. Fib is 10% faster with handlers in the context, but this may be due to changing the alignment of instructions in the cache leading to fewer cache misses. We need to average things over many programs to see if context handlers improve performance in general.
Marc