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

9224 commits

Author SHA1 Message Date
Daniel Llorens
4636eb2263 Reuse SCM_ASSERT_RANGE in scm_c_vector_ref, scm_c_vector_set_x 2020-04-09 16:59:39 +02:00
Daniel Llorens
82d8f025b1 Simplify vector constructor
* libguile/vectors.c: Remove redundant list check.
2020-04-09 16:59:39 +02:00
Daniel Llorens
5a2f73faf5 Remove superfluous type check in bitvector->list 2020-04-09 16:59:39 +02:00
Daniel Llorens
3b6a2f281a Move uniform-array->bytevector from (rnrs bytevectors) to core
This is to have arrays use bytevectors and not the other way
around. Besides, it's not an RnRS function.
2020-04-09 16:59:39 +02:00
Daniel Llorens
edf9abb4a0 Remove 'contiguous' flag in arrays
Was never used, so we save having to set it on various ops.

* libguile/arrays.h (SCM_I_ARRAY_FLAG_CONTIGUOUS,
  SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG,
  SCM_I_ARRAY_CONTP): Remove.
* libguile/arrays.c (scm_i_ra_set_contp): Remove. Elsewhere remove all
  uses of this and the other macros.
2020-04-09 16:59:39 +02:00
Daniel Llorens
d88d4d5558 Remove scm_from_contiguous_typed_array
This function was undocumented and not used anywhere.

libguile/arrays.h:
libguile/arrays.c: As stated.
2020-04-09 16:59:39 +02:00
Daniel Llorens
f43cf201d7 Merge generalized-arrays.[ch] in arrays.[ch]
The split was just confusing.
2020-04-09 16:59:39 +02:00
Daniel Llorens
68ae22eb5e Remove generalized-vectors.[hc]
* libguile/arrays.c: Assume the registry of array element types.
* libguile/arrays.h (scm_make_generalized_vector): Last decl from
  generalized-vectors.h.
* libguile/generalized-vectors.h:
* libguile/generalized-vectors.c: Remove.

Elsewhere remove references to generalized-vectors.
2020-04-09 16:59:39 +02:00
Daniel Llorens
26510db52c Pull generalized-vectors from under bytevectors 2020-04-09 16:59:39 +02:00
Daniel Llorens
0910fcde46 Pull generalized-vectors from under typed vectors 2020-04-09 16:59:39 +02:00
Daniel Llorens
f188424557 Pull generalized-vectors from under bitvector/string/vector
* libguile/generalized-vectors.c: Collect the register array type functions here.
* libguile/strings.c: Remove array registry code. Fix includes.
* libguile/vectors.c: Remove array registry code. Fix includes.
* libguile/bitvectors.c: Remove array registry code. Fix includes.
2020-04-09 16:59:39 +02:00
Daniel Llorens
9e785509e4 Rewrite vector-copy! using memmove
* libguile/vectors.c (vector-copy!): As stated. Provide C binding
  scm_vector_copy_x.
* module/srfi/srfi-43.scm: Re-export vector-copy! from core.
  (vector-reverse-copy!): Remove definer macro, simplify.
* doc/ref/api-data.texi: Document vector-copy!.
2020-04-09 16:59:39 +02:00
Daniel Llorens
53b9d678a6 Golf in srfi-4.h
Will make it easier to move the array_handle functions somewhere else.
2020-04-09 16:59:39 +02:00
Daniel Llorens
efe2317aff Move bitvector functions using array_handle to libguile/array-handle.[ch] 2020-04-09 16:59:39 +02:00
Daniel Llorens
88d690e15e Remove generalized vector support for vector-move-right!, vector-move-left!
This support was buggy and not advertised, so it has been removed.
2020-04-09 16:59:39 +02:00
Daniel Llorens
dbf08c3a96 Add lenp parameter back to scm_bitvector_(writable_)elements 2020-04-09 16:59:39 +02:00
Daniel Llorens
bf5b9a86bc Add lenp parameter back to scm_vector_(writable_)elements
Also fix uses.
2020-04-09 16:59:39 +02:00
Daniel Llorens
04c80519bf Simplify interfaces to scm_TYPEvector_(writable_)elements
Nothing is lost in these since the functions already required true typed
vectors, the extra arguments didn't serve any purpose.

