Commit graph

1569 commits

Author SHA1 Message Date
Daniel Kochmański
df339485eb Merge branch 'infinity-NaN-numeric-functions' into 'develop'
Make all numeric functions return sensible values for infinity/NaN

Closes #477

See merge request embeddable-common-lisp/ecl!160
2019-08-16 18:52:23 +00:00
Daniel Kochmański
8b82c98cac Merge branch 'alt-fix-513' into 'develop'
Fix 513 2nd try

Closes #514

See merge request embeddable-common-lisp/ecl!159
2019-08-16 18:44:23 +00:00
Marius Gerbershagen
5c7aecc15f ieee-fp: fix min/max for NaN
As for the C functions fmin/fmax, we ignore NaNs
2019-08-14 20:51:40 +02:00
Marius Gerbershagen
046c6b9f32 number_compare.d: fix number comparison for NaN
All comparisons with NaN should return NIL for consistency with the
IEEE standard.
2019-08-14 20:51:40 +02:00
Marius Gerbershagen
61e799074d cmp: fix type propagation for / with one argument
Fixes #522.
2019-08-06 19:38:47 +02:00
Daniel Kochmański
adace6ba08 cmp: replace magic number with a defined constant
The magic number was wrong anyway.
2019-07-20 09:22:01 +02:00
Daniel Kochmański
f3c6e4ccef cmp: remove unused interface *linking-calls*
Variable is always nil so blocks of code are never executed. Remove
it. TRAMPOLINK was used only in such bodies.
2019-07-19 14:30:53 +02:00
Daniel Kochmański
0e7ef61b69 cmp: t3local-fun-declaration: do not call next-lcl more than needed
When we process required arguments their amount may exceed maximum
number of arguments which are allowed to be passed on C stack. In this
case the remainder is shifted to optionals *but* we have called
next-lcl for all arguments what lead to a situation where all
arguments were passed on the list. Fixes #514.
2019-07-19 14:30:53 +02:00
Marius Gerbershagen
1334eb1765 cmp: prevent deadlock if the C compiler output is too large
The pipe from which we read the output of the C compiler could fill up
when a large number of warnings were printed leading to a deadlock
because we waited for the C compiler to finish before reading the
output.
2019-07-15 21:32:36 +02:00
Daniel Kochmański
fcdb1b0657 cmp: c1body: do not error when unknown declaration is encountered
it is hinted in the spec, that compiler issues a warning on unknown
declarations:

http://www.lispworks.com/documentation/HyperSpec/Body/d_declar.htm#declaration

also in other parts of compiler code we warn as well.
2019-05-25 09:56:08 +02:00
Daniel Kochmański
ea87100a06 long-float: remove conditionalization
Many parts of the source code were bent backward to support builds
without long floats which are always present given we depend expect
c99 compiler.

The corresponding C macros (ECL_LONG_FLOAT) and the *feature*
entry (:long-float) are marked as deprecated in the documentation.
2019-05-24 21:04:59 +00:00
Marius Gerbershagen
9dedfe95e5 complex-float: add inline definitions for si::complex-*-float-p 2019-05-20 21:54:05 +02:00
Daniel Kochmański
b8c328b558 coerce: allow coercing to si:complex-*-float
Previously coerce didn't understand these atomic specifiers.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
19526d4032 cmpffi: produce-inline-loc: do not return uninitialized variable
For functions without returned value we did return cl_object value0
which was not initialized. That could lead to segmentation faults if
we have used result of calling a function defined as such location.

SFFI definition like this:

(ffi:def-function ("my_test_function3" sffi-test-3)
    ((x :float) (y :double))
  :returning :void)

was previously compiled to

/*      function definition for SFFI-TEST-3                     */
/*      optimize speed 3, debug 0, space 0, safety 2            */
static cl_object L6sffi_test_3(cl_object v1x, cl_object v2y)
{
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
 {
TTL:
  my_test_function3(ecl_to_float(v1x),ecl_to_double(v2y));
  cl_env_copy->nvalues = 0;
  return value0;
 }
}

and now it is compiled to

/*      function definition for SFFI-TEST-3                       */
/*      optimize speed 3, debug 0, space 0, safety 2              */
static cl_object L6sffi_test_3(cl_object v1x, cl_object v2y)
{
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
 {
TTL:
  my_test_function3(ecl_to_float(v1x),ecl_to_double(v2y));
  value0 = ECL_NIL;
  cl_env_copy->nvalues = 0;
  return value0;
 }
}

void functions are treated the same as when *destionation* is 'RETURN
in cmpmulti.lsp.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
07ebf7dfc6 complex-float: add inline definitions to the compiler 2019-05-15 16:35:16 +02:00
Daniel Kochmański
8cc0ae7222 complex float: add compiler optimizations and ffi definitions
- add ffi implementation for long-float
- add ffi implementation for (complex float) types
- add compiler optimizations and definitions for complex float

We do not add c?float common constants (long-float i.e has optimizer
for 0.0 and -0.0), because we don't know if they are common at all and
if we think about it each would have four entries counting signed
zeros).

