ppc: Implement :stack-allocatable-fixed-objects

  * Alter SYS:SRC;COMPILER;PPC;MACROS.LISP, WITH-FIXED-ALLOCATION
to accept a parameter for requesting stack allocation instead of
heap allocation.

  * Alter SYS:SRC;COMPILER;PPC;ALLOC.LISP, VOP FIXED-ALLOC to pass
the new stack-allocation parameter.

  * And add :stack-allocatable-fixed-objects to the PPC section in
make-config.sh.
compiler/{sparc,ppc}/macros: with-pinned-objects improvements.

  * For all precise gencgc backends, with-pinned-objects uses an
explicit "pin list".  This pin list should be stack-allocated.

  * Declare the pin list to be TRULY-DYNAMIC-EXTENT, for both
backends.  This won't actually do anything unless the backend
also supports :stack-allocatable-fixed-objects or more than two
objects are to be pinned at once (one-arg LIST and two-arg LIST*
are both converted to CONS by the compiler, and CONS falls under
:stack-allocatable-fixed-objects rather than
:stack-allocatable-lists).
Add test cases for non-consing WITHOUT-GCING and WITH-PINNED-OBJECTS.

  * Neither of these two constructs should cons under normal
circumstances, but WITH-PINNED-OBJECTS is occasionally broken in
this respect on some backends.  May as well make it explicit and
official.
gencgc: Compute bytes_allocated correctly during dynamic space pickup.

  * Rather than computing bytes_allocated based on the number of
pages prior to the "alloc pointer" (really the heap high-water
mark), accumulate it based on the number of ALLOCATED pages.

  * Fixes some lossage in write_generation_stats(), which seems to
be the only place where this value is checked against reality.
ppc support for stack-allocatable-vectors

  * This turned out to be fairly straightforward.  Unlike in a
heap-allocation-only regime, where a VOP is required to :TRANSLATE
ALLOCATE-VECTOR, the :STACK-ALLOCATABLE-VECTORS feature enables an
LTN-ANNOTATE optimizer for ALLOCATE-VECTOR that substitutes
invocations of one of two named VOPs.

  * To convert from the old regime to the new, rename the old VOP
to fit the new naming scheme, and write a new VOP to do the stack
allocation.

  * As a cleaning-up-a-loose-end matter, lose the :TRANSLATE
option for the old VOP.

  * And as a "being somewhat cute about things" matter, make the
support for stack-allocatable-vectors selectable at build time,
which should provide a quick overview of how to make this work on
some other platform, should anyone else be interested later on.
tests/dynamic-extent.impure.lisp: One of the dx-vector test terms was misplaced.

  * MAKE-ARRAY-ON-STACK-1 tries to create a specialized vector,
but was being called from a test that only claims to handle
vectors suitable for a precisely-scavenged control stack.

  * Fix, by moving the call to the next test, which is for
specialized vectors (and thus only runs on conservative-stack
systems).
Correct integer-length on fixnums on x86-64 when n-fixnum-tag-bits > 1.

Use SAR, not SHR for untagging, to preserve the sign.
Thanks to Paul Khuong.
NEWS: Updates for recent PPC changes.

  * I recently committed a small batch of PPC changes, but none of
them had NEWS entries.  This was not quite an oversight, as the
original changes were written prior to the 1.1.7 release, but now
that they've been committed they should at least be mentioned as
NEWS.
Commiting fix by Doug Katzman:  disassembler missing ",8" on SHLD
sb-introspect:find-definition-sources-by-name: find VOPs by name.

(sb-introspect:find-definition-sources-by-name x :vop) now
also returns VOPs which do not translate any functions.
Micro-optimize values-list.

Compare a register with nil-value directly, without going through a
temporary register.
Better type derivation for APPEND, NCONC, LIST.

The result types of APPEND/NCONC depend on the last argument and the
presence of conses in the middle.
For example (append 42) => 42, (append nil nil 42) => 42,
(append (list 1) 42) => (1 . 42), etc.

LIST returns NIL in case of no arguments and a cons in other
cases. That fact required an adjustment for a values-list optimizer,
which removed all arguments from a LIST call making it change the type
from LIST to NULL and confusing things.

Closes lp#538957
Make %EMIT-ALIGNMENT be more friendly to multi-byte NOPs.

When %EMIT-ALIGNMENT needs to tighten the alignment, it used to emit
a fixed-size skip first and an alignment note afterwards. On x86-64,
where block headers are aligned using multi-byte NOPs, this could
lead to emitting one more such NOP than needed to span the desired
range, unnecessarily increasing the number of machine instructions
the processor needs to decode.

To avoid that, change %EMIT-ALIGNMENT to only emit an alignment note
(covering both the fixed-size skip and the alignment note from the
original version) in this situation.

