Commit graph

22 commits

Author SHA1 Message Date
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
c6b4296bb8 cosmetic: fix some compiler warnings 2020-04-29 20:35:37 +02:00
Marius Gerbershagen
bc9f75871e cmp: complain when the number of arguments of an exported function is not known
When we don't know how many arguments an exported function takes, we
can't create a correct declaration for the C function in the .eclh
file. To avoid having too many proclamations, we extract this
information from symbols_list.h for ECL core functions defined in
Lisp.
2019-12-08 10:26:52 +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
Daniel Kochmanski
15640a79e4 cmp: refactor: qualify package of *-prop interface
Usage was mixed, once it is si:put-sysprop, once just put-sysprop. Add
full package qualifiers to put-sysprop/get-sysprop/rem-sysprop.
2017-04-28 11:48:15 +02:00
Daniel Kochmański
9b82583884 newcmp: remove obsolete newcmp package 2016-03-11 16:06:45 +01:00
Matthew Mondor
8f07cd58d8 The ECL code no longer uses tabulator characters, they were replaced
by spaces.

A custom script was used to insert/replace Emacs and ViM per-file editor
settings according to their type and the new ECL coding style.
2015-09-03 07:35:47 -04:00
Daniel Kochmański
4d19a27424 cosmetic: untabify
Signed-off-by: Daniel Kochmański <dkochmanski@turtle-solutions.eu>
2015-06-21 14:38:20 +02:00
Juan Jose Garcia Ripoll
6adc64d00c FTYPE declarations allow (FUNCTION *) and (FUNCTION * *) and (FUNCTION * some-type), etc 2012-12-18 22:00:27 +01:00
Juan Jose Garcia Ripoll
3f3effd034 Fixes in how FTYPE proclamations are stored -- the return types were corrupted in previous implementations of DECLARE/PROCLAIM 2011-12-28 15:58:07 +01:00
Juan Jose Garcia Ripoll
4496a85039 More fixes to remove warnings about unused variables 2011-12-23 22:36:32 +01:00
Juan Jose Garcia Ripoll
6b4dc0c182 Yet another iteration about where to store the inline form of a function: the storage has to be enclosed by an eval-when form so that it is never executed when the form is in a LET, LAMBDA, or other expression that can potentially create a closure. 2011-12-19 16:52:59 +01:00
Juan Jose Garcia Ripoll
f12e4933a1 Fixed typo in C:PROCLAIM-INLINE. 2011-12-18 19:11:46 +01:00
Juan Jose Garcia Ripoll
3e1fcb7a2c New functions DECLARED-{INLINE,NOTINLINE}-P introduce some clarity in the inline process. 2011-12-18 18:49:27 +01:00
Juan Jose Garcia Ripoll
6512337535 Inline forms can be stored locally (if the function was DECLAIM'ed) or globally (if PROCLAIM'ed) 2011-12-18 18:08:10 +01:00
Juan Jose Garcia Ripoll
f0b11d639c Silence the compiler notes about inlined functions 2011-12-18 16:59:22 +01:00
Juan Jose Garcia Ripoll
a0873b2157 ECL now stores the inline form of functions that were declared so 2011-12-18 14:23:07 +01:00
Juan Jose Garcia Ripoll
905475f954 Allo (declare (notinline (setf ...))) (A. Gavrilov) 2010-07-11 12:35:00 +02:00
Juan Jose Garcia Ripoll
1eb33bb8af Fixed typo in GET-ARG-TYPES: local declarations were not properly parsed. 2010-07-01 22:45:19 +02:00
Juan Jose Garcia Ripoll
fd2848c9c7 Function proclamations are also used to deduce the argument types and automatically generate type checks. 2010-06-28 21:39:20 +02:00
Juan Jose Garcia Ripoll
17790c4770 Remove the function TYPE-FILTER and deal with the whole set of Common Lisp types in the compiler. 2010-05-09 22:20:47 +02:00
Juan Jose Garcia Ripoll
6a91d3b45a Refactored code so that it is shared by cmp and new-cmp:
* Use the new proclamations/sysfun.lsp files from the new compiler.
* We split src/cmp/cmpdefs.lsp into cmpdefs, cmppackage, cmptypes and cmpglobals
* Split cmpform.lsp out of cmpmac.lsp
* Merged in {cmp,new-cmp}/cmpc-wt.lsp some of the cmpmac wt routines
* Use functions instead of macros for the WT-* operations
* Split out from *cmp/cmpenv.lsp a file cmppolicy.lsp
* A single file, cmpenv-api.lsp for the manipulation of environments.
* The type comparison functions go into cmptype-arith.lsp and are cached.
* The code that propagates types in function calls goes into cmptype-prop.lsp.
* The remainings of cmpenv go into cmpenv-{declare,proclaim,declaim}.

Associated fixes:
* Fixed typo and wrong proclamation for SI:GET-SYSPROP.
* Fixed typo in SIMPLIFY-ARITHMETIC.
* Explicitely set the debug level when building ECL
* All declarations are stored in the compiler environment.
* Each function and form stores the compilation environment.
* Declaration POLICY-DEBUG-IHS-FRAME is acts only on the function environment.
* Make the definition if ihs_env only happen when it is used.
* Eliminated *notinline*, *inline-functions*  and *function-declarations*
* Slightly more efficient creation of accessors in kernel.lsp
* Remove the proxy C2DECL-BODY
* Fix the order of declarations in SI:PROCESS-DECLARATIONS
* Reimplemented C1BODY using SI:PROCESS-DECLARATIONS
* DECLAIM's proclamation do not propagate beyond the compiled file.
2010-05-05 17:36:19 +02:00