Andy Wingo [Sun, 9 Feb 2014 19:56:55 +0000 (20:56 +0100)]
Simplify scm_array_get_handle for tc7-arrays
* libguile/array-handle.c (scm_array_get_handle): Simplify for the array
case, as suggested by Daniel Llorens.
Daniel Llorens [Wed, 17 Apr 2013 12:33:40 +0000 (14:33 +0200)]
Test that typed-array? returns #f with non-array argument
* test-suite/tests/arrays.test: ditto.
Daniel Llorens [Wed, 17 Apr 2013 08:19:26 +0000 (10:19 +0200)]
Replace SCM_IMP in array-map.c
* libguile/array-map.c
- scm_ramapc: check scm_array_contents with scm_is_false.
Andy Wingo [Sun, 9 Feb 2014 11:31:59 +0000 (12:31 +0100)]
Remove array impl. registry; instead, hard-code array handle creation
* libguile/array-handle.h (scm_t_vector_ref, scm_t_vector_set): Rename
from scm_t_array_ref, scm_t_array_set. These were named
scm_i_t_array_ref and scm_i_t_array_set in 1.8 and 2.0. Change to
take the vector directly, instead of the array handle. In this way,
generic array handles are layered on top of specific implementations
of backing stores.
Remove scm_t_array_implementation, introduced in 2.0 but never
documented. It was a failed attempt to layer the array implementation
that actually introduced too many layers, as it prevented the "vref"
and "vset" members of scm_t_array_handle (called "ref" and "set" in
1.8, not present in 2.0) from specializing on array backing stores.
(scm_i_register_array_implementation) (scm_i_array_implementation_for_obj):
Remove these internal interfaces.
(scm_t_array_handle): Adapt to scm_t_vector_ref / scm_t_vector_set
change.
(scm_array_handle_ref, scm_array_handle_set): Adapt to change in
vref/vset prototype.
* libguile/array-handle.c (scm_array_get_handle): Inline all the
necessary initializations here for all specific array types.
* libguile/array-map.c (rafill, racp, ramap, rafe, array_index_map_1):
* libguile/arrays.c: Remove array implementation code.
* libguile/bitvectors.h:
* libguile/bitvectors.c: Remove array implementation code.
(scm_i_bitvector_bits): New internal interface.
* libguile/bytevectors.c: Remove array implementation code.
* libguile/srfi-4.h: Remove declarations for internal procedures that
don't exist (!).
* libguile/strings.c: Remove array implementation code.
* libguile/vectors.c: Remove array implementation code.
Daniel Llorens [Fri, 19 Apr 2013 10:57:13 +0000 (12:57 +0200)]
Fix array map functions with empty arguments
* libguile/array-map.c
- scm_ra_matchp: look for empty axes and return new case 5 if so. Use
array handles to remove the SCM_I_ARRAYP / not branch.
- scm_ramapc: Heed case 5.
* test-suite/tests/ramap.test
- test empty arguments for array-copy! and array-for-each. Note those
that failed in 2.0.9.
Daniel Llorens [Fri, 19 Apr 2013 08:42:40 +0000 (10:42 +0200)]
Fix empty array bug in array-index-map!
* libguile/array-map.c: (scm_array_index_map_x): bail out if any one of the
axes is empty.
* test-suite/tests/ramap.test: add tests for empty array-case of
array-index-map!. The 'f64 case with not-last emtpy axis is broken in 2.0.9.
Andy Wingo [Sat, 8 Feb 2014 21:11:36 +0000 (22:11 +0100)]
Add "vector" member to scm_t_array_handle
* libguile/array-handle.h (scm_t_array_handle): Add "vector" member.
* libguile/array-handle.c (scm_array_get_handle): Initialize the vector
member.
Andy Wingo [Sat, 8 Feb 2014 20:51:52 +0000 (21:51 +0100)]
Remove "impl" member of array handles.
* libguile/array-handle.h (scm_t_array_handle): Remove "impl" member.
* libguile/array-handle.c (scm_array_get_handle): Adapt.
Andy Wingo [Sat, 8 Feb 2014 20:42:53 +0000 (21:42 +0100)]
Inline scm_i_array_implementation_for_obj in scm_i_array
* libguile/generalized-arrays.c (scm_is_array, scm_is_typed_array): In
preparation for removing the registry of array implementations, remove
a couple uss of scm_i_array_implementation_for_obj.
Andy Wingo [Sat, 8 Feb 2014 20:02:48 +0000 (21:02 +0100)]
vref, vset members of scm_t_array_handle
* libguile/array-handle.h (scm_t_array_ref, scm_t_array_set): Rename
from scm_i_t_array_ref, scm_i_t_array_set.
(scm_t_array_handle): Copy vref and vset from impl to handle.
(scm_array_handle_ref, scm_array_handle_set):
* libguile/array-map.c (racp, ramap, rafe, rafill, array_index_map_1):
* libguile/array-handle.c (scm_array_get_handle): Adapt.
Daniel Llorens [Thu, 11 Apr 2013 16:11:35 +0000 (18:11 +0200)]
Change uses of scm_is_simple_vector to scm_is_vector
* libguile/filesys.c, libguile/random.c, libguile/stime.c, libguile/trees.c,
libguile/validate.h: use scm_is_vector instead of scm_is_simple_vector.
* libguile/sort.c (scm_sort_x, scm_sort, scm_stable_sort_x)
(scm_stable_sort): Remove scm_is_vector check; scm_is_array is
sufficient.
* test-suite/tests/arrays.test: Fix header.
* test-suite/tests/random.test: New coverage test covering
random:normal-vector!.
* test-suite/Makefile.am: Include random.test in make check.
Andy Wingo [Sat, 8 Feb 2014 16:14:47 +0000 (17:14 +0100)]
SCM_I_IS_VECTOR only true for tc7_vector, not weak vectors
* libguile/tags.h (SCM_TYP7S, SCM_HAS_TYP7S): Remove these, as we no
longer do the differs-by-one-bit thing for vectors and weak vectors.
* libguile/vectors.h (SCM_I_IS_VECTOR): Use SCM_HAS_TYP7.
(SCM_I_IS_NONWEAK_VECTOR): Remove.
* libguile/vm-engine.c (vector-length, vector-ref, vector-set!)
(vector-ref/immediate, vector-set!/immediate): We can inline these
instructions completely now.
* libguile/vm.c (vm_error_not_a_vector, vm_error_out_of_range): New
error conditions.
Andy Wingo [Sat, 8 Feb 2014 16:00:32 +0000 (17:00 +0100)]
Merge commit '
24cac6554073bb6e691605cd6ac6196f3c0851a3'
Conflicts:
libguile/vectors.c
Andy Wingo [Sat, 8 Feb 2014 15:54:01 +0000 (16:54 +0100)]
Merge commit '
5cfeff11cc58148c58a85a879fd7a3e7cfbbe8e2'
Conflicts:
libguile/vectors.c
Andy Wingo [Sat, 8 Feb 2014 15:13:54 +0000 (16:13 +0100)]
Deprecate the use of the vector interface on arrays
* libguile/vectors.c (scm_is_vector): Deprecate use on weak vectors and
arrays.
(scm_is_simple_vector): Deprecate use on weak vectors.
(scm_vector_length, scm_c_vector_ref, scm_c_vector_set_x): Deprecate
use on arrays.
* libguile/sort.c: Adapt to check explicitly for arrays.
Andy Wingo [Sat, 8 Feb 2014 15:02:59 +0000 (16:02 +0100)]
Deprecate use of vector-length, vector-ref, vector-set! as primitive-generics
* libguile/vectors.c (scm_vector_length, scm_c_vector_ref):
(scm_c_vector_set_x): Deprecate the use of vector-length, vector-ref,
and vector-set! as primitive generics.
Andy Wingo [Sat, 8 Feb 2014 14:31:37 +0000 (15:31 +0100)]
Merge commit '
fb7dd00169304a5922838e4d2f25253640a35def'
This commit also renames uniform-vector-element-type-code to
array-type-code.
Conflicts:
libguile/uniform.c
libguile/uniform.h
test-suite/tests/arrays.test
Andy Wingo [Sat, 8 Feb 2014 13:56:16 +0000 (14:56 +0100)]
Merge commit '
dc65b88d839c326889618112c4870ad3a64e9446'
Conflicts:
libguile/srfi-4.c
Andy Wingo [Sat, 8 Feb 2014 13:55:16 +0000 (14:55 +0100)]
Merge commit '
b9b88351ea2c4b43a6f90938554dc5693b17e328'
Conflicts:
libguile/deprecated.h
test-suite/tests/00-socket.test
Andy Wingo [Sat, 8 Feb 2014 13:48:56 +0000 (14:48 +0100)]
Andy Wingo [Sat, 8 Feb 2014 13:48:48 +0000 (14:48 +0100)]
Merge commit '
495cea0c931de23f074892b3f32808e676712a18'
Conflicts:
libguile/weaks.c
Andy Wingo [Sat, 8 Feb 2014 13:46:31 +0000 (14:46 +0100)]
Merge commit '
b86069c1308a6ca36f3a3bc56134b3f8fd693592'
Conflicts:
libguile/hashtab.c
Andy Wingo [Sat, 8 Feb 2014 13:44:23 +0000 (14:44 +0100)]
Andy Wingo [Sat, 8 Feb 2014 13:44:11 +0000 (14:44 +0100)]
Merge commit '
2f3b7e9a41677bfe802e8a1ee851827297384c58'
Conflicts:
module/ice-9/pretty-print.scm
Andy Wingo [Sat, 8 Feb 2014 13:31:42 +0000 (14:31 +0100)]
Andy Wingo [Sat, 8 Feb 2014 13:18:40 +0000 (14:18 +0100)]
Deprecate general "uniform-vector" interface
* libguile/uniform.h:
* libguile/uniform.c (scm_is_uniform_vector, scm_uniform_vector_p)
(scm_c_uniform_vector_length, scm_uniform_vector_length)
(scm_uniform_vector_element_type, scm_uniform_vector_element_size)
(scm_c_uniform_vector_ref, scm_uniform_vector_ref):
(scm_c_uniform_vector_set_x, scm_uniform_vector_set_x):
(scm_uniform_vector_to_list)
(scm_uniform_vector_elements, scm_uniform_vector_writable_elements):
Deprecate. This interface lacked both generality and specificity.
The general replacement is array-length, array-ref, and friends on the
scheme side, or the array handle interface on the C side. On the
specific side of things, there are the specific bytevector, srfi-4,
and bitvector interfaces.
* test-suite/tests/arrays.test:
* test-suite/tests/bitvectors.test:
* test-suite/tests/ports.test:
* test-suite/tests/srfi-4.test: Update to use array interfaces.
* doc/ref/api-foreign.texi (Void Pointers and Byte Access):
* doc/ref/srfi-modules.texi (SRFI-4): Update.
Andy Wingo [Sat, 8 Feb 2014 12:52:21 +0000 (13:52 +0100)]
Simplify srfi-4 C implementation
* libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): In the raw element
accessors (e.g scm_u32vector_writable_elements), only permit
bytevectors, as the constructors will only make bytevectors. This
harmonizes with the Scheme interfaces as well, which expect packed
bytevectors.
(scm_make_srfi_4_vector): Knowing that the new value is a bytevector
with base 0 and inc 1, simplify initialization.
Andy Wingo [Sat, 8 Feb 2014 13:27:49 +0000 (14:27 +0100)]
Deprecate htons, htonl, ntohs, ntohl
* libguile/sockets.h:
* libguile/sockets.c:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_htons, scm_htonl, scm_ntohs, scm_ntohl):
Deprecate. Bytevectors adequately subsume their functionality.
* doc/ref/posix.texi:
* test-suite/tests/00-socket.test: Update.
Mark H Weaver [Sat, 8 Feb 2014 02:42:28 +0000 (21:42 -0500)]
Improve handling of locales in the test suite.
* test-suite/guile-test (run-tests): Load each test file within
(with-locale "C" ...).
* test-suite/tests/encoding-iso88591.test:
* test-suite/tests/encoding-iso88597.test:
* test-suite/tests/encoding-utf8.test:
* test-suite/tests/srfi-14.test: Remove broken code to save and restore
the previous locale.
* test-suite/tests/bytevectors.test:
* test-suite/tests/format.test:
* test-suite/tests/regexp.test:
* test-suite/tests/srfi-19.test:
* test-suite/tests/tree-il.test: Make sure 'setlocale' is defined before
calling it.
Mark H Weaver [Sat, 8 Feb 2014 01:05:17 +0000 (20:05 -0500)]
Avoid using 'eval-when' with 'expand' in (oop goops).
* module/oop/goops.scm: Avoid using 'eval-when' with 'expand'.
Mark H Weaver [Fri, 7 Feb 2014 21:53:48 +0000 (16:53 -0500)]
Better error reporting in 'weak-vector-ref' and 'weak-vector-set!'.
* libguile/weaks.c (scm_c_weak_vector_ref, scm_c_weak_vector_set_x):
Pass procedure name to 'scm_out_of_range'.
Mark H Weaver [Fri, 7 Feb 2014 21:38:58 +0000 (16:38 -0500)]
Make size argument optional to 'make-doubly-weak-hash-table'; fix docs.
* libguile/hashtab.c (scm_make_doubly_weak_hash_table): Make 'size'
argument optional, like the weak hash table constructors.
* doc/ref/api-memory.texi (Weak hash tables): Document that 'size'
argument is optional for the weak hash table constructors.
Mark H Weaver [Fri, 7 Feb 2014 21:26:38 +0000 (16:26 -0500)]
Fix 'weak-vector?' doc: Weak hash tables are not weak vectors.
* doc/ref/api-memory.texi (Weak vectors): In 'weak-vector?' entry, don't
claim that weak hash tables are weak vectors. Remove statement that
weak vectors are mainly useful for implementing weak hash tables.
Andy Wingo [Fri, 7 Feb 2014 17:04:20 +0000 (18:04 +0100)]
Fix truncated-print for uniform vectors
* module/ice-9/pretty-print.scm (truncated-print): Use bytevector?
instead of uniform-vector?; the latter could be true for shared arrays
with non-zero lower bounds.
Andy Wingo [Fri, 7 Feb 2014 17:00:04 +0000 (18:00 +0100)]
(srfi srfi-4 gnu) uses private define-bytevector-type from (srfi srfi-4)
* module/srfi/srfi-4/gnu.scm: Re-use implementation of
define-bytevector-type from srfi-4.
Andy Wingo [Fri, 7 Feb 2014 16:57:30 +0000 (17:57 +0100)]
Remove private unused duplicate c32/c64vector definitions
* module/srfi/srfi-4.scm: Remove vestigial definitions for c32vectors
and c64vectors. Those are defined in (srfi srfi-4 gnu).
Andy Wingo [Fri, 7 Feb 2014 16:53:01 +0000 (17:53 +0100)]
SRFI-4 predicates, length accessors only accept bytevectors (not arrays)
* module/srfi/srfi-4.scm (define-bytevector-type): For the predicates
and length accessors, only accept bytevectors. Since arrays don't
work for u32vector-ref et al, they shouldn't pass u32vector?.
Andy Wingo [Fri, 7 Feb 2014 14:36:06 +0000 (15:36 +0100)]
Merge commit '
9b5da400dde6e6bc8fd0e318e7ca1feffa5870db'
Conflicts:
libguile/vectors.c
test-suite/tests/weaks.test
Andy Wingo [Fri, 7 Feb 2014 14:27:28 +0000 (15:27 +0100)]
Merge commit '
1e3fd6a0c81bb3e9900a93a9d1923cc788de0f99'
Conflicts:
doc/ref/api-memory.texi
libguile/weaks.c
libguile/weaks.h
module/ice-9/weak-vector.scm
Andy Wingo [Fri, 7 Feb 2014 14:26:18 +0000 (15:26 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:26:02 +0000 (15:26 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:25:49 +0000 (15:25 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:15:08 +0000 (15:15 +0100)]
Merge commit '
866af5da3d11ac4a9df44ee8c5b1781a0073c288'
Removes the special arity handler, and instead relies on the procedure
returning the correct number of values.
Andy Wingo [Fri, 7 Feb 2014 14:13:22 +0000 (15:13 +0100)]
Merge commit '
34e89877342f20fdb8a531ad78dab34cfd2b0843'
Conflicts:
module/Makefile.am
Andy Wingo [Fri, 7 Feb 2014 14:07:14 +0000 (15:07 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:06:26 +0000 (15:06 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:05:55 +0000 (15:05 +0100)]
Merge commit '
ca5e0414e96886177d883a249edd957d2331db65'
Conflicts:
module/language/tree-il/primitives.scm
Andy Wingo [Fri, 7 Feb 2014 14:01:33 +0000 (15:01 +0100)]
Merge commit '
60617d819d77a1b92ed6c557a0b49b8e9a8e97b9'
Conflicts:
libguile/continuations.c
libguile/eval.c
libguile/goops.c
libguile/instructions.c
Andy Wingo [Fri, 7 Feb 2014 13:51:42 +0000 (14:51 +0100)]
Merge commit '
f6ddf827f8f192af7a8cd255bd8374a0d38bbb74'
Conflicts:
module/ice-9/boot-9.scm
module/oop/goops.scm
Andy Wingo [Fri, 7 Feb 2014 13:43:42 +0000 (14:43 +0100)]
Andy Wingo [Fri, 7 Feb 2014 13:43:23 +0000 (14:43 +0100)]
Andy Wingo [Fri, 7 Feb 2014 13:42:40 +0000 (14:42 +0100)]
Merge commit '
8ca97482b01cf1a6aa538cc5a2d1f71fb60f080c'
Conflicts:
libguile/r6rs-ports.c
Andy Wingo [Fri, 7 Feb 2014 13:39:01 +0000 (14:39 +0100)]
Merge commit '
122f24cc8a3637ed42d7792ad1ff8ec0c49c58df'
Conflicts:
libguile/fports.c
libguile/ports.c
Andy Wingo [Fri, 7 Feb 2014 12:00:12 +0000 (13:00 +0100)]
Add weak-vector-length, weak-vector-ref, weak-vector-set!
* libguile/weak-vectors.h:
* libguile/weak-vectors.c (scm_is_weak_vector, scm_c_weak_vector_length):
(scm_c_weak_vector_ref, scm_c_weak_vector_set_x): New interfaces for
dealing with weak vectors from C.
(scm_weak_vector_length, scm_weak_vector_ref, scm_weak_vector_set_x):
New Scheme interfaces to weak vectors; to be used instead of
vector-length, vector-ref, etc.
* module/ice-9/weak-vector.scm: Export the new interfaces.
Andy Wingo [Fri, 7 Feb 2014 11:42:44 +0000 (12:42 +0100)]
Deprecate vector-ref, vector-length, vector-set! on weak vectors
* libguile/vectors.c (scm_vector_length, scm_c_vector_length):
(scm_c_vector_ref, scm_c_vector_set_x): Deprecate the use of these
procedures on weak vectors.
* test-suite/tests/guardians.test:
* test-suite/tests/weaks.test: Adapt test suites.
Andy Wingo [Fri, 7 Feb 2014 11:25:05 +0000 (12:25 +0100)]
Add weak-vector-length, weak-vector-ref, weak-vector-set!
* libguile/weaks.c (scm_is_weak_vector, scm_c_weak_vector_length):
(scm_c_weak_vector_ref, scm_c_weak_vector_set_x): New interfaces for
dealing with weak vectors from C.
(scm_weak_vector_length, scm_weak_vector_ref, scm_weak_vector_set_x):
New Scheme interfaces to weak vectors; to be used instead of
vector-length, vector-ref, etc.
* module/ice-9/weak-vector.scm: Export the new interfaces.
* doc/ref/api-memory.texi (Weak vectors): Document them.
Daniel Llorens [Thu, 11 Apr 2013 11:03:45 +0000 (13:03 +0200)]
Fix bad uses of base and lbnd on rank 1 arrays
* libguile/array-map.c
- rafill, ramap, rafe, racp: object from SCM_I_ARRAY_V always
has base 0, lbnd 0 and inc 1; make use of this.
* libguile/arrays.c
- array_handle_ref, array_handle_set: idem.
- array_get_handle: sanity check.
* libguile/generalized-vectors.c
- scm_c_generalized_vector_ref, scm_c_generalized_vector_set_x:
pos should be base when idx is lbnd. Furthermore, pos should be signed and
have its overflow checked; do this by handling the job to
scm_c_array_ref_1, scm_c_array_set_1_x.
* libguile/generalized-vectors.h
- fix prototypes.
Daniel Llorens [Wed, 10 Apr 2013 13:28:52 +0000 (15:28 +0200)]
Reorder arrays.test
* test-suite/tests/arrays.test: dependence reordering: first sanity, then
make-array, then array-equal?, then make-shared-array, shared-array-root,
then the rest, many of which use make-shared-array.
Daniel Llorens [Wed, 10 Apr 2013 13:11:33 +0000 (15:11 +0200)]
Don't use scm_is_generalized_vector in transpose-array
* libguile/arrays.c (scm_transpose_array)
- Use scm_c_array_rank(), which contains an implicit is_array test.
- Handle the rank 0 case.
* test-suite/tests/arrays.test
- Add test for rank 0 case.
- Add failure test for non array argument.
Daniel Llorens [Wed, 10 Apr 2013 12:53:10 +0000 (14:53 +0200)]
Tests for transpose-array
* test-suite/tests/arrays.test: test transpose-array for ranks 1, 2, 3.
Daniel Llorens [Wed, 10 Apr 2013 11:48:13 +0000 (13:48 +0200)]
Don't use scm_is_generalized_vector in shared-array-root
* libguile/arrays.c: (scm_shared_array_root): replace check for
scm_is_generalized_vector.
Daniel Llorens [Wed, 10 Apr 2013 11:45:05 +0000 (13:45 +0200)]
Tests for shared-array-root
* test-suite/tests/arrays.test: check shared-array-root against
make-shared-array, array-contents.
Daniel Llorens [Tue, 9 Apr 2013 23:07:02 +0000 (01:07 +0200)]
Remove unnecessary conditions in array constructors
* libguile/arrays.c: (scm_make_type_array, scm_from_contigous_typed_array,
scm_from_contigous_array): Remove conditions known to be true.
Daniel Llorens [Tue, 9 Apr 2013 16:27:29 +0000 (18:27 +0200)]
Remove generalized-vectors.h includes
* libguile/srfi-4.c, libguile/uniform.h: ditto.
Andy Wingo [Thu, 6 Feb 2014 20:34:14 +0000 (21:34 +0100)]
Fix array-index-map refactor
* libguile/ramap.c (array_index_map_1): Fix to use array handle
properly.
Andy Wingo [Thu, 6 Feb 2014 10:43:39 +0000 (11:43 +0100)]
Array-map refactors
* libguile/array-map.c (scm_ra_matchp): Refactor logic a bit.
(array_index_map_1, array_index_map_n)
(scm_array_index_map_x): Internally refactor array-index-map! to use
separate implementations for rank 1 versus rank >1 arrays.
Daniel Llorens [Tue, 7 May 2013 23:54:29 +0000 (01:54 +0200)]
Don't use generalized-vector in array-map.c (II)
* libguile/array-map.c
- replace scm_is_generalized_vector by scm_is_array && !SCM_I_ARRAY_P.
- replace scm_c_generalized_vector_length by scm_c_array_length.
- remove header.
Daniel Llorens [Mon, 8 Apr 2013 11:34:41 +0000 (13:34 +0200)]
Don't use generalized-vector in array-map.c (I)
* array-map.c: (AREF, ASET): Rename from GVREF, GVSET and use rank-1
array accessors.
Daniel Llorens [Thu, 6 Feb 2014 10:17:47 +0000 (11:17 +0100)]
Don't use generalized-vector functions in uniform.c
* libguile/uniform.c (scm_is_uniform_vector): Replace
scm_is_generalized_vector and scm_generalized_vector_get_handle by
scm_is_array and manual rank check.
(scm_c_uniform_vector_length): Use scm_c_array_length.
(scm_c_uniform_vector_ref): Use scm_c_array_ref_1.
(scm_c_uniform_vector_set): Use scm_c_array_set_1_x.
(scm_uniform_vector_writable_elements): Use scm_array_get_handle, and
assert that the rank is 1.
* test-suite/test/arrays.test: Rename the uniform-vector-ref block to
uniform-vector. Exercise uniform-vector-length and shared arrays
remaining uniform.
Modifications by Andy Wingo <wingo@pobox.com>.
Andy Wingo [Thu, 6 Feb 2014 10:02:20 +0000 (11:02 +0100)]
Replace generalized-vector calls in array_handle_ref/set
* libguile/arrays.c: (array-handle-ref, array-handle-set): Use the
rank-1 array accessors.
Daniel Llorens [Tue, 9 Apr 2013 16:17:21 +0000 (18:17 +0200)]
Replace scm_c_generalized_vector_length in arrays.c
* libguile/arrays.c: (scm_array_contents, scm_make_shared_array):
arrays are known of rank 1 so replace by scm_c_array_length.
Daniel Llorens [Tue, 9 Apr 2013 16:09:49 +0000 (18:09 +0200)]
Replace scm_c_generalized_vector_length in random.c
* libguile/random.c: (random:solid-sphere!): array is of known
rank 1, so use scm_c_array_length() instead.
Daniel Llorens [Thu, 18 Apr 2013 13:10:29 +0000 (15:10 +0200)]
Tests for array-copy!, empty case
* test-suite/tests/ramap.test: test array-copy! with empty destination.
Fix uses of constant array as destination.
Mark H Weaver [Thu, 6 Feb 2014 04:40:25 +0000 (23:40 -0500)]
Remove outdated documentation of LTDL_LIBRARY_PATH.
* doc/ref/guile-invoke.texi (Environment Variables): Remove
documentation of 'LTDL_LIBRARY_PATH'.
Mark H Weaver [Thu, 6 Feb 2014 04:25:32 +0000 (23:25 -0500)]
Document 'equal?' in list of R6RS incompatibilities.
* doc/ref/r6rs.texi (R6RS Incompatibilities): Mention that 'equal?'
may not terminate when applied to cyclic datums.
Andy Wingo [Wed, 5 Feb 2014 21:52:00 +0000 (22:52 +0100)]
Various VM stack management fixes
* libguile/vm.c (vm_increase_sp): New interface, to increase the SP to
some new level, possibly expanding the stack.
(vm_push_sp, vm_restore_sp): Intefaces to vm_increase_sp.
(vm_return_to_continuation): Don't throw an error if there's not
enough space; instead, expand.
(vm_reinstate_partial_continuation): Use the new helper.
(return_unused_stack_to_os): Avoid off-by-one error (sp points to
valid memory.)
(scm_call_n): Never write beyond the sp.
Mark H Weaver [Tue, 4 Feb 2014 19:21:13 +0000 (14:21 -0500)]
REPL Server: Remove unneeded error case in 'run-server'.
* module/system/repl/server.scm (run-server): Remove case that handled
'interrupt' exceptions specially. It is no longer needed since
e6c8e6047ed2e772cc4e1fb5ad4d389e5c616feb (REPL Server: Don't establish
a SIGINT handler.)
Mark H Weaver [Tue, 4 Feb 2014 17:08:48 +0000 (12:08 -0500)]
REPL Server: Redirect warnings to client socket.
* module/system/repl/server.scm (serve-client): Use parameterize.
Redirect warnings to client socket.
Mark H Weaver [Tue, 4 Feb 2014 04:09:23 +0000 (23:09 -0500)]
Don't check HAVE_ALARM, which no longer exists.
* libguile/scmsigs.c (scm_alarm): Remove check for HAVE_ALARM.
Conditionalize only on HAVE_DECL_ALARM.
Mark H Weaver [Tue, 4 Feb 2014 02:04:39 +0000 (21:04 -0500)]
Update Gnulib to
v0.1-77-gd9361da
Mark H Weaver [Mon, 3 Feb 2014 02:13:47 +0000 (21:13 -0500)]
define-values: Blackhole 'dummy'; work around lack of toplevel hygiene.
* module/ice-9/boot-9.scm (define-values): Use 'generate-temporaries' to
generate a fresh name for 'dummy', to work around the lack of hygiene
for macro-introduced toplevel identifiers. Blackhole 'dummy' to avoid
keeping garbage alive. Add more comments.
Andy Wingo [Sun, 2 Feb 2014 22:19:22 +0000 (23:19 +0100)]
Add VM and compiler support for calls to known procedures
* module/language/cps.scm ($callk): New expression type, for calls to
known labels. Part of "low CPS".
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm: Adapt call sites.
* libguile/vm-engine.c (call-label, tail-call-label): New instructions.
Renumber the rest; this is an ABI change.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* doc/ref/compiler.texi (CPS in Guile): Document $callk.
Andy Wingo [Sun, 2 Feb 2014 18:15:48 +0000 (19:15 +0100)]
Remove code to run GC more frequently as process image size increased
* libguile/gc.c: Remove code that would try to run GC more frequently as
the process image size was increasing. Before, it was often the case
that the heap was the main component of image size, but with
expandable stacks and statically allocated data that is no longer
true. Also, once scm_gc_register_allocation was incorporated, we
don't need to be so conservative any more. It seems this code was
simply causing too many gc's to run. Removing it improves some
micro-benchmarks; time will tell.
Andy Wingo [Sun, 2 Feb 2014 15:04:58 +0000 (16:04 +0100)]
Add thread-local lock-free, TLS-free freelists.
* libguile/bdw-gc.h: Remove a needless compatibility hack.
* libguile/gc-inline.h: New file, implementing thread-local freelists
providing faster allocation if we already have a scm_i_thread*
pointer. Based on gc_inline.h from libgc.
* libguile/threads.h (scm_i_thread): Add freelists here.
* libguile/threads.c (guilify_self_1, guilify_self_2): Initialize
freelists.
* libguile/vm.c: Include gc-inline.h.
* libguile/vm-engine.c: Rename current_thread to thread. Use
scm_inline_cons instead of scm_cons, scm_inline_cell instead of
scm_cell, and scm_inline_words instead of words.
Andy Wingo [Sun, 2 Feb 2014 10:43:03 +0000 (11:43 +0100)]
Add dead slot map cache
* libguile/vm.c (find_dead_slot_map, scm_i_vm_mark_stack): Use a little
cache for dead slot maps. Helps when marking very deep recursive
stacks.
Mark H Weaver [Sun, 12 Jan 2014 09:43:37 +0000 (04:43 -0500)]
Implement R7RS 'define-values'.
* module/ice-9/boot-9.scm (%define-values-arity-error): New procedure.
(define-values): New macro.
* doc/ref/api-binding.texi (Binding Multiple Values): Add docs.
* test-suite/tests/syntax.test: Add tests.
Mark H Weaver [Wed, 29 Jan 2014 07:20:01 +0000 (02:20 -0500)]
Implement SRFI-64 - A Scheme API for test suites.
* module/srfi/srfi-64.scm: New file.
* module/srfi/srfi-64/testing.scm: New file.
* module/Makefile.am: Add rule for srfi-64.go dependency on
srfi-64/testing.scm.
(SRFI_SOURCES): Add srfi/srfi-64.scm.
(NOCOMP_SOURCES): Add srfi/srfi-64/testing.scm.
* doc/ref/srfi-modules.texi (SRFI-64): New node.
* test-suite/tests/srfi-64.test: New file.
* test-suite/tests/srfi-64-test.scm: New file.
* test-suite/Makefile.am (SCM_TESTS): Add test-suite/tests/srfi-64.test.
(EXTRA_DIST): Add tests/srfi-64-test.scm.
Mark H Weaver [Mon, 27 Jan 2014 22:17:23 +0000 (17:17 -0500)]
Implement SRFI-43 Vector Library.
* module/srfi/srfi-43.scm: New file.
* module/Makefile.am (SRFI_SOURCES): Add module/srfi/srfi-43.scm.
* test-suite/tests/srfi-43.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add test-suite/tests/srfi-43.test.
* doc/ref/srfi-modules.texi (SRFI-43, SRFI-43 Constructors)
(SRFI-43 Predicates, SRFI-43 Selectors, SRFI-43 Iteration)
(SRFI-43 Searching, SRFI-43 Mutators, SRFI-43 Conversion): New nodes.
Mark H Weaver [Tue, 28 Jan 2014 22:44:22 +0000 (17:44 -0500)]
Compile numerical comparisons with more than 2 arguments to VM code.
* module/language/tree-il/primitives.scm (chained-comparison-expander):
New procedure.
(*primitive-expand-table*): Add primitive expanders for '<', '>',
'<=', '>=', and '='.
Andy Wingo [Fri, 31 Jan 2014 20:41:36 +0000 (21:41 +0100)]
Return unused parts of the stack to the OS
* libguile/vm.h (struct scm_vm): Reorder fields. Add "sp_max_since_gc"
field.
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME):
* libguile/vm.c (vm_return_to_continuation)
(vm_reinstate_partial_continuation, scm_call_n): In places where we
could increase the stack height, update sp_max_since_gc.
(vm_expand_stack): Relocate sp_max_since_gc on expansion.
(scm_bootstrap_vm): Record the page size using gnulib's getpagesize.
(return_unused_stack_to_os): New routine, run when marking stacks.
Andy Wingo [Fri, 31 Jan 2014 19:31:31 +0000 (20:31 +0100)]
Micro-optimization to scm_i_vm_mark_stack
* libguile/vm.c (scm_i_vm_mark_stack): Micro-optimize GC_MARK_AND_PUSH
to cache the plausible heap bounds locally.
Mark H Weaver [Fri, 31 Jan 2014 09:01:12 +0000 (04:01 -0500)]
Revert "Primitive expand numerical comparisons with more than 2 arguments."
This reverts commit
4dc4b86e858d391d20d0ea2551614a89fa3bd4d1.
Mark H Weaver [Tue, 28 Jan 2014 22:44:22 +0000 (17:44 -0500)]
Primitive expand numerical comparisons with more than 2 arguments.
* module/language/tree-il/primitives.scm (chained-comparison-expander):
New procedure.
(*primitive-expand-table*): Add primitive expanders for '<', '>',
'<=', '>=', and '='.
Mark H Weaver [Tue, 28 Jan 2014 21:54:10 +0000 (16:54 -0500)]
Add 'positive?' and 'negative?' as primitives.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*)
(*effect-free-primitives*): Add 'positive?' and 'negative?'.
(*primitive-expand-table*): Add primitive expanders for 'positive?'
and 'negative?'.
Andy Wingo [Tue, 28 Jan 2014 21:28:08 +0000 (22:28 +0100)]
Minor for-each speedup
* module/ice-9/boot-9.scm (for-each): Minor speedup by unrolling
tortoise/hare loop.
Andy Wingo [Tue, 28 Jan 2014 21:28:08 +0000 (22:28 +0100)]
Minor for-each speedup
* module/ice-9/boot-9.scm (for-each): Minor speedup by unrolling
tortoise/hare loop.
Andy Wingo [Tue, 28 Jan 2014 20:56:54 +0000 (21:56 +0100)]
Unnecessary VM_HANDLE_INTERRUPTS elision
* libguile/vm-engine.c: Remove VM_HANDLE_INTERRUPTS before entering a
subr or foreign call. The bytecode stub will have already done so
when entering the stub, and the return sequence handles doing so
before returning.
Andy Wingo [Tue, 28 Jan 2014 20:31:17 +0000 (21:31 +0100)]
Fix tracing
* module/system/vm/trace.scm (print-return): Remove frame argument.
(trace-calls-to-procedure, trace-calls-in-procedure): Adapt callers.
* module/system/vm/traps.scm (trap-in-procedure, trap-frame-finish):
(trap-calls-to-procedure): Since the pop continuation hook is now
called after the continuation is popped, we need to check the right
frame. Fixes tail-calls in the trace root, and probably other things.
Andy Wingo [Sun, 26 Jan 2014 19:55:04 +0000 (20:55 +0100)]
More precise stack marking via .guile.frame-maps section
* module/language/cps/slot-allocation.scm (lookup-dead-slot-map)
(allocate-slots): For each non-tail call in a function, compute the
set of slots that are dead after the function has begun the call.
* module/language/cps/compile-bytecode.scm (compile-fun): Emit the
`dead-slot-map' macro instruction for non-tail calls.
* module/system/vm/assembler.scm (<asm>): Add `dead-slot-maps' member.
(dead-slot-map): New macro-instruction.
(link-frame-maps, link-dynamic-section, link-objects): Write dead
slots information into .guile.frame-maps sections of ELF files.
* module/system/vm/elf.scm (DT_GUILE_FRAME_MAPS): New definition.
* libguile/loader.h:
* libguile/loader.c (DT_GUILE_FRAME_MAPS, process_dynamic_segment):
(load_thunk_from_memory, register_elf): Arrange to parse
DT_GUILE_FRAME_MAPS out of the dynamic section.
(find_mapped_elf_image_unlocked, find_mapped_elf_image): New helpers.
(scm_find_mapped_elf_image): Refactor.
(scm_find_dead_slot_map_unlocked): New interface.
* libguile/vm.c (scm_i_vm_mark_stack): Mark the hottest frame
conservatively, as before. Otherwise use the dead slots map, if
available, to avoid marking data that isn't live.
Andy Wingo [Fri, 24 Jan 2014 12:15:31 +0000 (13:15 +0100)]
Add NEWS for Guile 2.2
* NEWS: Update for 2.1.1.