Commit graph

9049 commits

Author SHA1 Message Date
Daniel Kochmański
0fb64f5c91 bytecmp: [degression] insert CFB local macros in the lexenv
This is necessary if we want to recompile bytecodes either with CCMP or BCMP.
2025-03-27 22:45:34 +01:00
Daniel Kochmański
92772b1afd bytecmp: implement flat closures
This commit replaces capturing whole LEX with an explicit vector of closed
variables. We introduce a set of additional opcodes that deal with closed
entities. Locals are referred as lcl and closed variables as lex.
2025-03-27 22:45:34 +01:00
Daniel Kochmański
7637f84629 bytecmp: [regression] don't stick macros at the lexenv beginning
This commit causes an intentional regression in the bytecodes compiler - we
don't carry over macros and symbol macros, so we can't recompile bytecompiled
function with the native compiler if they reference them.

That will be fixed in a more organized manner after flat closures are in place.
2025-03-27 22:45:34 +01:00
Daniel Kochmański
710ac09e1d bytecmp: refactor handling object references
- split c_tag_ref into three functions c_{tag,blk,fun}_ref, clean c_var_ref

  small differences between functions made the former harder to read
  also update comments about the compiler environment

  functions are refactored to have a similar shape and return the
  same (internal) structure that denotes the object scope and purpose

- don't push special variables as locations in the environment

  that was (an irrelevant) bug, because special variables are not in the en

- rename asm_c to asm_arg_data

  This name better resembles the purpose of the operator
2025-03-27 22:45:34 +01:00
Daniel Kochmański
4e95ee830a tests: add a failing test for minimal closures 2025-03-27 22:45:34 +01:00
Daniel Kochmański
8e44c6322f bytevm: enclose macros over local functions defined with flet/labels
This change requires a kludge that addresses an issue with creating shallow
copies of the environment.
2025-03-27 22:45:34 +01:00
Daniel Kochmański
85c6599d8d cmp: fix a bug in SET-CLOSURE-ENV wrt self-referncing objects
When we were compiling bytecodes with LABELS, the function SET-CLOSURE-ENV
exhibited infinite recursion by adding the record as FLET. C.f test "cmp.0100".
2025-03-27 22:45:34 +01:00
Daniel Kochmański
9161bd427e tests: add a regression test for a newly spotted bug in bytecmp 2025-03-27 22:45:34 +01:00
Daniel Kochmański
1ff274bf08 bytevm: don't use ecl_fdefinition for OP_FUNCTION
The function ecl_fdefinition checks also for lamdbas and whatnot, while all we
need is a lookup in the global namespace for the function name.

This commit also changes how we store SETF function definition -- instead of
maintaining them in a global environment, it is stored along with the symbol.
That saves us from taking a global lock repeatedly.
2025-03-27 22:45:34 +01:00
Daniel Kochmański
9c1bcd0b7b bytevm: use ecl_apply_from_stack_frame to dispatch calls 2025-03-27 22:45:34 +01:00
Daniel Kochmański
32dfca42e5 bytevm: introduce unsafe primops SI:CONS-CAR and SI:CONS-CDR 2025-03-27 22:45:34 +01:00
Daniel Kochmański
497ece5a77 bytevm: move stepping logic out to trace.lsp
We use the environment hook to install the stepper.
2025-03-27 22:45:34 +01:00
Daniel Kochmański
b1aa2e47f3 bytevm: provide function wrappers for all signaled conditions 2025-03-27 22:45:34 +01:00
Daniel Kochmański
d4c20918b9 core: register the finalizer immedietely after allocation
Previously we've registered the finalizer when a symbol was dynamically bound
for the first time; this commit changes that to remove a dependency on GC when
binding special variables.
2025-03-27 22:12:49 +01:00
Daniel Kochmański
fdbff61f51 cons: introduce macro ecl_cons_stack that allocates on the stack 2025-03-27 22:12:49 +01:00
Daniel Kochmański
0f882280c0 cosmetic: removeu nused argument 2025-03-27 09:44:37 +01:00
Daniel Kochmański
7e3dc96fa5 Merge branch 'improve-ensure-directories-exist' into 'develop'
ensure-directories-exist: minor improvements