An example of the difference, from the disassembly of
SB-C::FLATTEN-LIST:

Before:

  896: L0:   8F4508           POP QWORD PTR [RBP+8]
  899:       0F1F00           NOP
  89C:       0F1F4000         NOP
  8A0: L1:   4881F917001020   CMP RCX, 537919511

Afterwards:

  896: L0:   8F4508           POP QWORD PTR [RBP+8]
  899:       0F1F8000000000   NOP
  8A0: L1:   4881F917001020   CMP RCX, 537919511
Make CONTAINING-INTEGER-TYPE take N-WORD-BITS into account.

Replace the hardcoded 32s in the function with N-WORD-BITS. This in turn
allows SOURCE-TRANSFORM-NUMERIC-TYPEP to find better transformations
for type checks for types larger than fixnum but smaller than a machine
word also under 64-bit word size. The most important improvement this
achieves is to avoid generic arithmetic for the bounds tests in these
cases.

For example, the test (TYPEP X '(UNSIGNED-BYTE 63)) runs about four
times as fast on x86-64 with this change.

(Tests for the exact types (SIGNED-BYTE 64) and (UNSIGNED-BYTE 64) are
unaffected as compiling them takes another code path, which already
generates well optimized code.)
sb-introspect:find-definition-sources-by-name: more defoptimizer types.

Look for sb-c:ir2-convert and sb-c::stack-allocate-result defoptimizer types.
Allow inlining more calls to INVOKE-WITH-SAVED-FP-AND-PC during XC.

  * The INVOKE-WITH-SAVED-FP-AND-PC mechanism was defined in
ALIENCOMP, which occurs well after the first uses of ALIEN-FUNCALL,
thus preventing it from being inlined when used during XC (by
default, only on x86).

  * Fix, by relocating the mechanism from SB!C to
SB!ALIEN-INTERNALS and from COMPILER;ALIENCOMP to
CODE;EARLY-ALIENEVAL.

  * Also relocate and publish symbols for all of the magic from
SB!ALIEN-INTERNALS.
code/interr: Hook internal error contexts into the saved-fp-and-pc mechanism.

  * This covers the unfortunate case of a signal handler not
having an unbroken stack frame chain to the interrupted context,
which actually occurs on threaded x86-64 FreeBSD systems.

  * Use the existing saved-fp-and-pc mechanism, used for
ALIEN-FUNCALL to cover for code compiled -fomit-frame-pointer to
treat the internal error context as an alien funcall point.
NEWS updates.

  * Forgot to add a NEWS update to my recent commit involving the
internal-error logic.

  * And clarify that only vectors of boxed items may be stack-
allocated on PPC.
code/room: Improve type-format database initialization for simple vector types.

  * There has been a longstanding FIXME comment on a piece of code
which contains a hand-maintained list of specialized vector types
and the shift count for converting the length from elements to
octets.

  * It turns out that all of this information, plus the type names
that we currently do a song-and-dance with INTERN, SUBSEQ, and
MISMATCH to obtain, plus information for the string types, is
available from *SPECIALIZED-ARRAY-ELEMENT-TYPE-PROPERTIES*.  And
*S-A-E-T-P* is guaranteed to be up-to-date, as it's too central to
our implementation of UPGRADED-ARRAY-ELEMENT-TYPE and MAKE-ARRAY
for it to be allowed to break.

  * So, replace nasty KLUDGE of an initialization for simple
vector types with something more principled, making it explicit
which properties need to be derived and which are simply already
available, and picking off the one specialized array type that
needs to be handled differently (SIMPLE-ARRAY-NIL).
code/room: Completely rewrite MAP-ALLOCATED-OBJECTS.

  * The old version of M-A-O consisted of bizaare toplevel logic,
a scheme for figuring out what each heap object was and its size
that did not parallel what the garbage collector used and may or
may not have been correct, and relied heavily on inlining to
reduce consing.

  * This new version of M-A-O uses straightforward toplevel logic,
a scheme for figuring out what each heap object is and its size
that directly parallels what the garbage collector uses and is
verifiably correct, and relies heavily on the aligned unboxed
pointer to fixnum equivalence to reduce consing.

  * The new interface to M-A-O no longer includes the optional
"careful" argument, as it gains us nothing once the underlying
mechanism is so obviously correct.  sb-introspect has been updated
appropriately.

  * The way the new implementation walks the heap and page table
requires direct access to a "static" global variable in gencgc.c,
so the "static" attribute has been removed.

  * This implementation has been lightly tested on an x86-64 and
PPC, and it seems to work quite well, but there are still some
fairly obvious non-optimalities in terms of generated code (as
seen in the trace-file output from the cross compiler).  It does
pass the two test cases that exhausted the heap on PPC with the
previous implementation.