* libguile/sort.c (sort!, sort, restricted-vector-sort!, sorted?):
Support arrays of rank 1, whatever the type.
* libguile/quicksort.i.c: Fix accessors to handle typed arrays.
* test-suite/tests/sort.test: Test also with typed arrays.
* libguile/array-map.c (scm_array_for_each_cell): Bail out early if any
of the sizes is zero. Pack ais at the end of the fake stack.
* test-suite/tests/array-map.test: Add regression test.
This patch results in a 20%-40% speedup in the > 1 argument cases of
the following microbenchmarks:
(define A (make-shared-array #0(1) (const '()) #e1e7))
; 1, 2, 3 arguments.
(define a 0) ,time (array-for-each (lambda (b) (set! a (+ a b))) A)
(define a 0) ,time (array-for-each (lambda (b c) (set! a (+ a b c))) A A)
(define a 0) ,time (array-for-each (lambda (b c d) (set! a (+ a b c d))) A A A)
(define A (make-shared-array (make-array 1) (const '()) #e1e7))
(define B (make-shared-array #0(1) (const '()) #e1e7))
; 1, 2, 3 arguments.
,time (array-map! A + B)
,time (array-map! A + B B)
,time (array-map! A + B B B)
* libguile/array-map.c (scm_ramap): note on cproc arguments.
(rafill): assume that dst's lbnd is 0.
(racp): assume that src's lbnd is 0.
(ramap): assume that ra0's lbnd is 0. When there're more than two
arguments, compute the array handles before the loop. Allocate the arg
list once and reuse it in the loop.
(rafe): like rafe, when there's more than one argument.
(AREF, ASET): remove.
* module/system/vm/assembler.scm (simple-uniform-vector?): array-length
fails for rank 0 arrays; fix the shape condition.
* test-suite/tests/arrays.test: test reading of #0f64(x) in compilation
context.
SCM_I_ARRAY_FLAG_CONTIGUOUS (arrays.h) was set by all array-creating
functions (make-typed-array, transpose-array, make-shared-array) but it
was only used by array-contents, which needed to traverse the dimensions
anyway.
* libguile/arrays.c (scm_make_typed_array,
scm_from_contiguous_typed_array): don't set the contiguous flag.
(scm_transpose_array, scm_make_shared_array): don't call
scm_i_ra_set_contp.
(scm_array_contents): inline scm_i_ra_set_contp() here. Adopt uniform
type check order. Remove redundant comments.
(scm_i_ra_set_contp): remove.
* libguile/arrays.h: note.
* test-suite/tests/arrays.test: test array-contents with rank 0 array.
* libguile/arrays.c (scm_shared_array_root): adopt uniform check order.
(scm_shared_array_offset, scm_shared_array_increments): use the array
fields directly just as scm_shared_array_root does.
* test-suite/tests/arrays.test: tests for shared-array-offset,
shared-array-increments.
* module/texinfo/html.scm (itemize, acronym, tag-replacements, rules):
Fix HTML serialization of @itemize and @acronym. Fixes#21772.
* test-suite/tests/texinfo.html.test: New file.
* test-suite/Makefile.am: Add new file.
* libguile/filesys.c (scm_i_relativize_path): Canonicalize the file
names elements that we will be using as prefixes. Fixes the case
where a load path contains a relative file name: #19540.
* test-suite/tests/ports.test ("%file-port-name-canonicalization"): Add
tests that elements of the load path are canonicalized.
* doc/ref/vm.texi (Top-Level Environment Instructions): Update
documentation.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, sadly.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* libguile/vm-engine.c (define!): Change to store variable in dst slot.
* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
define! change.
* module/language/cps/effects-analysis.scm (current-module): Fix define!
effects. Incidentally here was the bug: in Guile 2.2 you can't have
effects on different object kinds in one instruction, without
reverting to &unknown-memory-kinds.
* test-suite/tests/compiler.test ("regression tests"): Add a test.
Also pinging this thread with a (very slightly) updated patch. :-)
[2. text/x-diff; 0001-Hashtable-hash-function-returns-f-on-eq-and-eqv-tabl.patch]
From 17599f6ce7ba0beb100e80455ff99af07333d871 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
<taylanbayirli@gmail.com>
Date: Tue, 21 Jun 2016 00:23:29 +0200
Subject: [PATCH] Hashtable-hash-function returns #f on eq and eqv tables.
* module/rnrs/hashtables.scm (r6rs:hashtable)[type]: New field.
(r6rs:hashtable-type): New procedure.
* test-suite/tests/r6rs-hashtables.test: Add related tests.
* module/rnrs/arithmetic/fixnums.scm (fxcopy-bit, fxbit-field)
(fxcopy-bit-field, fxarithmetic-shift)
(fxarithmetic-shift-left, fx-arithmetic-shift-right)
(fxrotate-bit-field, fxreverse-bit-field): Enforce range on amount by
which to shift. Fixes#14917.
* test-suite/tests/r6rs-arithmetic-fixnums.test ("fxarithmetic-shift-left"):
Update test to not shift left by a negative amount.
* module/language/tree-il/peval.scm (peval): Don't
inline (call-with-values foo (lambda (x) exp)) to (let ((x (foo)))
exp). The idea is that call-with-values sets up an explicit context
in which we are requesting an explicit return arity, and that dropping
extra values when there's not a rest argument is the wrong thing.
Fixes#13966.
* test-suite/tests/peval.test ("partial evaluation"): Update test.
* libguile/bytevectors.c (bytevector_large_set): Fix computation of
value size in words.
* test-suite/tests/bytevectors.test: Add test.
Thanks to Ben Rocer <fleabyte@mail.com> for the bug report and fix.
* module/ice-9/suspendable-ports.scm: Rename from ice-9/sports.scm, and
adapt module names. Remove exports that are not related to the
suspendable ports facility; we want people to continue using the port
operations from their original locations. Add put-string to the
replacement list.
* module/Makefile.am: Adapt to rename.
* test-suite/tests/suspendable-ports.test: Rename from sports.test.
* test-suite/Makefile.am: Adapt to rename.
* module/ice-9/textual-ports.scm (unget-char, unget-string): New
functions.
* doc/ref/api-io.texi (Textual I/O, Simple Output): Flesh out
documentation.
(Line/Delimited): Undocument write-line, read-string, and
read-string!. This is handled by (ice-9 textual-ports).
(Bytevector Ports): Fix duplicated section.
(String Ports): Move the note about encodings down to the end.
(Custom Ports): Add explanatory text. Remove mention of C functions;
they should use the C port interface.
(Venerable Port Interfaces): Add text, and make documentation refer to
recommended interfaces.
(Using Ports from C): Add documentation.
(Non-Blocking I/O): Document more fully and adapt to suspendable-ports
name change.
* module/ice-9/sports.scm: Export read-line, %read-line, and
read-delimited. Add these latest three to install-sports!, and fix
install-sports! if the current module isn't (ice-9 sports).
* test-suite/tests/sports.test: Use install-sports! instead of lexical
bindings, to allow us to nicely frob bindings in rdelim. Include
rdelim tests.
Fixes <http://bugs.gnu.org/23421>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.
* module/web/http.scm (parse-rfc-822-date): Add two clauses for hours
with a leading space.
* test-suite/tests/web-http.test ("general headers"): Add two tests.
Fixes <http://bugs.gnu.org/22273>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.
* module/web/http.scm (read-header-line): New procedure.
(read-response-line): Use it instead of 'read-line*'.
* test-suite/tests/web-http.test ("read-response-line"): Add test.
* module/web/response.scm (make-delimited-input-port)[close]: Replace
erroneous self-recursive call with a call to 'close-port'.
* test-suite/tests/web-response.test ("example-1")["response-body-port +
close"]: New test.
When encountering the #!r6rs directive, apply the appropriate reader
settings to the port.
* libguile/read.scm (read-string-as-list): New helper procedure.
(scm_read_shebang): Set reader options implied by the R6RS syntax
upon encountering the #!r6rs directive.
* test-suite/tests/reader.test (per-port-read-options): Add tests for
the #!r6rs directive.
Originally applied to stable-2.0 as "Fix bytevector and custom binary
ports to actually use ISO-8859-1 encoding.", commit
d574d96f87. Related to
http://bugs.gnu.org/20200, which was introduced in in stable-2.0 but
never existed on master. Test modified by Andy Wingo to add a
`force-output' where needed.
* test-suite/tests/r6rs-ports.test: Add tests.
Fixes <http://bugs.gnu.org/19646>.
Reported by John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>.
* test-suite/tests/posix.test ("affinity")["setaffinity"]: Wrap in
'catch' and throw 'unresolved upon ENOSYS.
* libguile/ports.c (scm_getc): If the port conversion strategy is
'error, signal an error before advancing the read pointer. This is a
change from previous behavior; before, we advanced the read pointer
under an understanding that that was what R6RS required. But, that
seems to be not the case.
* test-suite/tests/ports.test ("string ports"): Update decoding-error
tests to assume that read-char with an error doesn't advance the read
pointer.
* test-suite/tests/rdelim.test ("read-line"): Likewise.
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface): In Guile, a
module's public interface is just another module, and that means that
it can import other modules as well. Allow for R6RS modules that
import module whose interfaces import other modules to access all
visible bindings.
* test-suite/tests/rnrs-libraries.test ("import features"): Update
test.
* libguile/ports.h (struct scm_t_port_buffer): New data type.
(struct scm_t_port): Refactor to use port buffers instead of
implementation-managed read and write pointers. Add "read_buffering"
member.
(SCM_INITIAL_PUTBACK_BUF_SIZE, SCM_READ_BUFFER_EMPTY_P): Remove.
(scm_t_ptob_descriptor): Rename "fill_input" function to "read", and
take a port buffer, returning void. Likewise "write" takes a port
buffer and returns void. Remove "end_input"; instead if there is
buffered input and rw_random is true, then there must be a seek
function, so just seek back if needed. Remove "flush"; instead all
calls to the "write" function implicitly include a "flush", since the
buffering happens in the generic port code now. Remove "setvbuf", but
add "get_natural_buffer_sizes"; instead the generic port code can
buffer any port.
(scm_make_port_type): Adapt to read and write prototype changes.
(scm_set_port_flush, scm_set_port_end_input, scm_set_port_setvbuf):
Remove.
(scm_slow_get_byte_or_eof_unlocked)
(scm_slow_get_peek_or_eof_unlocked): Remove; the slow path is to call
scm_fill_input.
(scm_set_port_get_natural_buffer_sizes): New function.
(scm_c_make_port_buffer): New internal function.
(scm_port_non_buffer): Remove. This was a function for
implementations that is no longer needed. Instead open with BUF0 or
use (setvbuf port 'none).
(scm_fill_input, scm_fill_input_unlocked): Return the filled port
buffer.
(scm_get_byte_or_eof_unlocked, scm_peek_byte_or_eof_unlocked): Adapt
to changes in buffering and EOF management.
* libguile/ports.c: Adapt to port interface changes.
(initialize_port_buffers): New function, using the port mode flags to
set up appropriate initial buffering for all ports.
(scm_c_make_port_with_encoding): Create port buffers here instead of
delegating to implementations.
(scm_close_port): Flush the port if needed instead of delegating to
the implementation.
* libguile/filesys.c (set_element): Adapt to buffering changes.
* libguile/fports.c (fport_get_natural_buffer_sizes): New function,
replacing scm_fport_buffer_add.
(fport_write, fport_read): Update to let the generic ports code do the
buffering.
(fport_flush, fport_end_input): Remove.
(fport_close): Don't flush in a dynwind; that's the core ports' job.
(scm_make_fptob): Adapt.
* libguile/ioext.c (scm_redirect_port): Adapt to buffering changes.
* libguile/poll.c (scm_primitive_poll): Adapt to buffering changes.
* libguile/ports-internal.h (struct scm_port_internal): Remove
pending_eof flag; this is now set on the read buffer.
* libguile/r6rs-ports.c (struct bytevector_input_port): New type. The
new buffering arrangement means that there's now an intermediate
buffer between the bytevector and the user of the port; this could
lead to a perf degradation, but on the other hand there are some other
speedups enabled by the buffering refactor, so probably the memcpy
cost is dwarfed by the cost of the other parts of the ports
machinery.
(make_bytevector_input_port, bytevector_input_port_read):
(bytevector_input_port_seek, initialize_bytevector_input_ports): Adapt
to new buffering arrangement.
(struct custom_binary_port): Remove read buffer, as Guile handles that
now.
(custom_binary_input_port_setvbuf): Remove; now handled by Guile.
(make_custom_binary_input_port, custom_binary_input_port_read)
(initialize_custom_binary_input_ports): Adapt.
(scm_get_bytevector_some): Adapt to new EOF management.
(scm_t_bytevector_output_port_buffer): Hold on to the underlying port,
so we can flush it if it's open.
(make_bytevector_output_port, bytevector_output_port_write):
(bytevector_output_port_seek): Adapt.
(bytevector_output_port_procedure): Flush the port as appropriate, so
that we get all the bytes.
(make_custom_binary_output_port, custom_binary_output_port_write):
Adapt.
(make_transcoded_port): Don't muck with buffering.
(transcoded_port_write): Simply forward the write to the underlying
port.
(transcoded_port_read): Likewise.
(transcoded_port_close): No need to flush.
(initialize_transcoded_ports): Adapt.
* libguile/read.c (scm_i_scan_for_encoding): Adapt to buffering
changes.
* libguile/rw.c (scm_write_string_partial): Adapt to buffering changes.
* libguile/strports.c: Adapt to the fact that we don't manage the
buffer. Probably room for speed improvements here...
* libguile/vports.c (soft_port_get_natural_buffer_sizes): New function.
Adapt the rest of the file for the new buffering regime.
* test-suite/tests/r6rs-ports.test ("8.2.10 Output ports"): Custom
binary output ports need to be flushed before you can rely on the
write! procedure having been called. Add necessary flush-port
invocations.
("8.2.6 Input and output ports"): Transcoded ports now have an
internal buffer by default. This test checks that the characters are
transcoded one at a time, so to do that, call setvbuf on the
transcoded port to remove the buffer.
* test-suite/tests/web-client.test (run-with-http-transcript): Fix for
different flushing regime on soft ports. (The vestigial flush
procedure is now called after each write, which is not what the test
was expecting.)
* test-suite/standalone/test-scm-c-read.c: Update for changes to the C
interface for defining port types.
* doc/ref/api-io.texi (Ports): Update to discuss buffering in a generic
way, and to remove a hand-wavey paragraph describing string ports as
"interesting and powerful".
(Reading, Writing): Remove placeholder comments. Document
`scm_lfwrite'.
(Buffering): New section.
(File Ports): Link to buffering.
(I/O Extensions): Join subnodes into parent and describe new API,
including buffering API.
* doc/ref/posix.texi (Ports and File Descriptors): Link to buffering.
Remove unread-char etc, as they are documented elsewhere.
(Pipes, Network Sockets and Communication): Link to buffering.