Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmos72 committed Sep 21, 2018
2 parents e4dace5 + e54d768 commit e17f39d
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 47 deletions.
23 changes: 19 additions & 4 deletions README.md
Expand Up @@ -60,6 +60,9 @@ Supported systems
STMX is currently tested on the following Common Lisp implementations:

* [SBCL](http://sbcl.org/)
* version 1.3.6 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 1.3.5 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 1.3.4 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 1.3.3 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 1.3.2 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 1.3.1 (x86_64) on Debian GNU/Linux stretch (x86_64)
Expand All @@ -69,7 +72,7 @@ STMX is currently tested on the following Common Lisp implementations:
* version 1.2.6 (x86) on Debian GNU/Linux stretch (x86_64)
* version 1.1.14 (x86) on Debian GNU/Linux stretch (x86_64)
* version 1.0.57 (x86) on Debian GNU/Linux wheezy (x86)
[using old Quicklisp and libraries]
[requires old Quicklisp and libraries]
* version 1.2.8 (armhf) on Debian GNU/Linux wheezy (armhf) inside Qemu
* version 1.1.15 (powerpc) on Debian GNU/Linux stretch (powerpc) inside Qemu
* version 1.2.7 (x86_64) on Windows 7 (x86_64)
Expand All @@ -90,31 +93,43 @@ STMX is currently tested on the following Common Lisp implementations:

* [CLISP](http://www.clisp.org/)
* version 2.49 (x86_64) on Debian GNU/Linux stretch (x86_64)
(lacks multi-threading)

CLISP lacks multi-threading, and its builtin ASDF must be *manually* upgraded to ASDF3
to load STMX.

* [CMUCL](http://www.cons.org/cmucl/)
* version 20e Unicode (x86) on Debian GNU/Linux stretch (x86_64)
* version 20d Unicode (x86) on Debian GNU/Linux stretch (x86_64)

CMUCL must be started with the command line options "-fpu" "x87"
to run STMX reliably, see [doc/supported-systems.md](doc/supported-systems.md).

Version 20f and later no longer support the command line options "-fpu" "x87"
and are not supported by STMX, see Unsupported systems below.


### Partially supported systems

* [ECL](http://ecls.sourceforge.net/)
* version 16.1.2 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 16.0.0 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 15.2.21 (x86_64) on Debian GNU/Linux stretch (x86_64)
* version 13.5.1 (x86_64) on Debian GNU/Linux stretch (x86_64)

There are known issues running STMX on ECL,
see [doc/supported-systems.md](doc/supported-systems.md) for details.
There are known issues running STMX on ECL, see
[Github issues](https://github.com/cosmos72/stmx/issues/4)

ECL versions 16.0.0 and 16.1.2 run STMX reliably enough for lightweight use,
but sometimes still hang in test suite.


### Unsupported systems

* [CMUCL](http://www.cons.org/cmucl/)
* version 20f and later no longer support the command line options "-fpu" "x87"
needed to run STMX reliably.


### Untested systems

STMX will probably work on several other Common Lisp implementations as long as
Expand Down
26 changes: 13 additions & 13 deletions asm/README.md
@@ -1,5 +1,5 @@
SB-TRANSACTION
==============
STMX.ASM
========

Summary
-------
Expand All @@ -25,9 +25,9 @@ Supported systems
-----------------
Due to its nature, STMX.ASM is highly dependent on specific hardware and software:

- It can be **compiled** only with SBCL on a x86-64 CPU.
- It can be **compiled** only with SBCL on a x86 or x86-64 CPU.

- It can be **used** only with SBCL on a x86-64 CPU that actually supports Intel TSX.
- It can be **used** only with SBCL on a x86 or x86-64 CPU that actually supports Intel TSX.
As of February 2014, the CPUs supporting Intel TSX are:
* Intel Core i7 4771
* Intel Core i7 4770, 4770S, 4770T, 4770TE
Expand All @@ -37,15 +37,15 @@ Due to its nature, STMX.ASM is highly dependent on specific hardware and softwar

Note: all the current Intel Core K and R models, as for example Core i7 4770K and Core i5 4670K,
do **not** support Intel TSX.

Tested systems:
* SBCL version 1.1.14 (x86-64) on Debian GNU/Linux 7.0 (x86-64) on Intel Core i7 4770
* SBCL version 1.1.8 (x86-64) on Debian GNU/Linux 7.0 (x86-64) on Intel Core i7 4770
* SBCL version 1.1.8.60-77641d6 (x86-64) on Debian GNU/Linux 7.0 (x86-64) on Intel Core i7 4770
* SBCL version 1.0.57.0.debian (x86-64) on Debian GNU/Linux 7.0 (x86-64) on Intel Core i7 4770

A 32-bit version - targeting the same x86-64 CPUs running in 32-bit legacy mode -
is technically possibile but this version currently supports only native 64-bit mode.
The x86 version of STMX.ASM targets the same (x86-64) CPUs running in 32-bit legacy mode.



Installation and loading
Expand Down Expand Up @@ -98,7 +98,7 @@ In case you get errors:

A simple test is the following. From the REPL, run:

CL-USER> (use-package :sb-transaction)
CL-USER> (use-package :stmx.asm)
(defun dummy-tx () (progn
(when (= (transaction-begin) +transaction-started+)
(transaction-end)
Expand Down Expand Up @@ -137,8 +137,7 @@ You can test if your CPU supports RTM with the function:
T

It will return T if RTM instructions are supported by the CPU, otherwise it will return NIL.
Again, as of June 2013 only the Intel Core i5 4570, Core i5 4670 and Core i7 4770 do support RTM.
On such a machine, hardware transaction-based code is just regular Lisp code:
On such machines, hardware transaction-based code is just regular Lisp code:

CL-USER> (dummy-tx)
T
Expand All @@ -154,7 +153,8 @@ in the sources - remember `(describe 'some-symbol)` at REPL.
- `TRANSACTION-SUPPORTED-P` is a function returning T if the CPU supports
hardware memory transactions (RTM), and NIL if it does not.
If `(transaction-supported-p)` returns NIL, invoking any of the functions below
has undefined consequences - usually *bad* consequences like unhandled memory faults.
has undefined consequences - usually *bad* consequences like SIGILL signals
or unhandled memory faults.

- `TRANSACTION-BEGIN` starts a new transaction. It returns a fixnum
equal to `+transaction-started+` if the transaction started successfully,
Expand Down Expand Up @@ -199,7 +199,7 @@ in the sources - remember `(describe 'some-symbol)` at REPL.
Examples
--------

Since STMX.ASMS is a low-level library, short examples are necessarily limited
Since STMX.ASM is a low-level library, short examples are necessarily limited
to very simple tasks.

For example, a macro that tries to transactionally swap two memory locations (places) could
Expand All @@ -212,7 +212,7 @@ be written as:
t))

Please note that this example is intentionally simplified: a robust implementation
should also handle signals and, depending on the situation, probably invoke either
should also handle errors and, depending on the situation, probably invoke either
(transaction-abort) or (transaction-end) before propagating the signal,
and it should surely provide an alternative solution to perform the swap
if the transaction aborts.
Expand Down
13 changes: 8 additions & 5 deletions asm/compiler-late.lisp
Expand Up @@ -18,20 +18,23 @@
(let ((not-found (gensym (symbol-name 'not-found-))))
(defun instruction-defined? (inst-name &optional (package-name +impl-package+))
(block nil
;; recent SBCL versions annotate lowercase instructions symbols
;; recent SBCL versions annotate uppercase instructions symbols
;; with sb-disassem:instruction-flavors
;;
;; less recent SBCL versions annotate lowercase instructions symbols instead
#+#.(stmx.asm:compile-if-symbol :sb-disassem :instruction-flavors)
(let* ((inst-name (string-downcase (symbol-name* inst-name)))
(inst (find-symbol* inst-name package-name)))
(let* ((inst-name (symbol-name* inst-name))
(inst (or (find-symbol* (string-upcase inst-name) package-name)
(find-symbol* (string-downcase inst-name) package-name))))
(when
(and inst
(not (eq not-found
(get inst 'sb-disassem::instruction-flavors not-found))))
(return t)))

;; instead old SBCL versions use hash-table sb-assem:*assem-instructions*
;; finally, old SBCL versions use hash-table sb-assem:*assem-instructions*
;;
;; but we actually don't care: on such old versions we can always
;; but we actually don't care about the latter: on such old versions we can always
;; define CPU instructions, as we have all the necessary tools:
;; SB-DISASSEM:DEFINE-INSTRUCTION-FORMAT and SB-VM:DEFINE-INSTRUCTION
#+#.(stmx.asm:compile-if-symbol :sb-assem :*assem-instructions*)
Expand Down
2 changes: 1 addition & 1 deletion lang/thread.lisp
Expand Up @@ -20,7 +20,7 @@

;; CMUCL: fix some buggy bordeaux-threads type declarations
#+cmucl (declaim (ftype (function (t) t) bt:join-thread))
#+cmucl (declaim (ftype (function (t t) t) bt:condition-wait))
#+cmucl (declaim (ftype (function (t t &key (:timeout t)) t) bt:condition-wait))


;;;; ** Helpers to initialize thread-local variables
Expand Down
30 changes: 14 additions & 16 deletions main/optimize-for.lisp
Expand Up @@ -255,6 +255,19 @@ option ~S is supported only for DEFUN, not for DEFMETHOD"

(declaim (inline ,mangled-name))

(,defun-or-defmethod ,mangled-name ,args
,@docstrings
,@declares

(cond
#?+hw-transactions
((/= +invalid-version+ (hw-tlog-write-version)) ,(call-fun :hwtx params))
((use-$-swtx?) ,(call-fun :swtx params))
(t ,(call-fun :notx params))))

(eval-always
(add-optimized-fun* ',mangled-name #(,@funs ,args)))

;; macrolet used by WITH-TX cannot bind names like (setf ...)
;; thus we use a mangled name
;; and create a setf-expander on the original name
Expand All @@ -266,22 +279,7 @@ option ~S is supported only for DEFUN, not for DEFMETHOD"
`((fmakunbound '(setf ,simple-name))
(defsetf ,simple-name ,(rest args-quoted) (,(first args-quoted))
,@docstrings
`(,',mangled-name ,,@params)))))

(,defun-or-defmethod ,mangled-name ,args
,@docstrings
,@declares

#?+hw-transactions
(when (/= +invalid-version+ (hw-tlog-write-version))
(return-from ,mangled-name ,(call-fun :hwtx params)))

(if (use-$-swtx?)
,(call-fun :swtx params)
,(call-fun :notx params)))

(eval-always
(add-optimized-fun* ',mangled-name #(,@funs ,args)))
(list ',mangled-name ,@params)))))

',name))))))

Expand Down
2 changes: 1 addition & 1 deletion main/tclass.lisp
Expand Up @@ -95,7 +95,7 @@ Exactly analogous to TRANSACTIONAL-DIRECT-SLOT."))

(defun list-classes-containing-direct-slots (direct-slots class)
(if *recursive-call-list-classes-containing-direct-slots*
"error listing superclasses, recursive call to listing superclasses"
(error "unexpected recursive call to (stmx::list-classes-containing-direct-slots)")
(let1 *recursive-call-list-classes-containing-direct-slots* t
(handler-case
(loop for superclass in (class-precedence-list class)
Expand Down
2 changes: 1 addition & 1 deletion main/tlog.lisp
Expand Up @@ -211,7 +211,7 @@ Return T if slept, or NIL if some TVAR definitely changed before sleeping."

(with-lock (lock)
(unless (setf prevent-sleep (tlog-prevent-sleep log))
(condition-wait (tlog-semaphore log) lock)))
(condition-wait (tlog-semaphore log) lock #-ecl :timeout #-ecl 10)))

(when (log.debug)
(if prevent-sleep
Expand Down
2 changes: 1 addition & 1 deletion test/conflict.lisp
Expand Up @@ -131,7 +131,7 @@
(log:trace "ipc thread ready")

(loop while (eq t (ipc-command ipc))
do (bt:condition-wait wait-cmd lock))
do (bt:condition-wait wait-cmd lock #-ecl :timeout #-ecl 1))

(let ((command (ipc-command ipc))
(args (ipc-args ipc)))
Expand Down
7 changes: 2 additions & 5 deletions util/tcons.lisp
Expand Up @@ -54,11 +54,8 @@ To use TCONS cells, prepend T to the name of most list-manipulating functions. E
(deftype tlist () '(or tcons null))

(declaim (ftype (function (t t) (values tcons &optional)) tcons)
(ftype (function (#-ecl tlist #+ecl t) t) tfirst trest)
(notinline tcons)
(inline tfirst (setf tfirst)
trest (setf trest)))

(ftype (function (#-ecl tlist #+ecl t) (values t &optional)) tfirst trest)
(notinline tcons))

(defun tcons (first rest)
"Create and return a new TCONS."
Expand Down

0 comments on commit e17f39d

Please sign in to comment.