1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 06:20:30 +02:00
Commit graph

21772 commits

Author SHA1 Message Date
Andy Wingo
7af8bb6bd0 Add machinery to disable ragged-stop marking
We'll need to disable the optimization that mutators mark their own
stacks once we support evacuation.
2022-07-20 14:40:47 +02:00
Andy Wingo
e4342f6c45 Add helper for yielding in a spinlock 2022-07-20 14:40:47 +02:00
Andy Wingo
52166fe286 Add gc_edge data structure
Less casting in user programs, and it's a step on the way to evacuation
in whippet.
2022-07-20 14:40:47 +02:00
Andy Wingo
808d365f4b We identify empty blocks lazily now 2022-07-20 14:40:47 +02:00
Andy Wingo
bc73c5ad02 Whitespace fix 2022-07-20 14:40:47 +02:00
Andy Wingo
157d40466b mark_space_reacquire_memory updates pending_unavailable_bytes 2022-07-20 14:40:47 +02:00
Andy Wingo
33a3af2c73 Large object space properly acquires blocks from mark space
If the mutator finds completely empty blocks, it puts them on the side.
The large object space acquires empty blocks, sweeping if needed, and
causes them to be unmapped, possibly causing GC.
2022-07-20 14:40:47 +02:00
Andy Wingo
71b656bca4 When sweeping, return empty blocks to global freelist
This will facilitate management of overhead for defragmentation as well
as blocks to unmap, for compensating large object allocations.
2022-07-20 14:40:47 +02:00
Andy Wingo
8f06b914b0 Refactor to allow "next" pointer embedded in block summary 2022-07-20 14:40:47 +02:00
Andy Wingo
7d80d45c79 Rename mark-sweep.h to whippet.h 2022-07-20 14:40:44 +02:00
Ludovic Courtès
8c976c6a1f Update NEWS.
* NEWS: Update.
2022-07-04 11:52:14 +02:00
Ludovic Courtès
abd39f3328 Define IPPROTO_IPV6 and IPV6_V6ONLY.
* libguile/socket.c (scm_init_socket): Define IPPROTO_IPV6 and IPV6_V6ONLY.
* doc/ref/posix.texi (Network Sockets and Communication): Document them.
2022-07-04 11:49:31 +02:00
Ludovic Courtès
6da4be170a Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.
* libguile/socket.c (scm_init_socket): Define IN6ADDR_ANY and IN6ADDR_LOOPBACK.
* doc/ref/posix.texi (Network Address Conversion): Document them.
2022-07-04 11:39:14 +02:00
Christopher Baines
baa1424335 web: Don't hide missing data in the chunked input port.
This port is of limited use if it cannot be used reliably. Rather than
behaving as if the input has finished when it ends unexpectedly, instead
raise an exception.

* module/web/http.scm (make-chunked-input-port): Raise an exception on
premature termination.
(&chunked-input-ended-prematurely): New exception type.
(chunked-input-ended-prematurely-error?): New procedure.
* test-suite/tests/web-http.test (pass-if-named-exception): Rename to
pass-if-named-exception.
(pass-if-named-exception): New syntax.
("Exception on premature chunk end"): New test for this behaviour.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-07-04 11:22:13 +02:00
Christopher Baines
9a3353a993 web: Handle ending CRLF (\r\n) for chunked input and output ports.
The chunked transfer encoding specifies the chunked body ends with
CRLF. This is in addition to the CRLF at the end of the last chunk, so
there should be CRLF twice at the end of the chunked body:

  https://datatracker.ietf.org/doc/html/rfc2616#section-3.6.1

* module/web/http.scm (make-chunked-input-port): Read two extra bytes at
the end of the chunked input.
(make-chunked-output-port): Write the missing \r\n when closing the
port.
* test-suite/tests/web-http.test (chunked encoding): Add missing \r\n to
test data.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-07-04 11:22:11 +02:00
Aleix Conchillo Flaqué
a84d8f6473 web: send capitalized authorization header scheme
* module/web/http.scm (write-credentials): capitalize authorization
header scheme. The standard allows the scheme to be case-insensitive,
however most libraries out there expect the scheme to be capitalized,
which is what it is actually used in RFC
docs (e.g. https://datatracker.ietf.org/doc/html/rfc7617#section-2). Some
libraries even reject lowercase scheme making Guile incompatible.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-07-04 11:16:36 +02:00
Ludovic Courtès
7e048c6c51 Update NEWS.
* NEWS: Update.
2022-06-16 10:06:32 +02:00
Jessica Tallon
4456245753 Add missing #:modules argument for coverage-data->lcov.
The code coverage function `coverage-data->lcov` has a documented
`modules` argument, however that was missing from the source. I have
added it so when supplied it only converts the coverage data for the
supplied modules. If not supplied it defaults the old behavour of
including all the modules currently loaded.

* module/system/vm/coverage.scm (coverage-data->lcov): Add #:modules
parameter and honor it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-06-16 10:01:06 +02:00
Liliana Marie Prikler
01b686b701 Allow null bytes in UNIX sockets.
The current socket address constructors all assume, that there are no
null bytes in the socket path.  This assumption does not hold in Linux,
which uses an initial null byte to demarcate abstract sockets and
ignores all further null bytes [1].

[1] https://www.man7.org/linux/man-pages/man7/unix.7.html

* libguile/sockets.c (scm_fill_sockaddr)[HAVE_UNIX_DOMAIN_SOCKETS]:
Use scm_to_locale_stringn to construct c_address.
Use memcpy instead of strcpy and calculate size directly instead of
using SUN_LEN.
(_scm_from_sockaddr): Copy the entire path up to the limits imposed by
addr_size.
* test-suite/tests/00-socket.test: ("make-socket-address"): Add case for
abstract unix sockets.
("AF_UNIX/SOCK_STREAM"): Add abstract socket versions of bind, listen,
connect and accept.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-06-16 09:54:29 +02:00
Taylor R Campbell
e4e8afd6c8 Allow empty vendor string in GNU target triplets.
NetBSD and pkgsrc have been using an empty vendor string since the
mid-'90s, such as x86_64--netbsd.  pkgsrc has been carrying around a
workaround just the guile build for a long time.  (Before that,
NetBSD omitted the vendor altogether, so if x86_64 existed then it
might have been `x86_64-netbsd', but that caused more problems.)
This change makes Guile accept an empty vendor string so workarounds
are no longer necessary.

* module/system/base/target.scm (validate-target): Allow empty vendor
string in GNU target triplets.
* test-suite/tests/cross-compilation.test ("cross-compilation"): Add
tests for "x86_64--netbsd".

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2022-06-16 09:42:05 +02:00
Mihail Iosilevich
158da6966b Allow (library ...) form in cond-expand inside R7RS define-library.
Guile (3.0.8) reports a compilation error when cond-expand tries to
check existence of a missing library:

    scheme@(guile-user)> (define-library (test)
                           (cond-expand
                            ((library (scheme sort))
                             (import (scheme sort)))))
    While compiling expression:
    no code for module (scheme sort)

It looks like bug #40252 was not fully eliminated.

Also, (library ...) cannot handle module names like (srfi 1), though
(import (srfi 1)) works fine. For example, this code fails:

    scheme@(guile-user)> (define-library (test)
                           (cond-expand
                            ((library (srfi 1))
                             (import (srfi 1)))))
    While compiling expression:
    In procedure symbol->string: Wrong type argument in position 1
    (expecting symbol): 1

There are probably other cases when (library ...) and (import ...) does
not work identically: (library ...) uses resolve-interface while
(import ...) uses resolve-r6rs-interface.

This patch fixes both issues.

* module/ice-9/r7rs-libraries.scm (define-library): Replace
'resolve-interface' call by 'resolve-r6rs-interface', wrapped in
'cond-expand'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-06-16 09:36:31 +02:00
Ludovic Courtès
e8a41aee29 'module-define!' honors the 'module' parameter.
* module/ice-9/boot-9.scm (module-define!): In 'module-add!' call, pass
MODULE rather than (current-module).
2022-06-16 09:31:36 +02:00
Ludovic Courtès
64449a835a 'connect' handles EAGAIN like EINPROGRESS.
* libguile/socket.c (scm_connect): Handle EAGAIN the same way as
EINPROGRESS (connect(2) returns EAGAIN for Unix-domain sockets and
socketpairs).
2022-06-16 09:31:36 +02:00
Helmut Eller
f31fb0044d Fix some problems with callr and calli.
The problem with callr is that the register that contains the
function to be called, can be overwritten by the logic that moves
the values into argument registers.  To fix this, I added a
get_callr_temp function that should return a platform specific
register that is not used to pass arguments.  For Aarch64/Arm the
link registers seems to work; for Amd64/i686 the RAX register.
The function/tmp pair becomes an additional argument to the
parallel assigment; this way the original function register is not
accidentally overwritten.

The problem with calli is that it may not have enough temp
registers to move arguments.  The windmill paper says that at most
one temporary register is needed for the parallel assignment.
However, we also need a temp register for mem-to-mem moves.  So it
seems that we need a second temporary.  For Amd64/i686 we have
only one temporary GPR and one temporary FPR.  To fix this, I
modified the algorithm from the paper a bit: we perform the
mem-to-mem moves before the other moves.  Later when we need the
temp to break cycles, there shouldn't be any mem-to-mem moves
left.  So we should never need two temps at the same time.

* lightening/lightening.c: (get_callr_temp): New function; need
for each platform.
(prepare_call_args): Include the function/callr_temp pair in the
arguments for the parallel assignment.

* lightening/x86.c, lightening/arm.c, lightening/aarch64.c
(get_callr_temp): Implementation for each platform.

* lightening/arm.c (next_abi_arg): Fix the stack size for doubles.

* tests/call_10_2.c, tests/callr_10.c: New tests.
* tests/regarrays.inc: New file. Common code between the above two
tests that would be tedious to duplicate.
2022-06-08 16:20:42 +02:00
Andy Wingo
061d92d125 Update README 2022-05-15 22:06:41 +02:00
Andy Wingo
69d7ff83dd More wording 2022-05-11 22:29:37 +02:00
Andy Wingo
c39e26159d Some README updates 2022-05-11 22:25:09 +02:00
Andy Wingo
7ac0b5bb4b More precise heap size control
No longer clamped to 4 MB boundaries.  Not important in production but
very important for comparing against other collectors.
2022-05-11 21:19:26 +02:00
Andy Wingo
fa3b7bd1b3 Add global yield and fragmentation computation 2022-05-09 22:03:50 +02:00
Andy Wingo
3bc81b1654 Collect per-block statistics
This will let us compute fragmentation.
2022-05-09 21:46:27 +02:00
Andy Wingo
7461b2d5c3 Be more permissive with heap multiplier
Also if there's an error, print the right argument
2022-05-06 15:08:24 +02:00
Andy Wingo
815f206e28 Optimize sweeping
Use uint64 instead of uintptr when bulk-reading metadata bytes.  Assume
that live objects come in plugs rather than each object being separated
by a hole.  Always bulk-load metadata bytes when measuring holes, and be
less branchy.  Lazily clear hole bytes as we allocate.  Add a place to
record lost space due to fragmentation.
2022-05-06 15:07:43 +02:00
Andy Wingo
0d0d684952 Mark-sweep does bump-pointer allocation into holes
Instead of freelists, have mark-sweep use the metadata byte array to
identify holes, and bump-pointer allocate into those holes.
2022-05-01 17:07:30 +02:00
Andy Wingo
f51e969730 Use atomics when sweeping
Otherwise, there is a race with concurrent marking, though possibly just
during the ragged stop.
2022-05-01 16:23:10 +02:00
Andy Wingo
2a68dadf22 Accelerate sweeping
Read a word at a time from the mark byte array.  If the mark word
doesn't correspond to live data there will be no contention and we can
clear it with one write.
2022-05-01 16:09:20 +02:00
Andy Wingo
ce69e9ed4c Record object sizes in metadata byte array
This will let us avoid paging in objects when sweeping.
2022-05-01 15:19:13 +02:00
Andy Wingo
3a04078044 mark-sweep uses all the metadata bits
Don't require that mark bytes be cleared; instead we have rotating
colors.  Beginnings of support for concurrent marking, pinning,
conservative roots, and generational collection.
2022-05-01 15:04:21 +02:00
Andy Wingo
f97906421e Sweep by block, not by slab
This lets mutators run in parallel.  There is a bug currently however
with a race between stopping mutators marking their roots and other
mutators still sweeping.  Will fix in a followup.
2022-05-01 14:46:36 +02:00
Andy Wingo
83bf1d8cf3 Fix bug ensuring zeroed memory
If the granule size is bigger than a pointer, we were leaving the first
granule uncleared.
2022-05-01 14:45:25 +02:00
Andy Wingo
7fc2fdbbf7 Use block-structured heap for mark-sweep
There are 4 MB aligned slabs, divided into 64 KB pages.  (On 32-bit this
will be 2 MB ad 32 kB).  Then you can get a mark byte per granule by
slab plus granule offset.  The unused slack that would correspond to
mark bytes for the blocks used *by* the mark bytes is used for other
purposes: remembered sets (not yet used), block summaries (not used),
and a slab header (likewise).
2022-04-27 22:31:09 +02:00
Andy Wingo
bea9ce883d mark-sweep collector uses 16 byte granules, packed small freelists
Probably the collector should use 8 byte granules on 32-bit but for now
we're working on 64-bit sizes.  Since we don't (and never did) pack
pages with same-sized small objects, no need to make sure that small
object sizes fit evenly into the medium object threshold; just keep
packed freelists.  This is a simplification that lets us reclaim the
tail of a region in constant time rather than looping through the size
classes.
2022-04-20 10:54:19 +02:00
Andy Wingo
adc4a7a269 Add large object space to mark-sweep collector
This will let us partition the mark space into chunks of 32 or 64 kB, as
we won't need to allocate chunk-spanning objects.  This will improve
sweeping parallelism and is a step on the way to immix.
2022-04-18 21:20:00 +02:00
Andy Wingo
3ee2009de9 Move a lot of mark_space state to heap 2022-04-18 20:56:48 +02:00
Andy Wingo
119e273fa4 Rename mark-sweep "markers" to "tracers"
There could be other reasons than marking to trace the heap.
2022-04-18 15:19:55 +02:00
Andy Wingo
19f7f72b68 Rename mark-sweep "large" objects to "medium" 2022-04-18 10:00:44 +02:00
Andy Wingo
3f54fb3dbf Fix semispace page stealing
Ensure number of stolen pages is even.  Avoid madvising on every
collection.  Cache the page size.
2022-04-17 21:51:20 +02:00
Andy Wingo
3315fc7477 Add large object space to semi-space collector 2022-04-14 22:20:27 +02:00
Andy Wingo
619a49ba41 Add large object space
Not wired up yet.
2022-04-13 21:43:18 +02:00
Andy Wingo
d425620d37 Add address map and set 2022-04-12 21:41:26 +02:00
Mikael Djurfeldt
cc45597681 Find unidata_to_charset.awk from commit 9f8e05e5 in $(srcdir).
* libguile/Makefile.am: Find unidata_to_charset.awk in $(srcdir) in
order to support building in a separate directory.
2022-04-08 15:35:34 +02:00