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
b517a91ba4 Deprecate useless C bitvector interface
C should use scm_c_bitvector_length, not scm_bitvector_length.

* doc/ref/api-data.texi (Bit Vectors): Reorganize a bit to put typed C
  interfaces in their own section.
* libguile/bitvectors.h:
* libguile/bitvectors.c (bitvector-length, bitvector-count): Make
  SCM-flavored C interface private.
  (scm_c_bitvector_count): New function.
* libguile/deprecated.c (scm_bitvector_length): Deprecate.
  (scm_bit_count): Adapt to changes.
2020-04-29 11:14:17 +02:00
Andy Wingo
bfd38b8577 bitvector-count-bits replaces bit-count*
* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_c_bitvector_count_bits): New function.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bit_count_star): Deprecate.
* module/ice-9/sandbox.scm (bitvector-bindings): Replace bit-count* with
  bitvector-count-bits.
* test-suite/tests/bitvectors.test: Update.
2020-04-29 11:14:17 +02:00
Ludovic Courtès
1fbe89f7bd 'finalization_thread_proc' sets errno before calling 'perror'.
* libguile/finalizers.c (finalization_thread_proc): Set 'errno' before
calling 'perror'.
2020-04-26 16:30:31 +02:00
Andy Wingo
f897efa9f1 bitvector-flip-all-bits! replaces bit-invert!
* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_c_bitvector_flip_all_bits_x): New function.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bit_invert_x): Deprecate.
* module/ice-9/sandbox.scm (mutable-bitvector-bindings): Replace
  bit-invert! with bitvector-flip-all-bits!.
* module/system/vm/frame.scm (available-bindings): Use the new
  interface.
* test-suite/tests/bitvectors.test: Update.
2020-04-18 22:16:31 +02:00
Andy Wingo
d7fea13453 bitvector-set-all-bits! / bitvector-clear-all-bits! replace bitvector-fill!
* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_c_bitvector_set_all_bits_x)
  (scm_c_bitvector_clear_all_bits_x): New functions.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bitvector_fill_x): Deprecate.
* module/ice-9/sandbox.scm (mutable-bitvector-bindings): Replace
  bitvector-fill! with bitvector-set-all-bits! /
  bitvector-clear-all-bits!.
* module/system/vm/disassembler.scm (static-opcode-set): Use
  bitvector-set-bit!.
* module/system/vm/frame.scm (available-bindings): Use the new
  interfaces.
* test-suite/tests/bitvectors.test: Update.
2020-04-15 22:14:25 +02:00
Andy Wingo
8110061e64 bitvector-set-bit! / bitvector-clear-bit! replace bitvector-set!
* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/array-handle.h (bitvector_set_x, scm_array_get_handle): Adapt
  to bitvector changes.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_c_bitvector_set_bit_x)
  (scm_c_bitvector_clear_bit_x): New functions.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bitvector_set_x): Deprecate.
* module/ice-9/sandbox.scm (mutable-bitvector-bindings): Replace
  bitvector-set! with bitvector-set-bit! / bitvector-clear-bit!.
* module/system/vm/disassembler.scm (static-opcode-set): Use
  bitvector-set-bit!.
* module/system/vm/frame.scm (compute-defs-by-slot, available-bindings):
  Use bitvector-set-bit!.
* test-suite/tests/bitvectors.test: Update.
2020-04-14 22:40:43 +02:00
Andy Wingo
d804177be4 bitvector-bit-set? / bitvector-bit-clear? replace bitvector-ref
This is an opportunity to make a new interface that can be more
efficient in 3.0 (because no generic array support), easier to read (no
need for 'not'), and more consistent with other bitvector interfaces.

* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/array-handle.h (bitvector_ref, scm_array_get_handle): Adapt
  to bitvector changes.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_c_bitvector_bit_is_set)
  (scm_c_bitvector_bit_is_clear): New functions.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bitvector_ref): Deprecate.
* module/ice-9/sandbox.scm (bitvector-bindings): Replace
  bitvector-ref with bitvector-bit-set? / bitvector-bit-clear?.
* module/system/vm/disassembler.scm (instruction-has-fallthrough): Use
  bitvector-bit-clear?.
* test-suite/tests/bitvectors.test: Update.
2020-04-14 22:18:02 +02:00
Andy Wingo
ff9979b6bc Replace bit-set*! with bitvector-set-bits! / bitvector-clear-bits!
The old name was wonky and hard to read: you almost always pass a
literal as the value to set, so better to make separate functions.

* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_bitvector_set_bits_x)
  (scm_bitvector_clear_bits_x): New functions.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bit_set_star_x): Deprecate.
* module/ice-9/sandbox.scm (mutable-bitvector-bindings): Replace
  bit-set*! with bitvector-set-bits! / bitvector-clear-bits!.
* module/system/vm/frame.scm (available-bindings, compute-killv): Use
  bitvector-set-bits! and bitvector-clear-bits!.
* test-suite/tests/bitvectors.test: Update.
2020-04-13 22:06:56 +02:00
Andy Wingo
06709d77b9 Replace bit-position with bitvector-position
The old name was wonky and had bad argument order.

* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/bitvectors.h:
* libguile/bitvectors.c (scm_bitvector_position): New function.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bit_position): Deprecate.
* module/ice-9/sandbox.scm (bitvector-bindings): Replace bit-position
  with bitvector-position.
* module/language/cps/intset.scm (bitvector->intset): Use
  bitvector-position.
* module/system/vm/frame.scm (available-bindings): Use
  bitvector-position.
* test-suite/tests/bitvectors.test ("bitvector-position"): Add test.
2020-04-12 22:39:55 +02:00
Andy Wingo
cae74359de Replace bit-count with bitvector-count
The old name was wonky and had bad argument order.

* NEWS: Add entry.
* doc/ref/api-data.texi (Bit Vectors): Update.
* libguile/bitvectors.h:
* libguile/bitvectors.c (VALIDATE_BITVECTOR): New helper.
  (scm_bitvector_count): New function.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_bit_count): Deprecate.
* module/ice-9/sandbox.scm (bitvector-bindings): Replace bit-count with
  bitvector-count.
* module/srfi/srfi-60.scm: No need to #:replace bit-count.
* module/system/vm/frame.scm (available-bindings): Use bitvector-count.
* test-suite/tests/bitvectors.test ("bitvector-count"): Add test.
2020-04-12 22:17:22 +02:00
Andy Wingo
24a34074ef Deprecate bitvector-ref on array slices
* NEWS: Update.
* doc/ref/api-data.texi (Bit Vectors): Update documentation on bit-set*!
  and bit-count*.
* libguile/bitvectors.c: Add a to-do list.
  (scm_c_bitvector_ref, scm_c_bitvector_set_x, scm_bitvector_fill_x)
  (scm_bitvector_to_list, scm_bit_count, scm_bit_position):
  Issue deprecation warnings when used on array slices.
  (scm_list_to_bitvector): Simplify.
  (scm_bit_set_star_x, scm_bit_count_star): Deprecate arrays as target
  bitvectors, and also use of u32vector as selection vector.
* libguile/bitvectors.h:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_istr2bve): Deprecate.
* test-suite/tests/bitvectors.test ("bit-count*"): Remove test of u32
  selectors.
2020-04-12 21:36:30 +02:00
Mike Gran
187bfdc3e1 Update SRFI-14 tables to Unicode 13.0.0
* libguile/srfi-14.i.c (cs_lower_case_ranges, cs_upper_case_ranges)
  (cs_letter_ranges, cs_digit_ranges, cs_letter_plus_digit_ranges)
  (cs_graphic_ranges, cs_printing_ranges, cs_punctuation_ranges)
  (cs_symbol_ranges, cs_designated_ranges): updated to Unicode 13
2020-03-26 07:14:14 -07:00
Ludovic Courtès
6111b86bdc 'resize_set' no longer allocates in a loop.
* libguile/weak-set.c (resize_set): Call 'scm_gc_malloc_pointerless'
outside the loop.
2020-03-23 22:49:47 +01:00
Ludovic Courtès
02e3dc6ab9 Ensure weak sets are occasionally vacuumed.
Just like in dc8dda77e0, this ensures weak
sets are vacuumed in a timely fashion.  It also works around the fact
that 'vacuum_all_weak_tables' isn't getting called more than a couple of
times, for some reason.

Partly fixes <https://bugs.gnu.org/40194>.

