Commit graph

6946 commits

Author SHA1 Message Date
Marius Gerbershagen
711d17e373 si_clear_gfun_hash: only enqueue operations for threads with valid environments
Fixes #560.
2020-02-14 22:40:56 +01:00
Marius Gerbershagen
cc7c0d4386 multithreading: fix race condition on thread creation
Due to the fact that the thread local environment is allocated with
mmap, the garbage collector is only aware of it after the thread is
listed in cl_core.processes. Therefore, we have to list the thread
before we allocate any memory in its environment. We were doing this
previously, however a bit earlier than needed which had the
unfortunate side effect that not all threads listed in
cl_core.processes had valid environment associated to them. Now, we
delay the listing until immediately before allocating the contents of
environment, ensuring that all listed threads have valid environments.
2020-02-14 22:31:46 +01:00
Daniel Kochmański
471f3f8312 function-lambda-list: bytecmp: always use the annotation
I think that the old method is a relic from the past when bytecodes
had a different representation. bytecompiled functions also have
proper annotations so there is no need to attempt to disassemble their
lambda lists manually. Closes #561.
2020-02-11 17:06:51 +01:00
Daniel Kochmański
5d5fcc40d2 Merge branch 'develop' into 'develop'
cmpmain: fix link(msvc) arguments in linker-ar

See merge request embeddable-common-lisp/ecl!183
2020-02-10 09:25:55 +00:00
Yuguo Zhang
2532262c0a cmpmain: fix link(msvc) arguments bug in linker-ar 2020-02-10 13:17:18 +08:00
Marius Gerbershagen
c530793d2b doc: cosmetic improvements
Consistent formatting and capitalization, clickable links to functions
defined in other parts of the manual, better looking css for html
output. Some small errors and typos have been corrected as well.
2020-02-07 21:43:11 +01:00
Marius Gerbershagen
b85d628955 run-program: fix handling of nil argument to :if-output-exists, :if-input-does-not-exist
According to the documentation, we were supposed to return nil, but
instead we signaled a bogus error like

 :INPUT argument to RUN-PROGRAM does not have a file handle:
 #<output stream "/dev/null" 0x5645a22a5280>
2020-02-07 21:38:30 +01:00
Marius Gerbershagen
f1a92c422a cmp: Ignore compiler macros in (eval-when (:compile-toplevel))
Some of the compiler macros expand into FFI:C-INLINE forms, precluding
the compilation of statements like
  (eval-when (:compile-toplevel :load-toplevel :execute)
    (print "test")).

