Commit graph

1628 commits

Author SHA1 Message Date
Marius Gerbershagen
69e9e1d46c cmp: fix inlining of functions with mutually dependent keyword arguments
If we inline a function which contains keyword arguments whose default
value depends on the presence of other keyword arguments as for
example in

(funcall (lambda (&key (a nil a-p) (b a-p)) ...))

where `b` depends on the presence of `a`, we need to set the
key-flag `a-p` immediately after scanning for the keyword and not at
the end after we have finished scanning all keywords as we did previously.
2021-03-04 20:19:36 +01:00
Marius Gerbershagen
e5f6606ba7 cmp: fix type propagation for atan function 2021-03-04 19:54:20 +01:00
Marius Gerbershagen
4826398d36 cmp: improve type propagation for complex numbers 2021-02-23 21:04:04 +01:00
Marius Gerbershagen
a937a038a9 cmp: store all objects created with make-load-form in the permanent storage
See test cmp.0076.make-load-form-non-eq and removed FIXME comment for
why this change was made.
2021-02-14 19:23:12 +01:00
Marius Gerbershagen
8df76e9a60 Revert "cmp: fix typo" and "cmp: don't store the same object both in VV and VVtemp"
This reverts commit c5cb09f3cb and
84acbebd7f.

The solution as implemented does not work because we there is no clear
separation between assigning vv locations and later on writing them to
the created C file; we may have already written a vv location before
trying to add the same object again, resulting in miscompilation.
2021-02-14 18:51:54 +01:00
Marius Gerbershagen
c5cb09f3cb cmp: fix typo 2021-02-13 22:22:50 +01:00
Marius Gerbershagen
84acbebd7f cmp: don't store the same object both in VV and VVtemp
See test cmp.0076.make-load-form-non-eq and removed FIXME comment for
why this change was made.
2021-02-13 20:22:52 +01:00
Marius Gerbershagen
a8cbe5842c cmp: remove redundant information in *{permanent/temporary}-objects*
vv records already contain index and object, no need to save this twice
2021-02-13 20:22:46 +01:00
Marius Gerbershagen
194a9e0eab cmp: fix bug in inlining local functions which are closures
See added test case for explanations.
2021-01-16 16:12:13 +01:00
Marius Gerbershagen
ecb4ed10ea cmp: fix progv for return during evaluation of symbol and value arguments
Closes #620.
2021-01-02 16:38:21 +01:00
Marius Gerbershagen
ca6297ddc8 cmp: disable precompiled headers by default
Precompiled headers may not work in every scenario (for example
compilation currently fails for the --with-cxx=yes configure option
due to precompiled headers). If we disable them by default, we are on
the safe side.
2020-12-29 20:43:04 +01:00
Marius Gerbershagen
4e1847f775 clos: don't call make-load-form in the code walker for defmethod
Fixes #594.
2020-09-18 21:22:32 +02:00
Daniel Kochmański
57f58eaeee Merge branch 'wcon-stream-fixes' into 'develop'
Fix encoding issues for msvc

Closes #580, #582, and #581

See merge request embeddable-common-lisp/ecl!220
2020-08-14 07:01:38 +00:00
Marius Gerbershagen
2e94a6ac29 cmp: read msvc output in using the correct encoding
Fixes #581.
2020-08-02 10:55:25 +02:00
Marius Gerbershagen
c7d6ddbf38 cmp: fix inlining of local closures (2nd try)
We need to compile the function body in the same environment in which
the function was defined. However the function arguments need to be
compiled in the current argument.

Fixes #577.
2020-07-18 15:07:04 +02:00
Marius Gerbershagen
a9a63b1d50 cmp: small refactor of (funcall/apply (lambda ...) ...) handling
Unify handling of LAMBDA and LAMBDA-BLOCK in c1funcall and c1apply,
split off computation of let bindings and body in
optimize-funcall/apply-lambda into a separate function.

Preliminary work to fix inlining of local closures.
2020-07-18 15:07:04 +02:00
Marius Gerbershagen
a5671dcdab cmp: refactor c1let/let* into two stages
First stages handles the bindings, second stage the body, needed to
get inlining of local closures right.
2020-07-18 15:07:04 +02:00
Daniel Kochmański
f9db80dcbf cmp: for LAMBDA use an associated function-block-name
That makes lambda with a declaration si:function-block-name behave
consistently with ext:lambda-block (and in eval-macros
ext:lambda-block expands to have this declaration too to behave in
turn consistently with how the compiler treats ext:lambda-block).
2020-06-15 12:34:10 +02:00
Daniel Kochmański
0bd6bd6573 cosmetic: cmp: proclamations: add missing periods 2020-06-15 12:34:10 +02:00
Marius Gerbershagen
d6b422fe39 cmp: fix C compiler invocation for cygwin 2020-06-13 11:25:20 +02:00
Marius Gerbershagen
e89dce9631 cmp: fix multiple-value-setq for special variables
We need to save env->nvalues before calling cl_set on any variable
because cl_set overwrites env->nvalues. Otherwise, we only get nil for
any variable after the first special one.

