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

9310 commits

Author SHA1 Message Date
Andy Wingo
5b68bd7778 Fix compile warnings in jit_print.c
* libguile/lightning/lib/jit_print.c (_jit_print_node): Fix a couple
  printf format warnings by adding casts.
2018-07-03 10:39:05 +02:00
Andy Wingo
9338ef15c2 Wire up lightning into libguile build
* libguile/Makefile.am (AM_CPPFLAGS):
  (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): If ENABLE_JIT, build
  lightning.
  (EXTRA_DIST): Add lightning files.
* libguile/lightning/lightning.am (lightning_extra_files): Add COPYING
  and related files to the dist.
* libguile/jit.c:
* libguile/jit.h: New files.
2018-07-02 11:08:57 +02:00
Andy Wingo
0593a9aed7 Add GUILE_ENABLE_JIT macro
* acinclude.m4 (GUILE_ENABLE_JIT): New macro.
* libguile/lightning/configure.ac: Remove now-unused file.
2018-07-02 10:39:49 +02:00
Andy Wingo
f8b8f5f5c8 Remove unused AM_CONDITIONAL statements from lightning configure
* libguile/lightning/configure.ac: Remove more unused definitions.
2018-07-01 21:13:02 +02:00
Andy Wingo
2412cfbbaa Remove unused configure-time checks for x87, thumb, and sof float
* libguile/lightning/configure.ac: Remove unused checks.
2018-07-01 21:11:48 +02:00
Andy Wingo
fdfbfccdd6 Remove lightning configure snippet related to libdl
* libguile/lightning/configure.ac: Remove checks for how to add libdl,
  as embedder will handle this.
2018-07-01 20:59:29 +02:00
Andy Wingo
92a75703b1 Always enable assertions in embedded lightning
* libguile/lightning/configure.ac: Remove --enable-assertions option;
  always enable assertions.
* libguile/lightning/lib/jit_memory.c:
* libguile/lightning/lib/jit_note.c:
* libguile/lightning/lib/jit_print.c:
* libguile/lightning/lib/jit_rewind.c:
* libguile/lightning/lib/jit_size.c:
* libguile/lightning/lib/lightning.c: Define DEBUG to 1.
2018-07-01 20:58:08 +02:00
Andy Wingo
0ce8e6969e Remove special cflags for obsolete Lightning targets
* libguile/lightning/configure.ac: Remove compiler flags specializations
  for ia64 on HPUX, MIPS on Irix, and Alpha on OSF.
2018-07-01 16:38:55 +02:00
Andy Wingo
0465c8834e Refactor deps for built libpath.h
* libguile/Makefile.am (BUILT_INCLUDES): Move libpath.h here, from
  BUILT_SOURCES, so that .x files depend on it.  Thanks to Dale Smith
  for the report.
2018-07-01 12:18:32 +02:00
Andy Wingo
2a8ebe87e3 Remove disassembler support from lightning
* libguile/lightning/configure.ac: Remove checks for libiberty, BFD, and
  so on.
* libguile/lightning/lib/jit_disasm.c: Remove.
* libguile/lightning/lib/lightning.c: Define DISASSEMBLER and
  DEVEL_DISASSEMBLER to 0.
  (init_jit, finish_jit): Delete calls into jit_disasm.
* libguile/lightning/lib/jit_memory.c:
* libguile/lightning/lib/jit_note.c:
* libguile/lightning/lib/jit_print.c:
* libguile/lightning/lib/jit_rewind.c:
* libguile/lightning/lib/jit_size.c: Define DISASSEMBLER to 0.
* libguile/lightning/lightning.am (lightning_c_files): Remove
  jit_disasm.c.
2018-07-01 10:46:56 +02:00
Andy Wingo
8316707594 Further lightning integration work
* libguile/lightning/configure.ac: Start trimming down for inclusion in
  configure.ac.  Remove check for getopt things; we don't include bits
  of lightning that use getopt. Remove check for stdint, as we will have
  it.
* libguile/lightning/include/lightning.h: Unconditionally include
  stdint.h.