Commit b00e62f9d3 (now reverted)
attempted to fix this previously, but introduced other bugs (see #553).
Instead of the naive solution of evaluating everything
in (eval-when (:compile-toplevel)) directly with the bytecodes
compiler, the approach used in this commit is to be more specific and
ignore compiler macros during compile time evaluation (i.e. the output
of the compiler macro is used only in the emitted C code, but not as
input for CMP-EVAL).

Fixes #553.
2020-02-02 17:38:27 +01:00
Marius Gerbershagen
41fef66e1e Revert "cmp: remove unused variables: *compile-time-too*, *not-compile-time*"
This reverts commit 241f3ed172.
2020-02-02 16:01:38 +01:00
Marius Gerbershagen
2e4a23f7c9 Revert "cmp: Allow for compile time evaluation of inlined forms"
This reverts commit b00e62f9d3.
2020-02-02 16:01:24 +01:00
Marius Gerbershagen
56a75fec47 doc: document ext:with-backend
There's no perfect place to put this, I think it belongs next to
the documentation for the closely related ffi:defla.
2020-01-27 21:20:51 +01:00
Marius Gerbershagen
10c4f6e6d6 ffi: fix bogus error when using load-foreign-library with bytecmp
As it modifies the linker flags, the do-load-foreign-library function
only works with the C compiler.
2020-01-27 20:58:21 +01:00
Marius Gerbershagen
c8003c2fc4 cmp: quote arguments when invoking C compiler
Now we can compile files with spaces in their paths on windows.
2020-01-26 21:33:45 +01:00
Marius Gerbershagen
14951e4c0b reintroduce init functions for modules
Reintroduce the entry points like init_lib_CMP, init_lib_SOCKETS, ...
we had in ECL 16.1.3 for our builtin modules linked as static
libraries.
2020-01-22 19:06:38 +01:00
Marius Gerbershagen
3267bf7f62 tests: fix output-streams test from the run-program testsuite
The test was failing because it was detecting an output of

"

Hello stdoutHello stderr"

instead of the expected

"
Hello stdout
Hello stderr"

The reason for this is that the buffers of the
streams *standard-output* and *error-output* may be distinct, even if
the ouput send to both streams ends up in the same place. Thus, we
need to explicitely force-output in print-test. The error manifested
itself only in builds without thread support, because otherwise ECL
uses write instead of fwrite, avoiding any buffering.
2020-01-19 20:06:55 +01:00
Marius Gerbershagen
a97a881b90 bignums: fix wrong usage of bignum registers
Add comment explaining how bignum registers should be used.
2020-01-17 18:03:26 +01:00
Marius Gerbershagen
fdbfb8b81b Merge branch 'fix-550' into 'develop'
Fix 550

Closes #550

See merge request embeddable-common-lisp/ecl!178
2020-01-13 18:55:52 +00:00
Marius Gerbershagen
07c5c6b3c1 ecl_process_env_unsafe: don't mark as __attribute__((const))
This can cause the C compiler to optimize away multiple calls to this
function, which makes the ECL_WITH_LISP_FPE macro fail.
2020-01-12 18:53:50 +01:00
Marius Gerbershagen
793e2e9375 tests: add test for ECL_WITH_LISP_FPE macro 2020-01-12 18:53:48 +01:00
Marius Gerbershagen
865b9e7636 fpe: fix ECL_WITH_LISP_FPE macro after changes to floating point exception handling
Make sure that apart from turning on/off signaling for exceptions, we
also clear all exception bits. After the recent changes to how ECL
handles floating point exceptions, not doing that could lead to
spurious exceptions being signaled even when using the
ECL_WITH_LISP_FPE macro because an earlier calculation yielded
infinity/NaN.
2020-01-12 18:53:45 +01:00
Daniel Kochmański
9cf6e774a4 Merge branch 'fpe-without-sigfpe' into 'develop'
Fix floating point exceptions for systems without working feenableexcept

See merge request embeddable-common-lisp/ecl!177
2020-01-12 10:30:09 +00:00
Daniel Kochmański
3743c85d4d cmp: unoptimized long call: evaluate the function first
Fixes #550.
2020-01-12 11:18:46 +01:00
Daniel Kochmański
e399d33fc6 tests: add regression test for 550 2020-01-12 11:18:23 +01:00
Marius Gerbershagen
22ad495e26 ieee-fp: allow for infinity and NaN without floating point exceptions 2020-01-11 17:21:10 +01:00
Marius Gerbershagen
e65e23ee8a configure: check if feenableexcept is actually working
Not all processors will signal floating point exceptions even when
told so, for example the Raspberry Pi as Dave Richards pointed out on
the ecl-devel mailing list.
2020-01-11 15:37:15 +01:00
Marius Gerbershagen
cb03494a6d ieee_fp: use explicit checks for fpe bits if feenableexcept is not declared
Using isnan and isfinite to check for floating point exceptions
doesn't work when we want floats to be able to have infinity or NaN as
values, thus this option was removed with commit
5f71f728a3. However, we can still use
fetestexcept to explicitly check if floating point exceptions occurred
even when we can't use the feenableexcept/SIGFPE signal delivery
mechanism.

Previously, we had something like this in the
ECL_MATHERR_TEST/ECL_MATHERR_CLEAR macros, but this was not used
consistently in our codebase (the ECL_MATHERR_TEST macro was missing
in many places). Instead of error-prone testing at every point of
computation, we call fetestexcept in DO_DETECT_FPE when creating a new
float/complex float. In order to avoid having to do this twice, the
DO_DETECT_FPE2 macro is introduced.

A minor disadvantage of this strategy is that floating point
exceptions may be signaled later than they occurred.
2020-01-11 15:32:52 +01:00
Marius Gerbershagen
c2a577d609 bignums: prevent bignum registers from growing too big
We had this code before, but it made non-functional in commit
20f4c8931e and got removed with commit
749b97d06c.
2020-01-04 18:07:41 +01:00
Marius Gerbershagen
c301b108a7 bignums: don't use ecl_alloc_atomic for gmp
The gmp manual (https://gmplib.org/manual/Custom-Allocation.html) states

> GMP may use allocated blocks to hold pointers to other allocated
  blocks. This will limit the assumptions a conservative garbage
  collection scheme can make.

Thus we can't use ecl_alloc_atomic. We could just use ecl_alloc
instead, however our implementation is already structured in such a
way that it is sufficient to use ecl_alloc_uncollectable. The reason
for that is that currently all bignums except those in the bignum
registers in the thread local environment are allocated as compact
objects so that we only need to call mpz_clear for the few non-compact
objects in the bignum registers.

See also commits 7b536161 and bd48b859.
Fixes #485.
2020-01-04 17:49:08 +01:00
Marius Gerbershagen
f5dfc145d0 Merge branch 'fix-547' into 'develop'
Fix 547

Closes #547

See merge request embeddable-common-lisp/ecl!174
2020-01-02 15:25:36 +00:00
Daniel Kochmański
1ccf7db8f8 dffi: define ffi_type_complex_* types only when available
In ecl_type_to_libffi_types we have definitions for complex float
types when appropriate define is present. Fixes #546.
2019-12-31 10:16:38 +01:00
Daniel Kochmański
bbd3c2d6d0 expt: add a case for complex-float ^ integer.
Lack of this switch branch lead to unrecoverable error. Fixes #547.
2019-12-30 22:04:11 +01:00
Daniel Kochmański
78138b65dc tests: add regression test for 547
Also add complex tests to the make-check test suite. that was a clear omission.
2019-12-30 22:04:07 +01:00
Daniel Kochmański
d6b577233b Merge branch 'c-stack-size' into 'develop'
Change handling of C stack resizing

See merge request embeddable-common-lisp/ecl!173
2019-12-30 09:37:40 +00:00
Marius Gerbershagen
d908394007 cmp: don't return nil in compile if compilation failed
The ansi standard states that compile has to return a compiled
function. Fixes various errors in the ansi-test suite.
2019-12-29 23:02:40 +01:00
Marius Gerbershagen
cb2cc7a81a tests: Add stack overflow test 2019-12-26 19:14:21 +01:00
Marius Gerbershagen
d7b2dfb722 Change handling of C stack size
Previously: unconditionally use the size from ECL_OPT_C_STACK_SIZE if
it is larger than the OS provided value and if possible resize the
stack at runtime.

Now: Use ECL_OPT_C_STACK_SIZE if provided. Otherwise, use a) the OS
provided value if we can resize the stack at runtime (for Unix) or b)
the new build option ECL_DEFAULT_C_STACK_SIZE (1 MB) if we can set the
stack size at link time (for Windows).
2019-12-26 19:13:31 +01:00
Daniel Kochmański
87a1c5faed doc: be less ambigous in man page about lisp-stack and frame-stack
More specific information is provided in the complete
documentation. Closes #543.
2019-12-23 14:10:35 +01:00
Marius Gerbershagen
a4e93f7b61 cmp: fix compiler macro for sequence functions with :end argument
The :end argument was ignored previously.
2019-12-22 20:31:48 +01:00
Marius Gerbershagen
35e4a9160f cmp: fix proclamations for formatter functions
Some of the argument type proclamations were wrong.
2019-12-22 15:08:26 +01:00
Marius Gerbershagen
93e9c3b4ad cmp: add missing proclamations for formatter functions
All functions declared with si::c-export-fname must be either in
symbols_list.h or have a proclamation so that the compiler knows the
number of arguments that the function takes.
2019-12-22 00:14:19 +01:00
Marius Gerbershagen
7e381828f1 cmp: fix segmentation faults from coerce compiler macro
si::coerce-to-vector assumed that the to be coerced object had the
same length as that specified by the type. This lead to segmentation
faults even in safe code, for example in

