sbcl.git
10 years agorewrite DUMP-I-VECTOR
Christophe Rhodes [Wed, 18 Sep 2013 10:20:58 +0000 (11:20 +0100)]
rewrite DUMP-I-VECTOR

Simple, easy-to-understand cross-compiler version with limited
functionality; target version generated from sb-vm:*S-A-E-T-P*
so stands some chance of being correct.

Problem in previous version noted by Douglas Katzman (report
sbcl-devel 2013-09-16)

10 years agoRemove a level of indirection in *linkage-info*.
Stas Boukarev [Mon, 16 Sep 2013 19:56:40 +0000 (23:56 +0400)]
Remove a level of indirection in *linkage-info*.

Don't store the address in a linkage-info structure, only the linkage-info-address
slot was ever used. Store the address directly.

10 years agoRestore building of +sb-unicode with -sb-unicode.
Stas Boukarev [Mon, 16 Sep 2013 19:53:30 +0000 (23:53 +0400)]
Restore building of +sb-unicode with -sb-unicode.

Some host definitions slipped in during cross-compilation.
char-code-limit => sb!xc:char-code-limit.
**character-primary-compositions** was initialized at xc-time, move it to cold init.

Thanks to Christophe Rhodes for the latter.

10 years agoSET-FUNCALLABLE-INSTANCE-FUNCTION is user interface
Christophe Rhodes [Mon, 16 Sep 2013 11:34:49 +0000 (12:34 +0100)]
SET-FUNCALLABLE-INSTANCE-FUNCTION is user interface

It should therefore not trigger AVER failures if the user gets the
order of arguments wrong, but report the problem sanely.  The fix
in this commit is only semi-sane; it would be nice to report an
expected-type of SB-MOP:FUNCALLABLE-STANDARD-OBJECT rather than
SB-KERNEL:FUNCALLABLE-INSTANCE, but there are slightly tricky
bootstrap issues to sort out to get that to work.

10 years agominor optimization to restart-case
Christophe Rhodes [Fri, 13 Sep 2013 13:30:13 +0000 (14:30 +0100)]
minor optimization to restart-case

The generated non-local transfer functions go to a tag which will
always be in scope whenever the restart can be invoked, so wrap the
GO in a scary (safety 0) optimization declaration.  This fixes
lp#1023721 (but not the issue raised in comment #1, which would be
solved naturally if lp#383078 is addressed).

Include a test which deliberately breaks the normal dynamic-extent
lifetime for restarts; restarts generated by RESTART-CASE and friends
in fact have indefinite extent, even though once they're out of the
dynamic-extent of their creating/binding operator you can't really do
anything with them (INVOKE-RESTART signals a control-error if the
restart given is not active, and there's no way to reactivate a
restart).  However, the temptation to make the restart function
have dynamic-extent allocation must be resisted, because of the
indefinite lifetime of the restart object itself.

10 years agoNEWS update for RESTART-CASE clause parsing
Christophe Rhodes [Fri, 13 Sep 2013 09:36:37 +0000 (10:36 +0100)]
NEWS update for RESTART-CASE clause parsing

fixes lp#1203585

10 years agoSimplify RESTART-BIND and improve documentation string
Jan Moringen [Tue, 16 Jul 2013 21:15:02 +0000 (23:15 +0200)]
Simplify RESTART-BIND and improve documentation string

* Mention syntax in documentation string.

* Simplify implementation using a location function PARSE-BINDING and
  DESTRUCTURING-BIND.

10 years agoRemove convoluted keyword argument processing in RESTART-CASE
Jan Moringen [Sun, 21 Jul 2013 22:09:03 +0000 (00:09 +0200)]
Remove convoluted keyword argument processing in RESTART-CASE

* Replace a combination of TRANSFORM-KEYWORDS, PARSE-KEYWORD-PAIR and
  WITH-KEYWORD-PAIRS with a relatively simple local function
  PARSE-KEYWORDS-AND-BODY; Gets rid of KLUDGE regarding
  WITH-KEYWORD-PAIRS

* Add a smoke test and more cases for the :MALFORMED-CLAUSES test in
  tests/condition.pure.lisp; Gets rid of the "fair amount of
  rearrangement ... should be tested" FIXME

* Fix "test case from Gerd Moellmann" in tests/clos.impure.lisp which
  contained an invalid RESTART-CASE form uncovered by the above change

10 years agomore restrictive test naming
Christophe Rhodes [Wed, 11 Sep 2013 11:24:43 +0000 (12:24 +0100)]
more restrictive test naming

restrict test names to trees of integers and external symbols in
CL/KEYWORD/SB- packages.

10 years agorename recently-added tests
Christophe Rhodes [Wed, 11 Sep 2013 05:10:20 +0000 (06:10 +0100)]
rename recently-added tests

use only keyword symbols in the names to assist in continuous
integration

10 years agodetect cpl-protocol-violations early
Christophe Rhodes [Tue, 10 Sep 2013 22:24:46 +0000 (23:24 +0100)]
detect cpl-protocol-violations early

