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

9310 commits

Author SHA1 Message Date
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
f0be544463 Merge from upstream lightening 2019-04-25 18:12:42 +02:00
Andy Wingo
b0cd9c0b77 Merge from upstream lightening 2019-04-25 17:16:54 +02:00
Andy Wingo
fa6093c4ef Merge from upstream lightening 2019-04-24 22:57:26 +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
d75303780b Merge from upstream lightening 2019-04-24 15:53:22 +02:00
Andy Wingo
609df9ea55 Merge from upstream lightening 2019-04-22 09:17:26 +02:00
Mark H Weaver
63818453ad Reimplement SCM_MAKE_CHAR to evaluate its argument only once.
The motivation for this change is that SCM_MAKE_CHAR is sometimes passed
an expression that involves a procedure call that is not always trivial.
In other cases, the results are not guaranteed to be the same both
times, which could lead to the creation of invalid SCM objects.

* libguile/chars.h (SCM_MAKE_CHAR): Reimplement.
2019-04-17 03:02:55 -04:00
Andrea Azzarone
546b0e8729 Fix gc.test "after-gc-hook gets called" failures.
* libguile/scmsigs.c (signal_delivery_thread): Call scm_async_tick to
give any pending asyncs a chance to run before we block indefinitely
waiting for a signal to arrive.
2019-04-16 16:54:55 -04:00
Mark H Weaver
6b1de860ab Avoid passing NULL to 'memcpy' and 'memcmp'.
Reported by Jeffrey Walton <noloader@gmail.com> in
<https://lists.gnu.org/archive/html/guile-devel/2019-03/msg00001.html>.

Note that C11 section 7.1.4 (Use of library functions) states that:
"unless explicitly stated otherwise in the detailed descriptions [of
library functions] that follow: If an argument to a function has an
invalid value (such as ... a null pointer ...) ..., the behavior is
undefined."  Note that 'strxfrm' is an example of a standard C function
that explicitly states otherwise, allowing NULL to be passed in the
first argument if the size argument is zero, but no similar allowance is
specified for 'memcpy' or 'memcmp'.

* libguile/bytevectors.c (scm_uniform_array_to_bytevector): Call memcpy
only if 'byte_len' is non-zero.
* libguile/srfi-14.c (charsets_equal): Call memcmp only if the number of
ranges is non-zero.
* libguile/stime.c (setzone): Pass 1-character buffer to
'scm_to_locale_stringbuf', instead of NULL.
* libguile/strings.c (scm_to_locale_stringbuf): Call memcpy only if the
number of bytes to copy is non-zero.
2019-04-16 16:54:55 -04:00
Mark H Weaver
275c96dd1f Remove vestigial comment in tags.h.
* libguile/tags.h: Remove a vestigial comment which seems to have been
separated from its associated code long ago.
2019-04-16 16:54:55 -04:00
Andy Wingo
b35662fb4e Merge from upstream Lightening 2019-04-04 17:07:09 +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
39d1ed3c27 Merge from upstream Lightening 2019-04-04 12:11:08 +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
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