sbcl.git
10 years agofix (again) the handling of read errors in the debugger
Christophe Rhodes [Mon, 3 Jun 2013 08:47:32 +0000 (09:47 +0100)]
fix (again) the handling of read errors in the debugger

Actually the read errors were doing what we wanted, but EOF was no
longer popping one debugger level.  The control transfer is a bit
gnarly, so explicitly grab the restart we might want to use and pass
it as an argument to DEBUG-READ.

10 years agoAvoid consing in SLEEP.
Stas Boukarev [Sun, 2 Jun 2013 20:15:33 +0000 (00:15 +0400)]
Avoid consing in SLEEP.

Try to compute seconds without consing, when the arguments are small
enough (in the fixnum range).

Add a transform to go directly to sb-unix:nanosleep when possible.

10 years agoMake %coerce-callable-to-fun static on x86oids.
Stas Boukarev [Sun, 2 Jun 2013 19:18:20 +0000 (23:18 +0400)]
Make %coerce-callable-to-fun static on x86oids.

It's called a lot when doing funcall or apply.

10 years agoDon't go through fdefn when referencing #'known-functions.
Stas Boukarev [Sun, 2 Jun 2013 18:58:27 +0000 (22:58 +0400)]
Don't go through fdefn when referencing #'known-functions.

Known functions are know to be always present, save on indirection by
using them directly.

10 years agoslightly better handling of read errors in the debugger
Christophe Rhodes [Sun, 2 Jun 2013 18:50:05 +0000 (19:50 +0100)]
slightly better handling of read errors in the debugger

wrap the read as well as the eval in the WITH-SIMPLE-RESTART ABORT
so that the user can return to the existing debugger level on read
errors.

10 years agoCorrect call-indirect for >32-bit addresses.
Stas Boukarev [Sun, 2 Jun 2013 18:22:44 +0000 (22:22 +0400)]
Correct call-indirect for >32-bit addresses.

10 years agoBetter calls to static functions on x86-64.
Stas Boukarev [Sun, 2 Jun 2013 17:25:21 +0000 (21:25 +0400)]
Better calls to static functions on x86-64.

Encode the calls to static functions as an immediate argument to the
CALL instruction when possible.

10 years agoBetter calls to static functions on x86-64.
Stas Boukarev [Sun, 2 Jun 2013 17:14:15 +0000 (21:14 +0400)]
Better calls to static functions on x86-64.

Encode the calls to static functions as an immediate argument to the
CALL instruction when possible.

10 years agoBetter initialization of ir2-component-constants on x86-64.
Stas Boukarev [Sun, 2 Jun 2013 16:33:54 +0000 (20:33 +0400)]
Better initialization of ir2-component-constants on x86-64.

x86 uses the first constant for the fixup vector, x86-64 doesn't.
Don't leave empty space in ir2-component-constants.

On the C side, call gencgc_apply_code_fixups only on x86, and not on
x86_64 as well, since its body is conditionalized for x86_64 anyway.

10 years agoRemove unused variables in the compiler.
Stas Boukarev [Fri, 31 May 2013 16:08:19 +0000 (20:08 +0400)]
Remove unused variables in the compiler.

*code-vector* *next-location* *result-fixups* were last seen being
used on 24 Aug 1990.

10 years agodisassemble: Better annotation of static functions and safepoints.
Stas Boukarev [Sun, 2 Jun 2013 16:21:38 +0000 (20:21 +0400)]
disassemble: Better annotation of static functions and safepoints.

Static functions, like LENGTH and some others, weren't annotated in
the disassemble output.
Also add annotations for safepoints.

10 years ago1.1.8: will be tagged as "sbcl-1.1.8"
Christophe Rhodes [Sun, 2 Jun 2013 13:12:30 +0000 (14:12 +0100)]
1.1.8: will be tagged as "sbcl-1.1.8"

10 years agoFix expected result for a character comparison test under non-unicode.
Lutz Euler [Sun, 2 Jun 2013 12:58:49 +0000 (14:58 +0200)]
Fix expected result for a character comparison test under non-unicode.

The test "character.pure.lisp / :case-insensitive-char-comparisons
:exhaustive" was marked as an expected failure as the unicode
implementation is not yet complete, but on a non-unicode build it
actually already succeeds.

10 years agoFix a regression in APPEND type derivation.
Stas Boukarev [Fri, 31 May 2013 12:27:11 +0000 (16:27 +0400)]
Fix a regression in APPEND type derivation.

Do not just test the arguments for validity by being subtypes or
supertypes of LIST, but also if it's a subytpe of NULL, since ATOM or
SYMBOL won't satisfy the LIST tests.

Regression since f32ee7d.."Better type derivation for APPEND, NCONC,
LIST.", reported by Eric Marsden.

10 years agoStricter precondition when strength reducing variable right shifts
Paul Khuong [Fri, 31 May 2013 01:49:55 +0000 (21:49 -0400)]
Stricter precondition when strength reducing variable right shifts

 Looking at the node's derived type is safer than a result type
 constraint, which seems to consider the LVAR's derived or
 truly-declared type.

 Remove a redundant AVER too. If people call %ash/right directly and
 incorrectly, they're looking for trouble. Moreover, the call's
 type will be derived only if the argument types are correct.

 Reported by Eric Marsden on sbcl-devel; further reduced test cases
 by Christophe Rhodes.

10 years agoCompute single-value-type correctly in the absence of required values
Paul Khuong [Mon, 27 May 2013 21:38:15 +0000 (17:38 -0400)]
Compute single-value-type correctly in the absence of required values

 * For the longest time (at least 2003), we didn't take defaulting
   into account and did not union the single-value type with NULL.
   For some reason, the issue didn't manigest itself until we improved
   code generation for EQ/EQL this month.

   Thanks to Attila Lendvai for the reasonable test case.

 * Also, fix a typo in a VOP name for EQ of fixnum values.

