summaryrefslogtreecommitdiff
path: root/libguile
AgeCommit message (Collapse)AuthorFilesLines
2014-01-27Arrays are not an array implementationlloda-array-cleanupDaniel Llorens3-13/+11
* libguile/bitvectors.c: match other uses of SCM_ARRAY_IMPLEMENTATION. * libguile/generalized-arrays.c (scm_is_array): don't use scm_i_array_implementation_for_obj on arrays. (scm_is_typed_array): idem. Use impl->get_handle instead of scm_array_get_handle to avoid calling scm_i_array_implementation_for_obj twice. * libguile/arrays.c: remove SCM_ARRAY_IMPLEMENTATION on scm_tc7_array type.
2014-01-27array-contents returns root for empty arrays with empty rootDaniel Llorens1-3/+2
This fixes a compiler issue where (uniform-array->bytevector #2f64()) failed because of the stricter definition of uniform-vector? on this branch. Perhaps it would be better if uniform-array->bytevector didn't require a contiguous argument. * libguile/arrays.c: (scm_array_contents): return the root regardless of the value of SCM_I_ARRAY_DIMS (ra)->inc. * test-suite/tests/arrays.test: check.
2014-01-27Preallocate index list in scm_array_index_map_xDaniel Llorens1-17/+17
* libguile/array-map.c - (scm_array_index_map_x): preallocate the index list instead of constructing it on each rank-1 iteration. - (ramap, rafe): use SCM_I_ARRAY_V just once.
2014-01-27Rename scm_t_array_handle.array to .rootDaniel Llorens9-23/+23
Globally rename this field (after shared-array-root), since it's not an array.
2014-01-27Match types used in arrays.c to struct field typesDaniel Llorens1-22/+24
* libguile/arrays.c - scm_shared_array_root: check for SCM_I_ARRAYP first. - scm_i_shap2ra: * check valid bounds in the '(lbnd ubnd) case. This makes (make-array 0 '(4 -3)) fail with a 'bad dimension' instead of with a 'wrong index' error. * use ssize_t for lbnd/ubnd/inc, not long. - scm_make_shared_array: use ssize_t for indices, not long. - scm_transpose_array: use size_t for ndim, not ulong. - scm_i_print_array: idem.
2014-01-27Bounds error in vector_handle_ref/set is implementation errorDaniel Llorens3-9/+5
* libguile/vectors.c: bounds are already checked unless impl is called directly, so don't check again. * libguile/strings.c, libguile/bitvectors.c: fix comments.
2014-01-27Don't use ASET in scm_array_index_map_xDaniel Llorens1-5/+5
* libguile/array-map.c: (scm_array_index_map_x): replace ASET by direct use of handle->impl.
2014-01-27In scm_ramapc, only check unrolled axes for emptinessDaniel Llorens1-69/+50
* libguile/array-map.c: (scm_ramapc) - Don't check emptiness while preparing ra0, but only after kroll is known, and only before kroll. len = 0 will be caught by the unrolled loop. - Use ra0 axis length in unroll check depth for rest args, not ra1's. - Recover early exit feature when cproc returns 0.
2014-01-27Fix scm_ramapc bugs with 0-inc arraysDaniel Llorens1-4/+5
* libguile/array-map.c: (scm_ramapc): Cannot flag empty on the product inc * dim * dim ... Check every dim. * test-suite/tests/ramap.test: Tests the 0-inc, non empty case for both array-map! and array-copy!.
2014-01-27Fix corner cases of scm_ramapcDaniel Llorens1-206/+151
* libguile/array-map.c - (scm_ramapc): mismatched axes limit unrollk (kroll). Reorganize the function to do all checking as we go. - (scm_ra_matchp): unused; remove. - (find_unrollk): inlined in scm_ramapc; remove. - (klen): inlined in scm_ramapc; remove. - (rafill): n is size_t. - (racp): n is size_t. Use n and not i0end to bound the loop. - (ramap): Use n and not i0end to bound the loop. This is needed for the rank 0 case to work with the new scm_ramapc, as inc may be set to 0 in that case. - (rafe): idem. * test-suite/tests/ramap.test - check that size mismatch prevents unrolling (matching behavior III) with both array-copy! and array-map!. - check that non-contiguous stride in non-ref args prevents unrolling (rank 2, discontinuous) with both array-copy! and array-map!. - check rank 0 cases with array-for-each, array-map!.
2014-01-27Rewrite scm_ramapc()Daniel Llorens1-128/+129
* libguile/array-map.c - (cind): replace by cindk, that operates only on the unrolled index set. - (klen): new function. - (make1array): take extra inc argument. - (scm_ramapc): rewrite to unroll as many axes as possible instead of just all or one. - (AREF): lbnd is known to be 0: remove. - (ASET): v is known to come from SCM_I_ARRAY_V; assume base, inc, lbnd. - (racp): use ssize_t instead of long for the indices. - (scm_array_index_map_x): build the index list at the last-but-one axis, then set the car of the last element, instead of building the list at the last axis. * test-suite/tests/ramap.test - add array-map! test with offset arguments.
2014-01-27Check more cases of array-contentsDaniel Llorens1-2/+2
* libguile/arrays.c: (scm_array_contents): fix comment. * test-suite/tests/arrays.test: add cases that depend on correct setting of CONTIGUOUS_FLAG.
2014-01-27Simplify ASET in array-map.cDaniel Llorens1-1/+1
* libguile/array-map.c: (ASET): this is only ever used with a true vector type, so remove use of inc/base/lbnd.
2014-01-27Inline ASET in array-index-map! for rank 1 argumentsDaniel Llorens1-8/+14
* libguile/array-map.c: (scm_array_index_map_x): branch to special case on rank 1, instead of !SCM_I_ARRAYP (ra). Inline ASET in this case.
2014-01-27Fix compilation errors when reading arrays at the replDaniel Llorens1-22/+20
* compile-assembly.scm - vector-fold2: handle rank 1 arrays, since this is called with the result of array-contents which need not be a vector. - dump-constants: fix uses of vector-fold2. Replace vector-length on result of array-contents by array-length. * libguile/arrays.c - scm_array_contents: branch cases not on scm_is_generalized_vector but on SCM_I_ARRAYP. Thus lbnd!=0, which could happen with scm_is_generalized_vector, never appears in the output. * test-suite/tests/arrays.test - tests for array-contents.
2014-01-27Factor out make1array() in scm_ramapc()Daniel Llorens1-96/+93
* libguile/array-map.c: (scm_ramapc): factor out vector->array conversion to aux function make1array.
2014-01-27Raw pointer loop in array-copy! for vector/vector caseDaniel Llorens1-5/+16
This special case improves (define a (make-array 1. 1000000 10)) (define b (make-array *unspecified* 1000000 10)) (define c (transpose-array (make-array *unspecified* 10 1000000) 1 0)) ,time (array-copy! a b) ,time (array-copy! a c) from 0.041598s / 0.072561 to 0.012164s / 0.041886s on a i7-3930K. * libguile/array-map.c: (racp): if both src and dst are on vectors, use the element pointers to do the copy.
2014-01-27Have array impl->vref, vset take SCM, not handlesDaniel Llorens7-65/+66
* libguile/array-handle.h - scm_i_t_array_ref, scm_i_t_array_set take SCM. - scm_array_handle_ref, scm_array_handle_set: pass h->array. * libguile/array-map.c - AREF, ASET, rafill, racp, ramap, rafe: pass storage vector SCM instead of handle. * libguile/bitvector.c - bitvector_handle_ref, bitvector_handle_set_x: take bitvector arg. * libguile/bytevectors.c - bv_handle_ref, bv_handle_set_x: take bytevector arg. - scm_i_print_bytevectors: don't use array handles. * libguile/deprecated.c - scm_generalized_vector_to_list: pass h.array. * libguile/strings.c - string_handle_ref, string_handle_set: take string arg. * libguile/uniform.c - scm_c_uniform_vector_ref, scm_c_uniform_vector_set_x: pass h.array. * libguile/vectors.c - vector_handle_ref, vector_handle_set: take vector arg.
2014-01-27Fix array map functions with empty argumentsDaniel Llorens1-77/+50
* 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.
2014-01-27Fix empty array bug in array-index-map!Daniel Llorens1-8/+15
* 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.
2014-01-27Avoid using array_handle fields in impl->vref/vsetDaniel Llorens2-6/+6
* libguile/bytevectors.c: (bv_handle_set_x, bv_handle_ref): get length and element type fields from the bytevector, not from the handle. * libguile/vectors.c: (vector_handle_set, vector_handle_ref): get length from the vector, not from the handle.
2014-01-27Remove undocumented casting behavior in srfi4 vector_elementsDaniel Llorens1-21/+1
* libguile/srfi-4.c: scm_##tag##vector_writable_elements: if the argument's type doesn't match the tag, throw type error.
2014-01-27Avoid array API in make-srfi-4-vectorDaniel Llorens3-26/+23
* libguile/bytevector.h: publish SCM_BYTEVECTOR_TYPE_SIZE, bytevector_ref_fns and bytevector_set_fns from libguile/bytevector.c. * libguile/bytevector.c: bv_handle_ref, bv_handle_set: prefer SCM_BYTEVECTOR_TYPE_SIZE to scm_array_handle_uniform_element_size. * libguile/srfi-4.c: scm_make_srfi_4_vector: don't use array handles.
2014-01-27Replace SCM_IMP in array-map.cDaniel Llorens1-1/+2
* libguile/array-map.c - scm_ramapc: check scm_array_contents with scm_is_false.
2014-01-27Fix comment in scm_array_get_handleDaniel Llorens1-9/+5
libguile/array-handle.c: (scm_array_get_handle): comment applies to either branch.
2014-01-27Don't bother with array handle in scm_c_array_rankDaniel Llorens1-8/+7
* libguile/generalized-arrays.c: (scm_c_array_rank): compute rank directly from object.
2014-01-27Use underlying vector implementation directly in array handlesDaniel Llorens6-61/+33
* libguile/array-handle.c - scm_array_get_handle: if the object is an array, point impl to the underlying vector instead of array impl, then fix the axes. Avoid calling scm_i_array_implementation_for_obj twice. * libguile/arrays.c - array_handle_ref, array_handle_set, array_get_handle: remove. * libguile/bitvectors.c, libguile/bytevectors.c, libguile/strings.c, libguile/vectors.c: fix base = 0 in the array handle. * libguile/vectors.c: (vector_handle_set, vector_handle_ref): do not use h->dims.
2014-01-27Match uniform_vector_elements with vector_elementsDaniel Llorens3-68/+43
* libguile/vectors.c - (scm_vector_writable_elements): allow any non-uniform rank 1 array, after the doc. Match the implementation with scm_uniform_vector_elements. - (scm_vector_elements): after the above. * libguile/uniform.c - (scm_uniform_vector_writable_elements): ditto for uniform rank 1 arrays. * libguile/sort.c - revert the changes in 7a6fd9, except for the argument type test; allow what scm_vector_(writable_)elements allows.
2014-01-27Fix rank-1 indirection in array-map.cDaniel Llorens1-2/+2
* array-map.c: (AREF, ASET): fix buggy indirection carried over from old generalized_vector-ref/set!.
2014-01-27Online documentation for vector-ref, vector-set!Daniel Llorens1-53/+35
* libguile/vectors.c: (scm_vector_ref, scm_vector_set!): embed the comments as documentation.
2014-01-27vector-length rejects non vector? argDaniel Llorens1-17/+15
* libguile/vectors.c - scm_c_vector_length: error if SCM_I_IS_VECTOR (v) fails. - scm_vector_length: Documentation for vector-length.
2014-01-27vector-ref, vector-set! reject non vector? argsDaniel Llorens1-33/+1
* libguile/vectors.c: (scm_c_vector_ref, scm_c_vector_set_x): throw type error if v is not vector?.
2014-01-27Identify scm_is_vector with scm_is_simple_vectorDaniel Llorens7-46/+46
This patch fixes the bug (vector-ref #1@1(1 2 3) 1) => 2. * libguile/vectors.c: (scm_is_vector): just as scm_is_simple_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_restricted_vector_sort_x: use scm_array_handle_writable_elements instead of scm_vector_writable_elements, to work with non-vector rank-1 array objects. - scm_sort_x: check for scm_is_array instead of scm_is_vector. Rank check is in restricted_vector_sort_x. - scm_sort: ditto. - scm_stable_sort_x: like scm_restricted_vector_sort_x. - scm_stable_sort: like scm_sort. * 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.
2014-01-27For uniform vectors SCM_I_ARRAYP can't be trueDaniel Llorens1-6/+5
This fixes an inconsistency where uniform-vector? of a shared array could be true but -ref operations failed to account correctly for lbnd. * libguile/uniform.c - scm_is_uniform_vector: SCM_I_ARRAYP disqualifies obj as uniform vector. - scm_c_uniform_vector_length: lbnd is known 0, so don't use it. - scm_c_uniform_vector_ref: lbnd/base/inc are known to be 0/0/1. - scm_c_uniform_vector_set_x!: idem. - scm_uniform_vector_writable_elements: check uvec's type. * test-suite/tests/arrays.test - group the exception types at the top. - check that uniform-vector functions do not accept general arrays.
2014-01-27Fix bad uses of base and lbnd on rank 1 arraysDaniel Llorens4-34/+25
* 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.
2014-01-27Don't use scm_is_generalized_vector in transpose-arrayDaniel Llorens1-8/+8
* 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.
2014-01-27Don't use scm_is_generalized_vector in shared-array-rootDaniel Llorens1-5/+6
* libguile/arrays.c: (scm_shared_array_root): replace check for scm_is_generalized_vector.
2014-01-27Remove unnecessary conditions in array constructorsDaniel Llorens1-3/+4
* libguile/arrays.c: (scm_make_type_array, scm_from_contigous_typed_array, scm_from_contigous_array): Remove conditions known to be true.
2014-01-27Remove generalized-vectors.h includesDaniel Llorens2-2/+0
* libguile/srfi-4.c, libguile/uniform.h: ditto.
2014-01-27Replace scm_c_generalized_vector_length in arrays.cDaniel Llorens1-5/+5
* libguile/arrays.c: (scm_array_contents, scm_make_shared_array): arrays are known of rank 1 so replace by scm_c_array_length.
2014-01-27Replace scm_c_generalized_vector_length in random.cDaniel Llorens1-2/+2
* libguile/random.c: (random:solid-sphere!): array is of known rank 1, so use scm_c_array_length() instead.
2014-01-27Don't use generalized-vector in array-map.c (II)Daniel Llorens1-25/+24
* 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.
2014-01-27Don't use generalized-vector in array-map.c (I)Daniel Llorens1-21/+37
* array-map.c: (AREF, ASET): new internal functions replace scm_c_generalized_vector_ref/set. These remove a redundant check for rank in the generalized_vector set.
2014-01-27Don't use generalized-vector functions in uniform.cDaniel Llorens1-10/+31
* 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): inline length computation. This removes a redundant rank check. - (scm_c_uniform_vector_ref): inline impl->vref use. This removes a redundant rank check. - (scm_c_uniform_vector_set): inline impl->vset use. This removes a redundant rank check. - (scm_uniform_vector_writable_elements): replace scm_generalized_vector_get_handle by scm_array_get_handle. * test-suite/test/arrays.test - rename uniform-vector-ref block to uniform-vector. - exercise uniform-vector-length and shared arrays remaining uniform.
2014-01-27Inline generalized-vector calls in array_handle_ref/setDaniel Llorens1-4/+14
* libguile/arrays.c: (array-handle-ref, array-handle-set): Ditto.
2014-01-26More precise stack marking via .guile.frame-maps sectionAndy Wingo3-26/+154
* 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.
2014-01-21Merge branch 'stable-2.0'Mark H Weaver2-11/+31
Conflicts: libguile/read.c test-suite/tests/web-response.test
2014-01-20Fix (port-conversion-strategy #f).Mark H Weaver1-2/+0
Reported by Doug Evans <xdje42@gmail.com>. * libguile/ports.c (scm_port_conversion_strategy): Don't validate that 'port' is an open port until after the (port == #f) case has been handled.
2014-01-17Arrange so that 'file-encoding' does not truncate the encoding name.Ludovic Courtès1-7/+23
Fixes <http://bugs.gnu.org/16463>. Reported by Sree Harsha Totakura <sreeharsha@totakura.in>. * libguile/read.c (ENCODING_NAME_MAX_SIZE): New macro. (SCM_ENCODING_SEARCH_SIZE): Change to 500 + ENCODING_NAME_MAX_SIZE. (scm_i_scan_for_encoding): Return NULL if there's less than ENCODING_NAME_MAX_SIZE bytes once "coding: *" has been read. * test-suite/tests/coding.test ("line comment")["http://bugs.gnu.org/16463"]: New test.
2014-01-15Custom binary input ports sanity-check the return value of 'read!'.Ludovic Courtès1-3/+7
* libguile/r6rs-ports.c (cbip_fill_input): Throw an exception when C_OCTETS is greater than what was requested. * test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary input port 'read!' returns too much"]: New test.