2018-06-30 12:07:00 +02:00
Andy Wingo
fddd2069ed Remove some more of the lightning build machinery
* libguile/lightning/Makefile.am:
* libguile/lightning/lib/Makefile.am: Remove.
* libguile/lightning/lightning.am: Add all the C and H files here.
* libguile/lightning/configure.ac: Remove AC_OUTPUT clause.
2018-06-30 12:03:24 +02:00
Andy Wingo
2e489b3e5b Remove empty lightning m4 directory
* libguile/lightning/Makefile.am:
* libguile/lightning/configure.ac:
* libguile/lightning/m4/.gitkeep.
2018-06-30 12:03:24 +02:00
Andy Wingo
0e25ee5693 Remove lightning pkg-config file.
* libguile/lightning/lightning.pc.in: Remove.
* libguile/lightning/configure.ac:
* libguile/lightning/Makefile.am: Adapt.
2018-06-30 12:03:24 +02:00
Andy Wingo
f0891bed0b Beginnings of build integration of lightning and guile
* libguile/lightning/lightning.am: New file.  libguile will include
  this. Contents initially from include/Makefile.am and
  include/lightning/Makefile.am.
* libguile/lightning/include/Makefile.am:
* libguile/lightning/include/lightning/Makefile.am: Remove.
* libguile/lightning/configure.ac: Remove output of include Makefiles.
2018-06-30 12:03:12 +02:00
Andy Wingo
8810163627 Finish removing get-jit-size
* libguile/lightning/include/lightning/jit_private.h:
* libguile/lightning/lib/Makefile.am:
* libguile/lightning/lib/jit_ia64.c (_emit_code):
* libguile/lightning/lib/jit_size.c (jit_init_size, jit_finish_size):
* libguile/lightning/lib/lightning.c (_jit_regarg_set, _jit_regarg_clr):
  (_jit_realize, _jit_emit): Remove case where GET_JIT_SIZE is set.
2018-06-30 11:23:00 +02:00
Andy Wingo
0bdd27bdf6 Remove lightning unit tests
* libguile/lightning/configure.ac:
* libguile/lightning/Makefile.am:
* libguile/lightning/check: Remove unit tests.  If there is a problem
  with lightning on this target, users should check if the upstream tests
  pass.  Otherwise we will find errors via the Guile test suite.
2018-06-30 11:18:34 +02:00
Andy Wingo
7dec6cbb9e Remove documentation from embedded GNU lightning
* libguile/lightning/Makefile.am:
* libguile/lightning/configure.ac:
* libguile/lightning/doc: Remove documentation.  JIT hackers should use
  upstream's documentation.
2018-06-30 11:16:22 +02:00
Andy Wingo
25584ea4f9 Strip "get-jit-size" feature from lightning.
* libguile/lightning/Makefile.am:
* libguile/lightning/configure.ac:
* libguile/lightning/size.c: Remove devel-only "get-jit-size" feature.
2018-06-30 11:14:25 +02:00
Andy Wingo
40aafa5279 Merge GNU lightning to libguile/lightning
* libguile/lightning/: New directory, made by the following commands:

  git remote add lightning https://git.savannah.gnu.org/git/lightning.git
  git merge -s ours --no-commit --allow-unrelated-histories lightning/master
  git read-tree --prefix=libguile/lightning/ -u lightning/master

  In theory we will be able to update via:

  git merge -s subtree lightning/master
2018-06-30 10:54:39 +02:00
Ludovic Courtès
23af45e248 vm: Fix stack-marking bug in multi-threaded programs.
Fixes <https://bugs.gnu.org/28211>.

* libguile/vm-engine.c (call, call_label, handle_interrupts): Add
'new_fp' variable; set the dynamic link and return address of the frame
at NEW_FP before setting 'vp->fp'.  This fixes a bug whereby, in a
multi-threaded context, the stack-marking code could run after vp->fp
has been set but before its dynamic link has been set, leading the
stack-walking code in 'scm_i_vm_mark_stack' to exit early on.
2018-06-29 22:28:48 +02:00
Andy Wingo
b5dcdf2e25 Revert "Refactor hook dispatch in VM"
This reverts commit 593e2db1dd.  The goto
strategy works for hooks that run just before a "next"; it doesn't work
for ones that run at the beginning of opcodes.
2018-06-27 20:19:40 +02:00
Andy Wingo
593e2db1dd Refactor hook dispatch in VM
* libguile/vm-engine.c (GOTO_HOOK, HOOK_HANDLER): Split hooks that don't
  take args into a "goto" side and a "target" side.  The idea is to just
  reify the hook call at one place in the binary, since the VM
  continuation is fully in the registers.
  (APPLY_HOOK, PUSH_CONTINUATION_HOOK, NEXT_HOOK)
  (ABORT_CONTINUATION_HOOK): Reimplement in terms of goto hooks.
  (POP_CONTINUATION_HOOK): This one is still old-style.
  (CONTINUE): New helper definition.
  (call, call-label): Move the push-continuation hooks up a bit, so it's
  clear they don't depend on intermediate opcode state.
  (vm_engine): Reify hook handlers for apply, etc.
