Commit graph

7945 commits

Author SHA1 Message Date
Daniel Kochmański
6b789092c4 Merge branch 'develop' 2020-04-24 12:54:52 +02:00
Daniel Kochmański
f152a3000d Merge branch 'fix-576' into develop 2020-04-24 11:50:13 +02:00
Moritz Petersen
d5eafde045 Add a regression test for the bug described in #576
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.
2020-04-24 11:42:46 +02:00
Moritz Petersen
660b1bec69 Always close stream in with-output-to-string & cosmetic changes
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
2020-04-24 11:42:23 +02:00
Daniel Kochmański
496eb06675 Merge branch 'rc' into 'develop'
20.4.24 release

See merge request embeddable-common-lisp/ecl!200
2020-04-23 10:12:37 +00:00
Daniel Kochmański
eea597de34 20.4.24 release
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.
2020-04-21 11:24:02 +02:00
Marius Gerbershagen
29c415b19d Merge branch 'fix-573' into 'develop'
Fix 573

See merge request embeddable-common-lisp/ecl!198
2020-04-19 15:42:51 +00: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
f1bc883ed6 clos: introduce class stamps for marking instances obsolete
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.
2020-04-19 17:04:41 +02:00
Daniel Kochmański
81a85f37bd clos: introduce a new system function si:instance-obsolete-p
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.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
97f174c0a5 clos: specializer class: avoid a metastability issue
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.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
22f9d51560 clos: finalize-inheritance: don't refinalize structure-class 2020-04-19 14:34:23 +02:00
Daniel Kochmański
5c02111bfc clos: finalize-inheritance: don't always change the class-slots identity
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).
2020-04-19 14:34:23 +02:00
Daniel Kochmański
bee9e8db55 clos: finalize-inheritance: revert a non-conforming change
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.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
5feb42dfa3 clos: reinitialize-instance: don't remove generic functions
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.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
681caade84 clos: allocate-instance: add a comment in allocate-instance
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.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
3ec02d6daf clos: finalize-unless-forward: check for the class itself first
That was probably a typo, because finalize-unless-forward checked only
the class parents if they were forward-referenced classes, not the
class itself.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
d45f079c3c clos: cleanup: remove unused file, use when-let
File macros.lsp was used for bootstrapping in the past, but it is not
loaded anymore.
2020-04-19 14:34:23 +02:00
Daniel Kochmański
735d49bfd1 tests: improve some tests
- extend tests for make-instances-obsolete
- add a metastability test for the standard-method finalization
- fix tests which assume that metaclasses are finalized eagerly
2020-04-19 14:34:23 +02:00
Daniel Kochmański
34cd3dc221 Merge branch 'getaddrinfo-fixes' into 'develop'
Minor fixes for get-host-by-name from sockets

See merge request embeddable-common-lisp/ecl!199
2020-04-19 12:33:48 +00:00
Marius Gerbershagen
beadd585ce sockets: don't return the same address multiple times in get-host-by-name 2020-04-19 10:46:03 +02:00
Marius Gerbershagen
5451f73bb8 sockets: don't call getaddrinfo with AI_ADDRCONFIG
On linux, using AI_ADDRCONFIG causes getaddrinfo to return no ip
address for localhost when only the loopback connection is
active. Also, we only get ipv4 addresses anyway due to specifying
ai_family = AF_INET, therefore the AI_ADDRCONFIG flag in not necessary
anyway.
2020-04-19 10:46:03 +02:00
Daniel Kochmański
1fe88da7f1 Merge branch 'close-with-input-from-string-stream' into 'develop'
Always close stream in with-input-from-string

See merge request embeddable-common-lisp/ecl!197
2020-04-18 15:59:26 +00:00
Moritz Petersen
17f183873d Add a regression test for the bug described in !197 2020-04-18 17:49:46 +02:00
Moritz Petersen
72560efa5a Always close stream in with-input-from-string & Cosmetic changes
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.
2020-04-18 17:44:41 +02:00
Marius Gerbershagen
3e4c253a7d Merge branch 'fix-572' into 'develop'
Fix 572

Closes #572

See merge request embeddable-common-lisp/ecl!196
2020-04-12 08:29:55 +00:00
Daniel Kochmański
958a1c9f38 tests: add a regression test for #572 2020-04-11 20:02:00 +02:00
Daniel Kochmański
322eaddfa2 finalize-inheritance: guard against treating class as its own parent
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.
2020-04-11 20:01:01 +02:00
Marius Gerbershagen
abe2a2811f Merge branch 'fix-571' into 'develop'
Fix 571

Closes #571

See merge request embeddable-common-lisp/ecl!195
2020-04-09 16:51:47 +00:00
Marius Gerbershagen
0e6016559e Merge branch 'improve-congruency' into 'develop'
congruent-lambda-p: be more permissive with the congruency test

See merge request embeddable-common-lisp/ecl!194
2020-04-09 16:47:35 +00:00
Daniel Kochmański
b64da63efd tests: add a test for the change in congruent-lambda-p 2020-04-08 22:19:25 +02:00
Daniel Kochmański
896e7c5895 congruent-lambda-p: be more permissive with the congruency test
Lambda list congruency is described here:

