1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

141 commits

Author SHA1 Message Date
Andy Wingo
334d0ba860 Adapt to lightening changes
* libguile/jit.c (emit_entry_trampoline): Use
  jit_{enter,leave}_jit_abi.
  (compile_allocate_words_immediate): Use JIT_OPERAND_ABI_WORD.
2019-04-28 13:54:34 +02:00
Andy Wingo
26bd81716b Align stack before entering JIT code
* libguile/jit.c (emit_entry_trampoline): Ensure stack is aligned when
  going into JIT code.
2019-04-28 13:54:34 +02:00
Andy Wingo
14e64a8b57 Ensure stack alignment in JIT code.
* libguile/jit.c (emit_entry_trampoline): Explicitly align stack.
2019-04-26 12:45:16 +02:00
Andy Wingo
52248cf622 Adapt to changes in upstream lightening
* libguile/jit.c (emit_entry_trampoline): Adapt to change in callee-save
  predicates.
2019-04-25 23:47:27 +02:00
Andy Wingo
4088915a7e Lower default JIT threshold as JIT is cheaper now
* libguile/jit.c (default_jit_threshold): Lower from 50000 to 1000.
2019-04-25 18:41:03 +02:00
Andy Wingo
e9a372b020 Re-enable fixnum less-than JIT fast-path
* libguile/jit.c (compile_less): Re-enable fast-path for fixnums, now
  that the JIT library works :)
2019-04-25 18:24:20 +02:00
Andy Wingo
0ef614ecf9 Fix a JIT bug
* libguile/jit.c (compile): Reset frame size as well when restarting
  compilation.  Fixes JIT errors.
2019-04-24 22:20:00 +02:00
Andy Wingo
9a32b4b1ad Adapt to new lightening call API
* libguile/jit.c: Operands have their ABI in them.  We can now have
  addends on GPR and MEM operands, which can improve register
  allocation.  Use new jit_calli_3, etc helper APIs.
2019-04-24 16:02:33 +02:00
Andy Wingo
cfffd5b241 Fix compilation of call-scm<-u64
* libguile/jit.c (compile_call_scm_from_u64): Fix to take operands from
  the right place.
2019-04-04 16:35:44 +02:00
Andy Wingo
5df432b763 Fix arena expansion logic
* libguile/jit.c (compile): Fix logic to clear old labels.
2019-04-04 14:59:38 +02:00
Andy Wingo
891e7600f4 JIT fixes for arena overflow
* libguile/jit.c (compute_mcode): Move analysis outside the code
emitter, as it doesn't need to re-run on overflow.
(compile): Clear labels before emitting, as they may have changed if we
overflowed.
2019-04-04 14:32:05 +02:00
Andy Wingo
9ff21412ff Minor JIT cleanups
* libguile/jit.c (fp_scm_operand): Fix assertion about register state.
(compile_call_scm_sz_u32): Fix ABI declaration for immediate.
Some whitespace cleanups as well.
2019-04-04 12:48:37 +02:00
Andy Wingo
89de2cb286 More various JIT fixen
* libguile/jit.c (prepare_jit_state): Remove unused function.
(initialize_thread_jit_state): Since the lightening state is allocated
using GC memory, trace the JIT state.
(compute_mcode): Avoid double-compile.
2019-04-04 12:10:13 +02:00
Andy Wingo
f8fa1156a9 Fix some aspects of instruction mcode addresses
* libguile/jit.c (struct scm_jit_state): Remove entry_mcode member.
(add_inter_instruction_patch): Fix off-by-one.
(compile): Reset reloc_idx when restarting a compile.  All instructions
record their addresses.
2019-04-04 11:42:33 +02:00
Andy Wingo
c0369df5e7 Fix JIT bugs
* libguile/jit.c (compile): Fix reloc fixup.
(compute_mcode): Correctly compute entry mcode.
2019-04-04 11:33:16 +02:00
Andy Wingo
fb9003c137 Fix jit_gpr_is_callee_save usage
* libguile/jit.c (emit_entry_trampoline): Fix invocations for
  jit_gpr_is_callee_save.
2019-04-04 11:18:08 +02:00
Andy Wingo
93f430d282 jit: Fix inter-instruction relocs.
* libguile/jit.c (struct pending_reloc, emit_entry_trampoline)
(add_inter_instruction_patch, compile, compute_mcode): Fix
inter-instruction relocs.
2019-04-04 10:59:37 +02:00
Andy Wingo
2db4ccd68c Fix jit.c compilation
* libguile/jit.c: Finish adaptation for lightening.  Still crashes
  though.
2019-04-03 21:08:30 +02:00
Andy Wingo
061c967bfe Checkpoint for lightning to lightening conversion 2019-04-03 17:42:27 +02:00
Andy Wingo
e9be4ea73d Adapt to lightning -> lightening name change
* libguile/jit.c: Include lightening.h.
* libguile/Makefile.am: Adapt.
2019-04-03 14:08:06 +02:00
Andy Wingo
e08d10af67 Fix JIT of 64-bit comparisons on 32-bit architectures
* libguile/jit.c (compile_u64_imm_less): Compare high word using
  not-equal, to avoid a signedness compare.
