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

9538 commits

Author SHA1 Message Date
Andy Wingo
a4875baa4e Merge remote-tracking branch 'lightening/master' 2019-05-21 12:39:34 +02:00
Andy Wingo
03ceca9a2b Merge remote-tracking branch 'lightening/master' 2019-05-21 12:25:14 +02:00
Andy Wingo
f81f43591f Merge remote-tracking branch 'lightening/master' 2019-05-21 12:14:50 +02:00
Andy Wingo
66b96f9359 Merge remote-tracking branch 'lightening/master' 2019-05-20 21:36:17 +02:00
Andy Wingo
e057ea01f6 Merge remote-tracking branch 'lightening/master' 2019-05-20 15:48:27 +02:00
Andy Wingo
638846dc61 Merge from upstream lightening 2019-05-08 21:46:57 +02:00
Mark H Weaver
7c2b48a6bd Strings, i18n: Limit the use of alloca to approximately 8 kilobytes.
* libguile/i18n.c (SCM_MAX_ALLOCA): New macro.
(SCM_STRING_TO_U32_BUF): Accept an additional variable to remember
whether we used malloc to allocate the buffer.  Use malloc if the
allocation size is greater than SCM_MAX_ALLOCA.
(SCM_CLEANUP_U32_BUF): New macro.
(compare_u32_strings, compare_u32_strings_ci, str_to_case): Adapt.
* libguile/strings.c (SCM_MAX_ALLOCA): New macro.
(normalize_str, unistring_escapes_to_r6rs_escapes): Use malloc if the
allocation size is greater than SCM_MAX_ALLOCA.
* test-suite/tests/i18n.test, test-suite/tests/strings.test: Add tests.
2019-05-07 04:41:30 -04:00
Mark H Weaver
91b5b1631f put-u8: Always write a single byte, regardless of the port encoding.
Previously, 'put-u8' used textual I/O to write a single character,
relying on the usual practice of setting the port encoding to ISO-8859-1
for binary ports.

* libguile/r6rs-ports.c (scm_put_u8): Use 'scm_c_write', not 'scm_putc'.
2019-05-07 04:41:15 -04:00
Mark H Weaver
5b42fd80d7 Optimize fixnum exact integer square roots.
* libguile/numbers.c (scm_exact_integer_sqrt, scm_sqrt)
(exact_integer_is_perfect_square, exact_integer_floor_square_root):
Where it is trivial to do so, use GMP's low-level mpn functions to
avoid heap allocation.
2019-05-07 04:39:52 -04:00
Mark H Weaver
74d536bf52 Fix indentation in scm_sum. 2019-05-07 04:37:52 -04:00
Mark H Weaver
16b4bac355 Fix typo in comment. 2019-05-07 04:37:52 -04:00
Mark H Weaver
2a1f22c00a Add 'scm_c_make_char' and use it where appropriate.
This reverts the change to SCM_MAKE_CHAR made in the previous commit
63818453ad, which used an arithmetic trick
to avoid evaluating its argument more than once.

Here, we restore the previous implementation of SCM_MAKE_CHAR, which
evaluates its argument twice.  Instead, we introduce a new inlinable
function 'scm_c_make_char' and replace uses of SCM_MAKE_CHAR with calls
to 'scm_c_make_char' where appropriate.

* libguile/chars.h (scm_c_make_char): New inline function.
* libguile/inline.c: Include chars.h.
* libguile/srfi-13.c (REF_IN_CHARSET, scm_string_any, scm_string_every)
(scm_string_trim, scm_string_trim_right, scm_string_trim_both)
(scm_string_index, scm_string_index_right, scm_string_skip)
(scm_string_skip_right, scm_string_count, string_titlecase_x)
(string_reverse_x, scm_string_fold, scm_string_fold_right)
(scm_string_for_each, scm_string_filter, scm_string_delete):
Use 'scm_c_make_char' instead of 'SCM_MAKE_CHAR' in cases where the
argument calls a function.
* libguile/chars.c (scm_char_upcase, scm_char_downcase, scm_char_titlecase),
libguile/ports.c (scm_port_decode_char),
libguile/print.c (scm_simple_format),
libguile/read.c (scm_read_character),
libguile/strings.c (scm_string_ref, scm_c_string_ref),
libguile/vm-engine.c ("string-ref"): Ditto.
2019-05-07 04:37:52 -04:00
Andy Wingo
6e9d59f34d Merge from upstream lightening 2019-04-29 17:15:58 +02:00
Andy Wingo
7982839031 Merge from upstream lightening 2019-04-29 16:13:48 +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
8f695c058a Merge from upstream lightening 2019-04-28 18:44:13 +02:00
Andy Wingo
983af3be3b Merge from upstream lightening 2019-04-28 16:21:22 +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
51618e7e83 Merge from upstream lightening 2019-04-28 13:53:16 +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
5b45f04cc8 Merge from upstream Lightening 2019-04-26 12:41:47 +02:00
Andy Wingo
4e5329676b Fix backtraces with call-with-values during bootstrap
* libguile/programs.c (scm_i_program_name): Use scm_i_primitive_name for
  primitives.  No functional change though.
* libguile/vm.c (DEFINE_BUILTIN): Mark builtins as primitives.
2019-04-26 11:15:49 +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
5622396cd9 Merge from upstream lightening 2019-04-25 23:24: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
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