Fixes #591.
2020-05-28 21:23:54 +02:00
Marius Gerbershagen
636cb4cf60 cmp: add support for precompiled header files
Improves compilation speed for single functions by about 40-50
percent. Precompiled headers are specific to the compiler version and
options in use. Due to this, we regenerate the header whenever the
compiler configuration changes.
2020-05-16 18:53:57 +02:00
Daniel Kochmański
a2a12e2531 Revert "cmp: fix inlining of local closures"
This reverts commit 58f17f6c66.
2020-05-08 13:10:13 +02:00
Marius Gerbershagen
58f17f6c66 cmp: fix inlining of local closures
We have to compile the function expression in the environment in which
it was defined. Fixes #577.
2020-05-01 20:47:47 +02:00
Marius Gerbershagen
c6b4296bb8 cosmetic: fix some compiler warnings 2020-04-29 20:35:37 +02:00
Daniel Kochmański
b9d54d6be7 internals: rename instance.sig to instance.slotds
Slot definitions are no longer a signature, but they are still needed
to update obsolete instances. Reader function name is also changed to
SI:INSTANCE-SLOTDS. SI:INSTANCE-SIG-SET name does not change, because
it sets both SLOTDS and the STAMP.
2020-04-19 17:04:42 +02:00
Daniel Kochmański
aa34ab7119 compiler: rewrite clos::need-to-make-load-form-p
Function is rewritten in C in compiler.d to remove a dependency
between the bytecodes compiler and the clos module. It may be more
performant thanks to more precise type handing, however we use a list
instead of a hashtable, so it may be slower with lookup. To assess
that we should run some benchmarks against real code -- rewriting C
code to work with a hash table should be trivial.

clos::need-to-make-load-form-p is now si::need-to-make-load-form-p and
may be called from C code as si_need_to_make_load_form_p.
2020-04-08 22:01:16 +02:00
Daniel Kochmański
379254456e cmp: make-load-form: detect circular dependencies
Init forms are deferred when possible. This change solves two problems:

- init forms using uninitialized constant boxes
- make forms not signaling an error when circular

Partial fix for #562 (we need to fix bytecodes compiler too).
2020-03-27 11:33:53 +01:00
Daniel Kochmański
dade0b4688 cosmetic: cmp: refactor function add-object
Function is hopefully more readable now.
2020-03-27 11:33:51 +01:00
Marius Gerbershagen
91d251a7ba cmp: correctly handle unused special &rest variables
Even when the variable is not used, we still have to do the binding.
2020-03-21 13:05:23 +01:00
Marius Gerbershagen
14d46da134 cmp: fix evaluation order bugs in compiler macros 2020-03-21 11:44:01 +01:00
Marius Gerbershagen
dda466dd0e cmp: allow :allow-other-keys for functions with &key but zero keywords
Functions such as
(defun f (&key) ...)
would give an error when called like (f :allow-other-keys ...).
2020-03-20 21:29:18 +01:00
Marius Gerbershagen
a9065d1d8e cmp: fix closure type for local functions calling closures
When a local function calls a closure it has to be a closure too. Thus
when updating the closure type for a function f, we have to possibly
update also all functions referencing f.

Fixes #545.
2020-03-18 22:00:57 +01:00
Marius Gerbershagen
1aeb7823e8 cmp: add explicit type suffixes for emitted integer constants in C code
According to the C99 standard, compilers are supposed to automatically
choose the correct type. However, for the C89 standard explicit suffixes
are needed for long longs. Guess what standard msvc follows...
2020-03-07 22:26:44 +01:00
Yuguo Zhang
2532262c0a cmpmain: fix link(msvc) arguments bug in linker-ar 2020-02-10 13:17:18 +08: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
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
Daniel Kochmański
3743c85d4d cmp: unoptimized long call: evaluate the function first
Fixes #550.
2020-01-12 11:18:46 +01: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
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
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
Daniel Kochmański
83ec2c86c7 cmpcbk: improve +foreign-elt-type-codes+
- move the constant and a function foreign-elt-type-code to the top
- re-align the constant data
- fix the feature reader conditionals (they were misplaced)
- add reader conditionals for complex floats
2019-12-11 16:13:34 +01:00