- 7.6.4 Congruent Lambda-lists for all Methods of a Generic Function
- 7.6.5 Keyword Arguments in Generic Functions and Methods

Previously we have tested conformingly for the fourth point:

  4. If the generic function lambda list mentions &key, each method
  must accept all of the keyword names mentioned after &key, either by
  accepting them explicitly, by specifying &allow-other-keys, or by
  specifying &rest but not &key. Each method can accept additional
  keyword arguments of its own. The checking of the validity of
  keyword names is done in the generic function, not in each method. A
  method is invoked as if the keyword argument pair whose name is
  :allow-other-keys and whose value is true were supplied, though no
  such argument pair will be passed.

The fifth point mentions that if either the generic function or any
applicable method has &allow-other-keys, then function may be called
with extra keyword arguments:

  5. The use of &allow-other-keys need not be consistent across lambda
  lists. If &allow-other-keys is mentioned in the lambda list of any
  applicable method or of the generic function, any keyword arguments
  may be mentioned in the call to the generic function.

This change makes the fourth point more consistent with the fifth,
however it is *not* conformant when it is read literally. Reasons for
this change:

- this behavior is exhibited at least by SBCL and CCL, so we'll be
  more compatible with a non-conformant code tested on them

- the change won't impact results of a correct program unless it
  depends on the defmethod signaling an error condition
2020-04-08 22:18:44 +02:00
Daniel Kochmański
b41b60e7bf tests: add a regression test for #571 2020-04-08 22:02:25 +02:00
Daniel Kochmański
d769494674 defmethod: do not evaluate the method at the compilation time
Fixes #571.
2020-04-08 22:01:21 +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
Marius Gerbershagen
8fc3b4a56e Merge branch 'fix-568' into 'develop'
Fix 568

Closes #568

See merge request embeddable-common-lisp/ecl!193
2020-04-06 18:08:59 +00:00
Daniel Kochmański
cdf55007a4 tests: add a regression test for the issue #568
- also fix test which assumed constant unreadable representation of
  the object of class compiler-test-class
2020-04-05 15:13:59 +02:00
Daniel Kochmański
49b244db78 finalize-inheritance: do not refinalize when already finalized
We've reinitialized the class even when it was already finalized and
none of its parents has changed with the recomputed information.

That leads to replacing the class slots with a result of COMPUTE-SLOTS
and in effect changing the INSTANCE-SIG (see src/clos/change.lsp).
Next time when ENSURE-UP-TO-DATE-INSTANCE is called (i.e from the
STANDARD-INSTANCE-ACCESS), then the instance is reinitalized.

Behavior was the most notable when we had tried to re-finalize the
STANDARD-EFFECTIVE-SLOT-DEFINITION class, because then /its new/ slots
were by definition obsolete after calling setf on this class and
unbound, what leads to an infinite recursion when we try to signal
unbound-slot condition.

Fixes #568.
2020-04-05 15:06:55 +02:00
Daniel Kochmański
f532057a83 print-object: when printing the standard object print its address
Now instead of a default printer #<a foo> we have the identity
information #<a foo 0x56123571d240>. That is certainly useful for
printing when we have lists of instances of the same class.
2020-04-05 14:15:34 +02:00
Daniel Kochmański
3891bcc76b dpp: ensure null terminating character
putting \0 at the end of the string does not cut it.
2020-03-28 18:16:09 +01:00
Daniel Kochmański
fa24f95f7b Merge branch 'fix-562' into 'develop'
Compiler improvements

See merge request embeddable-common-lisp/ecl!190
2020-03-28 08:16:53 +00:00
Marius Gerbershagen
b94d07a072 Merge branch 'fix-logical-pathname' into 'develop'
fix logical-pathname.3 regression

See merge request embeddable-common-lisp/ecl!192
2020-03-27 20:12:16 +00:00
Marius Gerbershagen
320d3acdfd tests: don't pollute commonly used variables in the global environment in cmp.0030.make-load-form 2020-03-27 20:54:32 +01:00
Daniel Kochmański
6473d70ff3 fix logical-pathname.3 regression
We've abandoned original filename in favour of the coerced path. That
is not correct.
2020-03-27 13:57:23 +01:00
Daniel Kochmański
554855c8a4 compiler.d: add a static function push to a safe list handling
- the function push complements the function pop
- rename the local macro push from c_labels_flet to push_back to
  better reflect its purpose
2020-03-27 11:48:34 +01:00
Daniel Kochmański
b86a067788 dpp: add a syntax for parsing strings
@"foo" will expand to ecl_make_constant_base_string("foo", -1) now.
That saves some typing during testing when we want to feed a string to
the cl_format and other CL functions opearting on strings.

Now:

cl_format(3, @"~a: ~s", obj1, obj2);

Then:

cl_object str = ecl_make_constant_base_string("~a: ~s", -1);
cl_format(3, str, obj1, obj2);
2020-03-27 11:48:00 +01: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
3b6dd501e6 make-load-form: cons: initialize car in init form
This way we do not need to worry about cons recursion in make forms.
2020-03-27 11:33:53 +01:00
Daniel Kochmański
dcdb53f29e tests: add tests for #562 and #565 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