Looping around nanosleep() isn't a winning solution: we don't know if the remainder from nanosleep reflects the time spent in signal handler or not. Keep the nanosleep() based version around for Darwin and other non-conformant platforms: :OS-PROVIDES-CLOCK-NANOSLEEP tells us if we need to use it or not. Since neither clock_nanosleep nor nanosleep is guaranteed to be asynch signal safe, add a test-case that tries to hang them via nesting. My theory is that in practise they both /are/ asynch signal safe... FIXME: Stress test fails!
* Add "Deprecated Interfaces" chapter to the manual. * Add list of deprecated interfaces along with a policy note to a comment near DEFINE-DEPRECATED-FUNCTION. * Add a proper deprecation warning for SB-C::MERGE-TAIL-CALLS. * Fix the deprecation warning for WITH-SPINLOCK. (Accidentally referred to WITH-RECURSIVE-SPINLOCK before.)
coreparse.c: Move #define _BSD_SOURCE up, so that it won't conflict with subsequent files, and #undef it after it's used to include sys/mman.h search.c(search_for_type): Remove unused variable addr. interrupt.c: Remove double parentheses in if((x==y)). run-program.c: Include sys/wait.h
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 space. I took some inspiration from WHN's attempt at an accept-reject loop implementation in commit 0a7604d and following. 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.
With integer types that are neither an interval nor a single known value the DEFTRANSFORM used to generate an expression that had two problems: First, it yielded very uneven distributions of random values for most arguments to RANDOM that are not very small. Second, it used a too small RANDOM-CHUNK under 64 bits word size thus never generating numbers larger than (1- (EXPT 2 32)) even if RANDOM's argument was larger than (EXPT 2 32). Fix this by giving up the transform in these cases. Add a new file "tests/random.pure.lisp" containing tests for this.
…B-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.
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 deadlines. 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 finish. * 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 thread.
This means we have by default 5% of total heap usable in the nursery between GCs, and another 5% of the total heap split between all the generations -- and roughly matches the nursery/old generation sizes relations from before the dynamic-space-size based scaling. Fixes lp#991293, regression since 6848a92.
In MOVE-IMMEDIATE, when the target is in memory, avoid using a temporary register for more values than currently: The MOV instruction can move immediate values of type (SIGNED-BYTE 32) into 64-bit memory locations, not only (SIGNED-BYTE 31). Simplify a TYPE-CASE in MOVE-ARG: merge two clauses that generated exactly the same MOV instruction; spare a call to MOVE-IMMEDIATE and get rid of two ugly literal 29s thereby. Add a test.
package-nicknames, package-use-list, package-used-by-list, package-shadowing-symbols now have `package-designator' instead of `x' in their arlgists. Closes lp#854314. Clean up: remove a duplicate definition from tests/compiler-test-util.lisp
Unused except by %DEFKNOWN, which passed in *INFO-ENVIRONMENT* anyways.
Regular compiler macros defined on host do not take effect when XC is building the target -- so INFO calls in the build before globaldb got the slow path up to now. Using source-transforms we get the fast path for all INFO calls on target. Speeds up globaldb bound functions like FDEFINITION by 20% or so.
* Make SIMPLE-READER-PACKAGE-ERROR a subclass of PACKAGE-ERROR. * Make reader signal a SIMPLE-READER-PACKAGE-ERROR for missing packages, instead of a vanilla PACKAGE-ERROR: that way get the position reported as well. * Factor out line and column reporting logic for reader-errors into a separate function, and allow using other than current file position. * READ-FOR-COMPILE-FILE needs to use COMPILER-ERROR, and INPUT-ERROR-IN-COMPILE-FILE is a subclass of READER-ERROR, not a FATAL-COMPILER-CONDITION. * *COMPILER-ERROR-BAILOUT* binding in SUB-COMPILE-FILE was missing the condition argument from the lambda-list, and should not mumble to *STANDARD-OUTPUT*. This patch converts all input errors into COMPILE-FILE failures without dropping into the debugger. That might be taking things too far, though -- but the question of "which errors should we let enter the debugger" has no obvious answers to me at least. Perhaps *COMPILER-HANDLED-ERRORS* is the way to go? Fixes lp#493380
Arithmetic on tagged fixnums currently assembles only constant fixnums of type (SIGNED-BYTE 29) as immediate arguments to the machine instructions. When N-FIXNUM-TAG-BITS is less than 3 a larger range of fixnums could be treated this way. This is desirable as it avoids the costs of the alternative, namely to put the value into the constant pool. So change this type to (SIGNED-BYTE (- 32 N-FIXNUM-TAG-BITS)). Extend an existing test to cover constants in this range, too. Many thanks to Paul Khuong for help in finding a name for the type.
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.)
Or at least pretend harder. Ie. if the frame is a XEP frame, and the actual argument count is > number of parsed arguments, make up unprintable ersatz objects for the rest.
No out-of-bounds accesses, thanks! ...and thanks to Nathan who spotted my bogosity.
ERROR call needs to appear inline for that to happen without extra acrobatics.
Replace all occurrences of (INST OR REG REG) with (INST TEST REG REG) in VOPs and assembly routines. This removes, for the next read of REG, the dependency on this instruction, allowing more instruction-level parallelism, so is potentially faster. Moreover, most of the time the next instruction is a conditional branch, which allows processors that support macro-op fusion to fuse the TEST (but not the OR) with this branch instruction, reducing the resources needed to decode and execute the two instructions, which again is potentially faster.
The assembler instruction MOVZX is already assembled as a straight 32-bit MOV when it is used to zero-extend a 32-bit source into a 64-bit register, taking advantage of the processor's implicit zero extension, sparing the REX prefix (if it was only needed to indicate the 64-bit size) and thus reducing code size. Towards the same goal, change zero-extensions of 8- or 16-bit sources into a 64-bit register to use the corresponding 32-bit register as the destination instead, in the process refactoring EMIT-MOVE-WITH-EXTENSION for more OAOO-ness.