Commit graph

1694 commits

Author SHA1 Message Date
Daniel Kochmański
81a671dea7 cmp: defun-cached: fix reset-cache and a declaration
reset-cache did cons a new array but did not assign it to the cache variable
so it was essentially a no-op. Also we bind cache to lexvar and then declare
that lexvar to preserve declaration semantics.
2023-02-21 14:34:11 +01:00
Daniel Kochmański
e984568e7d cmp: rearrange cmppolicy to have a correct order
assume-right-types were used before it was defined.
2023-02-21 14:34:11 +01:00
Daniel Kochmański
d29a26cf8a cosmetic: cmp: declare unused variables as ignored 2023-02-21 14:34:11 +01:00
Daniel Kochmański
c38a18bd01 cmp: move env-related operators from cmpvar to cmpenv-var 2023-02-21 14:34:11 +01:00
Daniel Kochmański
0489f2e227 cmp: move functions from cmpmac to cmputil
both files served the same purpose
2023-02-21 14:34:11 +01:00
Daniel Kochmański
9eff84b622 cmp: rename env functions to comply to other naming conventions
c1make-global-variable -> make-global-var (and move to cmpvar) -- this function
does not create c1form so this name was wrong

cmp-env-declare-special -> declare-special (and move to cmpenv-var) -- this
function does not only declare special but it also creates an instance of a
variable - move that to a new file cmpenv-var.lsp
2023-02-21 14:34:11 +01:00
Daniel Kochmański
f1080c716c cmp: remove unused environment object type "cleanup" 2023-02-21 14:34:11 +01:00
Daniel Kochmański
a85b585108 cmp: move set-closure-env from cmpenv-api to cmpenv-fun 2023-02-21 14:34:11 +01:00
Daniel Kochmański
b3ec398d29 cmp: move all conditions to a separate file 2023-02-21 14:34:11 +01:00
Daniel Kochmański
66c7626a8f cmp: cleanup: some more cleanup 2023-02-21 14:34:11 +01:00
Daniel Kochmański
f38ef8ee2b cmp: cleanup: add ignore declarations, remove unused args etc 2023-02-21 14:34:11 +01:00
Daniel Kochmański
45bb774caf cmp: values-type-and: fix a typo - we should use rest1 for reference 2023-02-21 14:34:11 +01:00
Daniel Kochmański
7f1f97e1c0 cmp: cosmetic cleanups 2023-02-21 14:34:11 +01:00
Daniel Kochmański
93fbbcccfc cmp: more robust compiler-features collecting 2023-02-21 14:34:11 +01:00
Daniel Kochmański
e4988d1f7c cmp: don't USE the package EXT 2023-02-21 14:34:11 +01:00
Daniel Kochmański
e74826b9cd cmp: be explicit about symbol packages
In dispatch tables and other places where the symbol is a token of some
processing we try to be explicit about its home package (CL, SI, FFI, MP).
2023-02-21 14:34:11 +01:00
Daniel Kochmański
6ab1d0aded cmp: constants: be explicit about the package 2023-02-21 14:34:11 +01:00
Daniel Kochmański
2cbd91c3ac cmp: define-policy: use explicit package accessors 2023-02-21 14:34:11 +01:00
Daniel Kochmański
ee9e72e5aa cmp: use cmutil extensions by invoking them with prefix ext 2023-02-21 14:34:11 +01:00
Daniel Kochmański
acd1dd3c07 cmp: don't import symbols from the SYSTEM package
Use proper package accessors instead. This was mostly already done. Removal of
package imports make it easier to tell when symbols do not belong to cmp.
2023-02-21 14:34:11 +01:00
Daniel Kochmański
edb19dcf75 cmp: cleanup: remove unused special variables
It is worth noting that *active-protection* and *pending-actions* are generally
not used too (because *pending-actions* are never modified), but if we want to
add some useful semantics to with-compilation-unit one day then we'll need both.
2023-02-21 14:34:11 +01:00
Daniel Kochmański
7b56516679 cosmetic: improve cmpenv comments to include the qualifier :declare 2023-02-21 14:34:11 +01:00
Marius Gerbershagen
de89593216 fix typos 2023-02-18 17:30:30 +01:00
Daniel Kochmański
feff551c31 Merge branch 'inline-closure-global' into 'develop'
Fix compiler bug regarding inlining for global functions that are closures