Changing my mind from (vec) to (vec, lenp), though. Will fix
vector/bitvector next.

* libguile/srfi-4.h: scm_TYPEvector_(writable_)elements take (vec, lenp).
* libguile/srfi-4.c: Fix implementation.
* libguile/bitvectors.c: Fix use.
* test-suite/standalone/test-srfi-4.c: Fix old test and write variant
  with full array handle interface.
* doc/ref/srfi-modules.texi: Fix doc for srfi-4
  scm_TYPEvector_(writable_)elements.
2020-04-09 16:59:39 +02:00
Daniel Llorens
ef0579492a Simplify interfaces to scm_bitvector_elements and scm_bitvector_writable_elements
Doc fixes & tests TBD.

* libguile/bitvector.h: As stated.
* libguile/bitvector.c: Fix uses of scm_bitvector_elements,
  scm_bitvector_writable_elements.
* libguile/array-handle.c: scm_array1_bit_elements,
  scm_array1_bit_writable_elements: New functions.
* libguile/array-handle.h: Publish the new functions.
* libguile/posix.c: Fix use of scm_bitvector_elements.
2020-04-09 16:59:39 +02:00
Daniel Llorens
eb2d2c1a41 Simplify interfaces to scm_vector_elements and scm_vector_writable_elements
* vectors.h: As stated. Don't include array-handle.h.
* vectors.c (scm_vector_elements, scm_vector_writable_elements):
  Reimplement.
  (vector-move-right!, vector-move-left!): Replace uses of
  scm_vector_elements and scm_vector_writable_elements on array types.
* doc/ref/api-data.texi: Fix doc for scm_vector_elements and
  scm_vector_writable_elements.
* libguile/sort.c (stable-sort!): Fix use of
  scm_vector_writable_elements.
2020-04-09 16:59:39 +02:00
Daniel Llorens
40dbe69be5 Simple vectors are just vectors
* doc/ref/api-data.texi: Remove references to 'simple vectors'.
* libguile/vectors.h (SCM_VECTOR_REF,SCM_VECTOR_SET, SCM_VECTOR_LENGHT):
  Renamed from SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET,
  SCM_SIMPLE_VECTOR_LENGTH.
  (scm_is_simple_vector): Remove.

Elsewhere fix uses of SCM_SIMPLE_VECTOR_xxx or scm_is_simple_vector.
2020-04-09 16:59:39 +02:00
Daniel Llorens
6c97c8108e Remove the unused argument from scm_array_p
* libguile/generalized-arrays.h:
* libguile/generalized-arrays.c: As stated.
* doc/ref/api-data.texi: Fix documentation.
* NEWS-array-fixes.txt: Document branch changes.
2020-04-09 16:59:39 +02:00
Daniel Llorens
996bbb47f2 Require vector argument to scm_vector_elements, scm_vector_writable_elements
* libguile/vectors.c (scm_vector_elements, scm_vector_writable_elements): As
  stated.
* libguile/sort.c: Fix usage of scm_vector_elements on possibly non-vector
  array.
* doc/ref/api-data.texi (scm_vector_elements): Remove mention of non-vector
  arrays.
2020-04-09 16:59:39 +02:00
Daniel Llorens
fa19f702f6 Require vector as argument to vector->list
* libguile/vectors.c (vector->list): As stated. Simplify.
* test-suite/tests/vectors.test: Remove shared array test.
2020-04-09 16:59:39 +02:00
Daniel Llorens
21ede682af Require vector as argument to vector-copy
* libguile/vectors.c: Require vector and simplify.
2020-04-09 16:59:39 +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