Don't try to eagerly finalize classes which will cause
cpl-protocol-violations to be signalled.  (lp#309076)

10 years agoFix a regression in sb-safepoint.
Stas Boukarev [Tue, 10 Sep 2013 17:40:42 +0000 (21:40 +0400)]
Fix a regression in sb-safepoint.

WITH_GC_AT_SAFEPOINTS_ONLY is actually a fancy macro, which wraps the
form following it in some code. In a recent change that wasn't
accounted for and resulted in bad consequences. Add {} around the code
after WITH_GC_AT_SAFEPOINTS_ONLY.
Reported by Jan Moringen.

10 years agoMicro-optimize move-immediate on x86-64.
Stas Boukarev [Mon, 9 Sep 2013 15:54:05 +0000 (19:54 +0400)]
Micro-optimize move-immediate on x86-64.

Use XOR X, X when the immediate is 0.

10 years agoFix CHAR-EQUAL on base-chars on non-sb-unicode.
Stas Boukarev [Mon, 9 Sep 2013 15:43:58 +0000 (19:43 +0400)]
Fix CHAR-EQUAL on base-chars on non-sb-unicode.

BASE-CHAR-P, called by TWO-ARG-CHAR-EQUAL, isn't properly implemented
on non-sb-unicode, the transform by which it gets transformed into
(typep x 'base-char) is disabled, causing an infinite loop.
Since testing for base-char-p is usually redundant on #-sb-unicode,
don't define it there at all. This will catch inadvertent uses.
In the few places where it's currently used, it's can be safely
omitted.

Reported by Jan Moringen.

10 years agorename SB-SIMPLE-STREAMS utility function
Christophe Rhodes [Mon, 9 Sep 2013 14:09:42 +0000 (15:09 +0100)]
rename SB-SIMPLE-STREAMS utility function

At least, I think it was simply intended to be a utility function,
but the FILE-NAMESTRING name is unfortunate, as that's a CL function,
and (for other reasons) SB-SIMPLE-STREAMS claims to implement CL in
the package lock sense, so this was not noticed at the time.

This fixes lp#884603; I am unconvinced that the namestring logic is
actually correct (keeping the distinction between NAMESTRING and
NATIVE-NAMESTRING clear) but I'll wait for an actual user to complain
about that before thinking too hard.

10 years agobetter ctor fallback-generators
Christophe Rhodes [Mon, 9 Sep 2013 11:42:30 +0000 (12:42 +0100)]
better ctor fallback-generators

The logic surrounding default-initargs in the presence of "hairy"
methods on make-instance and friends was not quite right, leading
to evaluation of the wrong things at the wrong times.  Patch by
Jan Moringen with extra test cases (lp#1179858).

10 years agobetter comment describing INDEX type
Christophe Rhodes [Mon, 9 Sep 2013 09:21:54 +0000 (10:21 +0100)]
better comment describing INDEX type

merged ideas from Paul Khuong and Jan Moringen, from
<http://paste.lisp.org/display/138734>

10 years agosb-safepoint: Fix interrupts during GC.
Stas Boukarev [Sun, 8 Sep 2013 23:19:18 +0000 (03:19 +0400)]
sb-safepoint: Fix interrupts during GC.

In interrupt_handle_now, move

context_sap = alloc_sap(context);
info_sap = alloc_sap(info);

after WITH_GC_AT_SAFEPOINTS_ONLY(), otherwise the allocation will
break the running GC.
Fixes lp#1133018.

10 years agoLDB/DPB do not check for negative indexes.
Stas Boukarev [Sat, 7 Sep 2013 19:01:37 +0000 (23:01 +0400)]
LDB/DPB do not check for negative indexes.

Calling (lambda (x y) (ldb (byte x y) 100)) with -1 -2 didn't raise an
error.

Reported by Bart Botta.

10 years agoAdjust SETcc instruction encoding on x86-64.
Stas Boukarev [Sat, 7 Sep 2013 05:48:35 +0000 (09:48 +0400)]
Adjust SETcc instruction encoding on x86-64.

Avoid emitting REX for legacy registers.

10 years agoImprove knownfun declarations.
Stas Boukarev [Fri, 6 Sep 2013 22:03:08 +0000 (02:03 +0400)]
Improve knownfun declarations.

Make some types more accurate, add some
:derive-type #'result-type-first/last-arg.
Add missing %adjoin/member/assoc-test/not/key defknowns.

10 years agoRemove a wrong IGNORE declaration.
Stas Boukarev [Fri, 6 Sep 2013 17:58:24 +0000 (21:58 +0400)]
Remove a wrong IGNORE declaration.

An incorrect ignore declaration was used with #!-sb-package-locks,
even though the ignored variables are used without sb-package-locks
too.

Patch by Douglas Katzman.

10 years agoSave some space in WITH-OUTPUT-TO-STRING.
Stas Boukarev [Fri, 6 Sep 2013 14:23:40 +0000 (18:23 +0400)]
Save some space in WITH-OUTPUT-TO-STRING.

Not passing :element-type 'character to MAKE-STRING-OUTPUT-STREAM
saves a few bytes, since it's the default value.

10 years agoFix for sb-gmp bignum result allocation (lp#1206191)
Christophe Rhodes [Fri, 6 Sep 2013 11:43:40 +0000 (12:43 +0100)]
Fix for sb-gmp bignum result allocation (lp#1206191)

Patch based on 59e72c69c00abf9095d82e9a7b65f9c1b54d105c from
<https://github.com/sfrank/sb-gmp> (thanks to Stephan Frank)

10 years agoFix sb-gmp:mpz-pow for non-bignum bases
Christophe Rhodes [Fri, 6 Sep 2013 11:28:21 +0000 (12:28 +0100)]
Fix sb-gmp:mpz-pow for non-bignum bases

Don't declare types, and we don't need the check-type either

10 years agoOptimize CHAR-EQUAL on constant and base-char args.
Stas Boukarev [Thu, 5 Sep 2013 19:29:51 +0000 (23:29 +0400)]
Optimize CHAR-EQUAL on constant and base-char args.

The open-code transform for base-char arguments was never invoked, it
should have been defined on TWO-ARG-CHAR-EQUAL, not CHAR-EQUAL. And
enable it only for (> speed space).

Add a check for base-char into the TWO-ARG-CHAR-EQUAL function, and
invoke the optimized code, the same the transform uses.

Optimize (char-equal #\c x) by transforming it into a call to
(char-equal-constant x #\c #\C), which does
(or (char= #\c char) (char= #\C char)), or directly to that expression
with (> speed space).

(char-equal #\- x) is transformed to (char= #\- x).

10 years agoAdd defknowns for TWO-ARG-CHAR-* functions.
Stas Boukarev [Thu, 5 Sep 2013 17:49:58 +0000 (21:49 +0400)]
Add defknowns for TWO-ARG-CHAR-* functions.

This avoids the checks for multiple values.

10 years agoAdd a transform for EQUALP.
Stas Boukarev [Thu, 5 Sep 2013 16:39:53 +0000 (20:39 +0400)]
Add a transform for EQUALP.

Similar to the EQUAL one.

Also fix a bug in the EQUAL transform when types which include
specialized arrays inside them were resulting in EQUAL being
incorrectly folded to NIL.

10 years agoDocument extensible sequence protocol
Christophe Rhodes [Thu, 5 Sep 2013 16:29:02 +0000 (17:29 +0100)]
Document extensible sequence protocol

Based on patch by Jan Moringen from lp#994528

10 years agoOptimize some comparison functions for EQ cases.
Stas Boukarev [Thu, 5 Sep 2013 14:35:12 +0000 (18:35 +0400)]
Optimize some comparison functions for EQ cases.

Add (or (eq x y) ...) to bit-vector-=, two-arg-char-equal, pathname=.

10 years agoImprove the EQUAL transform.
Stas Boukarev [Thu, 5 Sep 2013 13:10:08 +0000 (17:10 +0400)]
Improve the EQUAL transform.

Transform to EQL when at least one argument is not of type
(or string cons pathname bit-vector).
Transform (equal (the pathname x) (the pathname y)) to (pathname= x y).

Closes lp#1220084, based on the patch by Elias Martenson.

10 years agoMicro-optimize calling assembly routines on x86oids.
Stas Boukarev [Wed, 4 Sep 2013 22:10:19 +0000 (02:10 +0400)]
Micro-optimize calling assembly routines on x86oids.

Do not check for multiple values in the :full-call return sequence, it
always returns just one value and CLC is issued before returning.

10 years agoMicro-optimize calling alloc_tramp on x86_64.
Stas Boukarev [Wed, 4 Sep 2013 09:30:17 +0000 (13:30 +0400)]
Micro-optimize calling alloc_tramp on x86_64.

In allocation-tramp, instead of using R11 temp-reg for storing the
address of alloc_tramp, use alloc-tn, because the result of
alloc_tramp will be stored there and its value doesn't have to be
preserved. And most of the time it will be allocated to a
non-64-bit-mode register, allowing to save 2 bytes on encoding.

10 years agoAdd SOCKET-SHUTDOWN in contrib/sb-bsd-sockets
Jan Moringen [Thu, 1 Aug 2013 16:54:12 +0000 (18:54 +0200)]
Add SOCKET-SHUTDOWN in contrib/sb-bsd-sockets

* The new generic function SOCKET-SHUTDOWN shuts down a socket for
  input, output or both. Calls shutdown(3posix)

* Test shutdown.{client,server}.{ub8,character}.{output,io} test
  shutting down TCP stream sockets from the client and server side for
  different element-types and directions

10 years agoHandle compiler-error in LOAD when it's not run from inside EVAL.
Stas Boukarev [Mon, 2 Sep 2013 05:44:38 +0000 (09:44 +0400)]
Handle compiler-error in LOAD when it's not run from inside EVAL.

When LOAD is run from the --load option or from within a new thread,
it doesn't go though EVAL and doesn't inherit its compiler-error
handler.

Fixes lp#1219601.

10 years agoslep-non-consing test: prevent from sleeping too much.
Stas Boukarev [Sat, 31 Aug 2013 06:17:18 +0000 (10:17 +0400)]
slep-non-consing test: prevent from sleeping too much.

Some platforms can't sleep for short amounts of time, add a
sb-ext:with-timeout around it and don't report it as a failure, since
there's basically nothing that can be fixed in such cases.

10 years agoMicro-optimize gc scavenge.
Stas Boukarev [Sat, 31 Aug 2013 03:29:06 +0000 (07:29 +0400)]
Micro-optimize gc scavenge.

Instead of putting the amount by which to increment the pointer and
then adding it at the end of the loop, increment the pointer
directly. Makes it slightly faster when compiled with GCC.

10 years agoRemove a couple of unused variables in the C runtime.
Stas Boukarev [Fri, 30 Aug 2013 23:36:19 +0000 (03:36 +0400)]
Remove a couple of unused variables in the C runtime.

10 years agotests/subr.sh: Fix sed invocation for Solaris.
Stas Boukarev [Fri, 30 Aug 2013 01:09:24 +0000 (05:09 +0400)]
tests/subr.sh: Fix sed invocation for Solaris.

10 years agotests/run-compiler.sh: use gcc, not cc.
Stas Boukarev [Fri, 30 Aug 2013 00:40:31 +0000 (04:40 +0400)]
tests/run-compiler.sh: use gcc, not cc.

10 years agoFix floating point exceptions persisting on Solaris.
Stas Boukarev [Thu, 29 Aug 2013 23:56:36 +0000 (03:56 +0400)]
Fix floating point exceptions persisting on Solaris.

(/ 0d0 0d0)
(cosh 90)

signaled an invalid-operation exception, and not overflow, on COSH,
because the previous error wasn't cleared. Clear the exception flags
in the sigfpe handler.

10 years agoPPRINT (setf . a) correctly.
Stas Boukarev [Thu, 29 Aug 2013 22:34:22 +0000 (02:34 +0400)]
PPRINT (setf . a) correctly.

It was printed as (setf a).

Reported by Douglas Katzman.

10 years agoFix building on Solaris x86-64.
Stas Boukarev [Thu, 29 Aug 2013 20:21:28 +0000 (00:21 +0400)]
Fix building on Solaris x86-64.

sb-unix:unix-select used macros which expanded into many forms,
limited by sb-unix:fd-setsize, which on Solaris-x86-64 is 65536, as
opposed to 1024 on Linux. This resulted in long compile times which
were likely to exhaust the heap.
Use functions instead of macros.

10 years agoImprove the test float.impure.lisp / (RANGE-REDUCTION PRECISE-PI).
Lutz Euler [Wed, 28 Aug 2013 21:09:05 +0000 (23:09 +0200)]
Improve the test float.impure.lisp / (RANGE-REDUCTION PRECISE-PI).

The way the test calculated its expected values was flawed and worked
correctly only accidentally due to the specific test values used and
to allowing a relatively large margin of error.

This commit corrects these calculations, removes some test values and
adds others and tightens the error margin. I do not expect this to cause
the test's outcome on any platform to change.

The flaw was to reduce the arguments by taking the remainder of
truncating modulo 2 pi. This allows precise calculations only of the
sine and the tangent of values slightly above even multiples of pi, but
not for example for the sine of an argument near an odd multiple of pi.
Instead the reduction is now done by taking the remainder of rounding
to the nearest multiple of pi/2 so that all arguments near the zeroes
of both sine and cosine reduce to values near zero.

This change was prompted when the test unexpectedly failed with some
values from gcc bug 43490 which I tried when investigating lp #1137924.

10 years agoPROBE-FILE on symlinks to pipes inside /proc on Linux.
Stas Boukarev [Wed, 28 Aug 2013 14:46:30 +0000 (18:46 +0400)]
PROBE-FILE on symlinks to pipes inside /proc on Linux.

PROBE-FILE now can access symlinks to pipes and sockets in
/proc/pid/fd/ on Linux.
query-file-system already has code for handling broken symlinks,
resolving the directory part, use it on files for which realpath(3)
fails, which includes pipes and socket links in /proc.

Reported by Eric Schulte.

10 years agoRemove debug-deinit, unused.
Stas Boukarev [Fri, 23 Aug 2013 22:32:00 +0000 (02:32 +0400)]
Remove debug-deinit, unused.

Its body consist of
;; Nothing to do right now. Once there was, maybe once there
;; will be again.

Once there is something to do, it can easily be put back.

10 years agoRemove an unused variable, *unwind-to-frame-function*.
Stas Boukarev [Fri, 23 Aug 2013 22:12:41 +0000 (02:12 +0400)]
Remove an unused variable, *unwind-to-frame-function*.

It isn't used for about three years now.

10 years ago1.1.11: will be tagged as "sbcl-1.1.11"
Christophe Rhodes [Wed, 28 Aug 2013 13:16:56 +0000 (14:16 +0100)]
1.1.11: will be tagged as "sbcl-1.1.11"

10 years agofix NEWS header
Christophe Rhodes [Wed, 28 Aug 2013 13:16:29 +0000 (14:16 +0100)]
fix NEWS header

10 years agoRevert "Clean up %more-arg-values."
Stas Boukarev [Sat, 24 Aug 2013 21:37:17 +0000 (01:37 +0400)]
Revert "Clean up %more-arg-values."

This reverts commit 1e5296127f5b384a2171646747021ebeee73b801.
It breaks slime, a better solution to come in the next release cycle.

10 years agoBetter support for NetBSD/current
Christophe Rhodes [Thu, 22 Aug 2013 12:39:10 +0000 (13:39 +0100)]
Better support for NetBSD/current

Wrap more syscalls to defend against linker rewriting (patch from Robert
Swindells sbcl-devel 2013-07-12, encouragement from NetBSD users on #sbcl
IRC).

10 years agoFix OPEN when :if-exists/:if-does-not-exist are both NIL or :ERROR.
Stas Boukarev [Wed, 21 Aug 2013 22:05:02 +0000 (02:05 +0400)]
Fix OPEN when :if-exists/:if-does-not-exist are both NIL or :ERROR.

Such combination results in OPEN never actually opening a file, only
either signalling an error or returning NIL.
Reported by Jan Moringen.

10 years agoDon't hardcode the number of gencgc generations.
Stas Boukarev [Wed, 21 Aug 2013 12:52:26 +0000 (16:52 +0400)]
Don't hardcode the number of gencgc generations.

Use sb-vm:+pseudo-static-generation+.
Patch by Andreas Franke.

10 years agoReplace the Kitten of Death message with a warning in the banner
Paul Khuong [Wed, 21 Aug 2013 03:53:01 +0000 (23:53 -0400)]
Replace the Kitten of Death message with a warning in the banner

 * Arguably, the Windows ports are now as (un)stable as the other
   non-Linux/x86oid ports.
 * Either way, the warning is now disabled by --noinform.
 * Also, replace the lossage message when the initial thread returns
   with a clearer description of the situation.

10 years agoFlush streams more precisely.
Stas Boukarev [Wed, 21 Aug 2013 01:27:35 +0000 (05:27 +0400)]
Flush streams more precisely.

The test for the space left in the stream buffer was too conservative,
leaving 1 byte unused.
Patch by Ken Olum.
Fixes lp#910213.

10 years agoFix thread-alloca test on Windows.
Stas Boukarev [Tue, 20 Aug 2013 23:06:28 +0000 (03:06 +0400)]
Fix thread-alloca test on Windows.

Invoke gcc in a more portable fashion.

10 years agoFix ROOM on Windows.
Stas Boukarev [Tue, 20 Aug 2013 21:12:00 +0000 (01:12 +0400)]
Fix ROOM on Windows.

A bit-field inside the page struct is defined as "unsigned fields", on
Linux it's packed into 8 bits, but on 32-bit Windows into 32-bits. The
code in room expects the former. Defining it as "unsigned char fields"
solves the problem.

10 years agoClean up %more-arg-values.
Stas Boukarev [Tue, 20 Aug 2013 17:06:05 +0000 (21:06 +0400)]
Clean up %more-arg-values.

The second argument to %more-arg-values is always 0. Remove it.

10 years agoClean up and micro-optimize list checking in some x86-64 VOPs.
Stas Boukarev [Mon, 19 Aug 2013 23:20:04 +0000 (03:20 +0400)]
Clean up and micro-optimize list checking in some x86-64 VOPs.

In length/list and values-list, instead of manually checking for LIST,
call %test-lowtag, which produces more compact code.

10 years agoMicro-optimize copy-more-arg on x86-64.
Stas Boukarev [Mon, 19 Aug 2013 22:32:18 +0000 (02:32 +0400)]
Micro-optimize copy-more-arg on x86-64.

Instead of copying RCX into RBX, then modifying RCX and later
restoring RCX from RBX, modify RBX instead.

10 years agoClean up listify-rest-args VOP on x86-64.
Stas Boukarev [Mon, 19 Aug 2013 22:29:01 +0000 (02:29 +0400)]
Clean up listify-rest-args VOP on x86-64.

It's no longer using loop instructions, remove STD and CLD.

10 years agoApply a recent optimization more widely.
Stas Boukarev [Mon, 19 Aug 2013 16:56:22 +0000 (20:56 +0400)]
Apply a recent optimization more widely.

FOREIGN-SYMBOL-SAP was missing changing
LEA REG, [#xADDRESS]
to
MOV REG, #xADDRESS

10 years agoAdd a memory barrier inside pseudo-atomic on PPC.
Stas Boukarev [Thu, 15 Aug 2013 18:02:54 +0000 (22:02 +0400)]
Add a memory barrier inside pseudo-atomic on PPC.

Solves problems with allocation and multiple threads.

10 years agoSet up alien stack correctly on non-x86oids.
Stas Boukarev [Thu, 15 Aug 2013 17:52:24 +0000 (21:52 +0400)]
Set up alien stack correctly on non-x86oids.

It's assumed that the C stack grows upward everywhere but X86oids,
which is not true. Define two new conditions,
ALIEN_STACK_GROWS_DOWNWARD and ALIEN_STACK_GROWS_UPWARD.

This fixes FFI issues on PPC.

10 years agocreate_os_thread: put pthread stack inside alien-stack.
Stas Boukarev [Thu, 15 Aug 2013 17:00:06 +0000 (21:00 +0400)]
create_os_thread: put pthread stack inside alien-stack.

On !LISP_FEATURE_C_STACK_IS_CONTROL_STACK set pthread stack to
alien_stack, not control_stack.

10 years agoWarn when defining a setf-function together with a setf-expander.
Stas Boukarev [Thu, 15 Aug 2013 14:40:51 +0000 (18:40 +0400)]
Warn when defining a setf-function together with a setf-expander.

Patch by Douglas Katzman.

10 years agoThrow errors on malformed FUNCTION.
Stas Boukarev [Thu, 15 Aug 2013 13:43:13 +0000 (17:43 +0400)]
Throw errors on malformed FUNCTION.

(funcall (function X junk)) didn't throw an error in the presence of a
compiler-macro for X.

Patch by Douglas Katzman.

10 years agoOptimize calling asm routines and static foreign functions on x86-64.
Stas Boukarev [Thu, 15 Aug 2013 13:21:04 +0000 (17:21 +0400)]
Optimize calling asm routines and static foreign functions on x86-64.

Instead of loading the address using
LEA REG, [#xADDRESS]
use
MOV REG, #xADDRESS

Which saves 2 bytes.

10 years agoFix undefined function errors on PPC and MIPS.
Stas Boukarev [Tue, 6 Aug 2013 17:11:16 +0000 (21:11 +0400)]
Fix undefined function errors on PPC and MIPS.

undefined_tramp hardcodes the register in which FDEFN resides, but the
format was recently changed (f69e89d..).

Other platforms can be susceptible to this.
A proper fix would avoid hardcoding this by exporting
sc-offset-scn-byte/sc-offset-offset-byte, and register offsets.

Thanks to the GCC Compile Farm project for providing machines for
testing and uncovering this.

10 years agoMicrooptimize (signed-byte 64) type test on x86-64.
Stas Boukarev [Thu, 1 Aug 2013 17:51:55 +0000 (21:51 +0400)]
Microoptimize (signed-byte 64) type test on x86-64.

Similar to the (unsigned-byte 64) one:
TEST CL, 3
MOV EAX, ECX
=>
MOV EAX, ECX
TEST AL, 3

Also add tests/run-tests-* to .gitignore.

10 years agofix manual build under texinfo 5
Christophe Rhodes [Wed, 31 Jul 2013 13:06:43 +0000 (14:06 +0100)]
fix manual build under texinfo 5

Texinfo 5 is more assertive about its syntax: macros with
non-alphanumerics have never actually been allowed, but we used to be
able to get away with @& to escape an ampersand under @iftex, and
defining @&key macros under @iffnottex.  Nuh-uh, not any more.  (fixes
lp#1189146)

The details of the indexes, particularly in html format, differ slightly
under texinfo 4 and 5 (related to the trickery around hiding package
prefixes for decent alphabetization).  It might be nice to sort this out
Once And For All, eventually.

10 years agoMicrooptimize comparisons with 0 on x86oids.
Stas Boukarev [Sun, 28 Jul 2013 18:26:18 +0000 (22:26 +0400)]
Microoptimize comparisons with 0 on x86oids.

Implement the common idiom of using TEST REG, REG in place of CMP REG,
0, saving 1 byte, for fast-if->/< VOPs.

10 years agoOptimize (unsigned-byte 32/64) type tests on x86oids.
Stas Boukarev [Sun, 28 Jul 2013 16:41:58 +0000 (20:41 +0400)]
Optimize (unsigned-byte 32/64) type tests on x86oids.

Instead of doing
TEST CL, 3
MOV EAX, ECX

do
MOV EAX, ECX
TEST AL, 3

AL has shorter encoding and can save 1 byte with ECX or 4 bytes with
ESI, which doesn't have SIL on x86.

Also revert a part of the previous commit which used untagged
pointers, which can cause problems with the GC.

10 years agoMicrooptimize type-tests on x86oids.
Stas Boukarev [Sun, 28 Jul 2013 15:42:41 +0000 (19:42 +0400)]
Microoptimize type-tests on x86oids.

On x86-64 in %test-lowtag instead of doing:

MOV EAX, ECX
AND AL, 15
CMP AL, 15
do
LEA EAX, [RCX-15]
TEST AL, 15

Which allows to save one byte.

On x86 this optimization is already applied, but since LEA loads a
32-bit integer, EAX can be later used as an already untagged pointer
in %test-headers: MOV EAX, [ECX-7] => MOV EAX, [EAX], which takes one
byte less to encode.

10 years ago1.1.10: will be tagged as "sbcl-1.1.10"
Christophe Rhodes [Sun, 28 Jul 2013 14:14:11 +0000 (15:14 +0100)]
1.1.10: will be tagged as "sbcl-1.1.10"

10 years agoModular integer %NEGATE on x86oids
Paul Khuong [Fri, 28 Jun 2013 06:36:13 +0000 (02:36 -0400)]
Modular integer %NEGATE on x86oids

Forms like (logand (- word) word) now compute the negation in modular
arithmetic, without consing an intermediate bignum, just like integer
addition, multiplication and subtraction.

The VOPs are trivial, and should be easily added on all other
platforms, I just don't have access to build hosts.

10 years agoPack (mostly) stack TNs according to lexical scope information
Paul Khuong [Tue, 25 Jun 2013 03:24:05 +0000 (23:24 -0400)]
Pack (mostly) stack TNs according to lexical scope information

 Packing TNs from shallow scopes before more deeply nested one
 is a perfect elimination order when the live ranges span the
 full scope (the interference graph is a comparability graph).
 Use that as a heuristic, and do that for TNs that are known
 to have such simple live ranges before the rest: this ensures
 that bad TNs don't mess everything up.

 The result is much tighter stack allocation (most of the effect
 comes from initialising stack frames at a smaller size, and growing
 less aggressively), and fewer long-lived stray references.

 Incidentally: fix catch block packing on win32, solving lp#1072739

10 years agoGrow regalloc datastructures geometrically for unbounded SCs
Paul Khuong [Thu, 27 Jun 2013 22:59:57 +0000 (18:59 -0400)]
Grow regalloc datastructures geometrically for unbounded SCs

10 years agoSmaller stack frames on x86oids
Paul Khuong [Thu, 27 Jun 2013 22:46:52 +0000 (18:46 -0400)]
Smaller stack frames on x86oids

Start at 4 slots (for some reason, it seems that 3 isn't really
the minimum, and grows by one slot at a time.

10 years agoDisentangle storage base initial size from growth increments
Paul Khuong [Thu, 27 Jun 2013 22:44:08 +0000 (18:44 -0400)]
Disentangle storage base initial size from growth increments

Before, an initial stack frame size of 8 meant that the stack frame
always grew in increments of 8. Not only is a large initial size bad
for GC (it leaves more dead references untouched), but a large increment
is even worse.

10 years agoInsert explicit cut to width when needed
Paul Khuong [Thu, 18 Jul 2013 19:03:21 +0000 (15:03 -0400)]
Insert explicit cut to width when needed

 When modular arithmetic operations are replaced with specialised
 modular variants, the result's bitwidth is determined by the variant,
 and might be wider than expected. If necessary, insert an explicit
 cut to the exact bitwidth before returning a value in a non-modular
 context.

 Spotted by pfdietz's random tester.

 Fixes lp#1199428.

10 years agoAvoid uselessly re-scanning modular arithmetic expressions
Paul Khuong [Thu, 18 Jul 2013 18:29:12 +0000 (14:29 -0400)]
Avoid uselessly re-scanning modular arithmetic expressions

When modular arithmetic transforms have already fired for a
subexpression, and that subexpression's width is at most as wide
as the bitwidth we're cutting to, there is no need to re-traverse
the subexpression.

There was already some code to detect that case. Make it more general,
and, more importantly, sound.

10 years agoNo more destructive MERGE of shared data in best-modular-version
Paul Khuong [Tue, 9 Jul 2013 12:16:41 +0000 (08:16 -0400)]
No more destructive MERGE of shared data in best-modular-version

The old code worked by accident: few/no platform implements
untagged signed modular arithmetic VOPs.

The new code handles that common case to avoid consing a fresh list
when the MERGE will be an identity.

10 years agoOptimize TYPEP of (MOD X) on x86/x86-64.
Stas Boukarev [Tue, 16 Jul 2013 01:12:51 +0000 (05:12 +0400)]
Optimize TYPEP of (MOD X) on x86/x86-64.

Optimize type-tests in the same vein as type-checks previously, and
implement type-checks by means of type-tests. Further optimize it by
avoiding doing fixnum tests on known fixnums and boxing of
signed/unsigned numbers.

10 years agoHandle unbounded integer types in INTEGER-TYPE-NUMERIC-BOUNDS
Paul Khuong [Mon, 8 Jul 2013 21:05:26 +0000 (17:05 -0400)]
Handle unbounded integer types in INTEGER-TYPE-NUMERIC-BOUNDS

If any of the integer type in the union lack upper or lower bounds,
immediately abort with unknown bounds (rather than taking the MIN
of NIL and an integer).

Thanks to pfdietz for his random testing.

Fixes lp#1199127.

10 years agoAdd a regression test for lp#1194673.
Lutz Euler [Sun, 7 Jul 2013 13:06:47 +0000 (15:06 +0200)]
Add a regression test for lp#1194673.

10 years agorestore CLISP cross-compilability
Christophe Rhodes [Fri, 5 Jul 2013 16:24:44 +0000 (17:24 +0100)]
restore CLISP cross-compilability

s is the marker for short-float, not single-float.  Use f instead.

10 years agoUpdate ASDF to 3.0.2.
Stas Boukarev [Thu, 4 Jul 2013 09:58:54 +0000 (13:58 +0400)]
Update ASDF to 3.0.2.

10 years ago1.1.9: will be tagged as "sbcl-1.1.9"
Christophe Rhodes [Thu, 4 Jul 2013 08:29:48 +0000 (09:29 +0100)]
1.1.9: will be tagged as "sbcl-1.1.9"

10 years agofix typo in FFI chapter
Christophe Rhodes [Wed, 3 Jul 2013 09:26:01 +0000 (10:26 +0100)]
fix typo in FFI chapter

noted by Michael Crouch (lp#1197129)

10 years agoRevert to binding *package* in bootstrappy code
Paul Khuong [Sat, 29 Jun 2013 23:54:25 +0000 (19:54 -0400)]
Revert to binding *package* in bootstrappy code

 I see no sane way to use sb!ext:print-symbol-with-prefix or
 sb-ext:... in ~//. Bind *package* to :keyword instead, for
 undefined function conditions.

 Reported by adeth on #lisp.

10 years agoFix SLEEP on 32-bit platforms.
James M. Lawrence [Tue, 25 Jun 2013 21:43:27 +0000 (17:43 -0400)]
Fix SLEEP on 32-bit platforms.

10 years agoFix a typo in the block comment on encoding/decoding universal times
Paul Khuong [Fri, 28 Jun 2013 13:08:11 +0000 (09:08 -0400)]
Fix a typo in the block comment on encoding/decoding universal times

 Might as well, while we're updating URLs.

 Spotted by Luis Oliveira.

10 years agos/32/n-word-bits/ in bignum-index
Paul Khuong [Fri, 28 Jun 2013 06:03:33 +0000 (02:03 -0400)]
s/32/n-word-bits/ in bignum-index

 For some reason we missed that during all the work on x86-64. Then
 again, our static inference is good enough that no runtime check
 seem to be left to detect that the declaration is wrong.

10 years agoStore FP values from x87 to the heap outside pseudo-atomic
Paul Khuong [Fri, 28 Jun 2013 06:01:06 +0000 (02:01 -0400)]
Store FP values from x87 to the heap outside pseudo-atomic

 It suffices to get the header right, and that way we avoid signaling
 FPEs in PA, when, as is bound to happen, a value is only truncated
 when it's boxed.

10 years agodouble->single float conversion isn't a no-op on x87 anymore
Paul Khuong [Fri, 28 Jun 2013 05:45:49 +0000 (01:45 -0400)]
double->single float conversion isn't a no-op on x87 anymore

 The conversion can result in overflow, so pass through a stack
 temporary to force a truncation.

 Test case by Peter Keller on sbcl-devel, 2013-06-26.

10 years agoNew contrib: SB-GMP
Paul Khuong [Fri, 28 Jun 2013 03:15:38 +0000 (23:15 -0400)]
New contrib: SB-GMP

 This contrib was developed by Stephan Frank to replace some of our
 bignum and rational arithmetic code with calls to libgmp.  Simply
 loading the contrib will transparently accelerate arithmetic on
 large rationals when libgmp is available; if libgmp cannot be found,
 the contrib should change nothing.

 The contrib also wraps additional functions in GNU MP, so that they
 accept and return SBCL-native integers or ratios.  See GNU MP's manual
 for more information.

10 years agoDefer some sanity checks to after testing for value refence to inline functions
Paul Khuong [Fri, 28 Jun 2013 02:03:24 +0000 (22:03 -0400)]
Defer some sanity checks to after testing for value refence to inline functions

 The functional corresponding to an inline function can be marked as dead when
 there remains references in for-value contexts.  Detect such references before
 making sure the function is still live.

 Reported with a reduced test case by Teemu Likonen to sbcl-devel on 2013-06-24.

10 years agoIn MAKE-THREAD, use WITH-SYSTEM-MUTEX for locking *MAKE-THREAD-LOCK*
Jan Moringen [Sun, 23 Jun 2013 17:13:14 +0000 (19:13 +0200)]
In MAKE-THREAD, use WITH-SYSTEM-MUTEX for locking *MAKE-THREAD-LOCK*

Otherwise MAKE-THREAD could be interrupted after having
locked *MAKE-THREAD-LOCK*. If the interrupting code also called
MAKE-THREAD, a recursive lock attempt for *MAKE-THREAD-LOCK* would
occur.

The problem could be easily triggered by

  (MAKE-TIMER ... :THREAD <T or a thread>)

Also move let bindings of SETUP-SEM, REAL-FUNCTION, ARGUMENTS and
INITIAL-FUNCTION and the NOT *GC-INHIBIT* assertion out of the
critical section.

Tests have been added in threads.pure.lisp and timer.impure.lisp.

fixes lp#1180102.

10 years agoWrap the body of sb-debug:backtrace with with-debug-io-syntax.
Attila Lendvai [Wed, 27 Oct 2010 12:03:34 +0000 (14:03 +0200)]
Wrap the body of sb-debug:backtrace with with-debug-io-syntax.

 Added with-debug-io-syntax macro.

 Some whitespace changes as well.