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

20710 commits

Author SHA1 Message Date
Ludovic Courtès
741c45458d r6rs-ports: 'put-bytevector' accepts 64-bit integers.
* libguile/r6rs-ports.c (scm_put_bytevector): Use 'size_t' for c_start,
c_count, and c_len.
2018-07-20 11:43:27 +02:00
Andy Wingo
950a762dc2 Multiple-value returns now start from slot 0, not slot 1
This should reduce frame sizes.

* libguile/vm-engine.c (halt): Adapt to multiple-values change.  Also
  adapt to not having the boot closure on the stack.
  (receive, receive-values, subr-call, foreign-call): Adapt to expect
  values one slot down.
  (prompt): Capture one less word for the values return.
* libguile/vm.c (vm_dispatch_pop_continuation_hook):
  (vm_dispatch_abort_hook): Adapt for where to expect values.
  (vm_builtin_values_code): Add a call to shuffle-down before
  returning.  This is more overhead than what existed before, but the
  hope is that the savings elsewhere pay off.
  (vm_builtin_values_code): Adapt to different values location.
  (reinstate_continuation_x, compose_continuation): Adapt to place
  resume args at right position.
  (capture_delimited_continuation): Remove unused sp and ip arguments.
  (abort_to_prompt): Adapt to capture_delimited_continuation change.
  (scm_call_n): Adapt to not reserve space for the boot closure.
* module/language/cps/compile-bytecode.scm (compile-function): When
  returning values, adapt reset-frame call for return calling convention
  change.  Adapt truncating or rest returns to expect values in the
  right place.
* module/language/cps/slot-allocation.scm (compute-shuffles):
  (allocate-lazy-vars, allocate-slots): Allocate values from the "proc
  slot", not proc-slot + 1.
* module/system/vm/assembler.scm (emit-init-constants): Reset the frame
  before returning so that the return value is in the right place.
* test-suite/tests/rtl.test: Update for return convention change.
* libguile/foreign.c (get_foreign_stub_code): Update for return calling
  convention change.
2018-07-20 11:42:30 +02:00
Andy Wingo
9b70129504 Fix stale stack frame clearing for frame size change
* libguile/vm-engine.c (return-values): Clear all 3 stack slots.  Not
  sure this is necessary though!
2018-07-20 11:42:30 +02:00
Andy Wingo
c2a8224a63 Rework VM approach to shuffling unknown numbers of args
* libguile/vm-engine.c (shuffle-down, expand-apply-argument): New
  instructions.
  (tail-call, tail-call-label, return-values): Don't reset the frame.
  The compiler should reset the frame appropriately.
  (tail-call/shuffle, tail-apply): Remove unused instructions.
* libguile/vm.c (vm_builtin_apply_code): Use new shuffle-down and
  expand-apply-argument opcodes.
  (vm_builtin_call_with_values_code): Replace tail-call/shuffle with
  shuffle-down then tail-call.
* libguile/jit.c (compile_shuffle_down, compile_expand_apply_argument):
  Add compiler stubs
  (COMPILE_X8_F12_F12): New definition.
  (compile_tail_call_shuffle, compile_tail_apply): Remove unused
  compilers.
* module/language/cps/compile-bytecode.scm (compile-function): Emit
  reset-frame before tail calls and returns.
* module/system/vm/assembler.scm (system): Remove unbound "emit-return"
  export.
* module/system/vm/disassembler.scm (code-annotation)
  (instruction-has-fallthrough?, define-stack-effect-parser): Adapt for
  opcode changes.
2018-07-20 11:42:30 +02:00
Andy Wingo
043432fd57 Reserve frame word for machine return address
* libguile/frames.h: Add machine return address to diagram.
  (SCM_FRAME_MACHINE_RETURN_ADDRESS):
  (SCM_FRAME_SET_MACHINE_RETURN_ADDRESS): New macros.
  (SCM_FRAME_PREVIOUS_SP):
  (SCM_FRAME_DYNAMIC_LINK):
  (SCM_FRAME_SET_DYNAMIC_LINK): Adapt for new frame size.
* libguile/vm-engine.c (halt): Set frame size to 3.
  (call, call-label): Set mRA to 0.
* libguile/vm.c (push_interrupt_frame, reinstate_continuation_x):
  (scm_call_n): Set frame size to 3.  In push_interrupt_frame, init the
  mRA of the frame.
  (vm_builtin_call_with_values_code, vm_handle_interrupt_code): Allocate
  larger frames.
* module/language/cps/slot-allocation.scm (allocate-slots): Frame size
  is 3.
* module/system/vm/disassembler.scm (define-clobber-parser): Bump frame
  size.
2018-07-20 11:42:30 +02:00
Andy Wingo
b1705bd0f0 Prepare for frames having separate virtual and machine return addrs
* libguile/frames.c (scm_frame_return_address): Use
  SCM_FRAME_VIRTUAL_RETURN_ADDRESS.
  (scm_c_frame_previous): Likewise.
* libguile/frames.h: Update diagram for new names.
  (union scm_vm_stack_element): Rename "as_ip" to "as_vcode", and
  add "as_mcode" for machine code pointers.
  (SCM_FRAME_VIRTUAL_RETURN_ADDRESS)
  (SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS): Rename to these, from
  SCM_FRAME_RETURN_ADDRESS and SCM_FRAME_SET_RETURN_ADDRESS.
* libguile/vm-engine.c (halt, call, call-label, return-values)
  (return-from-interrupt): Adapt to renamings.  Make "halt" have frame
  size as a parameter.
* libguile/vm.c (scm_i_vm_mark_stack): Adapt to renaming.
  (push_interrupt_frame): Take mRA as additional argument.  In future we
  will set it as frame mRA.
  (capture_continuation): Adapt to renaming.
  (scm_call_n): Adapt to renaming and make frame size adjustable.
  (push_interrupt_frame, reinstate_continuation_x): Make frame size
  adjustable.
* module/language/cps/slot-allocation.scm (allocate-slots): Make frame
  size adjustable.
* libguile/intrinsics.h (scm_t_thread_mra_intrinsic): New type; use for
  push_interrupt_frame.
  (scm_t_thread_u8_scm_sp_vra_intrinsic): Rename from the same but was
  "ra" instead of "vra", and change type to uint32_t*.
* module/system/vm/disassembler.scm (define-clobber-parser):
  Parameterize clobber set for calls by frame size.
2018-07-20 11:42:30 +02:00
Andy Wingo
e95f15c932 Add support for reading ELF symbol table from C
* libguile/loader.c (scm_i_program_address_range): New function.
  Currently unused, will wire up once we correct the compiler to emit
  symbols whose values are relative to the base addr.  Will be used by
  JIT so it needs to be fast.
  (register_elf): Rework to be less verbose, and record symtab/strtab.
  (struct mapped_elf_image): Add symtab and strtab members.
  (load_thunk_from_memory, process_dynamic_segment): Parse out DT_SYMTAB
  and DT_STRTAB.
  (Elf_Sym): New definition.
2018-07-20 11:42:13 +02:00
Andy Wingo
80ba0e2cb1 Make JIT compiler skeleton more terse
* libguile/jit.c (scm_jit_state): Add "ip" member so we don't have to be
  passing it around all the time.  Rename use variables to "j" from
  "state".
2018-07-20 11:42:13 +02:00
Andy Wingo
9fc5282ca5 Merge 'master' into 'lightning' 2018-07-20 11:41:54 +02:00
Ludovic Courtès
e45a33ce58 compile: Update copyright year.
* module/scripts/compile.scm (show-version): Update copyright year.
2018-07-19 18:00:19 +02:00
Ludovic Courtès
85c5bae4fd compile: Improve error message.
* module/scripts/compile.scm (parse-args): Add missing newline in
"unrecognized option" message.
2018-07-19 18:00:19 +02:00
Ludovic Courtès
887e495c6b compile: Add '-x' flag.
* module/scripts/compile.scm (%options, compile): Add '-x'.
* doc/ref/api-evaluation.texi (Compilation): Document it.
2018-07-19 18:00:19 +02:00
Ludovic Courtès
d677aca5c5 r6rs-ports: Accept 'port-position' values greater than 2^32.
Reported by Ricardo Wurmus <rekado@elephly.net>.
Fixes <https://bugs.gnu.org/32161>.

* libguile/r6rs-ports.c (custom_binary_port_seek): Use 'scm_to_off_t'
instead of 'scm_to_int'.
* test-suite/tests/r6rs-ports.test ("8.2.7 Input Ports")["custom binary
input port position, long offset"]: New test.
2018-07-19 18:00:19 +02:00
Andy Wingo
e6461cf1b2 Fix errors introduced when giving multiple-values objects a tc7
* libguile/values.c (scm_c_value_ref): Fix a case in which a request for
  the 0th value of a zero-valued object would return the object instead
  of erroring.
* libguile/vm-engine.c (halt): Fix construction of a multiple-valued
  return (off-by-one error).  Fixes a crash introduced in
  4a2d78b4d4.
2018-07-16 12:16:58 +02:00
Mark H Weaver
59a06d8392
Make srfi-71 visible through 'cond-expand'.
This is a followup to commit eb90831ce8.

* module/srfi/srfi-71.scm: Add missing 'cond-expand-provide'.
2018-07-04 20:42:07 -04:00
Andy Wingo
5577392738 Begin structure for template JIT compiler
* libguile/jit.c: Begin to wire up compilers for the VM opcodes.
  Currently all that's there is a parser for each opcode's operands.
2018-07-03 13:31:29 +02:00
Andy Wingo
a433620c38 Fix bad opcode in VM
* libguile/vm-engine.c (VM_NAME): Fix accidentally reused number 180.
  Both values were invalid opcodes though.
2018-07-03 13:30:32 +02:00
Andy Wingo
d6b8f6a658 Minor change to VM DSL
* libguile/instructions.c (DOP1, DOP2, DOP3, DOP4, DOP5): New parts of
  the DSL, equivalent to e.g. OP1(x) | OP_DST.  Will allow other
  definitions of OP* that use token pasting.
* libguile/vm-engine.c: Adapt to use new DOP descriptors.
2018-07-03 11:13:27 +02:00
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
07a787dc87 Remove -Wswitch-enum from compile flags
* configure.ac (POTENTIAL_GCC_CFLAGS): Remove -Wswitch-enum, which
  requires that switch statements mention all enumerated values, even if
  there is a default clause.  Note that -Wall enables -Wswitch, which is
  the same except it's silent if there's a default clause.  The reason
  is that lightning has a number of switches like this.
2018-07-03 10:32:24 +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
Ludovic Courtès
cdb194c8b4 Update release docs.
* doc/release.org: Update web site instructions.
2018-07-02 10:58:22 +02:00
Andy Wingo
2d84803884 Wire JIT availability check into Guile configure
* acinclude.m4 (GUILE_ENABLE_JIT): Add missing AC_CANONICAL_TARGET.
* configure.ac: Add check if JIT is available.
2018-07-02 10:47:15 +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
Ludovic Courtès
791cae940a Bump version for Guile 2.2.4.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_REVISION): Increment.
2018-07-01 23:33:46 +02:00
Ludovic Courtès
d571009370 build: Really build srfi/srfi-71.scm.
Commit eb90831ce8 added it to the wrong
makefile.

* module/Makefile.am (SOURCES): Add srfi/srfi-71.scm.
* module/srfi/Makefile.am: Remove.  It's a leftover from the 2009 build
system rework in commit 3bb299b3f0.
2018-07-01 23:33:46 +02:00
Ludovic Courtès
fbbab31c8b Update NEWS.
* NEWS: Update.
2018-07-01 23:33:46 +02:00
Ludovic Courtès
be1e6e6ab0 Update copyright years in '--version' and the manual.
* module/ice-9/command-line.scm (version-etc): Change #:copyright-year
to 2018.
* doc/ref/guile.texi: Add 2017 and 2018 to the copyright years.
* configure.ac (GUILE_CONFIGURE_COPYRIGHT): Add 2018.
2018-07-01 23:33:26 +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
Ludovic Courtès
533e3ff170 Serialize accesses to submodule hash tables.
Fixes <https://bugs.gnu.org/30602>.

Previously, when compiling files in parallel like Guix does, threads
would be concurrently inserting, rehashing, and reading the submodule
hash table of module ().  Thus, some threads would sometimes see an
inconsistent state, leading to errors such as:

  Module named (system repl debug) does not exist

* module/ice-9/boot-9.scm (call-with-module-autoload-lock): Move higher
in the file.
(module-name): Use it around call to 'nested-define-module!'.
(resolve-module): Wrap the whole thing in 'call-with-module-autoload-lock'.
2018-07-01 18:37:59 +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
Ludovic Courtès
b87068eee7 linker: Don't rely on out-of-range bv-ref exceptions.
* module/system/vm/linker.scm (find-shstrndx): Check whether NAME is
lower than the length of BV; remove 'false-if-exception' around
'string-table-ref' call.
2018-06-28 17:14:08 +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