10 years agofix CHAR-EQUALity of non-ascii caseful characters
Christophe Rhodes [Mon, 27 May 2013 07:11:05 +0000 (08:11 +0100)]
fix CHAR-EQUALity of non-ascii caseful characters

Or at least mostly fix it.  There are issues surrounding iota subscript and
titlecase, which aren't regressions in the current release and will require
some more investigation to fix.

11 years agoSkip unicode normalization tests on non-unicode builds.
Lutz Euler [Sat, 25 May 2013 14:39:28 +0000 (16:39 +0200)]
Skip unicode normalization tests on non-unicode builds.

This was accidentally missed when the tests were introduced.

11 years agoRevert "Fix (aref vector (+ i constant)) with i negative on x86oids"
Paul Khuong [Fri, 24 May 2013 20:45:57 +0000 (16:45 -0400)]
Revert "Fix (aref vector (+ i constant)) with i negative on x86oids"

This reverts commit 5d3a728a1d9a91e7218fe53f12f96ab63b846810.

The current code is still wrong, but better the bugs we've always had
than the ones that break currently-working code.

Kept the test case, and added the one we failed on.

11 years agoEven safer substitution of constants in CUT-TO-WIDTH
Paul Khuong [Fri, 24 May 2013 17:13:12 +0000 (13:13 -0400)]
Even safer substitution of constants in CUT-TO-WIDTH

 * Fix another aspect of the modular arithmetic bug that was only
   partially fixed by ccd2a1d (Substitute constants with modular
   equivalents more safely); detected by the previous fix not
   working on !x86oids.

