Commit graph

9176 commits

Author SHA1 Message Date
Daniel Kochmański
bd95bbe6df process: move process initialization to the process module hooks 2026-04-19 19:54:36 +02:00
Daniel Kochmański
5e42a59cc7 garbage: register and unregister GC threads manually from a module
This decouples thread primitives from the garbage collector and allows us to
build nucl once more.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
65da16bc7d process: abstract away create thread, exit thread and sigmask
Previously we've opencoded calls to these functions, although they may be nicely
abstracted with static inline functions. This change improves code readibility
and portability.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
f4252b1313 modules: [A/n] move the environment allocators to nucleus
Also clean up initialization code across different paths to have the same order.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
dc36777227 modules: [9/n] introduce ecl_module_thread 2026-04-19 19:54:36 +02:00
Daniel Kochmański
010e3e44b0 modules: [7/n] introduce ecl_module_stacks 2026-04-19 19:54:36 +02:00
Daniel Kochmański
e9f70b973e modules: [6/n] introduce ecl_module_aux 2026-04-19 19:54:36 +02:00
Daniel Kochmański
957587cefd modules: [5/n] introduce ecl_module_ffi 2026-04-19 19:54:36 +02:00
Daniel Kochmański
314a4f27b1 modules: [4/n] introduce ecl_module_bignum 2026-04-19 19:54:36 +02:00
Daniel Kochmański
6bb70627bf squash [3/n] 2026-04-19 19:54:36 +02:00
Daniel Kochmański
8fc02f287a modules: [3/n] introduce ecl_module_process 2026-04-19 19:54:36 +02:00
Daniel Kochmański
bf26866abc modules: [2/n] introduce ecl_module_unixint 2026-04-19 19:54:36 +02:00
Daniel Kochmański
2450a1483b modules: [1/n] introduce ecl_module_gc
We also remove conditionalization for garbage collector inclusion in autotools.
When we propose an alternative gc, then we may decide to put them back, or to
add necessary ifdef statements directly in files.

Moreover untangle c-stack from the gc code and assign the stack base with a
rough guess only when it is not initialized yet (GC will always fill it).

Finally remove a kludge from ecl_adopt_cpu and disable colleciton until the cpu
is fully initialized.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
54cf51d27c modules: [0/n] introduce a new structure ecl_module in the system
This will allow us to decouple forward system initialization from the early
process code.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
f60b328944 process: move ecl_clear_bignum_registers to _dealloc_env
This resolves a fixme.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
21d1d7d71b process: use GC_thread_is_registered() instead of the_env->cleanup
This allows us to remove unnecessary bookkeeping.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
531a8ecd84 nucleus: [2/n] move processing unit managament to nucleus 2026-04-19 19:54:36 +02:00
Daniel Kochmański
507018bd4a nucleus: [1/n] move processing unit managament to nucleus 2026-04-19 19:54:36 +02:00
Daniel Kochmański
79749d8400 signals: define *SIGNAL-HANDLERS* in cold_boot
I've also renamed *HANDLER-CLUSTERS* to a more appropriate *SIGNAL-HANDLERS*.
Currently this symbol is imported to the SYSTEM package, although this may be
revised in the future to cater to multiple global environments. Alternatively
the SYSTEM package may be common to all runtimes.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
9b0498e81a signals: handler-bind handles only objects of type CONDITION 2026-04-19 19:54:36 +02:00
Daniel Kochmański
fcec125944 signals: introduce signals to the early environment 2026-04-19 19:54:36 +02:00
Daniel Kochmański
940cf78f85 signals: rewrite signal handling to use functions and not lists
Instead of storing lists in *HANDLER-CLUSTERS*, we define functions that are
called unconditionally on the handler. HANDLER-BIND defines that function to be
a typecase that is dispatched based on the conditiont type, as specified by CL.