2018-06-27 19:56:55 +02:00
Andy Wingo
2a8d72f7e0 Microoptimizations to hook dispatch
* libguile/vm.c (vm_dispatch_hook): Add a check that we're in the debug
  engine and the trace level is positive.  Allows us to do cheaper
  checks for when to dispatch hooks.
  (scm_call_n): Just check if trace level is nonzero.
* libguile/vm-engine.c (RUN_HOOK): Likewise just check if trace level is
  nonzero.
2018-06-27 19:26:03 +02:00
Andy Wingo
19cff78bb5 Minor optimizations to debug hook dispatch
* libguile/vm.c (scm_call_n): Only call hooks if the engine supports
  it.
  (vm_dispatch_abort_hook, vm_dispatch_next_hook)
  (vm_dispatch_pop_continuation_hook, vm_dispatch_push_continuation_hook)
  (vm_dispatch_apply_hook, vm_dispatch_hook): Take a thread as arg
  instead of VM, because that will probably already be in a register in
  the VM.  Given that all values are taken relative to the SP, no
  need to pass that either.
* libguile/vm-engine.c (RUN_HOOK0, RUN_HOOK1): Update appropriately.
2018-06-27 19:16:38 +02:00
Andy Wingo
9c8c4060dd Remove "resume" arg from vm engine
* libguile/vm-engine.c (vm_engine): Remove "resume" argument; scm_call_n
  will handle the differences.
* libguile/vm.c (scm_call_n): Inline handling of what to do in normal
  and resume cases.  Remove resume argument to vm_engine.
2018-06-27 18:57:37 +02:00
Andy Wingo
64d114817a Intrinsics take registers from thread
* libguile/continuations.c (scm_i_make_continuation): Remove registers
  argument; instead get from thread.
* libguile/vm-engine.c (vm_engine): Adapt VM engine to not receive a
  registers argument, and thus to not pass it to intrinsics either.
* libguile/intrinsics.h:
* libguile/intrinsics.c (push_prompt):
* libguile/vm.c (capture_continuation, compose_continuation)
  (abort_to_prompt): Refactor these intrinsics to not take a registers
  argument; it's not necessary.
  (scm_call_n): Don't pass registers argument.
2018-06-27 18:42:21 +02:00
Andy Wingo
154a5de3d7 Minor scm_thread refactoring
* libguile/threads.h (scm_thread): Move stack base to be closer to
  related fields, and add a comment for why it's there.
2018-06-27 18:29:46 +02:00
Andy Wingo
18431e6e63 Refactor handling of active VM registers
* libguile/threads.h (scm_thread): Remove unused jmp_buf regs member.
* libguile/vm.h (struct scm_vm): Rename resumable_prompt_cookie to just
  "registers"; we know it's a jmp_buf pointer.
* libguile/vm.c (scm_call_n):
* libguile/throw.c (catch):
* libguile/eval.c (eval):
* libguile/control.c (scm_suspendable_continuation_p): Adapt to cookie
  renaming.
2018-06-27 18:21:04 +02:00
Andy Wingo
fd4eb14751 Use CALL_INTRINSICS helper in VM
* libguile/vm-engine.c (CALL_INTRINSIC): New helper macro.
  (ALLOC_FRAME, vm_engine): Use CALL_INTRINSIC when we need to call
  intrinsics.  GCC still doesn't allocate intrinsics to a register
  though!
2018-06-27 18:07:49 +02:00
Andy Wingo
7e11c992f3 bind-rest inst uses cons-rest intrinsic
* libguile/vm-engine.c (bind-rest): Use cons-rest intrinsic to build the
  rest list.
2018-06-27 17:40:46 +02:00
Andy Wingo
294e627c6b Intrinsic for "prompt"
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* libguile/intrinsics.c (push_prompt, scm_bootstrap_intrinsics): New
  intrinsic.
* libguile/vm-engine.c (prompt): Use push-prompt intrinsic.
2018-06-27 15:29:49 +02:00
Andy Wingo
85ab5f0299 Remove dedicated current-module instruction.
* libguile/vm-engine.c (current-module): Remove instruction.
2018-06-27 15:06:40 +02:00
Andy Wingo
8918165c40 Compile current-module as intrinsic call
* libguile/fluids.c (scm_i_fluid_ref): New internal function.
  (scm_fluid_ref): Use scm_i_fluid_ref.
* libguile/intrinsics.h:
* libguile/intrinsics.c (current_module): New intrinsic.
* libguile/modules.c (scm_i_current_module): New internal function.
  (scm_current_module): Use new internal function.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add current-module as an intrinsic primitive.