Also add informative comment about global-entries.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
a0a92dc2af complex float: add a new types and builtin classes
What has changed:

- new types si:complex-float, si:complex-single-float,
  si:complex-double-float and si:complex-long-float
- new builtin classes long-float (for completness) and
  si:complex-float
- new internal function si:complex-float and si:complex-float-p for
  constructing complex floats (both arguments must be of the same
  float type) and a type predicate
- printer for new types (right now it conses, see below)
- a new feature :complex-float
- a new type is recognized as a type disjoint of complex and real

- cleanup: +built-in-type-list+: remove some redundancy
  For instance instread of saying
    (real (or integer single-float double-float ratio))
  We say
    (real (or integer float ratio))
  etc.

Flaws which will be fixed in upcoming commits:

- complex-float hierarchy is independent of the complex hierarchy
- ecl_make_complex_float could be replaced by _ecl_make_complex_*float
- write_complex_float allocates new objects for printing
- write_complex_float does print unreadable object
- math dispatchers doesn't recognize the object

Testing things out:

> (si:complex-float 0.0d0 0.0d0)
; #<CF(0.0d0 0.0d0)>
> (si:complex-float 0.0d0 0.0s0)       ; signals type error
> (+ (si:complex-float 0.0d0 0.0d0) 1) ; signals type error

lisp runtime: make si_complex-float a subtype of a number.
2019-05-13 19:48:54 +02:00
Daniel Kochmański
0033f24be2 constant folding: fix regression for single and multiple values
Closes #497.
2019-05-05 10:38:02 +02:00
Daniel Kochmański
097fa96ae0 cmp: coerce: resolve fixme for atomic complex specifier
it is not true, that

  (type= '(complex) '(complex double-float)) == T

so we may put complex in +coercion-table+.
2019-04-20 17:14:14 +02:00
Daniel Kochmański
d7c351c76a predlib: type= doesn't yield T for complex types
TYPE= is only used from cmpopt's typep compiler macro which optimizes
atomic complex types by other means. Compound complex types are
handled differently for subtypep and typep (the first relies on
upgraded type and the second relies on the actual types), so we can't
rely in this case on SAFE-CANONICAL-TYPE.
2019-04-20 17:13:17 +02:00
Marius Gerbershagen
209434f91a cmp: fix constant folding for functions that return multiple values 2019-03-23 18:51:18 +01:00
Marius Gerbershagen
60870ae9b0 use correct unnormalized values for minimum float constants
Fixes #470.
2019-02-13 20:24:26 +01:00
Marius Gerbershagen
19c6635ff0 expt: use pow function for floating point numbers
Improves speed and accurracy.
2019-02-12 22:37:23 +01:00
Marius Gerbershagen
dff91be38c sysfun.lsp: clean up inline expansions for floating point numbers
Define all expansions also for long floats if available, use
    single float C functions when given a single float.
2019-02-12 22:30:57 +01:00
Daniel Kochmanski
13a42249e2 cas: add remcas operation for an expansion removal
It is a (fmakunbound (setf foo)) counterpart.
2019-02-07 13:29:03 +01:00
Daniel Kochmanski
9096514cff extensions: put ext:package-locked-p in core module. 2019-02-07 13:27:12 +01:00
Marius Gerbershagen
24dcb778cf clean up functions creating base strings from C strings
Make functions behave as documented, remove use of legacy names.
    Fixes #462.
2019-01-07 18:43:55 +01:00
Marius Gerbershagen
76941e25dc fix the broken serialization functions for externalizable objects 2018-12-10 18:14:01 +01:00
Marius Gerbershagen
9f4a5d4dd4 disassemble: display generated C source code instead of bytecodes
This behaviour makes more sense, since the ANSI standard mandates
    that disassemble should compile an interpreted function before
    displaying the output (our own documentation even says so).

    Also fixes disassemble for closures.
2018-11-24 19:20:06 +01:00
Marius Gerbershagen
71babf1f99 cmp: prevent spurious error when the compile function fails 2018-11-24 17:58:30 +01:00
Marius Gerbershagen
8a1e7f5c92 cmp: don't mark all lexical variables as crossing function boundaries
The compiler refactor of commit
    7ec2f4a939 introduced an error where
    all lexical variables where marked to cross function boundaries,
    leading them to be stored in volatile variables on the stack.
2018-10-29 19:15:49 +01:00
Marius Gerbershagen
892e21012a cmp: make behaviour of declaim inline more sensible
ECL needs the definition of a function to inline it. Previously,
    this definition would only be saved in the file local environment
    (*cmp-env-root*) but not in the global environment used by
    proclaim. Hence, ECL could only inline functions in the same file.
    Now, we also put the definition of inline functions in the global
    environment during load time. This leads to a behaviour of declaim
    for inline functions, which is consistent with other declarations
    (meaning that the declarations stay only in force during
    compilation, but are proclaimed again at load time of the compiled
    file).
    Fixes #451.
