Commit graph

7911 commits

Author SHA1 Message Date
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
Daniel Kochmański
2b5b2374b6 util: add binding macros from alexandria for convenience
if-let, when-let, when-let* are well known utilities and we have
plenty of places where we could use these idioms.
2020-03-26 13:42:37 +01:00
Daniel Kochmański
4c7658a6fe Merge branch 'minor-compiler-fixes' into 'develop'
Fix some minor compiler bugs

Closes #545

See merge request embeddable-common-lisp/ecl!191
2020-03-26 12:41:06 +00:00
Marius Gerbershagen
91d251a7ba cmp: correctly handle unused special &rest variables
Even when the variable is not used, we still have to do the binding.
2020-03-21 13:05:23 +01:00
Marius Gerbershagen
14d46da134 cmp: fix evaluation order bugs in compiler macros 2020-03-21 11:44:01 +01:00
Marius Gerbershagen
dda466dd0e cmp: allow :allow-other-keys for functions with &key but zero keywords
Functions such as
(defun f (&key) ...)
would give an error when called like (f :allow-other-keys ...).
2020-03-20 21:29:18 +01:00
Marius Gerbershagen
a9065d1d8e cmp: fix closure type for local functions calling closures
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.
2020-03-18 22:00:57 +01:00
Marius Gerbershagen
1d7551c773 doc: document ECLDIR and ecl_import/release_current_thread
Also reorganize the embedding reference into two subsubsections.
2020-03-14 19:56:51 +01:00
Marius Gerbershagen
d7529988f0 numbers: add workaround for log1p
log1pl is not present on NetBSD.
2020-03-12 21:29:12 +01:00
Marius Gerbershagen
1aeb7823e8 cmp: add explicit type suffixes for emitted integer constants in C code
According to the C99 standard, compilers are supposed to automatically
choose the correct type. However, for the C89 standard explicit suffixes
are needed for long longs. Guess what standard msvc follows...
2020-03-07 22:26:44 +01:00
Marius Gerbershagen
f776bd8615 fix daylight savings time detection for win64 2020-03-07 22:26:43 +01:00
Marius Gerbershagen
f76bd95786 fix array dimension limit for msvc win64 2020-03-07 22:26:43 +01:00
Marius Gerbershagen
f936415c0d process.d: add missing include 2020-03-02 22:07:29 +01:00
Daniel Kochmański
6f0bc19628 Merge branch 'fix-559' into 'develop'
Fix #559

Closes #559

See merge request embeddable-common-lisp/ecl!187
2020-03-02 13:39:38 +00:00
Daniel Kochmański
6c40cb1439 Merge branch 'windows-fixes' into 'develop'
various fixes for Windows

Closes #564

See merge request embeddable-common-lisp/ecl!189
2020-03-01 20:06:52 +00:00
Marius Gerbershagen
a7e694de0e ecl_import_current_thread: fix segmentation fault
Bug was introduced by the recent race condition fixes of commit
cc7c0d4386. ecl_list_process needs to be
able to allocate memory and bind special variables, which wasn't possible
previously, because the environment was not yet initialized. Since we can't
initialize the environment before calling ecl_list_process (that was the
reason for the race condition in the first place), we use the fake environment
allocated on the stack (where the gc can find its contents) until we can
safely call ecl_list_process and switch over to the real environment.