* libguile/weak-set.c (weak_set_add_x): When 'set->items > set->upper',
call 'vacuum_weak_set'.
2020-03-23 22:49:47 +01:00
Ludovic Courtès
168ad279e6 Avoid double initialization in 'vector-copy'.
* libguile/vectors.c (make_vector): New function.
(scm_c_make_vector): Use it instead of 'scm_words'.
(scm_vector_copy): Use it instead of 'scm_c_make_vector'.
2020-03-23 22:49:47 +01:00
Matt Wette
b62d849d36 Deprecate 'tmpnam' and add '--disable-tmpnam' configure option.
* configure.ac: Add '--disable-tmpnam'.
* libguile/posix.c (tmpnam): Conditionalize on 'SCM_ENABLE_DEPRECATED'
and 'ENABLE_TMPNAM'.  Call 'scm_c_issue_deprecation_warning'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-03-22 18:00:06 +01:00
Isaac Jurado
bef5e0b393 Interpret dynamic library name as literal file name first.
Fixes <https://bugs.gnu.org/21076>.

* libguile/dynl.c (sysdep_dyn_link): Try plain lt_dlopen first, to
  interpret fname as a literal path.
* doc/ref/api-foreign.texi: Update explanation to describe the new
  behavior.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2020-03-22 00:27:12 +01:00
Matt Wette
865d48058e Fix compilation --without-threads.
Fixes <https://bugs.gnu.org/40075>.
Reported by Thomas Klausner <tk@giga.or.at>.

* libguile/null-threads.h: Include "libguile/scm.h".
* libguile/null-threads.c: Include "libguile/scmconfig.h".

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-03-21 18:25:52 +01:00
Ludovic Courtès
89edd1bc2d Fix race condition between 'abort-to-prompt' and stack marking.
Fixes <https://bugs.gnu.org/28211>.

* libguile/vm.c (scm_i_vm_emergency_abort, abort_to_prompt): Move
'vp->fp' assignment above 'sp[nargs]' assignments.
2020-03-17 22:57:41 +01:00
Ludovic Courtès
5d715dd467 gdb: Avoid accessing values that are optimized out.
* libguile/libguile-3.0-gdb.scm (vm-frame-function-name)[ip-in-symbol?]:
Do not access SYM's value when it's optimized out.
2020-03-17 22:57:41 +01:00
Ludovic Courtès
a0aa8f01cc gdb: Adjust 'find-vp' for Guile 3.0.
* libguile/libguile-3.0-gdb.scm (find-vp): Adjust for Guile 3.0.
2020-03-17 22:57:41 +01:00
Ludovic Courtès
62d1335a61 gdb: Use <stdint.h> types.
* libguile/libguile-3.0-gdb.scm (vm-frame): Look up stdint.h types
instead of now-deprecated "scm_t_" types.
2020-03-17 22:57:41 +01:00
Ludovic Courtès
40f9a44c1b gdb: Delay type lookups.
This avoids errors while loading the file when types are not in scope.

* libguile/libguile-3.0-gdb.scm (%gdb-memory-backend)[void*]: Turn into
a promise and adjust user accordingly.
(ip-type, fp-type, sp-type, uint-type): Remove.
(vm-frame)[ip-type, uint-type]: New variables.
2020-03-17 22:57:41 +01:00
Ludovic Courtès
7c17655cd3 Fix incorrect allocation size in 'make-vtable-vtable'.
Fixes <https://bugs.gnu.org/39266>.
Thanks to <https://rr-project.org/> for its help!

* libguile/struct.c (set_vtable_access_fields): Fix first argument to
'scm_gc_malloc_pointerless'.
2020-03-09 15:22:53 +01:00
Ludovic Courtès
c5d3b45c9f 'hash' behaves like 'hashq' for tc7s without an 'equal?' implementation.
Fixes <https://bugs.gnu.org/39634>.

* libguile/hash.c (scm_raw_ihash): Add cases for scm_tc7 values that
were not explicitly listed.
2020-03-06 17:15:45 +01:00
Andy Wingo
5c950503a6 Add support for perf map creation
* libguile/jit.c (create_perf_map_once, create_perf_map, perf_map): New
  locals.
  (compute_mcode): Add an entry to perf_map for emitted JIT code.