See merge request embeddable-common-lisp/ecl!340
2025-03-17 20:23:42 +00:00
Marius Gerbershagen
270b3a4157 cmp: fix compiler-macro for make-array
Constant arguments for the dimensions were not handled correctly. The
valid-array-index function was lost in a refactor some time ago.
Moreover, we need to check all of the conditions on the
dimensions (limits on rank, dimension and total size) using an AND
statement instead of checking only the first condition using OR.
2025-03-02 19:36:06 +01:00
Marius Gerbershagen
a3d7036c36 ensure-directories-exist: minor improvements
Simply call mkdir and ignore EEXIST errors to prevent race conditions
when two processes try to create a directory at the same time. Also
avoids a redundant syscall since by not calling si::file-kind, so this
should be slightly faster.
2025-03-01 17:52:26 +01:00
Marius Gerbershagen
31bcb06d83 use separate directory for --with-extra-files to avoid name clashes
Fixes #772
2025-02-22 20:18:42 +01:00
Marius Gerbershagen
315ccd7d8d Merge branch 'improve-describe' into 'develop'
DESCRIBE prints arguments and source information for operators

Closes #711

See merge request embeddable-common-lisp/ecl!339
2025-02-15 14:55:43 +00:00
Daniel Kochmański
8d34f874d0 DESCRIBE prints arguments and source information for operators
After this commit DESCRIBE prints two additional pieces of information below the
docstring. To avoid duplication, corresponding arg piece in doc/help.lsp has
been removed. Fixes #711.
2025-01-28 09:22:08 +01:00
Marius Gerbershagen
3d6bc48e10 Merge branch 'bignum-cleanup' into 'develop'
Small cleanup of bignums

See merge request embeddable-common-lisp/ecl!337
2025-01-22 19:36:14 +00:00
Daniel Kochmański
77dc322364 bignum: factor out serialization functions for bignum 2025-01-20 12:39:59 +01:00
Daniel Kochmański
1102e58e0e bignum: replace numerous references to mpz with _ecl_big trampolines 2025-01-20 12:39:59 +01:00
Daniel Kochmański
ceae17c1bb bignum: replace references to gmp limbs with ecl macros
GMP_LIMB_BITS -> ECL_BIGNUM_LIMB_BITS
mp_limb_t -> ecl_limb_t
2025-01-20 12:39:59 +01:00
Daniel Kochmański
a826e65af0 bignum: internal interface cleanup
Remove unused wrappers and move things used only in big.d to that file.
2025-01-20 12:39:57 +01:00
Daniel Kochmański
c5f7b48a96 ecl_to_float: use the function ratio_to_float 2025-01-20 12:08:50 +01:00
Daniel Kochmański
44033ce73e si_need_to_make_load_form_p: use hash table for load form cache
For very long lists going with list search gives us O(n²).
2024-12-29 20:32:25 +01:00
Daniel Kochmański
295dfc0cd8 printer: fix the write_ugly method for bclosure
We've made an implicit cast from bclosure to bytecodes, so instead of a name
we've printed bytecodes itself.

Except from thsi fix we also write the closure address to make it possible to
distinguish two different closures over the same function.
2024-12-18 10:47:17 +01:00
Daniel Kochmański
58ffd18cc5 Merge branch 'emscripten-lazy-loading-files' into 'develop'
avoid unnecessary network requests when reading directories on emscripten

See merge request embeddable-common-lisp/ecl!335
2024-12-15 19:13:32 +00:00
Marius Gerbershagen
77879de20b Merge branch 'revert-small-cons-removal' into 'develop'
Revert "Merge branch 'remove-small-cons' into 'develop'"

See merge request embeddable-common-lisp/ecl!336
2024-12-15 10:01:30 +00:00
Daniel Kochmański
f73d4babbd Revert "Merge branch 'remove-small-cons' into 'develop'" 2024-12-15 10:01:30 +00:00
Marius Gerbershagen
e41a5efcb5 avoid unnecessary network requests when reading directories on emscripten
If we call stat in order to find out if a filename points to a
directory or an ordinary file, the emscripten stdlib may need to do a
network request to find out the size of the file even though we don't
care about that. This happens for files created with
FS.createLazyFile() by emscripten. By using readlink/opendir when
possible we avoid that.
2024-12-14 14:58:25 +01:00
Daniel Kochmański
82e01c0b7d cosmetic: replace @'t' with ECL_T in core 2024-12-11 12:38:30 +01:00
Daniel Kochmański
9dcd8ff7c3 Merge branch 'remove-small-cons' into 'develop'
core: remove the "small-cons" feature and build flag

