Commit graph

9196 commits

Author SHA1 Message Date
Daniel Kochmański
367def24c0 exceptions: introduce the concept of an exception
Exceptions, unlike conditions, are stack allocated and can't be captured.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
41833adcf3 [wip] reader: add a new helper function ecl_parse_fixnum
This funciton parses an integer and returns OBJNULL when it exceeds the size of
a fixnum.

It is used in format.d - a file that is not compiled currently. It should be
also used in cl_name_char.

[wip] because:
- is it really needed?
- I've commented unicode access for digitp
2026-04-19 19:54:36 +02:00
Daniel Kochmański
bf0cb12bbc [maybe] bytevm: open-code lexical environment allocation
To avoid dependency on vector.o we opencode allocating the vector.

Note that we can't use ecl_make_stack, because mallocated memory must be
reegistered as a root.

[todo] move finalizers to memory and fix t_bclosure
[note] ecl_stack_pshu never resizes the stack (realloc vs manual resize)
2026-04-19 19:54:36 +02:00
Daniel Kochmański
bd166139cd [maybe] stacks: add more operations 2026-04-19 19:54:36 +02:00
Daniel Kochmański
3f595e68a5 [maybe] boot: 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-04-19 19:54:36 +02:00
Daniel Kochmański
854255c6c5 memory: add a new allocator function realloc 2026-04-19 19:54:36 +02:00
Daniel Kochmański
6d47487ce4 memory: rename ecl_realloc to ecl_resize 2026-04-19 19:54:36 +02:00
Daniel Kochmański
c8f25c08de memory: ensure disabled interrupts in top-level operators
ecl_alloc_object, ecl_free_object
ecl_alloc, ecl_alloc_manual, ecl_alloc_atomic, ecl_dealloc

Moreover move all top-level ops to memory.d so they are not reliant on mem_gc.
The stubbed allocator uses manual memory managament for all ops.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
f986fdcd92 memory: move resource pools from reader.d to memory.d
si_get_buffer_string is used in a few places, and gneerally it is more
appropriate to put resources in memory.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
d05a5bba06 memory: reify the type_info database
We store information about the object size, its pointers and name. This
information is later reused by the garbage collector.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
448d56dc61 memory: move ecl_alloc_adjustable_*_string to memory.d
These constructors are used to provide buffers that may be returned to cl_core.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
f13141f5f6 memory: move ecl_cons to memory.d
ecl_cons requires a separate allocator because it may be a small cons.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
8ae02090f1 memory: make it possible to configure the allocator 2026-04-19 19:54:36 +02:00
Daniel Kochmański
39324aaf96 stacks: elide unnecessary call to ecl_symbol_type
having this call makes interpreter dependent on symbol.d
2026-04-19 19:54:36 +02:00
Daniel Kochmański
a0faf9ee70 stacks: move early stacks to a separate file
This is necessary if we want to link them into nucleus without CL env baggage.
2026-04-19 19:54:36 +02:00
Daniel Kochmański
2c018bb111 control: move aux throw/go/tagbody implementations to escape.d 2026-04-19 19:54:36 +02:00
Daniel Kochmański
6c7b5314c3 modules: [B/n] 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-04-19 19:54:36 +02:00
Daniel Kochmański
6d85475a6c modules: uninstall signal handlers when unixint is destroyed 2026-04-19 19:54:36 +02:00
Daniel Kochmański
179b7a0bfc modules: deallocate stacks when modules are destroyed 2026-04-19 19:54:36 +02:00
Daniel Kochmański
c9baaf67bc 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-04-19 19:54:36 +02:00
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