2020-02-26 16:41:21 +01:00
Rob Browning
8b3cad6183 Implement hashing for keywords, i.e. (hash #:x ...)
Add keyword handling to (hash ...).  Previously it would just return the
same value for all keywords.

* libguile/hash.c (scm_raw_ihash): Add scm_tc7_keyword case.

* libguile/keywords.h (SCM_I_KEYWORD_HASH): New macro.
2020-02-21 01:36:14 -06:00
Andy Wingo
cc30168878 Fix bug restoring a JIT continuation from the interpreter
* libguile/vm.c (push_interrupt_frame, compose_continuation): In places
  where we push on synthetic frames before possibly going back to mcode,
  make sure that the return mcode will trampoline back to the
  interpreter.  Fixes compose-continuation from the interpreter to
  partial continuations with mcode.
2020-02-19 16:53:44 +01:00
Andy Wingo
18e9366142 Better debugging in jit.c
* libguile/jit.c (emit_direct_tail_call): Assert self-tail call has
  mcode.
  (opcodes_seen, bitvector_ref, bitvector_set, compile1): Make the
  opcodes_seen set more compact, and log all instruction emissions at
  level 3.
  (compute_mcode): Don't overwrite mcode if compilation fails.
2020-02-19 16:50:32 +01:00
Andy Wingo
74eafacff0 Merge remote-tracking branch 'lightening/master' 2020-02-17 22:04:07 +01:00
Ludovic Courtès
41d470f0e9 Reintroduce 'SCM_MEMORY_ERROR' in terms of 'scm_report_out_of_memory'.
Suggested by Dale P. Smith <dsmich@roadrunner.com>.

* libguile/deprecated.h (SCM_MEMORY_ERROR): New macro.
* doc/ref/api-control.texi (Dynamic Wind): Use 'scm_report_out_of_memory'.
2020-02-11 14:47:16 +01:00
Ludovic Courtès
1a3e316c32 Remove traces of 'scm_memory_error'.
'scm_memory_error' was deprecated in 2014 in commit
c2247b782a and removed in 2017 in commit
c248ea10be.  This is a followup.

* libguile/error.h (SCM_MEMORY_ERROR): Remove.
* doc/guile-api.alist: Remove 'scm_memory_error'.
* doc/ref/api-control.texi (Handling Errors): Likewise.
(Dynamic Wind): Use 'scm_misc_error' instead of 'scm_memory_error'.
2020-02-10 00:10:10 +01:00
John Paul Adrian Glaubitz
43cfae3634 Fix build on ia64.
* libguile/continuations.c (capture_auxiliary_stack): Fix
  logic in preprocessor code when checking for ia64 host;
  fix dereferencing of ctx variable.
* libguile/threads.h (struct scm_thread): Add missing member
  SCM_STACKITEM *auxiliary_stack_base.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-02-08 15:11:34 +01:00
John Paul Adrian Glaubitz
ad91517da1 Fix build on platforms where the stack grows upwards.
* libguile/continuations.c (scm_dynthrow): Fix missing mra
   parameter to grow_stack for SCM_STACK_GROWS_UP.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-02-08 15:11:33 +01:00
Ludovic Courtès
00fbdfa734 Handle GMP allocations through libgc and remove bignum finalizers.
This significantly speeds up loads that create lots of bignums, like
(language cps slot-allocation) for files with many top-level
definitions.  Compiling such a file is typically 2.5 times faster.

See <https://lists.gnu.org/archive/html/guile-devel/2020-02/msg00023.html>.

* libguile/numbers.c (custom_gmp_malloc): Use
'scm_gc_malloc_pointerless' instead of 'scm_malloc'.
(custom_gmp_realloc): Use 'scm_gc_realloc'.
(custom_gmp_free): Remove call to 'free'.
(make_bignum): Use 'scm_gc_malloc' instead of 'scm_gc_malloc_pointerless'.
Call 'scm_i_set_finalizer' only when SCM_INSTALL_GMP_MEMORY_FUNCTIONS is
false.
2020-02-08 11:40:17 +01:00
Ludovic Courtès
491cc23f93 build: Actually install libguile-3.0-gdb.scm.
Reported by brandelune on #guile.

* libguile/libguile-2.2-gdb.scm: Rename to...
* libguile/libguile-3.0-gdb.scm: ... this.
* libguile/Makefile.am (install-data-hook): Replace hard-coded "2.2"
with @GUILE_EFFECTIVE_VERSION@.
2020-01-21 17:51:37 +01:00
Ludovic Courtès
228ae549ca Make 'scm_sym_lambda', 'scm_sym_quote', etc. public again.
Fixes <https://bugs.gnu.org/39183>.

These symbols had been inadvertently removed from libguile, even though
they were intended to be public (as they were in 2.2).

* libguile/expand.c: Include "memoize.h".
2020-01-20 10:21:40 +01:00
Andy Wingo
53a3602b20 Bump objcode minor version in preparation for new stable series
* libguile/loader.h (SCM_OBJCODE_MINIMUM_MINOR_VERSION):
  (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2020-01-13 08:01:40 +01:00
Rob Browning
2446e7dc29 Respect thread local fluid defaults
Previously (fluid-ref (make-thread-local-fluid #t)) would return #f via
scm_fluid_ref because the internal scm_hashq_ref would return #f when
the fluid had not been set, and that was interpreted as an actual value
for the fluid.

Instead, just pass the fluid default as the default for the hash table
lookups so that we don't need a second step to determine if the fluid
was set.

Thanks to Andrew Gierth for tracking down the problem.
2020-01-12 22:04:29 +01:00
Andy Wingo
74f46efc73 Fix build on 32-bit systems with JIT support
* libguile/intrinsics.h: Add s64->f64 intrinsic, for 32-bit targets.
* libguile/jit.c (compile_s64_to_f64): Call the intrinsic for 32-bit
  targets.
2020-01-11 10:28:36 +01:00
Andy Wingo
9f2b703101 Merge remote-tracking branch 'lightening/master' 2020-01-06 22:00:53 +01:00
Daniel Llorens
ddad8ae05a Extend core vector-fill! to handle a range
With this patch, these two lines

  (vector-fill! vec fill)
  (vector-fill! vec fill 0 end)

run at the same speed; before, the second one was much slower.

This patch also makes it an error to call vector-fill! with a non-vector
array. The previous implementation did not work correctly in this case.

* libguile/vectors.c (SCM_VALIDATE_MUTABLE_VECTOR): Better error message.
  (vector-fill!): Handle optional arguments start, end. Do not attempt
    to handle non-vector arrays. Rename the C binding to
    scm_vector_fill_partial_x.
  (scm_vector_fill_x): Reuse scm_vector_fill_partial_x.
* module/srfi/srfi-43.scm (vector-fill!): Remove & re-export the core
  version instead.
2020-01-03 13:01:04 +01:00
Daniel Llorens
6b0491233f Provide SCM_DEFINE_STATIC
From guile-gnome:plain/glib/gnome/gobject/private.h.

* libguile/gsubr.h (SCM_DEFINE_STATIC): As stated.
2020-01-03 12:45:07 +01:00
Andy Wingo
e3e3e691f8 Fix abort_to_prompt bug if dynwind leave thunk expands the stack
* libguile/vm.c (scm_i_vm_emergency_abort, abort_to_prompt): Unwinding
  the dynwind stack can run dynwind leave thunks, which may expand the
  stack, which may invalidate previously calculated SP / FP values.
  (Re)calculate SP/FP after unwinding, to avoid writing to unmapped
  memory.  Fixes compile errors seen on Ubuntu and some other ports.
2020-01-02 13:29:39 +01:00
Andy Wingo
dbc93d6195 Avoid throwing exceptions during early boot if stdin is closed
* libguile/fports.c (scm_i_fdes_is_valid): New internal helper.
  (scm_i_fdes_to_port): Use new helper.
* libguile/fports.h: Declare new helper.
* libguile/init.c (scm_standard_stream_to_port): Refactor to use
  scm_i_fdes_is_valid.
2019-12-13 13:52:58 +01:00
Andy Wingo
bcb4f7dca8 Merge remote-tracking branch 'origin/stable-2.2' 2019-12-11 21:26:54 +01:00
Andy Wingo
114198d15f Move less? slow path out of line
* libguile/jit.c (compile_less, compile_less_slow): Move slow path out
  of line.
2019-12-10 23:03:19 +01:00
Andy Wingo
5e41d58ab9 Add fixnum fast-path for =
* libguile/jit.c (compile_numerically_equal): Add fixnum fast-path.
  (compile_numerically_equal_slow): New slow path.
2019-12-10 22:54:17 +01:00
Andy Wingo
6b335506ef Move allocate-pointerless-words/immediate slow path out of line
* libguile/jit.c (compile_allocate_pointerless_words_immediate)
  (compile_allocate_pointerless_words_immediate_slow): Move slow path
  out of line.
2019-12-10 22:38:45 +01:00
Andy Wingo
f1578c98b2 Move allocate-words/immediate slow path out of line
* libguile/jit.c (compile_allocate_words_immediate)
  (compile_allocate_words_immediate_slow): Move slow path out of line.
2019-12-10 22:33:47 +01:00