Commit graph

9195 commits

Author SHA1 Message Date
Daniel Kochmański
0ca3142d06 lwp: add smoke test 2026-03-16 21:05:26 +01:00
Daniel Kochmański
7fd467321d lwp: use mprotect to catch stack overflows 2026-03-16 21:05:23 +01:00
Daniel Kochmański
c73b2e73d9 [wip] write ugly print corrupted objects 2026-03-15 20:24:13 +01:00
Daniel Kochmański
5ea9949838 lwp: call the thread function 2026-03-15 20:24:08 +01:00
Daniel Kochmański
fdf810173d [wip] compile: add debug flags 2026-03-15 20:24:05 +01:00
Daniel Kochmański
843fb8a245 [wip] hack module accessors into core runtime 2026-03-15 20:20:45 +01:00
Daniel Kochmański
8f909348f1 lwp: use si_pass to swtich context from both sides
Add current continuation slot to process, and create the current process on
demand.
2026-03-15 09:47:50 +01:00
Daniel Kochmański
2be359ca6d lwp: demonstrate successful yield/resume with lisp env 2026-03-15 09:47:50 +01:00
Daniel Kochmański
a7181567c6 lwp: first jump to a different stack 2026-03-15 09:47:50 +01:00
Daniel Kochmański
7a4589ff7f lwp: add new types CONTINUATION and THREAD 2026-03-15 09:47:50 +01:00
Daniel Kochmański
e4b66f0740 [nucl] experimental runtimes 2026-03-15 09:47:50 +01:00
Daniel Kochmański
92060b703d exceptions: make reader.d usable in the early env 2026-03-15 09:47:50 +01:00
Daniel Kochmański
3b329812b3 exceptions: make stream.d usable in the early env
This is a step towards introducing the I/O system.
2026-03-15 09:47:50 +01:00
Daniel Kochmański
468209ace1 exceptions: make character.d usable in early runtime 2026-03-15 09:47:50 +01:00
Daniel Kochmański
5283c00943 exceptions: make cfun_dispatch use exception trampolines 2026-03-15 09:47:50 +01:00
Daniel Kochmański
fbd097e6da exceptions: dispatch signals exceptions (not conditions) 2026-03-15 09:47:50 +01:00
Daniel Kochmański
733072e88f 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-15 09:47:50 +01:00
Daniel Kochmański
60c325bbad exceptions: interpreter signals exceptions (not conditions) 2026-03-15 09:47:50 +01:00
Daniel Kochmański
19de2a53bd exceptions: make escape signal an exception not internal error 2026-03-15 09:47:50 +01:00
Daniel Kochmański
67418ed1c7 exceptions: introduce the concept of an exception
Exceptions, unlike conditions, are stack allocated and can't be captured.
2026-03-15 09:47:50 +01:00
Daniel Kochmański
37e084e042 [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-03-15 09:47:50 +01:00
Daniel Kochmański
50814e6ed5 [wip] msvc: update a makefile and specify /std:c11 minimal standard
MSVC does not allow for specifying /std:c99 so we need c11. We don't rely on the
default standard because it does not allow for static struct initializers.
2026-03-15 09:47:50 +01:00
Daniel Kochmański
a54570352a [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-03-15 09:47:50 +01:00
Daniel Kochmański
0f616e9e2c [maybe] stacks: add more operations 2026-03-15 09:47:50 +01:00
Daniel Kochmański
357ef042ed [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-03-15 09:47:50 +01:00
Daniel Kochmański
f31a4b7a34 memory: add a new allocator function realloc 2026-03-15 09:47:50 +01:00
Daniel Kochmański
715f472565 memory: rename ecl_realloc to ecl_resize 2026-03-15 09:47:50 +01:00
Daniel Kochmański
12f1458a32 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-03-15 09:47:50 +01:00
Daniel Kochmański
de73c24bd4 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-03-15 09:47:50 +01:00
Daniel Kochmański
7d7352cf6b 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-03-15 09:47:50 +01:00
Daniel Kochmański
ee4dcb7a62 memory: move ecl_alloc_adjustable_*_string to memory.d
These constructors are used to provide buffers that may be returned to cl_core.
2026-03-15 09:47:50 +01:00
Daniel Kochmański
4fc8bb7c45 memory: move ecl_cons to memory.d
ecl_cons requires a separate allocator because it may be a small cons.
2026-03-15 09:47:50 +01:00
Daniel Kochmański
2130da17b5 memory: make it possible to configure the allocator 2026-03-15 09:47:50 +01:00
Daniel Kochmański
cffeae0a1d stacks: elide unnecessary call to ecl_symbol_type
having this call makes interpreter dependent on symbol.d
2026-03-15 09:47:50 +01:00
Daniel Kochmański
bc8385486b stacks: move early stacks to a separate file
This is necessary if we want to link them into nucleus without CL env baggage.
2026-03-15 09:47:50 +01:00
Daniel Kochmański
97406afb12 control: move aux throw/go/tagbody implementations to escape.d 2026-03-15 09:47:50 +01:00
Daniel Kochmański
8776a249d6 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-03-15 09:47:02 +01:00
Daniel Kochmański
20ecefa4f6 modules: uninstall signal handlers when unixint is destroyed 2026-03-15 09:47:02 +01:00
Daniel Kochmański
ac05b750dd modules: deallocate stacks when modules are destroyed 2026-03-15 09:47:02 +01:00
Daniel Kochmański
d875e235eb 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-15 09:47:02 +01:00
Daniel Kochmański
424ba93a2a process: move process initialization to the process module hooks 2026-03-15 09:47:02 +01:00
Daniel Kochmański
30bccdefcf 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-15 09:47:02 +01:00
Daniel Kochmański
1eb9822065 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-15 09:47:02 +01:00
Daniel Kochmański
49e2aed7be modules: [A/n] move the environment allocators to nucleus
Also clean up initialization code across different paths to have the same order.
2026-03-15 09:47:02 +01:00
Daniel Kochmański
c9f41e29f1 modules: [9/n] introduce ecl_module_thread 2026-03-15 09:47:00 +01:00
Daniel Kochmański
4ef1a5097b modules: [7/n] introduce ecl_module_stacks 2026-03-15 09:46:58 +01:00
Daniel Kochmański
75a3449eb4 modules: [6/n] introduce ecl_module_aux 2026-03-15 09:46:55 +01:00
Daniel Kochmański
b8e5d2b6c0 modules: [5/n] introduce ecl_module_ffi 2026-03-15 09:46:52 +01:00
Daniel Kochmański
f4a0e6ee36 modules: [4/n] introduce ecl_module_bignum 2026-03-15 09:46:45 +01:00
Daniel Kochmański
9469886a62 squash [3/n] 2026-03-15 09:46:45 +01:00