(compile_s64_imm_less, compile_imm_s64_less): Fix the not-less cases.
2018-10-09 12:32:38 +02:00
Andy Wingo
d41f2e9978 Better ursh/ulsh/srsh JIT on 32-bit platforms
* libguile/jit.c (compile_ursh_immediate, compile_ulsh_immediate)
(compile_srsh_immediate): Special-case shifts by 32 bits on 32-bit
platforms.  Avoids shifting by 0.
2018-10-09 12:32:33 +02:00
Andy Wingo
afced398d4 Fix JIT register state tracking for use of SP or FP as temp
* libguile/jit.c (record_gpr_clobber): If we clobber SP or FP, clear the
  appropriate register state bits.  Only exercised for 32-bit targets in
  practice!
  (emit_alloc_frame, emit_push_frame): Fix a couple places where we were
  failing to track the register state correctly.
  (compile_umul): Remove a needless register state flush, nowthat
  qmulr_u has a wrapper that tracks this for us.
2018-10-09 08:55:34 +02:00
Andy Wingo
9feb3a633f Fix JIT compilation on 32-bit targets
* libguile/jit.c: Fix compilation on 32-bit targets.  Still not working
  however.
2018-10-08 15:24:03 +02:00
Andy Wingo
03581c04d7 Comment out some unused definitions
* libguile/jit.c: Comment out unused var decls.
2018-10-07 15:57:27 +02:00
Andy Wingo
6f3357b0df Fix f32-set! JIT compilation
* libguile/jit.c (compile_f32_set): Fix to write an f32, not a f64.
2018-10-04 16:50:10 +02:00
Andy Wingo
a74b4a45fa Update comments in vm-engine.c
* libguile/jit.c (compile_s64_numerically_equal): Remove as this
instruction was removed in previous refactoring.
(compile_atomic_scm_set_immediate), compile_atomic_scm_ref_immediate):
Adapt to change in C name of these instructions.
* libguile/vm-engine.c: Add comments for all instructions.
2018-09-22 18:42:27 +02:00
Andy Wingo
ce9169804e Fix --disable-jit compilation
* libguile/jit.c: Wrap the whole thing in ENABLE_JIT.
* libguile/threads.c (on_thread_exit):
* libguile/vm.c (scm_call_n):
* libguile/init.c (scm_i_init_guile):
* libguile/vm-engine.c (VM_NAME): Wrap calls into jit.c with ENABLE_JIT.
* configure.ac: Move up AC_CANONICAL_TARGET, as autoconf was complaining
  about it coming after AC_ARG_PROGRAM.
* acinclude.m4 (GUILE_ENABLE_JIT): Fix to honor --enable-jit arg.
2018-09-17 09:28:41 +02:00
Andy Wingo
f03ff5304a Turn on automatic JIT compilation by default
* libguile/jit.c (default_jit_threshold): New static const variable.
(scm_sys_jit_compile): Remove.
(scm_init_jit): Rename GUILE_JIT_COUNTER_THRESHOLD to
GUILE_JIT_THRESHOLD, and default to default_jit_threshold.  Remove
%jit-compile definition.
2018-09-15 10:54:14 +02:00
Andy Wingo
0ccd2d0d9e Remove hook intrinsics: hooks are just for the VM
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Remove VM hook
  intrinsics, now that we're going to rely on the interpreter for
  stepping and breakpoints.
* libguile/jit.c (struct scm_jit_state): Remove "hooks_enabled" member,
  now that we won't JIT.  Remove all code related to calling hooks.
* libguile/vm-engine.c (RUN_HOOK): Call hooks directly instead of
  through intrinsics.  Use precise per-hook enable flags.
* libguile/vm.c (DEFINE_INVOKE_HOOK): New helper.  Use to define the
  hook invokers.
2018-09-14 09:34:31 +02:00
Andy Wingo
ce5c05ac4a Fix JIT compilation of intrinsics that return doubles
* libguile/jit.c (emit_retval_d): New helper.
(compile_call_f64_from_scm): Take the f64 result from the correct
registers.
2018-09-10 16:33:10 +02:00
Andy Wingo
46fe5b069b Fix positional-arguments<=? compilation
* libguile/jit.c (compile_check_positional_arguments): Fix.
2018-09-10 16:28:31 +02:00
Andy Wingo
18aa995cbb Fix compilation of compare-and-swap
* libguile/jit.c (compile_atomic_scm_compare_and_swap_immediate): Call
  the right intrinsic.
2018-09-07 15:19:19 +02:00
Andy Wingo
227c3acc5d Refactor handling of lightning state
* libguile/jit.c (prepare_jit_state, reset_jit_state): New helpers.
(emit_code): Prevent emission of auxiliary data.
(compile_handle_interrupts): Assume the handle_interrupts_trampoline is
compiled eagerly.
(initialize_thread_jit_state): New helper.
(initialize_jit): Refactor.  Emit handle-interrupts code here.
(compute_mcode): Adapt to initialize_jit refactorings.
(scm_jit_state_free): Nothing to do.
2018-09-07 15:06:28 +02:00
Andy Wingo
377c3e117e Fix compilation of handle-interrupts
* libguile/jit.c (compile_handle_interrupts): Fix check for blocked
  interrupts.