* module/system/vm/assembler.scm (define-scm<-thread-intrinsic):
  (current-module): Arrange to compile to intrinsic call.
2018-06-27 14:57:51 +02:00
Andy Wingo
0faa4144d1 allocate-words intrinsic
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* libguile/intrinsics.c (allocate_words, scm_bootstrap_intrinsics): New
  intrinsic.
* libguile/vm-engine.c (allocate-words, allocate-words/immediate): Use
  new intrinsic.
2018-06-27 14:56:39 +02:00
Andy Wingo
7883290d88 Inline handling of non-program apply
* libguile/vm.c (vm_apply_non_program_code): Remove, now unneeded.
* libguile/vm-engine.c (vm_engine, call, tail-call, tail-call/shuffle)
  (tail-apply, call/cc): Inline handling of non-programs, as will be the
  case with JIT code.
2018-06-27 13:54:45 +02:00
Andy Wingo
1735cc1fec Apply-non-program is an intrinsic
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add
  apply-non-program intrinsic.
* libguile/vm-engine.c (apply-non-program): Replace impl with call to
  intrinsic.
* libguile/vm.c (vm_error_wrong_type_apply): Inline into
  apply_non_program intrinsic.
  (apply_non_program): New intrinsic.
  (scm_bootstrap_vm): Wire it up.
2018-06-27 13:38:30 +02:00
Andy Wingo
6eb4735149 Add intrinsics for error conditions (wrong num args etc)
* libguile/intrinsics.c (error_wrong_num_args, error_no_values)
  (error_not_enough_values, error_wrong_number_of_values): New
  intrinsics.
* libguile/intrinsics.h: Add new intrinsics.
* libguile/vm-engine.c: Signal errors using the new intrinsics.
* libguile/vm.c (vm_error): Remove, now that it's unused.
  (vm_error_bad_instruction): Abort instead of throwing an exception.
  If we get a bad instruction, nothing good will ever happen!
  (compose_continuation): Use wrong-type-arg for unrewindable
  continuations.
  (scm_bootstrap_vm): No need to make "vm-run" or "vm-error" symbols.
2018-06-27 09:47:31 +02:00
Andy Wingo
0ce9a1f870 VM throw uses intrinsics
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add intrinsics for
  throw, throw/value, and throw/value+data.
* libguile/intrinsics.c (throw_, throw_with_value):
  (throw_with_value_and_data): And here they are.
* libguile/vm-engine.c (throw, throw/value, throw/value+data): Use
  intrinsics.
* libguile/vm.c: Remove vm_throw et al.
2018-06-26 20:45:26 +02:00
Andy Wingo
51e71a473f Allow abort_to_prompt to avoid a longjmp
* libguile/vm-engine.c (abort):
* libguile/vm.c (abort_to_prompt): Allow fallthrough if longjmp isn't
  needed.
2018-06-26 17:16:19 +02:00
Andy Wingo
bf66fdca55 Optimize abort-to-prompt to avoid alloca
* libguile/vm.c (capture_delimited_continuation): Adapt to caller not
  truncating vp->sp to vp->fp before calling.
  (abort_to_prompt): Inline vm_abort and avoid the alloca.
2018-06-26 17:08:24 +02:00
Andy Wingo
770360e066 Refactors to abort-to-prompt implementation
* libguile/control.c (scm_abort_to_prompt_star)
* libguile/throw.c (abort_to_prompt): Pass prompt tag and argv in one
  array.
* libguile/vm.c (scm_i_vm_abort): Reimplement as a call into the VM's
  abort_to_prompt builtin.
  (vm_abort): New helper, a copy of scm_i_vm_abort.  Will allow us to
  avoid some arg shuffling when aborting from the VM.
* libguile/vm.h: Remove setjmp include and simplify scm_i_vm_abort
  decl.
2018-06-26 16:39:34 +02:00
Andy Wingo
e7778c62aa abort-to-prompt uses an intrinsic
* libguile/control.h:
* libguile/control.c (scm_i_make_composable_continuation): Rename from
  make_partial_continuation and expose internally.
  (scm_abort_to_prompt_star): Adapt to scm_i_vm_abort name change.
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Define
  abort_to_prompt intrinsic.
* libguile/throw.c (abort_to_prompt): Adapt to scm_i_vm_abort name
  change.
