We can't use the ECL_WITH_SPINLOCK_BEGIN/END macros since they check
for pending interrupts at the end of their unwind-protect frame. This
leads to various bugs:
- in queue_signal the to be queued interrupt is executed immediately
after being queued even if interrupts are disabled
- in pop_signal if multiple interrupts are queued they are executed in
reverse order
To fix these issues, use a) ecl_get/giveup_spinlock directly and b)
ecl_disable/enable_interrupts_env to prevent the spinlock not being
released due to an interrupt happening during the execution of the
main body of pop_signal/queue_signal.
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.
The spec says:
The generic function make-instances-obsolete is invoked
automatically by the system when defclass has been used to
redefine an existing standard class and the set of local slots
accessible in an instance is changed or the order of slots in
storage is changed. It can also be explicitly invoked by the user.
If the local slot's class is changed then indeed the set has
changed. We also check whether the slot class is S-D-S-D or S-E-S-D
and in both cases we also decide that layouts are not compatible.
Fixes#586.
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.
According to the spec, we should compare values using equalp if two
matching keys are found, but we were only checking if matching keys
exist.
Fixes#587.
Getting this lock in thread_entry_point was problematic: when the
thread was killed from another thread the catch point in
thread_entry_point was reached and the call to ecl_get_spinlock was
skipped. This lead to threads exiting without protection and to
segfaults.
Doing it the other way around leads to race conditions, since an
unlucky interrupt arriving just after the mprotect call (but before
the the_env->disable_interrupts = 0 write) will write protect the
environment again, leading to a segfault. This is no problem if
SIGSEGV is unblocked (in which case we will just enter sigsegv_handler
again and arrive at the same point). However if SIGSEGV is blocked (and
another segfault arises) the whole process will die.
Bug was introduced in commit c6b4296bb8
in converting buffer_write_char from a macro to an inline
function. Problem reported by Vladimir Sedach on the ecl-devel mailing
list.
Merge a test for with-output-to-string with the one for
with-input-input-from-string to ensure both close their streams.
Remove check for stream-var being a stream outside of w-i-f-s &
w-o-t-s. According to the specification, the streams' extent ends with the
respective providing form. If the stream was indeed not acccessible anymore, the
test would not pass. In that case open-stream-p should signal a type-error,
causing the test to crash. However in ECL we can assume that the stream is still
intact.
Fix#576, Related to !197, 72560efa5a
with-output-to-string is required to close the output stream that it provides
for the extent of the body forms [1]. The current definition does not do that.
This change wraps the body forms in unwind-protect clauses to ensure the stream
is always closed on exit. Because declarations cannot appear at the beginning of
progn forms, any potential declarations are extracted from the body forms and
moved to the beginning of the surrounding let form's body.
element-type is no longer bound to a gensym, but evaluated inside the let body.
The uppercased names are downcased for a more coherent appearance.
[1]: http://www.lispworks.com/documentation/HyperSpec/Body/m_w_out_.htm
Announcement proposal. When this is merged to the develop branch, then
we should make a PR against master and merge. Then we shall publish
tarballs and the announcement on the website.
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.
We should call make-instances-obsolete from finalize-inheritance if we
want to be conforming, because user may have added their own auxiliary
methods.
This change while being last in a serie of commits was locally the
first change which solved problems. It will enable us to implement the
fast generic dispatch after the release.
It helps to determine whether the instance needs to be updated for a
class after redefinition. Currently it is done by comparing the
signature with the instance's class slots.
1. We've implemented SPECIALIZER-DIRECT-METHODS and
SPECIALIZER-DIRECT-GENERIC-FUNCTIONS as accessors to slots in the
specializer DIRECT-METHODS and DIRECT-GENERIC-FUNCTIONS.
2. As specified in MOP these collections are maintained by
ADD-DIRECT-METHOD and REMOVE-DIRECT-METHOD functions.
3. When we finalize standard-method, we remove old methods and among
them is a method for a function METHOD-GENERIC-FUNCTION, and that
function must be called from REMOVE-DIRECT-METHOD when we want to
update SPECIALIZER-DIRECT-GENERIC-FUNCTIONS, so we end up in a
debugger that there is no specialization for this function.
We adapt approach similar to one taken in SBCL (did they encounter a
similar issue?): specializer class has a SPECIALIZER-METHOD-HOLDER
accessor which stores a CONS cell. We add/remove methods to CAR and
take generic functions from CDR. The trick is that CDR is lazily
computed when SPECIALIZER-DIRECT-GENERIC-FUNCTIONS is called and
invalidated when we add and remove method.
Specification of M-I-O explicitly says that instances are not made
when "local slots" are compatible. This change is necessary to prevent
infinite recursion as reported in #568 without breaking the
finalization protocol, because currently class-slots are used as a
signature for its instances (and that's how being obsolete is
determined).
finalize-inheritance is expected to run regardless of the fact that
class has been already finalized. I suppose that it is in case when
compute-slot-* methods are specialized to return something else.
Local function REMOVE-OPTIONAL-SLOT-ACCESSORS removed generic
functions after removing methods while redefining the class if said
generic functions have no other methods. There is nothing in the spec
what would justify it, so we don't fmakunbound these functions
anymore.
As pointed out by Dr. Robert Strandth initargs argument may be passed
to allocate-instance only after the class has been already finalized,
and indeed we finalize it in make-instance. To be on a safe side,
unlike CLASP, we still check whether the class is already finalized in
case of someone calling allocate-instance outside the make-instance
method.
That was probably a typo, because finalize-unless-forward checked only
the class parents if they were forward-referenced classes, not the
class itself.
- extend tests for make-instances-obsolete
- add a metastability test for the standard-method finalization
- fix tests which assume that metaclasses are finalized eagerly
The Common Lisp Standard defines that with-input-from-string always closes the
input stream that it creates. But with the current definition it would only be
closed in the case of an index variable being provided.
This change wraps the code for both cases (index given or not) in a unified
unwind-protect form, updates the index if present, and always closes the
stream. It also unifies the processing of declarations.
Downcase code & fix indentation:
Set the uppercased code in lower case to harmonise appearance and increase
readability. Differentiated indentation for the first forms in unwind-protect
and multiple-value-prog1 helps to understand their special meaning.
Fix 49b244db78 assumed, that the class
itself is first in the CPL list, and this assumption while correct in
light of MOP specification may be broken by a non-conforming code.
Bringing back the check whether (eq x class) when we try to finalize
the "top-most class which is not yet finalized" does not break
conforming code whiel still enabling slihgtly broken code to work.
Fixes#572.