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

153 commits

Author SHA1 Message Date
Andy Wingo
9c5098ab25 Dynamically assert functions start with instrument-entry
* libguile/jit.c (emit_indirect_tail_call): Add dynamic assertion.
2019-05-27 19:09:12 +02:00
Andy Wingo
1fb39929f9 Reapply atomics inlining
This patch reapplies 230a555976 and
e8d34258be, but fixing a misplaced
comma (!).
2019-05-27 19:05:10 +02:00
Andy Wingo
d0a95bfbe8 Revert "Fix atomics usage in handle-interrupts JIT."
This reverts commit e8d34258be.
2019-05-27 18:40:41 +02:00
Andy Wingo
e8d34258be Fix atomics usage in handle-interrupts JIT.
* libguile/jit.c (compile_handle_interrupts): Use atomics in
  handle-interrupts.
2019-05-27 12:08:58 +02:00
Andy Wingo
33e07fc56c Use new atomic instructions from lightening
* libguile/jit.c (compile_atomic_scm_ref_immediate):
(compile_atomic_scm_set_immediate):
(compile_atomic_scm_swap_immediate):
(compile_atomic_scm_compare_and_swap_immediate): Use lightening
instructions.
2019-05-27 11:57:36 +02:00
Andy Wingo
e9e52b6ab9 Mark a couple functions as maybe-unused.
* libguile/jit.c (fp_scm_operand, sp_slot_operand): Maybe unused.
2019-05-23 09:34:08 +02:00
Andy Wingo
da0cc5d3e6 Bless enter_mcode as a function pointer
* libguile/jit.c (initialize_jit): Bless enter_mcode, to allow ARMv7
  interworking.
2019-05-21 14:02:27 +02:00
Andy Wingo
e00936d46b Allow jit_end to fail
* libguile/jit.c (emit_code): Emitting a constant table might cause us
  to fail.
2019-05-21 13:36:37 +02:00
Andy Wingo
107926f8dd Fix allocator passed to lightening
* libguile/jit.c (jit_alloc_fn): On targets that need a dynamically
  allocated literal pool, we will need to trace that pool, so pass a
  pointerful malloc.  Fixes JIT on AArch64.
2019-05-21 12:39:55 +02:00
Andy Wingo
c461126fab Fix u64-ref JIT on 32-bit
* libguile/jit.c (compile_u64_ref): Fix 32-bit load path; endianness was
  reversed.
2019-04-29 09:41:03 +02:00
Andy Wingo
85b3ee0ec3 Fix unneeded stack alignment.
* libguile/jit.c (emit_entry_trampoline): Remove unneeded alignment.
2019-04-28 18:45:10 +02:00
Andy Wingo
fb1f3ba051 Fix errors in 32-bit JIT support
* libguile/jit.c (compile_ursh_immediate):
(compile_ulsh_immediate): Fix immediate/register variant calling.
Happily a benefit of lightening, as type safety did this for us.
(DEFINE_CLOBBER_RECORDING_EMITTER_R_R_2): Pass JIT state.
2019-04-28 13:54:34 +02:00
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