See merge request embeddable-common-lisp/ecl!334
2024-12-06 13:04:35 +00:00
Daniel Kochmański
31fdffa6ab core: remove the "small-cons" feature and build flag 2024-12-06 13:04:34 +00:00
Daniel Kochmański
a08d60d11a process: check for bindings_array in env (c.f the previous commit) 2024-12-06 12:28:25 +01:00
Daniel Kochmański
6b2a0d7ed0 process: alloc_process used OBJNULL instead of ECL_NIL 2024-12-06 11:43:40 +01:00
Daniel Kochmański
fcd9abba71 universal_error_handler: print more of the error
Having *PRINT-LENGTH* at 3 is not satisfactory, especially in the early handler
where there are no other means to introspect errors. Change it to 8.

Before:

    ;;; Message:
    |TYPE-ERROR|
    ;;; Arguments:
    (:|EXPECTED-TYPE| |FUNCTION| :|DATUM| ...)

After:

    ;;; Message:
    |TYPE-ERROR|
    ;;; Arguments:
    (:|EXPECTED-TYPE| |FUNCTION| :|DATUM| (|QUOTE| |WHILE|))
2024-12-06 10:20:39 +01:00
Daniel Kochmański
0ebcbbd70c Merge branch 'update-gc' into develop 2024-12-05 22:33:56 +01:00
Daniel Kochmański
193fa8dca0 changelog: add libgc bump to the changelog 2024-12-05 22:33:10 +01:00
Daniel Kochmański
3f8e82351d build: remove a workaround in bdwgc masking a bug in bdwgc 8.2.4 2024-12-05 22:28:33 +01:00
Daniel Kochmański
6246c8aa85 build: regenerate configure script with autoconf 2.72 2024-12-05 22:27:10 +01:00
Daniel Kochmański
dd14c9bf71 bdwgc: update bundled gc to version 8.2.8
libatomic_ops did not change in the meantime
2024-12-05 22:21:45 +01:00
Daniel Kochmański
0d8720dd49 util: turn off thread-events in proposed gdbinit 2024-12-05 14:07:14 +01:00
Daniel Kochmański
8d6a9ab3f0 gmp: fix the configure script
The config script as it is now fails on gcc version 14.2.1 20240912 (Red Hat 14.2.1-3) (GCC)
This is because one test did not include string.h before memcpy, and two other tests relied
on implicit function definitions -- in one test definitions are moved before the first use
and the second test is removed wholesale as it relies on undefined behavior and tests some
obscure (and ancient) gcc flavor segfault.
2024-11-27 22:10:37 +01:00
Daniel Kochmański
cf09521700 Merge branch 'fix-weak-hash-table' into 'develop'
hash: resolve collision-handling issues in hash tables with weakness

Closes #761

See merge request embeddable-common-lisp/ecl!333
2024-11-20 05:55:30 +00:00
Daniel Kochmański
c17627779b weak hash: add entry to changelog 2024-11-01 08:46:33 +01:00
Daniel Kochmański
5c138480d0 hash: fix numerous issues with weak hash tables
1. We don't normalize garbage collected entries.

Doing that created a false free bucket, so GETHASH and SETHASH stopped searching
for entry too early. Fixes #761.

2. MAPHASH does not map over garbate collected entries.

Previously MAPHASH did not call copy_entry, so it was always accessing key/val
even if they were recently garbage collected, effectively mapping over NIL in
the place of the collected value

3. HASH-TABLE-CONTENT had a similar issue to MAPHASH.

4. REMHASH did fill the hole, but didn't replace the moved entry with a free
bucket, moreover we've used the value to comptue the hash when computing the
distance function.

Moreover we introduce an optimization, where SETHASH first tries to fill a
garbage collected entry in the bucket before it tries to extend the table.
2024-11-01 08:46:33 +01:00