about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2020-12-25 11:41:48 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2020-12-25 12:08:21 +0100
commit3f6a3b5ebece5f6d3b1010b68a5fd86756593098 (patch)
treeb57a10461b73d921be7fbbab4ed2d6159b0b6c78 /scripts
parent0b9b2532d262bf590b769a7cd2f32602b8925183 (diff)
downloadrust-3f6a3b5ebece5f6d3b1010b68a5fd86756593098.tar.gz
rust-3f6a3b5ebece5f6d3b1010b68a5fd86756593098.zip
Implement lazy compilation in JIT mode
Lazy compilation has the potential to significantly improve the startup
time of a program. While functions have to be codegened when called, it
is expected that a significant amount of all code is only required when
an error occurs or only when the program is used in certain ways.

The basic approach is to first codegen a shim for each function. This
shim calls the `__cg_clif_jit` function of cg_clif with a pointer to the
`Instance` corresponding to the function for which it is a shim.
`__cg_clif_jit` function then codegens this function and uses the hot
code swapping support of SimpleJIT to redirect future calls to the
function to the real version. Finally it calls the newly codegened
function.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/tests.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/scripts/tests.sh b/scripts/tests.sh
index 60ed7aac8aa..a61774f479e 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -16,6 +16,9 @@ function no_sysroot_tests() {
     if [[ "$JIT_SUPPORTED" = "1" ]]; then
         echo "[JIT] mini_core_hello_world"
         CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
+
+        echo "[JIT-lazy] mini_core_hello_world"
+        CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
     else
         echo "[JIT] mini_core_hello_world (skipped)"
     fi
@@ -38,6 +41,9 @@ function base_sysroot_tests() {
     if [[ "$JIT_SUPPORTED" = "1" ]]; then
         echo "[JIT] std_example"
         $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
+
+        echo "[JIT-lazy] std_example"
+        $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --cfg lazy_jit --target "$HOST_TRIPLE"
     else
         echo "[JIT] std_example (skipped)"
     fi