2018-10-28 16:32:55 +01:00
Marius Gerbershagen
7ff23cbb92 cmp: fix inline definition for mp:lock-count 2018-10-17 22:07:53 +02:00
Marius Gerbershagen
8676abe519 cmp: add proclamations for multithreading functions 2018-10-17 22:07:19 +02:00
Daniel Kochmański
4021fbdcf8 Merge branch 'atomic-ops' into 'develop'
Add support for atomic operations

Closes #278

See merge request embeddable-common-lisp/ecl!122
2018-10-15 19:23:52 +00:00
Marius Gerbershagen
239a2aa4f1 threading: add support for atomic operations
We support both compare-and-swap and fetch-and-add (via
    atomic-incf/decf) on the most common places and define an
    extension interface for compare-and-swap similiar to the one in
    SBCL.

    These changes introduce new dependencies on the libatomic_ops
    macros AO_fetch_compare_and_swap and AO_fetch_and_add.
2018-10-15 19:55:39 +02:00
ZhangYuguo
5eeae0d823 build system: suppress some logo(copyright) information for msvc toolchains. 2018-09-23 13:41:22 +00:00
Daniel Kochmanski
703771fc3d Revert "cmp: execute cleanup forms of unwind-protect with interrupts disabled"
This reverts commit b8df7a777c.
2018-09-04 17:53:30 +02:00
Marius Gerbershagen
a3e1cf7c78 cmp: correctly restore compile-file(-pathname) in ext:install-c-compiler
After a call to ext:install-c-compiler while the bytecodes compiler
    is installed, compile-file and compile-file-pathname still point
    to bc-compile-file and bc-compile-file-pathname. Reported and
    fixed by gitlab user pouar. Fixes #444.
2018-07-08 17:33:09 +02:00
Marius Gerbershagen
25a72ff80a cosmetic: indentation fixes and some comments 2018-06-23 21:37:26 +02:00
Marius Gerbershagen
d27f1494e1 cmp: fix compile call for closures
Signal an error for compilation of cclosures. Allow for
    compilation of bclosures over macros, functions and variables.
    Macros are simply added to the compiler environment. For functions
    and variables we enclose the definition of the closure in
    appropiate let/flet forms, e.g. for `(lambda () (fun var))'
    closing over the function `fun' and variable `var':
    (let ((var ...))
      (flet ((fun (x) ...))
        (lambda () (fun var))))
    Closures over tags and blocks are not implemented and will signal
    an error during compilation.
2018-06-23 21:37:26 +02:00
Marius Gerbershagen
dff75dc004 cmp: push the generic function name in the IHS for CLOS methods
Makes debugging easier, since now the backtrace prints the correct
    generic function name instead of some symbol generated by gensym.
2018-05-31 19:48:48 +02:00
Marius Gerbershagen
b00e62f9d3 cmp: Allow for compile time evaluation of inlined forms
The following statement:
    (eval-when (:compile-toplevel :load-toplevel :execute)
      (print "test"))
    resulted in an error, since the compiler would expand the print
    statement in a FFI:C-INLINE form, which can't be evaluated at
    compile time.
2018-04-21 15:34:20 +02:00
Marius Gerbershagen
b8df7a777c cmp: execute cleanup forms of unwind-protect with interrupts disabled
Unifies behaviour with ECL_UNWIND_PROTECT.
2018-03-27 19:03:03 +02:00
Marius Gerbershagen
55d6367b6c cmp: add blocks around ecl_frs_push in generated C code
Avoids redefinition of __ecl_frs_push_result if e.g. two tagbodies
    follow each other in the same C block. This redefinition is an
    error in C and compilers will not accept the generated code.
2018-03-27 18:49:23 +02:00
Daniel Kochmański
c09256866f Merge branch 'threading-fixes' into 'develop'
Threading fixes

Closes #419

See merge request embeddable-common-lisp/ecl!100
2018-03-16 15:08:27 +00:00
Daniel Kochmanski
e92cfdf437 Unify compilation environment markers
In both bytecmp and c compiler we use si:function-boundary and
si:unwind-protect-boundary where appropriate. Previously bytecmp used an ad-hoc
special variable for function-boundary and didn't mark unwind-protect at all.

Remove recently-introduced ECI package (maybe we will reintroduce it later when
we'll have a common frontend for compilers).
2018-02-15 12:44:49 +01:00
Daniel Kochmanski
50fb814fd1 Accept all valid function names in c::compile
Previously we accepted only symbols, now we use si:valid-funciton-name-p
predicate to allow (setf foo) as well.
2018-02-13 13:22:12 +01:00
Daniel Kochmanski
d9da8648cd Look up a lexical macro before a compiler macro.
Fixes #83. Fixes #237.
2018-02-12 16:02:00 +01:00
Marius Gerbershagen
59a6d0ae44 threading: ensure that we don't get interrupted during setjmp
Interrupting a thread during setjmp with a call to ecl_unwind
    leads to segmentation faults, since we try to call longjmp
    before the corresponding setjmp has finished. Thus, we also need
    to wait until setjmp has finished before we can set frs_val of
    the frame.
2018-02-10 21:47:39 +01:00