Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Run-time monomo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 2262 of 2529
Post > Topic >>

Run-time monomorphization

by Jon Harrop <usenet@[EMAIL PROTECTED] > Dec 5, 2007 at 11:25 AM

Some compilers like Stalin (for Scheme) and MLton (for SML) use
whole-program optimizations to completely remove the run-time cost of
polymorphism. In contrast, languages like OCaml often suffer a 2x slowdown
due to polymorphism in performance critical functions (due to run-time
dispatch inserted into inner loops and not hoisted) that must then be
optimized manually.

If I'm using LLVM to JIT compile code for an OCaml-like language, can I
monomorphize function definitions on the fly easily?

May I conjecture how:

.. Fetching a handle to a function "f" at its call site uses a
function "get".

.. The application "get f" is memoized with respect to the instantiations
of
the type variables of "f" used at its call site.

Consider the example:

  val List.fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
  let sum_int = List.fold_left (+) 0
  let sum_float = List.fold_left (+.) 0.

The call to "List.fold_left" inside "sum_int" uses 'a = 'b = int and a
version of "List.fold_left" is JIT compiled specifically for those types.

Similarly for "sum_float" with 'a = 'b = float.

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?u
 




 1 Posts in Topic:
Run-time monomorphization
Jon Harrop <usenet@[EM  2007-12-05 11:25:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 8:21:39 CDT 2008.