5110 Commits
Author SHA1 Message Date
nabeel-dev21 dc0f243bb9 reject short sourcemap and symbolmap entries in janet_asm1 (#1927) 2026-10-23 18:21:37 -05:00
Calvin Rose cc57cf5bd7 Redo cleanup for too many closures.
With more fuzzing data and closer inspection, seems we were just not
properly balancing scope pops. Handling a NULL pop just hid the issue.
2026-10-23 05:35:41 -05:00
Calvin Rose e98c33b6b6 Handle compiler failure cleanup better.
After adding the "too many closures" error, we tried to pop a NULL scope
during cleanup - this can segfault. Handle bad scope state better during
cleanup.
2026-10-23 05:19:55 -05:00
nabeel-dev21 a2fa318663 reject function env count that disagrees with funcdef in unmarshal (#1925) 2026-10-22 20:49:50 -05:00
Calvin Rose 9281343716 Fix #1918 - Generalize the fix for compiler configurations where pointer size is not
the same as our register size.

Mostly for x32, but gets rid of the hard-coded ifdef with logic that
calls out the issue and makes it clear what assumptions we are making.
2026-10-21 21:29:15 -05:00
Calvin Rose 2ff6b2cec0 Raise a compile error on too many closures.
Previously, we had silent miscompiles in some cases.

The ideal fix is to let us reference upvalues beyond slot 255. One way
would be to add a new instruction pair that would reference a 16-bit
constant index, which would itself encode a pair of at least 16 bit
values instead of the current instruction which encodes a pair of 8 bit
values.
2026-10-21 18:16:42 -05:00
nabeel-dev21 3606abc6d7 reject oversized bytecode length in peg unmarshal (#1921)
* reject oversized bytecode length in peg unmarshal

* trim peg unmarshal size check and cover the abstract header
2026-10-19 20:01:47 -05:00
Calvin Rose 914e3b7cc8 clunky language 2026-10-17 08:00:27 -05:00
nabeel-dev21 aebd5d71b7 reject negative argument index in peg unmarshal (#1920) 2026-10-17 07:30:45 -05:00
jcates14andjcates 6e4217836a Register streams with the event loop on unmarshal on all Unix backends (#1919)
Streams sent to another thread with ev/thread were only re-registered with the receiving thread's event loop on the poll backend. On kqueue and epoll, waiting on them hung forever, and on epoll closing them raised "No such file or directory".

Co-authored-by: jcates <jcates@>
2026-10-16 21:21:19 -05:00
Calvin Rose b7e32da0aa Formatting. 2026-10-10 13:21:42 -05:00
Calvin Rose af2471cefb peg undefined behavior fixes. 2026-10-10 11:39:05 -05:00
sogaiuandsogaiu b61531881b Update man page and tweak a bit (#1917)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-10-09 18:34:50 -05:00
Alex Alejandre 246951c809 Add cffi support to x32 (#1911) 2026-10-08 08:07:21 -05:00
Arthur Chan 8357f71519 OSS-Fuzz: Add new fuzzer targets assembly process (#1913)
Signed-off-by: Arthur SC Chan <arthur.chan@adalogics.com>
2026-10-08 08:01:48 -05:00
Arthur Chan f73474eb2f OSS-Fuzz: Update fuzz_fiber for breakpoint calls (#1912)
Signed-off-by: Arthur SC Chan <arthur.chan@adalogics.com>
2026-10-08 08:01:30 -05:00
Alex Alejandre 78f5996fcf Protect against different vector widths (#1909)
GCC aligns alloca to the widest enabled vector type (16 bytes, 32 with avx,
64 with avx-512). With AVX the block address is `lea 0x1f(%rsp)` rounded down
to the nearest 32-divisible, but half the time the block starts 16 bytes higher
so the function reads the stack arguments 2 slots away from where it should.
Without AVX the address is `lea 0xf(%rsp)` which is the stack pointer.
2026-10-07 21:55:15 -05:00
Arthur Chan 3bc551a29d OSS-Fuzz: Add new fuzzer targets fiber functions (#1908)
Signed-off-by: Arthur SC Chan <arthur.chan@adalogics.com>
2026-10-07 07:50:34 -05:00
veqqq d7052410f1 Add x32 Support (#1907) 2026-10-07 06:58:13 -05:00
Calvin Rose c495f11f15 Prefer janet_buffer_extra over janet_buffer_ensure. 2026-10-05 22:02:49 -05:00
sogaiuandsogaiu 809355fcf7 Support inttypes in JDN (#1905)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-10-05 21:46:28 -05:00
veqqqandAlex Alejandre 820ad0780c Decide once per lookup if janet_equals needed (#1903)
As key types can't change during lookup, we only need to check them once. The check is now
inlined in util.h, so structs and tables can use the same implementation. (Structs had a simpler
copy of the table implementation before, now they just ignore the table specific parts as they
lack deleted buckets)

Co-authored-by: Alex Alejandre <alex@alexalejandre.com>
2026-10-05 21:34:41 -05:00
Calvin Rose 0809778b41 Don't use eval for doing hooks.
Instead, require -> module/value -> normal function call
2026-10-05 09:03:40 -05:00
Calvin Rose 0e5fdd5309 Update CHANGELOG.md 2026-10-04 19:58:30 -05:00
Calvin Rose 9c6e68d52c Add shorthand for running hooks from the bundle module.
Useful for local testing and development from the command line.
2026-10-04 19:53:51 -05:00
sogaiuandsogaiu f63cc1df29 More suite inttypes work (#1900)
* Split assert-error into pieces and remove a piece

* Add helpful reminder in comment

* Format hack

* Use underscores to help readability

---------

Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-10-04 08:39:06 -05:00
sogaiuandsogaiu 6e8bb2df15 Modify suite inttypes (#1898)
* Stop using abbreviations

* Put parser tests first

* Fix incorrect code

* Deal with linting

* Change some comments and labels

* Improve test

* Use syntax literals for int/u64 and int/s64

---------

Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-10-03 13:39:30 -05:00
Calvin Rose fe0e19804e Remove out of date gnome builder link. 2026-10-01 06:34:00 -05:00
Calvin Rose 0d018921ca Format. 2026-09-30 21:11:32 -05:00
veqqqandAlex Alejandre 1d917e6813 Add bitwise key check to skip janet_equals calls (#1894)
* Add bitwise key check to skip janet_equals calls

* Skip janet_equals for identity-comparing keys

Since symbols, keywords, non-0 numbers, bools, tables, buffers, arrays, funcs and fibers are only equal by identity, we now fail them all if the bitwise check fails instead of passing them to `janet_equals`, so lookups only call `janet_equals` for strings, tuples, structs, abstract values and 0

* Skip traversal in janet_equals for non tuples and structs

---------

Co-authored-by: Alex Alejandre <alex@alexalejandre.com>
2026-09-30 21:10:12 -05:00
David Marker 28f35518ea workaround longstanding bug in FreeBSD mkdir(1) (#1891) 2026-09-29 18:41:34 -05:00
sogaiuandsogaiu d19dae6781 Align some parameter names (#1889)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-09-29 08:19:45 -05:00
Arthur Chan 3ca0253c10 OSS-Fuzz: Add new fuzzer targets peg processing (#1890)
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-09-29 08:13:29 -05:00
Calvin Rose 65a64a3b72 Add threaded channel memory leak test.
Found by @pepe with Claude. This makes some changes to the initial AI
suggested fix but is mostly verbatim. The memory leak was of the form of
ever increase GC roots with threaded channels.
2026-09-28 18:03:50 -05:00
Calvin Rose cd946c4541 Apply fix for threaded channels "eating" values.
Reported by @pepe with help from Claude.
2026-09-28 17:35:18 -05:00
Calvin Rose 38ef5b53ba Make implementation match intention in comment.
We were doing forward instead of a backward search. This is slower, and
for the unrootall case was also incorrect. unrootall was not commonly
used but should still work as expected.

Bug found by @pepe with help from Claude.
2026-09-28 17:15:26 -05:00
Calvin Rose b437ae3feb Apply fix for #1888 from Paolo Marrone
Just mark janet_vm.top_dyns during mark phase of collection. It was
skipped as it is not part of the usual interpreter flow and was missed
in testing. Also add a test case for it.
2026-09-28 16:56:36 -05:00
Calvin Rose ffebf2c497 Add test cases for missing programs with os/spawn and os/execute. 2026-09-28 16:53:09 -05:00
Calvin Rose ec73cf884f Better prose 2026-09-28 16:10:42 -05:00
sogaiuandsogaiu 86ca958eeb Make italics use italic ANSI escape codes (#1886)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-09-24 06:23:45 -05:00
Calvin Rose d2560d538b Add bytecode slot compaction pass.
Codegen may allocate and then never use slots. Free up those slots
and rewrite bytecode to be smaller. The resulting bytecode will be
slightly faster, result in better inlining, and be somewhat normalized
for further optimizations.
2026-09-24 06:19:53 -05:00
Calvin Rose b0acda4fa5 Add bytecode inlining at optimization >= 2.
Currently very simple hueristic, and not supported
on many functions that instatiate closures or load/set upvalues.

We also now, more than ever, need a slot-compaction routine to reduce
the number of slots used by functions.
2026-09-24 06:19:38 -05:00
sogaiuandsogaiu 6dadb83570 Align slice-related docstrings (#1887)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-09-24 06:19:31 -05:00
Calvin Rose d763d0d51a Move optimiize out of pop_funcdef. 2026-09-19 16:28:41 -05:00
Calvin Rose f442b310ef Add comments dicussing requirements for optimize=0
The goal of optimize=0 is both fast compilation and perfect debug info.
We would like to do some simple optimizations but the possibility of
breaking symbol mappings prevents it.
2026-09-19 14:53:32 -05:00
Calvin Rose 95bc5742e0 Add passes to remove unused constants and closures.
Dead code elimination and value numbering may remove
closures and constants from a function def - remove these from our
constant and defs buffers to avoid keeping phantom references and
bloating marshalled function size.
2026-09-19 12:59:04 -05:00
Calvin Rose 6e79ac9f62 Expose optimization level
This exposes the optimization level for a few reasons.

First, Local value numbering exposed some bad codegen. Playing with
optimiaztion level exposes this more easily.

When compiling dead code in a known unused scope, we
would generate code that tried to load invalid slots.

Make sure that unused code will still pass `janet_verify()` as
invalid code could trigger bad behavior in our optimizer or garbage
collector.

Since the code was proven dead, this would not trigger any runtime
behavior issues though.

Second, even trivial optimizations tend to break debug information. For
example, constant propogation will eliminated symbol mappings which can
be useful for debugging. By default, don't eliminate any symbol map
debug info.
2026-09-19 11:22:33 -05:00
Calvin Rose 0432110572 Improve the constant propogation.
However, we will likely need to gate some of these optimizations
behind a switch as they are beginning to destruct debug info. For
example, local value number maybe should be off by default or at the
very least turned off for named loads.
2026-09-19 11:22:33 -05:00
Calvin Rose 02f0718460 Expose bytecode optimization in the assembler.
Also fix value numbering missing some cases due to bad encoding
routines.
2026-09-19 11:22:32 -05:00
sogaiuandsogaiu d64918010a Use square brackets for data tuples in docstrings (#1881)
Co-authored-by: sogaiu <983021772@users.noreply.github.com>
2026-09-19 11:22:26 -05:00