* libguile/vm-engine.c (abort): Use abort_to_prompt intrinsic.
* libguile/vm.c (capture_delimited_continuation): Move here from
  control.c where it was named reify_partial_continuation.
  (scm_i_vm_abort): Move from control.c where it was named
  scm_c_abort (and only exposed internally).
  (abort_to_prompt): New intrinsic, replacing vm_abort.
* libguile/vm.h: Add setjmp include and scm_i_vm_abort decl.
2018-06-26 16:23:02 +02:00
Andy Wingo
03a9b71479 Add rest-arg-length intrinsic.
* libguile/intrinsics.h:
* libguile/vm.c (rest_arg_length): New intrinsic.
  (vm_error_apply_to_non_list): Remove now-unused error proc.
* libguile/vm-engine.c (tail-apply): Use new intrinsic.
2018-06-26 15:34:40 +02:00
Andy Wingo
b4553dbb02 compose-continuation uses an intrinsic
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add
  compose-continuation intrinsic.
* libguile/vm-engine.c (compose-continuation): Call compose-continuation
  intrinsic.
* libguile/vm.c (compose_continuation_inner, compose_continuation): Move
  down and rename from vm_reinstate_partial_continuation, and make into
  a form that works as an intrinsic.
2018-06-26 15:10:58 +02:00
Andy Wingo
ba23bc12fd Add intrinsic for call/cc
* libguile/intrinsics.h: Add "capture-continuation" intrinsic.
* libguile/vm-engine.c (call/cc): Rework to use capture_continuation
  intrinsic.
* libguile/vm.c (capture_continuation): New intrinsic.
2018-06-26 12:01:01 +02:00
Andy Wingo
5804c977d7 Rename scm_i_thread to scm_thread
* libguile/scm.h (struct scm_thread, scm_thread): Rename from
  scm_i_thread.
* libguile/deprecated.h (scm_i_thread): Add deprecated typedef.
* libguile/threads.h: Adapt to renaming.
* libguile/intrinsics.h:
* libguile/scmsigs.h:
* libguile/cache-internal.h: Remove threads.h includes; unnecessary with
  the forward decl.
* libguile/continuations.h:
* libguile/gc-inline.h:
* libguile/async.h: Adapt scm_thread type name change.
* libguile/async.c:
* libguile/continuations.c:
* libguile/control.c:
* libguile/dynstack.c:
* libguile/dynwind.c:
* libguile/eval.c:
* libguile/finalizers.c:
* libguile/fluids.c:
* libguile/gc.c:
* libguile/intrinsics.c:
* libguile/load.c:
* libguile/memoize.c:
* libguile/print.c:
* libguile/read.c:
* libguile/scmsigs.c:
* libguile/script.c:
* libguile/stackchk.c:
* libguile/stacks.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/throw.c:
* libguile/vm-engine.c:
* libguile/vm.c: Adapt to type name change, and add additional includes
  as needed.
2018-06-26 11:40:22 +02:00
Andy Wingo
51e35158ba Refactor continuation capture in VM
* libguile/continuations.h:
* libguile/continuations.c (scm_i_make_continuation): Refactor to expect
  registers to already be captured.
* libguile/scm.h (scm_i_thread): Add forward decl.
* libguile/threads.h (struct scm_i_thread): Just fill in the struct
  type.
* libguile/vm-engine.c (call/cc); Use the registers already captured
  before entering the VM.
2018-06-26 11:25:07 +02:00
Andy Wingo
185d19dfb1 Foreign-call intrinsic boxes errno
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* libguile/foreign.c (foreign_call):
* libguile/vm-engine.c (foreign-call): Change foreign-call intrinsic to
  handle boxing of errno.
2018-06-26 11:09:40 +02:00
Andy Wingo
5e8e816c61 Reinstating undelimited continuations uses intrinsic
* libguile/continuations.h (scm_t_contregs): Remove "struct vm*" member;
  unneeded.
* libguile/continuations.c (scm_i_make_continuation): No need to store
  continuation->vp.
  (scm_i_contregs): New internal function, replaces scm_i_contregs_vp
  and scm_i_contregs_vm_cont.
  (scm_i_check_continuation): Remove; moved to vm.c.
  (scm_i_reinstate_continuation): Add an abort(), to satisfy
  SCM_NORETURN.
* libguile/intrinsics.h: Add new "reinstate-continuation!" intrinsic.
* libguile/vm-engine.c (continuation-call): Use new
  reinstate-continuation! intrinsic.
* libguile/vm.c (vm_return_to_continuation_inner): Move later in the
  file.
  (reinstate_continuation_x): New intrinsic.
  (scm_bootstrap_vm): Init new intrinsic.
2018-06-26 11:09:36 +02:00