From 4567db45b8efa292a72c4c73bc74794a84a02658 Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Tue, 27 Oct 2009 20:30:28 +0000 Subject: Change the JIT to compile eagerly by default as agreed in http://llvm.org/PR5184, and beef up the comments to describe what both options do and the risks of lazy compilation in the presence of threads. llvm-svn: 85295 --- llvm/docs/tutorial/LangImpl4.html | 35 +++++++++++++++------------------- llvm/docs/tutorial/OCamlLangImpl4.html | 31 +++++++++++++----------------- 2 files changed, 28 insertions(+), 38 deletions(-) (limited to 'llvm/docs/tutorial') diff --git a/llvm/docs/tutorial/LangImpl4.html b/llvm/docs/tutorial/LangImpl4.html index 3188135384e..728d518a473 100644 --- a/llvm/docs/tutorial/LangImpl4.html +++ b/llvm/docs/tutorial/LangImpl4.html @@ -388,24 +388,19 @@ entry: -

This illustrates that we can now call user code, but there is something a bit subtle -going on here. Note that we only invoke the JIT on the anonymous functions -that call testfunc, but we never invoked it on testfunc -itself.

- -

What actually happened here is that the anonymous function was -JIT'd when requested. When the Kaleidoscope app calls through the function -pointer that is returned, the anonymous function starts executing. It ends up -making the call to the "testfunc" function, and ends up in a stub that invokes -the JIT, lazily, on testfunc. Once the JIT finishes lazily compiling testfunc, -it returns and the code re-executes the call.

- -

In summary, the JIT will lazily JIT code, on the fly, as it is needed. The -JIT provides a number of other more advanced interfaces for things like freeing -allocated machine code, rejit'ing functions to update them, etc. However, even -with this simple code, we get some surprisingly powerful capabilities - check -this out (I removed the dump of the anonymous functions, you should get the idea -by now :) :

+

This illustrates that we can now call user code, but there is something a bit +subtle going on here. Note that we only invoke the JIT on the anonymous +functions that call testfunc, but we never invoked it +on testfunc itself. What actually happened here is that the JIT +scanned for all non-JIT'd functions transitively called from the anonymous +function and compiled all of them before returning +from getPointerToFunction().

+ +

The JIT provides a number of other more advanced interfaces for things like +freeing allocated machine code, rejit'ing functions to update them, etc. +However, even with this simple code, we get some surprisingly powerful +capabilities - check this out (I removed the dump of the anonymous functions, +you should get the idea by now :) :

@@ -453,8 +448,8 @@ directly.

resolved. It allows you to establish explicit mappings between IR objects and addresses (useful for LLVM global variables that you want to map to static tables, for example), allows you to dynamically decide on the fly based on the -function name, and even allows you to have the JIT abort itself if any lazy -compilation is attempted.

+function name, and even allows you to have the JIT compile functions lazily the +first time they're called.

One interesting application of this is that we can now extend the language by writing arbitrary C++ code to implement operations. For example, if we add: diff --git a/llvm/docs/tutorial/OCamlLangImpl4.html b/llvm/docs/tutorial/OCamlLangImpl4.html index 26f253249bb..543e12fe25b 100644 --- a/llvm/docs/tutorial/OCamlLangImpl4.html +++ b/llvm/docs/tutorial/OCamlLangImpl4.html @@ -406,22 +406,17 @@ entry:

This illustrates that we can now call user code, but there is something a bit subtle going on here. Note that we only invoke the JIT on the anonymous -functions that call testfunc, but we never invoked it on testfunc -itself.

- -

What actually happened here is that the anonymous function was JIT'd when -requested. When the Kaleidoscope app calls through the function pointer that is -returned, the anonymous function starts executing. It ends up making the call -to the "testfunc" function, and ends up in a stub that invokes the JIT, lazily, -on testfunc. Once the JIT finishes lazily compiling testfunc, -it returns and the code re-executes the call.

- -

In summary, the JIT will lazily JIT code, on the fly, as it is needed. The -JIT provides a number of other more advanced interfaces for things like freeing -allocated machine code, rejit'ing functions to update them, etc. However, even -with this simple code, we get some surprisingly powerful capabilities - check -this out (I removed the dump of the anonymous functions, you should get the idea -by now :) :

+functions that call testfunc, but we never invoked it +on testfunc itself. What actually happened here is that the JIT +scanned for all non-JIT'd functions transitively called from the anonymous +function and compiled all of them before returning +from run_function.

+ +

The JIT provides a number of other more advanced interfaces for things like +freeing allocated machine code, rejit'ing functions to update them, etc. +However, even with this simple code, we get some surprisingly powerful +capabilities - check this out (I removed the dump of the anonymous functions, +you should get the idea by now :) :

@@ -467,8 +462,8 @@ calls in the module to call the libm version of sin directly.

get resolved. It allows you to establish explicit mappings between IR objects and addresses (useful for LLVM global variables that you want to map to static tables, for example), allows you to dynamically decide on the fly based on the -function name, and even allows you to have the JIT abort itself if any lazy -compilation is attempted.

+function name, and even allows you to have the JIT compile functions lazily the +first time they're called.

One interesting application of this is that we can now extend the language by writing arbitrary C code to implement operations. For example, if we add: -- cgit v1.2.3