jit.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef SCM_JIT_H
  2. #define SCM_JIT_H
  3. /* Copyright 2018-2019
  4. Free Software Foundation, Inc.
  5. This file is part of Guile.
  6. Guile is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Guile is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with Guile. If not, see
  16. <https://www.gnu.org/licenses/>. */
  17. #include "libguile/scm.h"
  18. struct scm_jit_function_data;
  19. struct scm_jit_state;
  20. #ifdef BUILDING_LIBGUILE
  21. struct scm_jit_function_data
  22. {
  23. uint8_t *mcode;
  24. uint32_t counter;
  25. int32_t start;
  26. int32_t end;
  27. #if SCM_SIZEOF_UINTPTR_T == 4
  28. #elif SCM_SIZEOF_UINTPTR_T == 8
  29. uint32_t pad;
  30. #else
  31. #error unhandled sizeof(uintptr_t)
  32. #endif
  33. };
  34. /* These values should be even, so that a function's counter is never
  35. 0xffffffff, so that setting the JIT threshold to 0xffffffff always
  36. disables compilation. */
  37. enum scm_jit_counter_value
  38. {
  39. SCM_JIT_COUNTER_ENTRY_INCREMENT = 30,
  40. SCM_JIT_COUNTER_LOOP_INCREMENT = 2,
  41. };
  42. #endif
  43. SCM_INTERNAL uint32_t scm_jit_counter_threshold;
  44. SCM_INTERNAL const uint8_t *scm_jit_compute_mcode (scm_thread *thread,
  45. struct scm_jit_function_data *data);
  46. SCM_INTERNAL void scm_jit_enter_mcode (scm_thread *thread,
  47. const uint8_t *mcode);
  48. SCM_INTERNAL void scm_jit_state_free (struct scm_jit_state *j);
  49. SCM_INTERNAL void *scm_jit_return_to_interpreter_trampoline;
  50. SCM_INTERNAL void scm_jit_clear_mcode_return_addresses (scm_thread *thread);
  51. SCM_INTERNAL void scm_init_jit (void);
  52. #endif /* SCM_JIT_H */