Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created March 11, 2011 18:12
Show Gist options
  • Save jnthn/866304 to your computer and use it in GitHub Desktop.
Save jnthn/866304 to your computer and use it in GitHub Desktop.
Multiple Dispatch Optimization in Rakudo
The Rakudo Perl 6 compiler has implemented multiple dispatch for a
while. This is a mechanism by which we pick a routine to call based
on the types of the arguments it is being invoked with. By the Perl 6
specification, in any given lexical scope the set of multi dispatch
candidates is statically known. One opportunity that arises from
this is to try and statically decide some multi-dispatches at compile
time. It won't always be possible - for example, we may have no clue
about the argument types - but when it is possible there could be
some great performance wins.
This task will probably need some initial refactorings to make
implementation of the optimization easier, followed by the core work
of actually implementing it. An adventurous student could then go on
to explore some further optimizations that then become possible after
this, such as inlining. Other static analysis could also follow on
from the work, such as statically determining and telling the user
at compile time that there's no way any of the available multi-dispatch
candidates will match.
Suggested mentor: Jonathan Worthington
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment