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

9141 commits

Author SHA1 Message Date
Andy Wingo
62df897929 Merge from upstream Lightening 2019-04-04 11:43:36 +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
c63764f439 Merge from upstream Lightening 2019-04-04 11:18:30 +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
11fa54646f Merge from upstream Lightening 2019-04-04 11:09:24 +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
1308404b5b Merge from upstream lightening 2019-04-03 19:24:47 +02:00
Andy Wingo
061c967bfe Checkpoint for lightning to lightening conversion 2019-04-03 17:42:27 +02:00
Andy Wingo
9f22ec9e2d Merge from upstream Lightening 2019-04-03 17:38:00 +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
2e4fb1e665 Merge in changes from upstream lightening 2019-04-03 13:59:33 +02:00
Andy Wingo
d351f13bc2 Add subdir-objects option to libguile makefile.
* libguile/Makefile.am (AUTOMAKE_OPTIONS): Add subdir-objects, to allow
  for having two files named "jit.c".
2019-04-03 13:37:35 +02:00
Andy Wingo
985faf35c1 Replace GNU Lightning with Lightening 2019-04-03 13:28:13 +02:00
Michael Gran
92105d13ad Handle newlib C library's langinfo constant names
The newlib C library (used in Cygwin) has alternative names for
nl_langinfo GNU extensions

* configure.ac (_NL_NUMERIC_GROUPING): new test
* libguile/i18n.c (INT_CURR_SYMBOL, MON_DECIMAL_POINT, MON_THOUSANDS_SEP)
   (MON_GROUPING, POSITIVE_SIGN, NEGATIVE_SIGN, GROUPING, INT_FRAC_DIGITS)
   (FRAC_DIGITS, P_CS_PRECEDES, P_SEP_BY_SPACE, N_CS_PRECEDES, N_SEP_BY_SPACE)
   (P_SIGN_POSN, N_SIGN_POSN, INT_P_CS_PRECEDES, INT_P_SEP_BY_SPACE)
   (INT_N_CS_PRECEDES, INT_N_SEP_BY_SPACE, INT_P_SIGN_POSN, INT_N_SIGN_POSN)
   [HAVE_DECL__NL_NUMERIC_GROUPING]: map to newlib C constants, when present
2019-02-23 16:33:50 -08:00
Andy Wingo
61a8c9300d Fix race when expanding syntax-parameterize and define-syntax-parameter
* libguile/macros.c (scm_i_make_primitive_macro): Give primitive macros
  a primitive-macro macro-type.
* module/ice-9/psyntax.scm (put-global-definition-hook)
  (get-global-definition-hook): Inline into uses.
  (make-binding): Change format of lexically defined or rebound syntax
  parameters to just be the transformer, not a list of the transformer.
  (resolve-identifier, expand-install-global, expand-body)
  (syntax-parameterize): Adapt to use the variable object (box) holding
  the top-level syntax parameter as the "key" for lookups into the
  lexical environment, instead of a fresh object associated with the
  syntax transformer.
* module/ice-9/psyntax-pp.scm: Regenerate.

Fixes #27476, a horrible race when one thread is expanding a
syntax-parameterize form including uses, and another thread is expanding
the corresponding define-syntax-parameter.  See
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27476#102.
2019-02-22 15:11:29 +01:00
Mike Gran
78468baa11 Fix binary output on files created by mkstemp!
Some operating systems require a O_BINARY flag.

* libguile/filesys.c (scm_i_mkstemp): Don't mask out O_BINARY flag
* test-suite/tests/posix.test ("binary mode honored"): new test
2019-02-09 16:59:38 -08:00
Mike Gran
139c702fc8 Fix strftime compile with null threads
* libguile/stime.c (scm_strftime): use correct pthread lock function
2019-02-09 16:20:13 -08:00
Ludovic Courtès
45e4ace660 Do not warn the user when 'madvise' returns ENOSYS.
* libguile/vm.c (return_unused_stack_to_os): Avoid 'perror' calls when
'madvise' returns ENOSYS.
2018-12-16 11:34:14 +01:00
Mark H Weaver
fbdcf63585 scm_seed_to_random_state: Support wide string arguments.
Partially fixes <https://bugs.gnu.org/33044>.
Reported by Tom de Vries <tdevries@suse.de>.

* libguile/random.c (scm_seed_to_random_state): Use 'scm_to_utf8_string'
(or 'scm_to_latin1_string' for a narrow string, for compatibility) to
convert the string into raw bytes for use by 'scm_c_make_rstate'.  Make
sure the length in bytes fits within an 'int'.
2018-10-19 22:18:20 -04:00
Mark H Weaver
1d3cfc3548 Fix typo in strings.h.
* libguile/strings.h: In a comment, add the missing "i_" in
"scm_i_is_narrow_string".
2018-10-19 21:52:39 -04:00
Mark H Weaver
c2a654b7d2 Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.
Partial fix for <https://bugs.gnu.org/33044>.
Reported by Tom de Vries <tdevries@suse.de>.

Fix several instances of the mistake of using 'scm_from_locale_*' for C
strings that originally came from a C string literal.  Change several
uses of 'scm_from_latin1_*' as well, to promote the practice of writing
code that works for arbitrary C string literals.

Also add missing years to the copyright notices of changed files, based
on the git history.

* libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c,
libguile/eval.c, libguile/expand.c, libguile/extensions.c,
libguile/filesys.c, libguile/init.c, libguile/load.c,
libguile/modules.c, libguile/pairs.c, libguile/posix.c,
libguile/print.c, libguile/random.c, libguile/read.c,
libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c,
libguile/stacks.c, libguile/stime.c, libguile/strports.c,
libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
2018-10-17 21:38:43 -04:00
Mark H Weaver
1990aa9163 In 'ash' and 'round-ash', handle right shift count of LONG_MIN.
Fixes <https://bugs.gnu.org/21901>.
Reported by Zefram <zefram@fysh.org>.

* libguile/numbers.c: Add another top-level 'verify' to ensure that
LONG_MIN is not a fixnum.
(scm_ash, scm_round_ash): Ensure that when the shift count is LONG_MIN,
it is not handled via the normal code path, to avoid signed overflow
when the shift count is negated.
* test-suite/tests/numbers.test: Add tests.
2018-10-14 05:37:18 -04:00
Mark H Weaver
9448a078b5 Fix 'round-ash' of negative integers by huge right shift counts.
This is a followup to commit 011aec7e24.

When rounding, right shifting a negative integer by a huge shift count
results in 0, not -1.

* libguile/numbers.c: Add top-level 'verify' to ensure that the
assumptions in 'scm_ash' and 'scm_round_ash' are valid.
(scm_round_ash): In the case that handles huge right shifts, require
that the shift count _exceeds_ the integer length, and return 0 instead
of -1.
* test-suite/tests/numbers.test: Adjust tests accordingly.
2018-10-14 05:35:50 -04:00
Mark H Weaver
011aec7e24 Gracefully handle huge shift counts in 'ash' and 'round-ash'.
Fixes <https://bugs.gnu.org/32644>.
Reported by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.

The need for this arose because the type inferrer for 'ursh' sometimes
passes (- 1 (expt 2 64)) as the second argument to 'ash'.

* libguile/numbers.c (scm_ash, scm_round_ash): Gracefully handle several
cases where the shift count does not fit in a C 'long'.
* test-suite/tests/numbers.test: Add tests.
2018-10-14 03:27:52 -04:00
Mark H Weaver
fe73fedab4 Fix list validation of *list->bytevector procedures.
Fixes <https://bugs.gnu.org/32938>.
Reported by Josh Datko <jbd@cryptotronix.com>.

* libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN)
(SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to
validate the result of 'scm_ilength' after it has been stored in
the user variable 'cvar'.
* test-suite/tests/bytevectors.test: Add tests.  Use '#:use-module'
instead of ':use-module' in 'define-module' form.
2018-10-14 02:27:23 -04:00
Mark H Weaver
b44f505f15 Improve the documentation for 'nil?'.
* libguile/boolean.c (scm_nil_p): Improve docstring.
* doc/ref/api-languages.texi (Nil): Add documentation for 'nil?', along
with a description of how Elisp interprets Scheme booleans and
end-of-list.
2018-10-14 01:37:37 -04:00
Daniel Llorens
b9cf3517ef Fix 32/64 bit bug in INTEGER_ACCESSOR_PROLOGUE 2018-10-10 19:51:58 +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
5787f4e516 Fix -Wunused-function error for x86 not on sun
* libguile/lightning/lib/jit_x86-x87.c (_fstcwm): Surround definition
  with ifdef(sun).
2018-10-07 16:44:13 +02:00
Andy Wingo
8bcba78eda Fix unused local warning in vm-engine.c
* libguile/vm-engine.c (return-values): Remove needless frame_size=3
  local var.
2018-10-07 16:33:04 +02:00
Andy Wingo
2388193bbf Fix lightning build with jit_names.c
* libguile/lightning/lightning.am (lightning_extra_files): Move
  jit_names.c here.
2018-10-07 16:30:17 +02:00
Andy Wingo
ae188ac6b7 Revert "Remove jit_names.c."
This reverts commit b74e1f0de3.
2018-10-07 16:29:18 +02:00
Andy Wingo
b74e1f0de3 Remove jit_names.c.
* libguile/lightning/lib/jit_names.c: Remove unused file.
* libguile/lightning/lightning.am (lightning_c_files): Remove
  jit_names.c.
* libguile/lightning/lib/jit_print.c: Remove jit_names.c inclusion.
2018-10-07 16:28:36 +02:00
Andy Wingo
173b44a224 Fix GCC warning with %char-set-dump.
* libguile/srfi-14.c (scm_sys_char_set_dump): Silence an erroneous
  -Wformat-overflow warning based on an incorrect range inference by
  increasing output buffer size.
2018-10-07 16:14:06 +02:00
Andy Wingo
f34d50ad6b Deprecate scm_find_executable
* libguile/deprecated.h:
* libguile/deprecated.c (scm_find_executable): Deprecate.  Use strdup
  instead of weird scm_cat_path function.
* libguile/script.h:
* libguile/script.c: Remove old decls.
2018-10-07 16:04:59 +02:00
Andy Wingo
edba440885 Remove unimplemented decl in script.h
* libguile/script.h (scm_find_impl_file): Remove unimplemented decl.
2018-10-07 15:57:50 +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
6cd9b3114f Fix use of uninstalled header by installed headers
* libguile/Makefile.am (libpath.h): Remove definition of
  SCM_EFFECTIVE_VERSION, which is defined in version.h.
* libguile/extensions.h: Remove libpath.h inclusion, as it's not
  installed.
* libguile/atomic.c:
* libguile/bytevectors.c:
* libguile/control.c:
* libguile/fdes-finalizers.c:
* libguile/foreign-object.c:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/frames.c:
* libguile/goops.c:
* libguile/i18n.c:
* libguile/instructions.c:
* libguile/intrinsics.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/loader.c:
* libguile/poll.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/programs.c:
* libguile/r6rs-ports.c:
* libguile/srfi-1.c:
* libguile/srfi-60.c:
* libguile/threads.c:
* libguile/unicode.c:
* libguile/vm.c:
* libguile/weak-vector.c: Include version.h for the
  SCM_EFFECTIVE_VERSION definition.
2018-10-07 15:15:02 +02:00
Mark H Weaver
2d09e0513f Fix 'atomic-box-compare-and-swap!'.
Fixes <https://bugs.gnu.org/32786>.

'scm_atomic_compare_and_swap_scm' is a thin wrapper around
'atomic_compare_exchange_weak' (where available), and therefore it may
spuriously fail on some platforms, leaving the atomic object unchanged
even when the observed value is equal to the expected value.  Since
'scm_atomic_compare_and_swap_scm' returns both a boolean result and the
observed value, the caller is able to detect spurious failures when
using that API.

'atomic-box-compare-and-swap!' presents a simpler API, returning only
the observed value.  The documentation advises callers to assume that
the exchange succeeded if the observed value is 'eq?' to the expected
value.  It's therefore not possible to report spurious failures with
this API.

'atomic-box-compare-and-swap!' uses 'scm_atomic_compare_and_swap_scm',
and prior to this commit would simply ignore the boolean result and
return the observed value.  In case of spurious failures, the caller
would legitimately conclude that the exchange had succeeded.

With this commit, 'atomic-box-compare-and-swap!' now retries in case of
spurious failures.

* libguile/atomic.c (scm_atomic_box_compare_and_swap_x): If
'scm_atomic_compare_and_swap_scm' returns false and the observed value
is equal to 'expected', then try again.
* libguile/vm-engine.c (atomic-box-compare-and-swap!): Ditto.
2018-10-05 18:19:34 -04: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
4e8d27f0d1 Finish updating vm.texi
* doc/ref/compiler.texi (Bytecode): Update macro-assembler instructions,
  and move most of them to the instruction set reference.
* doc/ref/vm.texi (A Virtual Machine for Guile, VM Programs): Minor
  fixes.
(Instruction Set): Update for Guile 3 instruction set.
* libguile/vm-engine.c (vm_engine): Update a few instruction
  docstrings.
2018-09-30 16:08:40 +02:00
Ludovic Courtès
3ee7673cc9 Define AT_SYMLINK_NOFOLLOW et al.
* libguile/posix.c (scm_init_posix): Define AT_SYMLINK_NOFOLLOW,
AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, and AT_EMPTY_PATH when available.
(scm_utime): Mention AT_SYMLINK_NOFOLLOW.
* doc/ref/posix.texi (File System): Update accordingly.
* test-suite/tests/posix.test ("utime")["AT_SYMLINK_NOFOLLOW"]: New test.
2018-09-23 16:41:13 +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
1e7c541b2f Fix case where running abort hook could trash registers
* libguile/vm-engine.c (abort): If the abort doesn't need to longjmp and
  the abort hook was enabled, cache registers first to avoid restoring
  a bad IP to the VM.
2018-09-22 17:33:58 +02:00
Andy Wingo
4060728e0a Renumber instructions and bump objcode version
* libguile/loader.h (SCM_OBJCODE_MINIMUM_MINOR_VERSION):
  (SCM_OBJCODE_MINOR_VERSION): Bump version.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* libguile/vm-engine.c: Rearrange opcodes to be contiguous and in a
  somewhat sensible order.
2018-09-20 11:22:15 +02:00