(coerce '(a b c) '(vector * 4))

(coerce.error.3 test in ansi-tests)

Actually, si::coerce-to-vector had some checks for a correct length
previously, but they did not work correctly and were removed in commit
baaab01841.
2019-12-21 23:03:07 +01:00
Marius Gerbershagen
00934b358b format: don't signal an error if ~T and ~<...~> are mixed
Only ~:T is forbidden inside ~<...~> or in conjunction with
~<...~:;...~>.
Fixes #540.
2019-12-20 13:37:25 +01:00
Marius Gerbershagen
dbe43c09e6 libffi: disable building the documentation 2019-12-18 21:38:59 +01:00
Marius Gerbershagen
a7a18707b8 Merge branch 'refactor-compiler' into 'develop'
Minor compiler improvements

See merge request embeddable-common-lisp/ecl!170
2019-12-16 18:02:36 +00:00
Daniel Kochmański
b8dfd2784c tests: ffi: add a smoke test for complex float handling 2019-12-16 11:47:36 +01:00
Daniel Kochmański
ad5fe834bb ffi: enable complex floats for ffi
See
https://gitlab.com/embeddable-common-lisp/ecl/merge_requests/149#note_169658319
https://github.com/libffi/libffi/issues/489

complex float support in libffi shipped with my Ubuntu still have
these problems, but when I've built the libffi myself all works fine.