This change will aid further refactor.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
971d6df472 boot: move ecl_eql to a separate file eql.d
This is a low-level comparison operator. We opencode EQL comparison for bignums
to avoid a dependency on GMP (in this file).
2026-04-19 19:54:36 +02:00
Daniel Kochmański
eea2623849 boot: move ecl_core_struct to boot.d 2026-04-19 19:54:36 +02:00
Daniel Kochmański
37f062569e boot: move protect and dummy tags to boot.d 2026-04-19 19:54:36 +02:00
Daniel Kochmański
0127a66aa1 boot: move early constants from main.d to boot.d 2026-04-19 19:54:36 +02:00
Daniel Kochmański
e1bb1aaabe boot: add a file boot.d for booting the core
Currently it contains only option setters.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
53ef51f4cd boot: add a file escape.d for program control transfer
Currently it contains early errors and backtrace.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
07bcb949fb hash: rename cl__make_hash_table to ecl_make_hash_table
The latter name follows the codebase convention that functions that do not work
in the environment have a prefix ecl_. The old name is defined in legacy.h.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
57b23ec224 hash: use explicit ecl_returnX forms instead of (@return)
This also fixes an issue, where si:hash-table-synchronized-p did not populate
VALUES (it used raw return).
2026-04-19 19:54:36 +02:00
Daniel Kochmański
633dec58ab reader: open-code token-specific version of ecl_push_string_extend
This way we make the reader independent of string.d and array.d while still
enabling adjustable token buffers.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
ba107079d5 reader: make token parser installable in the readtable 2026-04-19 19:54:36 +02:00
Daniel Kochmański
3f939b360f reader: merge back readtable.d into read.d and reader.d 2026-04-19 19:54:36 +02:00
Daniel Kochmański
ee88dfcba0 reader: store separately macro and a dispatch table
This improves code readibility, because dispatch macro characters are built on
top of "normal" macro characters.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
e7f66676e3 reader: init_read has now shorter definitions (use macros) 2026-04-19 19:54:36 +02:00
Daniel Kochmański
19974af442 reader: cosmetic change 2026-04-19 19:54:35 +02:00
Daniel Kochmański
adc8540857 reader: turn separate parameters into flags in low-level read
Instead of passing parameters as values, we make a bitfield:

ECL_READ_LIST_DOT, ECL_READ_RETURN_IGNORABLE, ECL_READ_SUPPRESS,
ECL_READ_ESCAPE_FIST;

this way we don't rely on a dynamic variable in a low-level function.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
59e43024ec reader: low level functions accept explicit readtable argument
Previously the readtable was accessed as a value of a variable *READTABLE*.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
0b358e3bf4 reader: wrap up the escaping and remove kludges 2026-04-19 19:54:35 +02:00
Daniel Kochmański
07a97746d6 reader: honor *read-suppress* in #\foo:bar reader 2026-04-19 19:54:35 +02:00
Daniel Kochmański
fc5e6ce73d reader: add new operators and fix found regressions
- low limit in escapes was off-by-one
- quoted character immediately after :, like :|foo| did not pare correctly
2026-04-19 19:54:35 +02:00
Daniel Kochmański
b8f9a71ecc reader: separate token parsing from token reading
Parsing the token ends in a separate file.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
51c1fb0955 reader: use token object to pass tokens prior parsing 2026-04-19 19:54:35 +02:00
Daniel Kochmański
c7ff0b93a7 reader: add a new object to the system ecl_token
It represents unparsed token constructed by the reader.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
702f01968d reader: cleanup of mapping over escape intervals
This still needs some work, but we remove CONS in favor of flat list of even
number of elements and simplify loops over them.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
f6a449a1b2 reader: turn ecl_read_token into symbol/number parser
First it call ecl_only_read_token and then it parses it.
Fixes #814.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
f4824754f2 reader: factor out ecl_read_only_token from ecl_read_token
The end goal is to make ecl_read_token become ecl_parse_token and read tokens
only from ecl_read_only_token, to keep Common Lisp -specific processing out of
the token reader.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
dea815abcb reader: store escape intervals on a stack
To enable access from both sides we store escape intervals in a vector (a
stack). This also fixes #813.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
b24902574d reader: always cons full escape_list
This is in preparation for separating CL-specific tokenization from general
rule. We need to carry information about all escaped characters even when we
don't change their case, this is to allow for interpretation of special token
characters, like ":" - when it is escaped then it has no meaning, otherwise it
separates the symbol from the package.
2026-04-19 19:54:35 +02:00
Daniel Kochmański
5e049179c2 reader: simplify and clarify arguments of ecl_read_token 2026-04-19 19:54:35 +02:00