2018-09-07 14:22:48 +02:00
Andy Wingo
f8229c603d Use custom JIT code allocator
* libguile/jit.c (struct code_arena): New data type.
(struct scm_jit_state): Add code arena member.
(allocate_code_arena): New helper.
(emit_code): New helper.  Emits code into a thread-local code arena.
(compute_mcode): Allow for failure to JIT.
(scm_jit_compute_mcode): Stop automatic JIT compilation on resource
exhaustion.
2018-09-07 12:22:44 +02:00
Andy Wingo
3e2b173158 Revert "<?" fast path for now
* libguile/jit.c (compile_less): Revert fast path; causing errors in
  benchmarks.
2018-09-05 22:30:43 +02:00
Andy Wingo
93112d3ed5 Add JIT fast paths for inum arithmetic
* libguile/jit.c (compile_call_scm_from_scm_scm): Add fast paths for
  inum add and sub.
  (compile_call_scm_from_scm_uimm): Add fast paths for inum
  add/immediate and sub/immediate.
  (compile_less): Add fast path for inum compare.
2018-09-05 22:09:42 +02:00
Andy Wingo
218fe1b962 Fix JIT compilation of [positional-]arguments<=?
* libguile/jit.c (compile_check_arguments)
  (compile_check_positional_arguments): Fix these functions.  The
  compiler uses "jge" as a "compare result not NONE", but the VM
  instructions set NONE on greater-than, not greater-than-or-equal.
  Sad!
2018-09-05 21:53:56 +02:00
Andy Wingo
cf712c0eb1 Improve JIT cleanup a bit
* libguile/jit.c (initialize_jit): Improve cleanup a bit.
2018-09-05 16:35:00 +02:00
Andy Wingo
24b4d09394 Improve compute_mcode allocation logic
* libguile/jit.c (compute_mcode): Move up some assertions before using
  them to allocate.
2018-09-02 21:56:36 +02:00
Andy Wingo
162e313311 Fix a memory leak in JIT
* libguile/jit.c (compute_mcode): Fix memory leak.  Ultimate fix will be
  to use arena allocation, but that will come later.
2018-09-02 21:35:54 +02:00
Andy Wingo
e9b44c00fd Fix assertion error running compile-file with threshold 0
* libguile/jit.c (emit_alloc_frame_for_sp): Don't require that FP be in
  a register, but if it was and we call out, do restore it.
2018-09-02 21:29:24 +02:00
Andy Wingo
54b23adc13 Add ability to tier up from within loops
* libguile/jit.c (struct scm_jit_state): Add entry and entry_label
  members.
(analyze): Assert entry is jump target.
(compile): Record indirect entry label.
(compute_mcode): Record entry IP, and return entry mcode.
(scm_sys_jit_compile, scm_jit_compute_mcode): Adapt to compute_mcode
change.  Support hot-loop transfer.
2018-09-02 11:54:12 +02:00
Andy Wingo
b176e714f8 Add configurable JIT logging levels
* libguile/jit.c (jit_log_level): New local.
(_LOG, INFO, DEBUG, LOG): New macros.
(compile1):
(compute_mcode):
(scm_jit_enter_mcode): Use new logging macros.
2018-09-02 10:49:24 +02:00
Andy Wingo
449ef7d975 Prevent Lightning from stompling our registers
* libguile/jit.c (emit_exit): Add uses of SP and FP.
2018-09-02 09:21:54 +02:00
Andy Wingo
1f42a6042e Add ability to stop JIT after N compilations.
* libguile/jit.c (jit_stop_after, jit_pause_when_stopping): New locals.
  (scm_jit_compute_mcode): Add ability to stop after N compilations.
  (scm_jit_enter_mcode): Comment out printfs for the time being.
  (scm_init_jit): Init locals from environment variables.
2018-09-01 11:28:59 +02:00
Andy Wingo
7c0bfcb097 Minor 32-bit untag-fixnum optimization
* libguile/jit.c (compile_untag_fixnum): Minor optimization in 32-bit
  case.
2018-09-01 10:29:05 +02:00
Andy Wingo
dafa648915 Fix compilation of compile_eq
* libguile/jit.c (compile_eq): Compare to register, not immediate.
2018-09-01 10:11:17 +02:00
Andy Wingo
79be7028e4 More JIT debugging
* libguile/jit.c (compile1): Add debug for when instructions are first
  compiled.  Will be removed when all is working.
  (compute_mcode): Add debugging about what code is compiled.
  (scm_sys_jit_compile): Remove per-instruction output.
  (scm_jit_compute_mcode): Actually compile JIT code.  Use
  GUILE_JIT_COUNTER_THRESHOLD to control when JIT happens.
2018-08-31 15:50:46 +02:00