> (ffi:def-function "catanhf" ((x :csfloat)) :returning :csfloat :module :default)
 CATANHF
> (catanhf #C(10.0s0 0.5s0))
 #C(0.10008093 1.5657587)
>
2019-12-16 11:17:47 +01:00
Daniel Kochmański
69af894224 cmp: remove dynamic variable *compiler-input*
*compiler-input* was only passed to the first-pass, there is no need
for a dynamic binding.
2019-12-16 10:20:47 +01:00
Daniel Kochmański
05cc54a75e cmp: remove global entries machinery
This is a dead code which is not used in the compiler. It was meant
for providing entry points from Common Lisp code to ECL functions
written in C, but it was replaced by more robust machinery.
2019-12-16 10:20:47 +01:00
Daniel Kochmański
01e49c845a cmp: cmpc-machine: cosmetic: put tables in columns
It is easier to read this code this way. It goes well beyond 80
character limit but the alternative is not readable for human.
2019-12-16 10:20:47 +01:00
Daniel Kochmański
7dbde99b7c ffi: defcallback: unify behavior of dffi and compiled versions
- normalize return-type from NIL to :void, ARRAY and '* in interpreted
  dffi implementation -- it is already normalized in sffi

- remove invalid path where argument type was not a valid elementary
  FFI type

  when it was not c1-defcallback pushed result of add-object to
  arg-type-constants and tried to pass the data as opaque
  pointers. That said it could never work, because:

  1. add-object could return a string (i.e for known symbols expanding
     to ECL_SYM) and they were fed as elementary FFI type leading to
     errors during compilation by C compiler (invalid enum type)

  2. when ecl_make_foreign_data was called to pass opaque objects a
     function FFI:SIZE-OF-FOREIGN-TYPE was called which resulted in
     error (because return type is not a valid elementary FFI type
     what this code path was meant to be)

Moreover we validate both return type and argument types during the
first compiler to fail as early as possible (previously only argument
types were validated early).

- some cosmetic fixes like indentation or redundant PROGN
2019-12-16 10:20:42 +01:00