Minor improvements to define-compiler-macro* (bail out if we detect
:allow-other-keys arguments, define a named block such that
return-from works as expected).
Major refactor of sequence compiler-macros: use define-compiler-macro*
which handles correct evaluation order, define new macro to handle
common stuff for all sequences compiler-macros (e.g. inline policy
checking, check that test and test-not are not both given). The main
expansion logic in the compiler macros is unchanged although the code
had to be slightly rewritten to accomodate the new macros.
Remove the now superfluous seq-opt-parse-args function.
Example:
(let ((x '(quote ...))) ...)
We really have to quote the value in all cases, si::maybe-quote would
strip away one level of quotation leaving only the equivalent
of (let ((x (quote ...))) ...) which of course is incorrect.
The previous version had several problems: argument evaluation order
was not handled correctly and the compiler-macro produced an error for
valid code like
(let ((etype :element-type))
(make-array 10 etype 'character))
Introduce a new generally applicable macro define-compiler-macro*
which fixes these issues.
Also search lexical environment for variables instead of only the
list of variables being established by the current form (which is nil
anyway in the case of locally; only let or multiple-value-bind
statements create new variables).
The declaration is still ignored, but fixing that would require a much
larger refactor because currently variable types are associated to the
variable itself. Thus the type can only be set for the full scope in
which the variable is active and not locally in some subscope.
We are transforming these functions into (loop :on ...). This simply
stops when the objects which we are looping on is not a list, but we
need to signal a type-error because the mapping functions are
specified to take only lists.
We were doing no error checking that we got the right number of
arguments. Also remove the manual creation of forms with a backquote
for better readability.
If a variable which is set with multiple-value-setq is bound to a
symbol-macro, we need to handle the order of side-effects as in setf.
Previously, we were first evaluating the value generating form
of the multiple-value-setq before setting the places from the
symbol-macro. The correct order is to first evaluate the forms from
the symbol macro giving the places to set, then evaluate the value
generating form from the multiple-value-setq and then set the places
to the generated values.
The ansi standard specifies that declaring symbols bound with
symbol-macrolet to be special or binding symbols that are defined as
global variables must signal a program-error. Previously, we simply
ignored this issues.
Also fix an issue with cmp-env-search-variables which would wrongly
return variables when searching for symbol macros. This allows us to
remove another check in symbol-macro-declaration-p.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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).
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.