sbcl Log

Commit Date  
[83fc8f] (135.4 kB) by David Lichteblau David Lichteblau

New predicate THREAD-EPHEMERAL-P for certain system threads

Adds an `ephemeral' flag to the thread structure and exports it.
When true, we can assume that the thread will be started and stopped
by the runtime automatically as needed.

The flag is currently of a purely informational nature; it does not
change the behaviour of thread-related functions.

Thanks to Anton Kovalenko.

2012-09-19 13:45:06 View
[af3fdb] (135.4 kB) by Nikodemus Siivola Nikodemus Siivola


2012-09-15 11:27:08 View
[6d9e22] (135.3 kB) by Stas Boukarev Stas Boukarev

disassemble: New customization variable sb-ext:*disassemble-annotate*.

sb-ext:*disassemble-annotate*: Controls whether to annotate
DISASSEMBLE output with source forms, defaults to T.

Also remove an unused function.

2012-08-24 23:35:26 View
[dd54f9] (135.3 kB) by David Lichteblau David Lichteblau

Use safepoints for INTERRUPT-THREAD

* In INTERRUPT-THREAD, stop threads using safepoints instead of

* Currently not used by default. Users need to set feature
SB-THRUPTION to enable this code. SB-THRUPTION should only be set
when SB-SAFEPOINT is also enabled.

* This feature should ultimately be rolled into SB-SAFEPOINT, but
remains as a separate build option until both versions are equally
well-tested, and until other avoidable uses of signals have also
been replaced by safepoints.

* On the term "thruption": Earlier work on this feature sometimes
used "interrupt" to refer to INTERRUPT-THREAD, causing confusion
with the traditional meaning of "interrupt" as POSIX signal or WIN32
exception. To avoid such confusion, the runtime now refers to
INTERRUPT-THREAD as a "thruption", short for th(read) (inter)ruption.

* SIGPIPE is not used for threads running Lisp code, but a low-level
handler for SIGPIPE still exists which arranges for threads running
FFI code (in particular, threads blocked in poll, select,
futex_wait) to be interrupted.

* OS support: Minor changes to signal handling required, currently
implemented for Linux and Solaris.

Credits: This is a POSIX backport of Windows threading changes by
Anton Kovalenko and Dmitry Kalyanov.

2012-08-10 18:54:28 View
[e6f4c7] (135.2 kB) by David Lichteblau David Lichteblau

Add safepoint mechanism

* Stop threads for GC at safepoints only.

* Replaces use of SIG_STOP_FOR_GC.

* Currently not used by default. Users need to set feature
SB-SAFEPOINT to enable this code. SB-SAFEPOINT should only be set
when SB-THREAD is also enabled.

* ISA support: Each architecture needs VOP support, and changes to
foreign call-out assembly; only x86 and x86-64 implemented at this

* OS support: Minor changes to signal handling required, currently
implemented for Linux and Solaris.

* Performance note: Does not currently replace pseudo-atomic entirely,
except on Windows. Only once further work has been done to reduce
use of signals will pseudo-atomic become truly redundant. Therefore
use of safepoints on POSIX currently still implies the combined
performance overhead of both mechanisms.

* Design alternatives exist for some choices made here. In particular,
this commit places the safepoint trap page into the SBCL binary for
simplicity. It is likely that future changes to allow slam-free
runtime changes will have to go back to a hand-crafted address

* This feature has been extracted from work related to Windows
support and backported to POSIX.

Credits: Uses the CSP-based stop-the-world protocol by Anton Kovalenko,
based on the safepoint and threading work by Dmitry Kalyanov. Use of
safepoints for SBCL originally researched by Paul Khuong.

2012-08-10 12:51:45 View
[333049] (135.1 kB) by Nikodemus Siivola Nikodemus Siivola

adjust compiler-macro expansion and lambda-list parsing

* Don't convert errors during compiler-macro expansion into runtime
PROGRAM-ERRORs: signal a compile-time warning, and simply decline to expand
the compiler-macro.


* Make compiler not expand compiler-macros if there are arguments in keyword
positions that are not self-evaluating constant symbols.

This lives in two places:

encounters either an unknown keyword or anything except a
self-evaluating symbol in a keyword position when parsing
compiler-macro keywords.

(2) IR1-CONVERT-FUNCTOID handles this condition by unwinding from the
compiler-macro expansion, printing a note about the problem, and
returning the original form.

Calling COMPILER-MACRO-FUNCTION directly behaves exactly as before, for
both good and ill: good in the sense that it is compliant, ill in the
sense that doing things that way may expand things the compiler would
decline to expand:

(define-compiler-macro foo (&key ((a ax) t)) (format nil "a=~S" ax))

The compiler would refuse to expand (foo a 42) unless

(defconstant a 'a)

had been done beforehand, but calling the COMPILER-MACRO-FUNCTION directly
would expand it even without that -- as the spec unfortuntely requires.

2012-06-09 12:28:09 View
[a0773e] (135.0 kB) by Nikodemus Siivola Nikodemus Siivola

sb-alien: some alien refactoring


-DATAP. HEAP-ALIEN-INFO-SAP-FORM becomes a function that conses up the form
for the compiler, and HEAP-ALIEN-INFO-SAP replaces EVAL of the form.

* Better error checking in PICK-LISP-AND-ALIEN-NAMES, and an error message
that explains the correct form.

2012-06-09 12:28:09 View
[b916ee] (135.0 kB) by Lutz Euler Lutz Euler

Use multi-byte NOPs for code alignment on x86-64.

This is intended to speed up execution of such code sequences. It makes
the disassembly output somewhat more readable, too. The multi-byte NOP
instructions are chosen according to the recommendations of both AMD and
Intel. All existing x86-64 processors should support the "0f 1f" opcode

This adds the needed infrastructure to the backend-independent compiler
parts and uses it from x86-64. Backends not using this functionality are
left unchanged.

Extend EMIT-ALIGNMENT to allow to specify multi-byte NOPs to be used
instead of repetitions of the single-byte NOP and change the call in
EMIT-BLOCK-HEADER on x86-64 to trigger this. Extend EMIT-SKIP to call
EMIT-LONG-NOP in this case.

On x86-64, add EMIT-LONG-NOP as the instruction emitter and extend the
disassembler entry for NOP to understand the multi-byte forms, too.

Make EMIT-FILLER decide more carefully whether to join fillers that are
adjacent in the list of segment annotations: Only join them if they are
immediately adjacent in the segment, too. (Otherwise the joined filler
would cover the wrong parts of a shortened alignment sequence.)

In certain circumstances %EMIT-ALIGNMENT splits an alignment into two
parts. This may not be necessary but has not yet been changed, so
sometimes one more long NOP than needed is assembled.

2012-05-25 14:56:49 View
[a6a12e] (135.0 kB) by Nikodemus Siivola Nikodemus Siivola

refactor GET-TOPLEVEL-FORM &co between debugger and disassembler

* Merge the implementations in debug.lisp and target-disassembler.lisp.

* Get rid of most of the cacheing.

* Prefer the DEBUG-SOURCE-FORM if it exists: thanks to *SOURCE-NAMESTRING*
we can have misleading namestrings for functions generated by calls to
EVAL during LOAD, etc.

2012-05-21 05:37:56 View
[6e60dc] (135.0 kB) by Nikodemus Siivola Nikodemus Siivola


Allow binding it to a symbol, which is resolved when entering the debugger:
it denotes the name of the first uninteresting frame.

This simplifies ERROR, CERROR, BREAK, %BREAK, and makes interrupts more
efficient as we no longer need to find the interrupted frame when entering
an interupt handler.

It also makes (handler-bind ((error #'invoke-debugger)) ...) once again gain
the benefits of the stack top hint, which we lost when we ceased the provide
the hint around the call to SIGNAL for efficiency reasons. Best of both
worlds, one hopes.

2012-05-21 05:37:38 View
[126b9c] (135.0 kB) by Nikodemus Siivola Nikodemus Siivola


Nicer than having to write explicit CAS loops.

Also improve COMPARE-AND-SWAP docstring, and remove the EXPERIMENTAL label
from it.

2012-05-21 05:35:36 View
[8a3305] (134.9 kB) by Nikodemus Siivola Nikodemus Siivola

better timeout handling in EXIT and %EXIT-OTHER-THREADS

Account the timeout against all the threads being joined, not each

Also move handling of "main thread exiting even though another
thread got the call" handling to %EXIT.

...and one missing #!+sb-doc

2012-05-04 08:04:11 View
[436b2a] (134.9 kB) by Lutz Euler Lutz Euler

Better equidistributed and faster/less consing integer RANDOM.

Up to now the implementation of RANDOM with an integer argument just
generated a few more random bits than the length of the argument and
took this value MOD the argument. This led to a slightly uneven
distribution of the possible values unless the argument was a power of
two. Moreover, for bignums, the algorithm was quadratic both in time and
space dependent on the number of bits of the argument.

Instead generate random integers using an accept-reject loop and change
the bignum implementation to an algorithm that is linear in time and

I took some inspiration from WHN's attempt at an accept-reject loop
implementation in commit 0a7604d54581d2c846838c26ce6a7993629586fa and

Thanks to Christophe Rhodes for reviewing this patch!

Some details:

The implementation works correctly with both a random chunk size equal
to the word size and equal to half the word size. This is currently
necessary as a 32-bit pseudo random generator is used both under 32 and
under 64 bit word size.

In the generic RANDOM case, fixnum and bignum limits are differentiated:

With a fixnum limit an accept-reject loop on a masked random chunk is
always used. Under 64 bit word size two random chunks are used only if
the limit is so large that one doesn't suffice. This never conses.

With a bignum limit four cases are differentiated to minimize consing.
If just one random chunk is needed to supply a sufficient number of bits
the implementation only conses if the result is indeed a bignum:
* If the limit is a power of two, a chunk is generated and shifted to
get the correct number of bits.
* If the limit is not a power of two an accept-reject loop with shifting
is used.
If more than one random chunk is needed, a bignum is always consed even
if it happens to normalize to a fixnum:
* If the limit is a power of two a straightforward algorithm is used to
fill a newly created bignum with random bits.
* If the limit is not a power of two an accept-reject loop is used that
detects rejection early by starting from the most significant bits,
thus generating on the average only one random chunk more than needed
to fill the result once.
The test for power of two is non-consing, too.

In the case of a compile-time constant integer argument (of at most word
size) a DEFTRANSFORM triggers, that, in the general case, compiles an
accept-reject loop. For values of the limit where this sufficiently
reduces the rejection probability the largest multiple of the limit
fitting in one or two random chunks is used instead inside the loop.
To bring the result in the correct range a division is then necessary
(which the compiler converts into a multiplication). Powers of two are
optimized by leaving out the rejection test. In those cases where a word
has more bits than a random chunk, the generated expression uses two
chunks only if necessary.

2012-05-01 16:59:12 View
[ef61e6] (134.8 kB) by Nikodemus Siivola Nikodemus Siivola

add SB-UNIX:UNIX-EXIT back, use the deprecation framwork for it and SB-EXT:QUIT

Also extend the deprecation framwork to support multiple replacements:
SB-EXT:QUIT should be replaced either by SB-EXT:EXIT or SB-EXT:ABORT-THREAD,
depending on the way it was being used.

2012-05-01 12:13:50 View
[f0da2f] (134.8 kB) by Nikodemus Siivola Nikodemus Siivola

redesign exiting SBCL

Deprecate QUIT. It occupies an uncomfortable niche between processes
and threads, and doesn't actually do what it says on the tin unless
you call it from the main thread.

SIGTERM now uses EXIT, and doesn't depend on sessions.

WITH-DEADLINE (:SECONDS NIL :OVERRIDE T) can now be used to ignore

JOIN-THREAD on the main thread now blocks indefinitely instead of
claiming the thread did not exit normally.

New functions:

* SB-EXT:EXIT. Always exits the process. Takes keywords :CODE,
:ABORT, and :TIMEOUT. Code is the exit status. Abort controls if
the exit is clean (unwind, exit-hooks, terminate other threads) or
dirty. Timeout controls how long to wait for other threads to

* SB-THREAD:RETURN-FROM-THREAD. Normal termination for current
thread -- equivalent to return from the thread function with the
specified values. Takes keyword :ALLOW-EXIT, which determines if
returning from the main thread is an error, or equivalent to
calling EXIT :CODE 0.

* SB-THREAD:ABORT-THREAD. Abnormal termination for current thread --
equivalent to invoking the initial ABORT restart estabilished by
MAKE-THREAD (previously known as TERMINATE-THREAD, but ANSI
recommends there to always be an ABORT restart.) Takes keyword
:ALLOW-EXIT, which determines if aborting the main thread is an
error, or equivalent to calling EXIT :CODE 1.

* SB-THREAD:MAIN-THREAD-P. Let's you determine if a given thread is
the main thread of the process. This is important for some
functions on some operating systems -- and RETURN-FROM-THREAD and
ABORT-THREAD also need it.

* SB-THREAD:MAIN-THREAD. Returns the main thread object. Convenient
for when you need to eg. load a foreign library in the main

2012-04-29 18:18:53 View
[aa01df] (134.4 kB) by Nikodemus Siivola Nikodemus Siivola

teach IR1-TRANSFORM-TYPE-PREDICATE about alien types

Convert to ALIEN-VALUE-TYPEP (new function). Avoids both the need to do the
whole type parsing rigamarole at runtime, and checking for lisp-rep-type.

Need to do this as late in the game as possible, because after we convert to
ALIEN-VALUE-TYPEP, the rest of the system stops understanding it as a type
test. (We really should have some sort of annotation for this sort of stuff,
so we could convert whenever.)

2012-04-20 16:13:56 View
[3f3033] (134.4 kB) by Nikodemus Siivola Nikodemus Siivola

correct octets in c-string decoding errors

Also add SAP-REF-OCTETS for grabbing a vector of bytes from
memory. We'll need it elsewhere as well.

Fixes lp#985505

2012-04-19 14:23:45 View
[41cb42] (134.3 kB) by Nikodemus Siivola Nikodemus Siivola

faster FIND and POSITION on bit-vectors

Read data a word at a time for efficiency's sake.

Could do even better with VOPs, but this already wins hugely on sparse
vectors -- and works on all backends. (Tested on both little- and big-endian

This also makes constraint propagation in sparse universes a bit less sucky.

2011-12-29 18:25:42 View
[fb2d28] (134.2 kB) by Nikodemus Siivola Nikodemus Siivola


Use a WITH-ARRAY-DATA to get to the underlying vector, and use a widetag
dispatch table to pick the correct SUBSEQ implementation for the underlying

This is actually just as fast even for simple strings as STRING-SUBSEQ*, so
throw it out.

Also make inlining SUBSEQ conditional on SPEED > SPACE now that the
out-of-line version doesn't suck so much.

Fixes lp#902537.

2011-12-10 18:25:04 View
[a3706c] (134.2 kB) by Nikodemus Siivola Nikodemus Siivola

FAST-READ-BYTE refactoring



FAST-READ-BYTE is a local inline function instead of a macro.

2011-12-09 21:52:16 View
[a98da0] (134.3 kB) by Nikodemus Siivola Nikodemus Siivola

fix unthreaded non-x86oid builds

Better representation selection for constants broke things, since it assumed
that IMMEDIATE is the only immediate boxed SC -- which is true only on
x86oids: elsewhere there is also NULL and ZERO.

Add new VM support routine: BOXED-IMMEDIATE-SC-P.

2011-12-05 19:48:50 View
[171fde] (134.2 kB) by Attila Lendvai Attila Lendvai , pushed by Nikodemus Siivola Nikodemus Siivola


When non-NIL, OUTPUT-OBJECT (our main entry to the printer) binds a handler
that handles conditions of the specified type by printing an error marker
instead of signaling an error.


Calls SIGNAL before handling the condition so outer handlers get a chance to
use restarts, etc.

2011-12-05 10:21:29 View
[146343] (134.1 kB) by Nikodemus Siivola Nikodemus Siivola

refactor PRINT-NOT-READABLE condition signaling

SB-INT:PRINT-NOT-READABLE-ERROR both signals the condition,
and binds the restarts.

2011-11-27 12:28:54 View
[179812] (134.1 kB) by Alastair Bridgewater Alastair Bridgewater


* This is for those cases where you know that you are trying to
read valid boxed data, the address of the data you want to read
is in some sense "stable" (meaning, won't be moved by the GC),
and you don't want to deal with the requirements for calling

* Implemented across the board, but only tested on PPC. What
could possibly go wrong?

2011-11-22 18:40:21 View
[1a61f0] (134.0 kB) by Zach Beane Zach Beane , pushed by Christophe Rhodes Christophe Rhodes

new SET-SBCL-SOURCE-LOCATION convenience function

From Zach Beane sbcl-devel 2011-11-15.

Signed-off-by: Christophe Rhodes <>

2011-11-19 21:36:30 View
Older >