11 years agoRobustify specialised IF/IF conversion introduced in 729ce57
Paul Khuong [Fri, 24 May 2013 17:08:55 +0000 (13:08 -0400)]
Robustify specialised IF/IF conversion introduced in 729ce57

 * When unlinking a node from its destination LVAR, always mark
   the node as potentially up for dead code elimination. IR2 can
   become really confused when converting dead code; a more
   systematic cleanup pass might provide a useful safety net.

 * The changes make a widely-used ir1-manipulation function safer,
   so this might also fix some other obscure compiler bug.

 * Reported by James Y Knight on IRC and Fila Kolodny on Launchpad
   (fixes lp#1183496).

11 years agoSilence the compiler when (runtime-) compiling PCL innards
Paul Khuong [Fri, 24 May 2013 17:07:36 +0000 (13:07 -0400)]
Silence the compiler when (runtime-) compiling PCL innards

11 years agoFix (aref vector (+ i constant)) with i negative on x86oids
Paul Khuong [Fri, 24 May 2013 17:07:35 +0000 (13:07 -0400)]
Fix (aref vector (+ i constant)) with i negative on x86oids

 * The VOPs for indexed access with constant offset take a fixnum
   index. Adjust fndb entries to reflect that.

 * Fix FOLD-INDEX-ADDRESSING: don't convert if the resulting index
   would be wider than a fixnum, and compute the new offset correctly
   for subtractions.

 * Test case by Douglas Katzman.

11 years agotweak so that block-delete-p is findable by grep for 'def.*block-delete-p'
Jingyi Hou [Thu, 23 May 2013 18:20:32 +0000 (02:20 +0800)]
tweak so that block-delete-p is findable by grep for 'def.*block-delete-p'

11 years agosearch_for_executable() fails to process last part of PATH if PATH does not end with ':'
Jingyi Hou [Thu, 23 May 2013 18:18:23 +0000 (02:18 +0800)]
search_for_executable() fails to process last part of PATH if PATH does not end with ':'

11 years agofix build with #!-SB-UNICODE
Christophe Rhodes [Thu, 23 May 2013 19:31:59 +0000 (20:31 +0100)]
fix build with #!-SB-UNICODE

Don't build a hash table with high-codepoint characters as values under
those circumstances.

11 years agoImproved SIMD-PACK manipulation VOPs on x86-64
Paul Khuong [Wed, 22 May 2013 18:19:47 +0000 (14:19 -0400)]
Improved SIMD-PACK manipulation VOPs on x86-64

 * Tighten naive (and, in one case, wrong-looking) lifetime
   specifications to enable more register coalescing.

 * Exploit the coalescing by replacing explicit move instructions
   with MOVE, and specify the SC to get MOVAPS for float data.

 * Microoptimise away some PSRLDQ by 0.

11 years agoSpecialised VOPs for EQ of fixnum values on x86oids
Paul Khuong [Wed, 22 May 2013 18:17:23 +0000 (14:17 -0400)]
Specialised VOPs for EQ of fixnum values on x86oids

 Steal fixnum EQL VOPs to implement EQ, like we already do for
 characters, words and signed-words: otherwise they're converted
 as signed-word EQ.

11 years agoPreserve types when swapping constant arguments and commute LOGTEST
Paul Khuong [Wed, 22 May 2013 18:12:17 +0000 (14:12 -0400)]
Preserve types when swapping constant arguments and commute LOGTEST

 * Add a transform to ensure any constant argument to LOGTEST is in
   second position.

 * Commutative-arg-swap used to often cause suboptimal code: subsequent
   transforms fire before constraint propagation has tightened types
   back to their original value.  Hack with TRULY-THE for now. A more
   general fix (e.g. by declaring the type of arguments in spliced-in
   lambda expressions) would be even better.

11 years agoUpdate/clarify the status of FUNCTIONP and COMPILED-FUNCTION-P
Paul Khuong [Wed, 22 May 2013 05:31:28 +0000 (01:31 -0400)]
Update/clarify the status of FUNCTIONP and COMPILED-FUNCTION-P

The two functions aren't collapsed anymore on #!+sb-eval builds.

11 years agoOptimize (- (* x constant)) into (* x (- constant))
Paul Khuong [Wed, 22 May 2013 04:50:01 +0000 (00:50 -0400)]
Optimize (- (* x constant)) into (* x (- constant))

Another marginal lvar-fun-name/splice-fun-arg hack.

Closes lp#1065770.

11 years agoMore efficient move-from-signed on x86-64 with 63-bit fixnums
Paul Khuong [Wed, 22 May 2013 04:18:26 +0000 (00:18 -0400)]
More efficient move-from-signed on x86-64 with 63-bit fixnums

We can SHL instead of IMUL to check for overflow, and only have to
RCR the sign bit back in to recover the original value.

11 years agoSimpler word-sized variable right shifts on x86 and x86-64
Paul Khuong [Wed, 22 May 2013 03:46:32 +0000 (23:46 -0400)]
Simpler word-sized variable right shifts on x86 and x86-64

 * Known negative shifts are converted to another function that
   only handles machine-friendly right shifts.

 * The transforms and VOPs are conditionalised on ash-right-vops,
   so other platforms aren't penalised.

 * The new transforms trigger a lot of notes; this is suboptimal,
   and one test had to be adjusted.

11 years agoSimplify (- (- x)) for rationals
Paul Khuong [Wed, 22 May 2013 03:43:03 +0000 (23:43 -0400)]
Simplify (- (- x)) for rationals

 The transform is trivial enough to execute without a real pattern
 matching framework, but we're close to the limit.

11 years agoEvaluate global inline functions via their fdefinition
Paul Khuong [Tue, 21 May 2013 23:49:19 +0000 (19:49 -0400)]
Evaluate global inline functions via their fdefinition

 * When inlinable global functions are evaluated for value, emit
   code to refer to their fdefinition, rather than to a bogus
   entry point.

 * Make sure we only generate code to refer to XEPs and fail early
   otherwise, rather than after backpatching.

 * Fixes lp#1035721.

11 years agoTruthful error reporting for complicated compile-time type mismatches
Paul Khuong [Tue, 21 May 2013 21:57:04 +0000 (17:57 -0400)]
Truthful error reporting for complicated compile-time type mismatches

Type mismatches for multiple-use LVARs (i.e. resulting from conditional
expressions) can't be pinpointed to a single source for the value(s).

Such expressions used to be reported as type mismatches with the constant
NIL. Instead, switch to a more complex format with the lowest common source
form, if any (hopefully the conditional), and the nodes that may deliver
the form's value.

Do the same when warning about non-EQ-comparable CATCH tags.

11 years agoImplement EQ of unboxed characters and small integers on x86oids
Paul Khuong [Tue, 21 May 2013 20:20:40 +0000 (16:20 -0400)]
Implement EQ of unboxed characters and small integers on x86oids

 More important now that we actually weaken EQL of EQ-comparable
 types into EQ.  We just have to re-purpose pre-existing EQL and
 CHAR= templates (and adjust the generic test's cost to be less
 attractive), but I can't test on !x86oids.

 Spotted by Douglas Katzman.

11 years agoComplete SSE instruction definitions for x86-64
Paul Khuong [Tue, 21 May 2013 19:12:58 +0000 (15:12 -0400)]
Complete SSE instruction definitions for x86-64

 * New instruction formats:
  - 2-byte instructions with GP/mem source and XMM destination.
  - 1- and 2-byte instructions with XMM source and GP/mem destination.
  - F3-escape instructions GP/mem source and GP destination.
  - 2-byte instructions with GP/mem source and GP destination.

 * Complete support for SSE instruction sets:
  - SSE3
  - SSSE3
  - SSE4.1
  - SSE4.2

 * Fix definition of pblendvb, blendvps, blendvpd: These require a third operand,
   implicitly in XMM0.

 * PEXTRW has a new 2-byte encoding in SSE4.1 which allows a memory address as
   the destination operand. The new encoding is only used when dst is a memory
   address, otherwise the old backward-compatible encoding is used.

 * Fix 64-bit popcnt (F3 still comes REX.W), and make it check for operand sizes,
   like the new CRC32.

 * Slightly adapted from Jonathan Armond to work with Douglas Katzman's F3-specific
   r, r/m instruction format.

11 years agoExport SB-SIMD-PACK symbols from SB-EXT
Paul Khuong [Tue, 21 May 2013 19:12:46 +0000 (15:12 -0400)]
Export SB-SIMD-PACK symbols from SB-EXT

 Export the SIMD-PACK type, the SIMD-PACK-P predicate,
 %make-simd-pack-{ub32,ub64,single,double}, and
 %simd-pack-{ub32s,ub64s,singles,doubles}.

 These are far from useful yet, but at least future extensions
 can work with SB-EXT instead of SB-KERNEL.

 Also, says so in NEWS.

11 years agoSB-SIMD-PACK on x86-64
Paul Khuong [Tue, 21 May 2013 19:12:26 +0000 (15:12 -0400)]
SB-SIMD-PACK on x86-64

 * Enable them by default on x86-64;

 * And run some smoke tests, at least.

11 years agoAdditional niceties and middle end support for short vector SIMD packs
Paul Khuong [Tue, 21 May 2013 19:11:54 +0000 (15:11 -0400)]
Additional niceties and middle end support for short vector SIMD packs

 * Allow FASL loading/dumping of (boxed) SIMD packs, and mark them as
   trivially (i.e. without going through make-load-form) dumpable.

 * SIMD packs print nicely, and take the element type into account while
   doing so.

 * (C)TYPE-OF is more accurate for SIMD packs; this enables IR2 conversion
   to choose the right primitive type and storage class for constants.

The FASL code was kept on life support by Alexander Gavrilov for too many years,
and the printing logic is a very light adaptation of the output code he developed
for his branch.

11 years agoBack end work for short vector SIMD packs
Paul Khuong [Tue, 21 May 2013 19:11:26 +0000 (15:11 -0400)]
Back end work for short vector SIMD packs

 * Platform-agnostic changes:
   - Declare type testing/checking routines.
   - Define three primitive types: simd-pack-double for packs
     of doubles, simd-pack-single for packs of singles, and
     simd-pack-int for packs of integer/unknown.
   - Define a heap-representation for 128-bit SIMD packs,
     along with reserving a widetag and filling the corresponding
     entries in gencgc's tables.
   - Make the simd-pack class definition fully concrete.
   - Teach IR1 how to expand SIMD-PACK type checks.
   - IR2-conversion maps SIMD-PACK types to the right primitive type.
   - Increase the limit on the number of storage classes: SIMD packs
     went way past the previous (arbitrary?) limit of 40.

 * Platform-specific changes, in src/compiler/target/simd-pack:
   - Create new storage classes (that are backed by the float-reg [i.e. SSE]
     storage base): one for each of double, single and integer sse packs.
   - Also create the corresponding immediate-constant and stack storage
     classes.
   - Teach the assembler and the inline constant code about this new kind
     of registers/constants, and how to map constant SIMD-PACKs to which SC.
   - Define movement/conversion VOPs for SSE packs, along with VOP routines
     needed for basic creation/manipulation of SSE packs.
   - The type-checking VOP in generic/late-type-vops is extremely
     x86-64-specific... IIRC, there are ordering issues I do not
     want to tangle with.

 * Implementation idiosyncrasy: while type *tests* (i.e. TYPEP calls) consider
   the element type, type *checks* (e.g. THE or DECLARE) only check for
   SIMD-PACKness, without looking at the element type.  This is allowed by the
   standard, is similar to what Python does for FUNCTION types, and helps
   code remain efficient even when type checks can't be fully elided.

The vast majority of the code is verbatim or heavily inspired by Alexander
Gavrilov's branch.

11 years agoFront end infrastructure for short vector SIMD packs
Paul Khuong [Tue, 21 May 2013 19:10:50 +0000 (15:10 -0400)]
Front end infrastructure for short vector SIMD packs

 * new feature, sb-simd-pack.

 * define a new IR1 type for SIMD packs:
   - (SB!KERNEL:SIMD-PACK [eltype]), where [eltype] is a subtype
     of the plaform-specific SIMD element type universe, or * (default),
     the union of all these possibilities;
   - Element types are always upgraded to the platform's element type
     (small) universe, so we can easily manipulate unions of SIMD-PACK
     types by working in terms of the element types.

 * immediately specify the universe of SIMD pack element types
   (sb!kernel:*simd-pack-element-types*) for x86-64, to ensure
   #!+sb-simd-pack buildability.

 * declare basic functions to create/manipulate SIMD packs:
   - simd-pack-p is the basic type predicate;
   - %simd-pack-tag returns a fixnum tag associated with each SIMD-PACK;
     currently, we suppose it only encodes the element type, as the
     position of the element type in *simd-pack-element-types*;
   - %make-simd-pack creates a 128-bit SIMD pack from a tag and two
     64 bit integers;
   - %make-simd-pack-double creates an appropriately-tagged pack from
     two double floats;
   - %make-simd-pack-single creates a tagged pack from four single
     floats;
   - %make-simd-pack-ub{32,64} creates a tagged pack from four 32 bit
     or two 64 bit integers;
   - %simd-pack-{low,high} returns the low/high integer half of a
     128 bit pack;
   - %simd-pack-ub{32,64}s returns the four integer quarters or two
     integer halves of a 128 bit pack;
   - %simd-pack-singles returns the four singles in a 128 bit pack;
   - %simd-pack-doubles returns the two doubles in a 128 bit pack.

Alexander Gavrilov kept a branch alive for the last couple years. The
creation/manipulation primitives are largely taken from that branch,
or informed by the branch's usage.

11 years agoFix foreign-symbol-address transform on +sb-dynamic-core.
Stas Boukarev [Tue, 21 May 2013 11:05:19 +0000 (15:05 +0400)]
Fix foreign-symbol-address transform on +sb-dynamic-core.

Badly placed ` was resulting in a wrong result.

11 years agoMake some instances of IF/IF conversion more direct
Paul Khuong [Tue, 21 May 2013 00:02:04 +0000 (20:02 -0400)]
Make some instances of IF/IF conversion more direct

When faced with CFGs that look like (if (if ...) ...), we duplicate
the outer NULL test forward in the branches (and jump to the correct
branch, so very little code is duplicated).  However, this transform
depends on later ir1 optimisation to handle patterns like
(if (if ... nil t) ...).  Try and get them right with a specialised
rewrite to get good code even when ir1opt doesn't run until fixpoint.

Also, refactored the code a bit while working on it.

11 years agoExploit specialised VOPs for EQL of anything/constant fixnum
Paul Khuong [Mon, 20 May 2013 22:14:43 +0000 (18:14 -0400)]
Exploit specialised VOPs for EQL of anything/constant fixnum

 By swapping constant arguments to the right ourselves before
 strength reducing EQL into EQ, rather than erroneously using
 commutative-arg-swap.

 Spotted by Douglas Katzman.

11 years agoMore efficient integer=>word conversion and fixnump tests on x86-64
Paul Khuong [Mon, 20 May 2013 21:38:19 +0000 (17:38 -0400)]
More efficient integer=>word conversion and fixnump tests on x86-64

 * Special-case on 63-bit fixnums to detect non-zero fixnum tag bits
   with a shift right when converting fixnum-or-bignum to ub64.

 * In fixnump/unsigned-byte-64, use MOVE to avoid useless mov x, x.

 * In fixnump/signed-byte-64, use the conversion's left shift to
   detect overflows.

 * Based on a patch by Douglas Katzman.

11 years agoCleverer handling of medium (32 < bit width <= 64) constants on x86-64
Paul Khuong [Mon, 20 May 2013 20:58:30 +0000 (16:58 -0400)]
Cleverer handling of medium (32 < bit width <= 64) constants on x86-64

 * Exploit sign-extension for large unsigned constants.

 * Always force the remaining operand and the result in a register:
   in the worst case, we use a RIP-relative unboxed constant.

 * Based on a patch by Douglas Katzman.

11 years agoPOPCNT instruction on x86-64
Paul Khuong [Mon, 20 May 2013 19:26:44 +0000 (15:26 -0400)]
POPCNT instruction on x86-64

 Patch by Douglas Katzman.

11 years agoFix disassembly for BT* instructions on x86oids
Paul Khuong [Mon, 20 May 2013 19:17:36 +0000 (15:17 -0400)]
Fix disassembly for BT* instructions on x86oids

 * A dedicated instruction format gets the details right.

 * Patch by Douglas Katzman.

11 years agoAnnotate disassembly with unboxed constant values
Paul Khuong [Mon, 20 May 2013 19:02:45 +0000 (15:02 -0400)]
Annotate disassembly with unboxed constant values

 * Only on x86-64, for qword-sized values.

 * Patch by Douglas Katzman.

11 years agoImproved local call analysis for inlined higher-order functions
Paul Khuong [Mon, 20 May 2013 18:49:33 +0000 (14:49 -0400)]
Improved local call analysis for inlined higher-order functions

Locall analysis greatly benefits from forwarding function arguments to
their use site.  Do that in locall and hopefully trigger further rewrites,
rather than waiting for a separate ir1opt phase to do its magic.

11 years agoConstant-fold backquote of constant expressions
Paul Khuong [Mon, 20 May 2013 18:11:48 +0000 (14:11 -0400)]
Constant-fold backquote of constant expressions

 * There is no guarantee that backquote expressions cons up fresh
   storage, so we are free to allocate (sub)lists or vectors at
   compile-time. In addition to regular constant-folding, perform
   part of LIST/LIST*/APPEND at compile-time.

 * Fix one instance of CL:SORT of now-literal data.

 * Implement SB!IMPL:PROPER-LIST-P because BACKQ-APPEND needed that.

 * Based on a patch by James Y Knight; closes lp#1026439.

11 years agoEnable (type-directed) constant folding for LOGTEST on x86oids and PPC
Paul Khuong [Mon, 20 May 2013 16:19:27 +0000 (12:19 -0400)]
Enable (type-directed) constant folding for LOGTEST on x86oids and PPC

 * COMBINATION-IMPLEMENTATION-STYLE can return :maybe. Like :default,
   it enables transforms, but transforms can call C-I-S themselves to
   selectively disable rewrites.

 * Implement type-directed constant folding for LOGTEST. !x86oids/PPC
   platforms get that for free via inlining.

 * Use :maybe to enable all LOGTEST transforms except inlining.

11 years agoExploit associativity to fold more constants
Paul Khuong [Mon, 20 May 2013 15:36:21 +0000 (11:36 -0400)]
Exploit associativity to fold more constants

 * Implement transforms for logand, logior, logxor and logtest to
   detect patterns like (f (f x k1) k2) => (f x (f k1 k2)).

 * Same for + and * of rational values.

 * Similar logic for mask-signed-field: we only need to keep the
   narrowest width.

11 years agoroom: Fix reconstituting CONS cells with unbound-marker in the CAR.
Alastair Bridgewater [Mon, 20 May 2013 19:43:19 +0000 (15:43 -0400)]
room: Fix reconstituting CONS cells with unbound-marker in the CAR.

  * When I originally rewrote ROOM in terms of RECONSTITUTE-OBJECT,
I looked at what constitutes a valid CONS according to the runtime.
I noticed that one of the immediate types was an unbound marker
and said to myself "nobody's going to put one of those in a list".
This turned out to be a mistake.

  * x86 systems (and plausibly not any others) put unbound-markers
in lists when loading FASLs.  I have no real idea how or why, but
they do.  This would lead to an error, "Unrecognized widetag #x4A
in reconstitute-object".

  * Fix, by recording unbound-marker-widetag as being valid as the
first word of a CONS cell.

  * Issue reported by "scymtym" on #sbcl.

11 years agogencgc: Decide earlier about pinning large object pages.
Alastair Bridgewater [Sun, 19 May 2013 17:00:52 +0000 (13:00 -0400)]
gencgc: Decide earlier about pinning large object pages.

  * The old logic here called maybe_adjust_large_object(), and
then re-checked the pointer to preserve for validity.  This is
non-optimal, as it means that maybe_adjust_large_object can't
promote pages to newspace directly, it instead merely adjusts the
page allocation to fit the possibly-shrunken object.

  * It turns out that large_object pages can contain bignums,
vectors, code-objects, or in unusual cases instances.  Neither
bignums, vectors, nor instances can contain embedded objects.
Code-objects can contain only functions or LRAs.  None of these
objects have list-pointer-lowtag on their references.  The "tail"
of a shrunken object is comprised of conses with both cells as
fixnum zero.  The minor catch is that we allow untagged pointers
to pin code-allocated pages, but the saving grace here is that
code-objects don't shrink.

  * Alter preserve_pointer() to test the lowtag and page type to
check for invalid pointers to large-object pages before calling
maybe_adjust_large_object() instead of bounds-checking the pointer
after the fact.

11 years agogencgc: Fix potential out-of-bounds access in page_ends_contiguous_block_p().
Alastair Bridgewater [Tue, 14 May 2013 22:45:30 +0000 (18:45 -0400)]
gencgc: Fix potential out-of-bounds access in page_ends_contiguous_block_p().

  * If we're testing to see if the LAST page in dynamic space is
the end of a contiguous block, and it is a full page (bytes_used
is GENCGC_CARD_BYTES), we turn around and start investigating the
next page table entry... but there isn't one, it's beyond the end
of the allocation.

  * Fix, by bounds-testing the page index against the index of the
high-water mark for dynamic space.  This is guaranteed to be no
more than the total maximum for the page table, and is slightly
more micro-efficient than using the actual maximum, as any page
after the high-water mark will be page_free_p().

11 years agogencgc: Introduce a new predicate, page_ends_contiguous_block_p().
Alastair Bridgewater [Tue, 14 May 2013 22:39:06 +0000 (18:39 -0400)]
gencgc: Introduce a new predicate, page_ends_contiguous_block_p().

  * There are a number of places in gencgc where a number of
attributes of a page and possibly the subsequent page are tested
for various values.  Invariably, this is actually testing to see
if a page ends a contiguous block.

  * Extract the various tests to a new inlined predicate function,
page_ends_contiguous_block_p(), thus revealing the intent of
what's going on far better than the bare tests, and coalescing the
code to a single copy to make it easier to fix if there is a bug
in it (and there is, but this is a refactoring commit, not a
behavior change commit).

11 years agogencgc: Introduce a new predicate, page_starts_contiguous_block_p().
Alastair Bridgewater [Tue, 14 May 2013 00:57:03 +0000 (20:57 -0400)]
gencgc: Introduce a new predicate, page_starts_contiguous_block_p().

  * There are a number of places in gencgc where scan_start_offset
for a page is tested for zero.  Invariably, this is actually
testing to see if a page starts a contiguous block...  Or starts
on an object boundary.

  * Extract the various tests for a zero scan_start_offset to a
new inlined predicate function, page_starts_contiguous_block_p(),
thus revealing the intent of what's going on far better than the
bare test.

11 years agogencgc: Rename page_table field region_start_offset to scan_start_offset.
Alastair Bridgewater [Mon, 13 May 2013 23:19:43 +0000 (19:19 -0400)]
gencgc: Rename page_table field region_start_offset to scan_start_offset.

  * Let's call it what it is: The offset from where to start any
scan through the page to the start of the page.  The only relation
this field has to an alloc_region is the way it is initialized.

11 years agogencgc: Commentary fix for struct page, field region_start_offset.
Alastair Bridgewater [Mon, 13 May 2013 22:41:11 +0000 (18:41 -0400)]
gencgc: Commentary fix for struct page, field region_start_offset.

  * Simply describing region_start_offset as being related to an
allocation region which contains a page is disingenuous at best,
and misleading at worst.  Its relation with an alloc_region is due
to its initialization strategy, and has nothing to do with what
the value is for.

  * Say it like it is, it's an offset to a known object boundary,
from where we can start a call to gc_search_space() or scavenge().
That's what it's for, not for keeping track of alloc_regions.

11 years agogencgc: Defer moving pinned pages to newspace as late as possible.
Alastair Bridgewater [Sun, 12 May 2013 14:49:55 +0000 (10:49 -0400)]
gencgc: Defer moving pinned pages to newspace as late as possible.

  * Rather than moving pinned pages to newspace immediately, defer
moving them until just before we start to scavenge (evacuate) all
of the oldpsace pages.

  * This, in theory, makes it easier to move pages to newspace if
they are mostly-live, rather than having to allocate new pages for
the data (increasing peak address-space use during GC), assuming
that we know that some page meets such criteria.

  * While we're here, commentary updates also replace an "XX I'd
rather not do this but the GC logic can't cope with not doing it"
with an actual explanation of WHY it needs to be done.  In fact,
commentary updates explain it twice, in two different locations.

11 years agogencgc: Fix commentary for page table allocation field.
Alastair Bridgewater [Sun, 12 May 2013 15:43:09 +0000 (11:43 -0400)]
gencgc: Fix commentary for page table allocation field.

  * The commentary for the page table allocation field was
misleading, presumably not updated when the definitions for the
constants used for its actual contents were last changed, and cost
me a bit of surprise and time spent trying to figure out why core
file saving and loading worked at all.

  * Updated the commentary on the allocation field to match
current reality, and added cross-references between the field
itself and the definitions for its contents, so that a future
desync between commentary and reality is less likely.

11 years agoMore robust function-name testing in CUT-TO-WIDTH
Paul Khuong [Mon, 20 May 2013 14:40:00 +0000 (10:40 -0400)]
More robust function-name testing in CUT-TO-WIDTH

 Let's use lvar-fun-name instead of replicating half the logic; as
 a bonus, modularity transforms now heeds NOTINLINE.

11 years agoFix (CONCATENATE 'null ...) for generic sequences
Paul Khuong [Mon, 20 May 2013 05:03:01 +0000 (01:03 -0400)]
Fix (CONCATENATE 'null ...) for generic sequences

 * (CONCATENATE 'NULL SEQUENCE1 SEQUENCE2 ...) ensures that SEQUENCE1,
   SEQUENCE2, ... are empty, but only did so for lists and
   vectors. Instead, use new function EMPTYP which works for all
   sequences. EMPTYP is not exported.

 * Add generic function SEQUENCE:EMPTYP to which EMPTYP dispatches for
   generic sequences. Methods for lists, vectors and generic sequences
   use NULL or (ZEROP (LENGTH ...)).

 * Test cases in seq.impure.lisp.

 * Patch by Jan Moringen; fixes lp#1162301.

11 years agoPrint intermediate evaluation results for some ASSERTed expressions
Paul Khuong [Mon, 20 May 2013 04:40:33 +0000 (00:40 -0400)]
Print intermediate evaluation results for some ASSERTed expressions

* The reports of errors signaled by ASSERT now print intermediate
  evaluation results under the following conditions:
   1. The ASSERTed expression is known to be a function call.
   2. Arguments in the call are not constants.

* Test the new feature in condition.impure.lisp.

* Original patch from Alexandra Barchunova; closes lp#789497.

11 years agoTake bitwidth into account in BOOLEAN alien type
Paul Khuong [Mon, 20 May 2013 03:47:13 +0000 (23:47 -0400)]
Take bitwidth into account in BOOLEAN alien type

Some ABIs (x86/x86-64) allow garbage in unused upper bits of return
values; take that into account when converting BOOLEAN return types
to CL BOOLEANs.

11 years agoDeclare the argument type for float-radix
Paul Khuong [Mon, 20 May 2013 03:27:26 +0000 (23:27 -0400)]
Declare the argument type for float-radix

 Otherwise, inlined copies sometimes skip the type check.

11 years agoEnable dumping huge (> 64k) pages in genesis
Paul Khuong [Sun, 19 May 2013 23:35:30 +0000 (19:35 -0400)]
Enable dumping huge (> 64k) pages in genesis

bvectors for a page can be smaller than the page size; zero-padding
explicitly as needed lets the build proceed further along before
failing, when configured with large GC card size.

11 years agoMake ir1-convert-hairy-lambda safe for non-local exits.
Stas Boukarev [Sun, 19 May 2013 16:37:27 +0000 (20:37 +0400)]
Make ir1-convert-hairy-lambda safe for non-local exits.

The function it calls may throw a tag, locall-already-let-converted,
which will leave a partially initialized optional-dispatch structure
in new-functionals of the current component, which may cause problems
down the line.

Fixes lp#1180992.

Also add a test-case for f3a2cd.. "Add a stub for %other-pointer-p.".

11 years agoFree-er form FILTER-LVAR
Paul Khuong [Sun, 19 May 2013 15:12:43 +0000 (11:12 -0400)]
Free-er form FILTER-LVAR

The DUMMY argument can now be in any argument position.  Use that
in CUT-TO-WIDTH instead of ((lambda (...) ...) ...) hack.

11 years agoMore robust FILTER-LVAR through CASTs
Paul Khuong [Sun, 19 May 2013 14:14:35 +0000 (10:14 -0400)]
More robust FILTER-LVAR through CASTs

 * IR1-conversion can insert casts between a combination and its
   arguments. Handle that case via principal-lvar{-use}.

 * Fixes a regression in b111015 (lp#1181684).

11 years agoNEWS entries for Unicode normalization work
Christophe Rhodes [Sat, 18 May 2013 20:46:33 +0000 (21:46 +0100)]
NEWS entries for Unicode normalization work

11 years agoimplement primary and canonical composition, and hence NFC/NFKC
Christophe Rhodes [Sat, 18 May 2013 12:37:55 +0000 (13:37 +0100)]
implement primary and canonical composition, and hence NFC/NFKC

Read in the non-algorithmically-specified composition exclusions from
Unicode's CompositionExclusions.txt file, and generate a hash table
using the concatenated 42 bits of code points.  This is a bit of a
sucky hash-table key, particularly on 32-bit platforms; I have a plan
to reduce the key to 24 bits (using some auxiliary information in ucd)
but the advantage of getting this try in is...

... hook in NFC/NFKC into normalization tests, and check that tests
pass.

11 years agoactually run Part3 of Unicode Normalization tests
Christophe Rhodes [Sat, 18 May 2013 09:54:12 +0000 (10:54 +0100)]
actually run Part3 of Unicode Normalization tests

11 years agobetter UCD treatment of characters not allocated by Unicode
Christophe Rhodes [Thu, 9 May 2013 14:22:26 +0000 (15:22 +0100)]
better UCD treatment of characters not allocated by Unicode

fixes lp#1178038 (reported by Ken Harris)

11 years agofinish handling NormalizationTest test vectors
Christophe Rhodes [Fri, 19 Apr 2013 08:17:15 +0000 (09:17 +0100)]
finish handling NormalizationTest test vectors

NFC/NFKC still not hooked in, but otherwise complete.

11 years agofirst cut at testing unicode normalization
Christophe Rhodes [Thu, 18 Apr 2013 21:20:58 +0000 (22:20 +0100)]
first cut at testing unicode normalization

Parts 0 and 1 from Unicode NormalizationTest.txt, fully tested for
NFD and NFKD.

11 years agoadd a comment about one-basing the character tables
Christophe Rhodes [Thu, 18 Apr 2013 19:14:21 +0000 (20:14 +0100)]
add a comment about one-basing the character tables

11 years agoapply recursive decomposition in DECOMPOSE-STRING
Christophe Rhodes [Thu, 18 Apr 2013 17:03:09 +0000 (18:03 +0100)]
apply recursive decomposition in DECOMPOSE-STRING

We should really precompute the result of the recursion during the build;
working on getting tests up and running so that we can check whether
we've done that correctly.

11 years agofix test for Blocked condition in canonical normalization
Christophe Rhodes [Sun, 14 Apr 2013 19:02:08 +0000 (20:02 +0100)]
fix test for Blocked condition in canonical normalization

Would most likely otherwise fail in Jamo with combining characters in
between.

11 years agoimprove normalize-string
Christophe Rhodes [Sun, 14 Apr 2013 19:01:18 +0000 (20:01 +0100)]
improve normalize-string

* now works on non-simple strings;
* more likely to be correct under #!-sb-unicode

11 years agocomment on LSTRING implementation
Christophe Rhodes [Sun, 14 Apr 2013 15:40:24 +0000 (16:40 +0100)]
comment on LSTRING implementation

11 years agohandle Hangul syllable decomposition
Christophe Rhodes [Wed, 27 Mar 2013 12:58:19 +0000 (12:58 +0000)]
handle Hangul syllable decomposition

Entries for the codepoint range (#xac00 -- #xd7a3) have 1 for
their decomposition-info, a decomposition length of 2 or 3, but
a zero decomposition index (the decomposition is handled
algorithmically instead).

11 years agowork-in-progress towards full normalization support
Christophe Rhodes [Fri, 22 Mar 2013 12:03:24 +0000 (12:03 +0000)]
work-in-progress towards full normalization support

11 years agobeginnings of decomposition
Christophe Rhodes [Sun, 17 Mar 2013 21:23:59 +0000 (21:23 +0000)]
beginnings of decomposition

Store enough information in output from ucd.lisp to be able to actually
decompose individual characters.  Include proof-of-concept implementation
of decomposition, not hooked into anything yet.

11 years agodelete now-unused code from ucd.dat
Christophe Rhodes [Sun, 17 Mar 2013 09:23:36 +0000 (09:23 +0000)]
delete now-unused code from ucd.dat

11 years agoIncorporate some decomposition information in ucd table
Christophe Rhodes [Fri, 15 Mar 2013 21:44:31 +0000 (21:44 +0000)]
Incorporate some decomposition information in ucd table

Oh boy.  This one is quite intricate.  We have two bytes free in
the 8-byte entries for information about characters, so use one of
them to indicate if the character has a decomposition, and if so of
what kind it is.  Adapt the ucd.lisp tools-for-build code to
parse and preserve that information.

However, this causes there to be more than 256 distinct possible
classes of character known to the system: not a problem in principle,
but Teemu Kalvas' implementation of the double indirection depended on
having a one-byte index.  But since Unicode characters are limited to
21 bits, with a careful packing scheme we can in fact steal 3 more bits
for the index, at the cost of needing to do an extra memory reference
and some arithmetic to reconstruct the index.  (In the process, change
the endianness of the ucd.dat filesystem representation, because it's
easier that way).

But wait, there's more.  Before, there were only two kinds of
lower-case characters: those whose upper-case transformation
lowercase back to the original character, and those where there is
no round-trip.  (The former are cl:lower-case-p, the latter aren't).
This gave rise to straightforward implementations of lower-case-p
and friends; in the new world, where there are multiple different
kinds of lower-case characters (with various decomposition classes)
we need to adjust the implementations, still fairly straightforward,
of lower-case-p and related functions.

The extra information provided in the ucd table by this commit
is largely useless on its own; the next step is to incorporate
the actual decomposition data.  Stay tuned.

11 years agoMORE COMMENT regarding the careful format of the encoded UCD data
Christophe Rhodes [Fri, 15 Mar 2013 14:29:57 +0000 (14:29 +0000)]
MORE COMMENT regarding the careful format of the encoded UCD data

11 years agoupdate to unicode 6.2
Christophe Rhodes [Wed, 13 Mar 2013 12:33:24 +0000 (12:33 +0000)]
update to unicode 6.2

11 years agoComplete cut-to-width
Paul Khuong [Sat, 18 May 2013 00:22:44 +0000 (20:22 -0400)]
Complete cut-to-width

 * Insert logand/mask-signed-field even around references to variables
   in modular arithmetic: avoid recursive rewriting by disabling the
   transform when the destination is a direct logand/mask-signed-field
   combination.

 * Fixes lp#1026634 (reported by Anton Marsden on sbcl-devel).

11 years agoMore efficient MASK-SIGNED-FIELD
Paul Khuong [Fri, 17 May 2013 21:44:12 +0000 (17:44 -0400)]
More efficient MASK-SIGNED-FIELD

 Word => signed-word and {word, signed-word} => fixnum conversions
 are implemented with unchecked move VOPs.

11 years agoInsert typechecks before RAW-INSTANCE-INIT in structure constructors
Paul Khuong [Fri, 17 May 2013 21:21:55 +0000 (17:21 -0400)]
Insert typechecks before RAW-INSTANCE-INIT in structure constructors

 * Usually, FTYPE declarations ensure that happens, but multiple
   inlining of the same structure constructor cause strangeness.

 * Fixed lp#1177703, reported by Jan Moringen.

11 years agoMore robust erroneous local call detection
Paul Khuong [Fri, 17 May 2013 20:54:06 +0000 (16:54 -0400)]
More robust erroneous local call detection

 * When possible, convert known bad calls into calls to error-signaling
   stubs.

 * Fixes lp#504121 (and likely other occurrences of
   "failed AVER (ZEROP (HASH-TABLE-COUNT ...))."

11 years agoCOMPILE-FILE shouldn't "attempt to dump invalid structure" anymore
Paul Khuong [Fri, 17 May 2013 20:08:00 +0000 (16:08 -0400)]
COMPILE-FILE shouldn't "attempt to dump invalid structure" anymore

 * When CAST nodes detect definite type mismatch, they are replaced
   with debugging instrumentation to provide source locations at
   compile and run -time. When code is generated internally, the
   source can include literal internal data structures. Skip those
   when recovering source locations.

 * Fixes lp#943953 and a bunch of equally baffling duplicates.

11 years agoRecover full backtraces with generic arithmetic on x86 and x86-64
Paul Khuong [Fri, 17 May 2013 19:25:50 +0000 (15:25 -0400)]
Recover full backtraces with generic arithmetic on x86 and x86-64

 * Errors in generic arithmetic (or comparisons) used to hide the caller
   in the backtrace: it was replaced with a frame in the anonymous
   assembly stub.

 * Regression since 1.0.24.35, fixes lp#800343.

 * Also remove a misleading FIXME in typed-accessor-definitions
   (reported by Matt Novenstern in lp#1171646).

11 years agoAdd a stub for %other-pointer-p.
Stas Boukarev [Thu, 16 May 2013 17:08:48 +0000 (21:08 +0400)]
Add a stub for %other-pointer-p.

Otherwise the VOP isn't translated on literal objects, and
sb-sequence:do-sequence stops working on literal vectors. Having a
stub allows constant folding to work.

Reported by adeht on #lisp.

11 years agoloop: remove code size-estimation.
Stas Boukarev [Thu, 16 May 2013 12:51:47 +0000 (16:51 +0400)]
loop: remove code size-estimation.

Loop has a facility to determine whether it's ok to duplicate variable
initialization and stepping code when the variable preceding it has
different initialization and stepping forms. The code which determines
code size is quite strange and it may have been relevant 20 years ago
on primitive implementations, but not anymore, and people who really
care about code size would use functions, which will also improve code
readability.

As a side effect, it fixes a bug which was present in the
estimate-code-size function.

Fixes lp#1178989.

11 years agoFix describe-object for characters.
Stas Boukarev [Mon, 13 May 2013 15:40:20 +0000 (19:40 +0400)]
Fix describe-object for characters.

Don't prefix lines with ":_".