See merge request embeddable-common-lisp/ecl!280
2023-02-14 21:05:19 +00:00
Daniel Kochmański
8ba1bb888a si_process_lambda_list: process all variables in an uniform manner
The comment mentioned that aux variables (the sixth value) are returned the
same way as requireds, optionals and keywords however factually that was not
the case - the number of variables was not the first element of the list. This
commit updates the function and all its callers.
2023-01-22 20:12:58 +01:00
Daniel Kochmański
26c8e18750 cmputil: fix invalid iteration
Instead of using the iteration variable we've used the same list repeatedly.
2023-01-22 20:12:58 +01:00
Marius Gerbershagen
02280203a4 cmp: fix typos 2022-12-30 16:15:24 +01:00
Marius Gerbershagen
fdcf5e7eff cmp: disable inlining for global functions that are closures
For functions already compiled and loaded, we simply check if the
definition is a closure. For functions defined in the same file, we
don't store their definition in the compiler environment but instead
use *global-funs*. The advantage is that this directly allows us to
determine whether a function is a closure or not and we don't have to
run the first compiler pass again each time we inline the function.

This commit also fixes some minor issues with the inline policy,
described in detail as follows:

1. The inline policy differed subtly between `proclaim` and `declaim`.
If a file like

(eval-when (:compile-toplevel)
  (proclaim '(inline f)))
(defun f ...)

was compiled (but not loaded), subsequent compilations would inline
`f` but for

(declaim (inline f))
(defun f ...)

the function `f` would only get inlined if the file was compiled _and_
loaded. We now use the latter approach for both cases. Thus, calling
`compile-file` without `load` has no side-effects regarding whether
functions are inlined or not.

2. We did not distinguish between functions which were declared inline
at a global versus local level such that e.g. in

(locally
    (declare (inline f))
  (defun f ...))

the function f would get inlined outside the scope of the `locally`
form. This is changed now such that local inline declarations only
apply to the scope in which they are made.

3. Inline declarations were made by expanding into statements like

(eval-when (:compile-toplevel)
  (c::declare-inline ...))

during the macroexpansion of `defun`. However this only works if the
`defun` appears at the toplevel and hence in code like

(declaim (inline f))
(let (...)
  (defun f ...))

the function `f` could not get inlined later on in the same file. This
is fixed now by calling the code which should run during compilation
directly when macro expanding defun.
2022-12-30 16:14:53 +01:00
Marius Gerbershagen
de15a85420 cosmetic: fix some compiler warnings 2022-10-22 19:58:24 +02:00
Daniel Kochmański
6d191760b3 cosmetic: cmp: rename a function guess-ld-flags to guess-ld-libs
... to better reflect what it returns.
2022-09-08 09:02:42 +02:00
Marius Gerbershagen
826cc92983 cmp: introduce new variables for linker flags
Split up the options into additional flags for the linker and
additional libraries.

Quoting from issue #636:

> Here's an example, attempting to link one object file named
  example.o into an executable named example. Libcrypto here is
  superfluous and should be removed by --as-needed:

```
LDFLAGS="-Wl,--as-needed"
LIBS="-lcrypto"
gcc ${LDFLAGS} ${LIBS} example.o -o example # doesn't link libcrypto!
gcc example.o ${LDFLAGS} ${LIBS} -o example # doesn't honor --as-needed!
gcc ${LDFLAGS} example.o ${LIBS} -o example # works great!
```

> In short, the placement of your -l<foo> flags differs from that of
  all the other linker flags. Since ECL is only providing one big
  variable ld-flags for all of the linker flags, there's no correct
  way to pass in options like --as-needed and -l<foo> at the same
  time.

Fixes #636.
2022-08-24 16:38:20 +02:00
Marius Gerbershagen
3db6ad91ff cmp: fix infinite loop for files containing lists with the same circular structure
Closes #630.
2022-08-14 17:17:57 +02:00
Daniel Kochmański
1ce4713804 floats: add operators to convert between floats and bits (integers)
The interface is in the system package (that is - not part of the official api).
2022-07-07 13:24:38 +02:00
Daniel Kochmański
fe27ab8600 core: add a new utility 'si_adjust_vector' to arrays.d
This function is added to avoid using in the core the f unction CL:ADJUST-ARRAY,
that is not defined during bootstrapping.
2022-04-27 13:50:17 +02:00
Daniel Kochmański
653cba539f clos: various bootstrap improvements
The most notable change applies to the file fixup.lsp. Functions destined to
be generic are converted to their final version.

Previously this conversion was done in a few steps in order to avoid issues
with infinite recursion in dispatch. We achieve this by assigning to these new
generic function a simplified discriminating function:

    (lamda (&rest args)
      (unless (or (null *clos-booted*)
                  (specializers-match-p args specializers))
        (apply #'no-applicable-method generic-function args))
      (apply old-function args))

The old function is also seeded as a primary method for the generic
function. This works correctly because functions have only one method so we
may directly call it (it is also a fine optimization strategy we do not
incorporate generally yet), and because the discriminating function will be
recomputed when other methods are added etc.

This way we may use these generic functions without issues directly with newly
redefined versions and the file is now ordered as follows:

- fixup early methods
- redefine functions to their final version
- convert functions to generics
- define missing methods
- implement the dependant maintenance protocol

After this file is loaded it is possible to use generic functions as usual.
2022-02-05 15:03:52 +01:00
Marius Gerbershagen
f873e8e653 cmp: check number of arguments when inlining funcall or apply of lambda expression
Closes #672.
2022-01-29 20:21:00 +01:00
Marius Gerbershagen
f3d4cf4b66 cmp: fix specification of integer suffixes for the C compiler
Fixes #667.
2022-01-15 18:11:26 +01:00
Daniel Kochmański
bf62cd9d40 mp: semaphores: add a new function semaphore-wait
This function offers a functionality similar to sbcl, namely allows
specifying the timeout and the resource count.
2021-12-23 12:09:57 +01:00
Yuguo Zhang
e279df5d77 cmpos-features: fix command line arguments for msvc 2021-12-01 15:20:07 +00:00
Daniel Kochmański
6aa02de4c4 compiler: better checking whether a variable may be introduced
Previously c1make-var checked whether the symbol NAME is CONSTANTP, but
ECL expands symbol macros in CONSTANTP so this returned false positives.
A similar concern applied to the CMP-ENV-REGISTER-SYMBOL-MACRO-FUNCTION.

C1EXPR-INNER when encountered a symbol tried to yield C1CONSTANT-VALUE
for if it iwas CONSTANTP - this was correct except for that we didn't
pass the environment to the predicate and symbols weren't shadowed.

In this commit one function is added to the core - si:constp (with
similar purpose to si:specialp) and one function to the compiler -
constant-variable-p (similar to special-variable-p) and they are
appropriately used when necessary. A regression test is added.

Fixes #662.
2021-11-19 11:56:23 +01:00
Marius Gerbershagen
ff8cf4d3c1 pathnames: handle unicode characters
On Unix, pathnames are converted into the default encoding specified
by ext:*default-external-format* and back. On Windows, the operating
system already gives us utf16 encoded pathnames, so we use those.

ecl_namestring with ECL_NAMESTRING_FORCE_BASE_STRING encodes with the
specified encoding. Decoding is handled individually in the filesystem
functions.

Includes a minor refactor of list_directory, changing the
PARSE_DIRECTORY_ENTRY macro into an inline function.

Closes #609, #549.
2021-08-19 14:00:28 +02:00
Marius Gerbershagen
ed0c3843ba Merge branch 'compiler-improvements' into 'develop'
cmp: major cleanup, separate passes

See merge request embeddable-common-lisp/ecl!251
2021-07-17 09:25:26 +00:00
Tarn W. Burton
c0e56f23af Add ed hooks 2021-07-01 11:15:05 -04:00
Daniel Kochmański
eacc5a25fb cmp: cosmetic: remove the file notes.org
Information there is not up to date and may confuse a reader.
2021-07-01 14:14:53 +02:00
Daniel Kochmański
a70c2fa36c cmp: ctop-write: don't reverse *static-constants* twice
This was probably a braino. *static-constants* is always a list.
2021-07-01 14:14:53 +02:00
Daniel Kochmański
7efb01d7d1 cmp: separate type propagation pass
The type propagation is invoked with a function compiler-pass/propagate-types
before the compiler-pass2. Previously the type propagation was invoked in
ctop-write.
2021-07-01 14:14:36 +02:00
Daniel Kochmański
8716c62f6d cmp: p1fset type propagator returns FUNCTION
Previously the propagator incorrectly returned the type of the function lambda.
2021-07-01 14:11:33 +02:00
Daniel Kochmański
e4fca7e8e7 cmp: separate fun/var ir functions from passes
Also provide better load grouping.
2021-07-01 14:11:33 +02:00
Daniel Kochmański
c8c59167d0 cmp: major cleanup, separate passes
- separate passes

  The separation is not fine-grained but is a good starting point for further
  cleanup. This is a preliminary requirement for multiple backends.

- use uninternet symbol in the package definition

- remove "execute" permission from all files

- remove a few unused functions

- rearrange loaded files

- less verbose compiler

  Don't print "End of pass 1." message. This doesn't provide any valuable
  information to the programmer.
2021-07-01 14:11:33 +02:00
Marius Gerbershagen
cdeea489cb cmp: fix typo to make constant folding work again 2021-04-01 16:19:14 +02:00