1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Manual JIT interface via %jit-compile

* libguile/init.c (scm_i_init_guile): Call scm_init_jit ().
* libguile/jit.c (enter_mcode, exit_mcode): New static members; code
  pointers for the JIT trampoline.
  (emit_exit): New helper.  The Lightning tramp/frame mechanism that we
  use needs to exit via a jmp instead of a return.  Adapt callers of
  jit_ret.
  (emit_entry_trampoline): Use the "frame" mechanism to enter the JIT.
  (compile1): Add missing "break" after case statements.  Oops!
  (compile): Add prolog and "tramp" to compiled functions.
  (initialize_jit): New local routine to init the JIT on demand.
  (compute_mcode): New helper, to compile a function.
  (scm_sys_jit_compile): New function, exported to Scheme as
  %jit-compile.
  (scm_jit_compute_mcode): Return the existing mcode if the function is
  at the start.
  (scm_jit_enter_mcode): Call the enter_mcode trampoline.
* libguile/jit.h (struct scm_jit_state): Declare, so we can make
  pointers to it.
* libguile/threads.h (struct scm_thread): Add jit_state member.
* libguile/threads.c (on_thread_exit): Free the jit state.
This commit is contained in:
Andy Wingo 2018-08-20 08:48:00 +02:00
parent 698bff8748
commit dca1e9d7bd
5 changed files with 171 additions and 19 deletions

View file

@ -53,6 +53,7 @@
#include "hashtab.h"
#include "init.h"
#include "iselect.h"
#include "jit.h"
#include "list.h"
#include "modules.h"
#include "numbers.h"
@ -513,6 +514,8 @@ on_thread_exit (void *v)
t->dynstack.top = NULL;
t->dynstack.limit = NULL;
scm_i_vm_free_stack (&t->vm);
scm_jit_state_free (t->jit_state);
t->jit_state = NULL;
#ifdef SCM_HAVE_THREAD_STORAGE_CLASS
scm_i_current_thread = NULL;