Commit graph

9163 commits

Author SHA1 Message Date
Daniel Kochmański
1cdaf35d54 nucleus: introduce a table with early symbols ecl_symbols
This table contains symbols that are essential to the core runtime: ECL_T,
ECL_UNBOUND, ECL_SIGNAL_HANDLERS, ECL_RESTART_CLUSTERs, ECL_INTERRUPTS_ENABLED,
ECL_ALLOW_OTHER_KEYS and ECL_UNBOUND.

The table is initialized with constexpr, so it is possible to use its elements
in static elements. We also add ecl_def_function to ecl-inl to allow
appropriating C functions into Lisp world at top level.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
844296da75 nucleus: move early stacks to a separate file
This is necessary if we want to link them into nucleus without CL env baggage.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
6333d146a4 nucleus: move aux throw/go/tagbody implementations to jump.d 2026-03-11 08:42:05 +01:00
Daniel Kochmański
536286125e garbage: allow for building ecl without bdwgc and with nogc
In that case we use a dummy object nogc.o that contains stubs for GC-related
functions. It also defines a substitute module.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
219f7d7ba9 modules: uninstall signal handlers when unixint is destroyed 2026-03-11 08:42:05 +01:00
Daniel Kochmański
cd5fd26bf3 modules: deallocate stacks when modules are destroyed 2026-03-11 08:42:05 +01:00
Daniel Kochmański
278ca85097 modules: release all resources on ecl_halt
Previously we were lazy and simply marked the runtime as "not booted", but now
we do perform a proper shutdown.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
be01170689 process: move process initialization to the process module hooks 2026-03-11 08:42:05 +01:00
Daniel Kochmański
1f5e752013 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-03-11 08:42:05 +01:00
Daniel Kochmański
7a7e14d0ef 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-03-11 08:42:05 +01:00
Daniel Kochmański
f50abe49b9 modules: [A/n] move the environment allocators to nucleus
Also clean up initialization code across different paths to have the same order.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
4ece70632d modules: [9/n] introduce ecl_module_thread 2026-03-11 08:42:05 +01:00
Daniel Kochmański
907036afcb modules: [7/n] introduce ecl_module_stacks 2026-03-11 08:42:05 +01:00
Daniel Kochmański
4877ae5999 modules: [6/n] introduce ecl_module_aux 2026-03-11 08:42:05 +01:00
Daniel Kochmański
48636cf579 modules: [5/n] introduce ecl_module_ffi 2026-03-11 08:42:05 +01:00
Daniel Kochmański
4b67426ef9 modules: [4/n] introduce ecl_module_bignum 2026-03-11 08:42:05 +01:00
Daniel Kochmański
942a06e724 modules: [3/n] introduce ecl_module_process 2026-03-11 08:42:05 +01:00
Daniel Kochmański
7a0a4cf705 modules: [2/n] introduce ecl_module_unixint 2026-03-11 08:42:05 +01:00
Daniel Kochmański
99921d340b 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-03-11 08:42:05 +01:00
Daniel Kochmański
e5357950a6 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-03-11 08:42:05 +01:00
Daniel Kochmański
9b8335bed5 process: move ecl_clear_bignum_registers to _dealloc_env
This resolves a fixme.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
ff4b4bcc91 process: use GC_thread_is_registered() instead of the_env->cleanup
This allows us to remove unnecessary bookkeeping.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
9835c2fbec nucleus: [2/n] move processing unit managament to nucleus 2026-03-11 08:42:05 +01:00
Daniel Kochmański
5d188c61bd nucleus: [1/n] move processing unit managament to nucleus 2026-03-11 08:42:05 +01:00
Daniel Kochmański
89457d91f0 exceptions: make reader.d usable in the early env 2026-03-11 08:42:05 +01:00
Daniel Kochmański
d715593e20 exceptions: make stream.d usable in the early env
This is a step towards introducing the I/O system.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
ec3c2a8b47 exceptions: make character.d usable in early runtime 2026-03-11 08:42:05 +01:00
Daniel Kochmański
741cb86215 exceptions: make cfun_dispatch use exception trampolines 2026-03-11 08:42:05 +01:00
Daniel Kochmański
fb62ba9367 exceptions: dispatch signals exceptions (not conditions) 2026-03-11 08:42:05 +01:00
Daniel Kochmański
3bc8418365 exceptions: runtime stack error signals exceptions (not conditions)
Replace calls to CEstack_overflow with exceptions - this is a necessary step
before moving stacks into nucleus.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
db0b49a599 exceptions: interpreter signals exceptions (not conditions) 2026-03-11 08:42:05 +01:00
Daniel Kochmański
9d0573fbb5 exceptions: introduce the concept of an exception
Exceptions, unlike conditions, are stack allocated and can't be captured.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
4e860d86bc 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-03-11 08:42:05 +01:00
Daniel Kochmański
7f43fd550e signals: handler-bind handles only objects of type CONDITION 2026-03-11 08:42:05 +01:00
Daniel Kochmański
a87e48e88a signals: introduce signals to the early environment 2026-03-11 08:42:05 +01:00
Daniel Kochmański
7c99f775c6 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-03-11 08:42:05 +01:00
Daniel Kochmański
06d31f7f77 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-03-11 08:42:05 +01:00
Daniel Kochmański
fd72156073 boot: move ecl_core_struct to boot.d 2026-03-11 08:42:05 +01:00
Daniel Kochmański
fdb7578f8c boot: move protect and dummy tags to boot.d 2026-03-11 08:42:05 +01:00
Daniel Kochmański
982ac30055 boot: move early constants from main.d to boot.d 2026-03-11 08:42:05 +01:00
Daniel Kochmański
c511f293c1 boot: add a file boot.d for booting the core
Currently it contains only option setters.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
ca957e2d22 boot: add a file escape.d for program control transfer
Currently it contains early errors and backtrace.
2026-03-11 08:42:05 +01:00
Daniel Kochmański
730ff85112 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-03-11 08:42:05 +01:00
Daniel Kochmański
dd839fdea2 reader: make token parser installable in the readtable 2026-03-11 08:42:05 +01:00
Daniel Kochmański
aff7cb7f09 reader: merge back readtable.d into read.d and reader.d 2026-03-11 08:42:05 +01:00
Daniel Kochmański
f0046250f8 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-03-11 08:42:05 +01:00
Daniel Kochmański
4be70d8b1d reader: init_read has now shorter definitions (use macros) 2026-03-11 08:42:05 +01:00
Daniel Kochmański
40a13b9da1 reader: cosmetic change 2026-03-11 08:42:05 +01:00
Daniel Kochmański
2479e0d244 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-03-11 08:42:05 +01:00
Daniel Kochmański
04bf497ac0 reader: low level functions accept explicit readtable argument
Previously the readtable was accessed as a value of a variable *READTABLE*.
2026-03-11 08:42:05 +01:00