Fixes #564.
2020-03-01 18:49:50 +01:00
Marius Gerbershagen
0577802718 ecl_release_current_thread: don't close handle twice
thread_cleanup already calls CloseHandle
2020-03-01 18:49:50 +01:00
Marius Gerbershagen
313d553918 tests: fix embedding tests on cygwin 2020-03-01 18:49:50 +01:00
Marius Gerbershagen
fd7b4c6f85 tests: add test for ecl_import_current_thread 2020-03-01 18:49:50 +01:00
Marius Gerbershagen
14fa51f172 fix config.h for MSVC win64 2020-03-01 18:49:50 +01:00
Marius Gerbershagen
2155e354e4 doc: more detailed build instructions for MSVC 2020-03-01 18:49:49 +01:00
Marius Gerbershagen
6dce405b2a tests: stop compilers from complaining about division by zero in emb.0003.with-lisp-fpe 2020-03-01 18:49:49 +01:00
Marius Gerbershagen
a3eebf1ba3 Revert "ieee-fp: remove _fpreset from si_trap_fpe"
This reverts commit bd9c590810.
Apparently, _fpreset is not just equivalent to feclearexcept and really
needed when doing a longjmp out of a signal handler. On top of that, with
MSVC 2019, I now observe segmentation faults without _fpreset, but not with
_fpreset in si_trap_fpe!
2020-03-01 18:49:49 +01:00
Marius Gerbershagen
6729693650 fix fixint and fixnnint for apis with long smaller than cl_fixnum
Concerns especially win64. These functions have been broken since
commit 0102aed9f5.
2020-03-01 18:49:49 +01:00
Marius Gerbershagen
350c493cb4 configure: only disable fpe but not ieee-fp for mingw
Due to recent changes, it is possible to have infinity and NaN, but
without floating point exceptions.
2020-03-01 18:49:49 +01:00
Marius Gerbershagen
c704f34ce2 Merge branch 'develop' into 'develop'
restore 21bit unicode on windows msvc build

See merge request embeddable-common-lisp/ecl!188
2020-03-01 17:44:57 +00:00
Yuguo Zhang
b59bbd6164 restore 21bit unicode on windows msvc build
ecl_character is a signed type actually,
16bit signed short is not big enough to hold big charsets, such as
CP936.

this commit rolls back 74b67347.
2020-02-26 11:36:34 +08:00
Marius Gerbershagen
4faac4dcb8 doc: replace legacy names by their new counterparts 2020-02-22 19:12:43 +01:00
Marius Gerbershagen
f18cbde8e7 queue.d: don't call _ecl_big_register_free for a normalized bignum
Fixes segmentation faults on windows when using semaphores.
2020-02-21 22:39:36 +01:00
Daniel Kochmański
db3079f8a0 Merge branch 'fpe-without-sigfpe2' into 'develop'
ieee_fp: move fetestexcept checks directly after floating point calculations

See merge request embeddable-common-lisp/ecl!186
2020-02-17 21:44:35 +00:00
Daniel Kochmański
f0d8f8dcf7 Merge branch 'fix-560' into 'develop'
Fix #560

Closes #560

See merge request embeddable-common-lisp/ecl!185
2020-02-17 21:32:06 +00:00
Marius Gerbershagen
f020031047 defclass: don't create class at compile time
This lead to problems in code that defined validate-superclass methods
for custom metaclasses. Such methods are not installed at compile
time, giving errors when we called validate-superclass from
ensure-class during compilation.
2020-02-17 21:33:21 +01:00
Marius Gerbershagen
3afa3e1a42 ieee_fp: move fetestexcept checks directly after floating point calculations
The C standard allows compilers to ignore side effects of floating
point operations unless the STDC FENV_ACCESS pragma is in effect. This
could lead to spurious floating point exceptions being signaled
because the C compiler optimized a calculation that would ordinarily
not set fpe bits to one that did (observed with clang for a cast
double to cl_fixnum).

To solve this, we resurrect the ECL_MATHERR macro which was removed in
commit cb03494a6d. We handle fpe bits
only around calculations which are known to be "unsafe" in the sense
that they can produce floating point exceptions. Before the
calculation, all bits are unset and afterwards, we test for
exceptions.

The disadvantage of this method is that optimizations by the C
compiler resulting in unboxed float arithmetic might lead to
missing exceptions, because our native C compiler does not insert
ECL_MATHERR statements around these calculations.
2020-02-16 22:32:37 +01:00
Marius Gerbershagen
711d17e373 si_clear_gfun_hash: only enqueue operations for threads with valid environments
Fixes #560.
2020-02-14 22:40:56 +01:00
Marius Gerbershagen
cc7c0d4386 multithreading: fix race condition on thread creation
Due to the fact that the thread local environment is allocated with
mmap, the garbage collector is only aware of it after the thread is
listed in cl_core.processes. Therefore, we have to list the thread
before we allocate any memory in its environment. We were doing this
previously, however a bit earlier than needed which had the
unfortunate side effect that not all threads listed in
cl_core.processes had valid environment associated to them. Now, we
delay the listing until immediately before allocating the contents of
environment, ensuring that all listed threads have valid environments.
2020-02-14 22:31:46 +01:00