Repository navigation
Releases
Releases · tizoc/shen-jit
v0.5
Added
lib/datalog.shen: relations, facts, recursive rules, stratified negation, arithmetic on 32-bit integers and
aggregates (count,sum,minandmax), evaluated bottom up to a fixed point, with each rule compiled to
native code withlib/native.shen, facts added to a database incrementally, and facts removed. See the guide.lib/native.shenwrites loops and branches without labels:if,when,unless,while,for,block,exit
andnext, which become the same instructions.shen-jit.expand-nativeshows what they become.- Libraries for bytes and I/O that do not use Shen's streams:
lib/buffer.shenandlib/cursor.shen, checked
views over heap bytes or foreign memory and positions in them;lib/io.shen,lib/io-file.shenand
lib/io-socket.shen, bounded readers and writers over memory, files and TCP connections, which keep what a short
transfer moved and flush on close;lib/frame.shen, bounded binary messages read across chunks; and
lib/deadline.shenwithlib/clock.shen, a monotonic time budget for a whole operation, across retries. - HTTP/1.1, in
lib/http-head.shen,http-request.shen,http-response.shen,http-server.shenand
http-listener.shen: request bodies bounded by Content-Length or chunked, with trailers kept apart, responses
whole or streamed with a length or chunked under a write budget, a deadline for each phase, persistent connections
under request, idle and lifetime limits, and a listener with a connection limit and controlled shutdown. Ambiguous
framing is rejected. lib/json.shen: JSON decoded from and encoded to byte views, with strict UTF-8, numbers kept as written until
converted exactly, and bounded output.example-apps/sqlite-http/, a counter served over HTTP from SQLite, which takes JSON bodies and streams NDJSON
exports.tools/has smaller examples:buffer-parsers.shen,frame-echo.shen,http-echo.shenand
http-head-capture.shen.make test-overridesruns each kernel function that the port replaces beside the kernel's own definition, over
generated values, as compiled and through C.
Changed
- Release archives carry the example applications and the tests, beside the libraries and the guide.
- Prolog does less work:
(when (= X Y))compares as it dereferences, without copying both terms first, a cut
followed by(when false)no longer makes a closure, and a chain of Prolog variables is followed without a call to
C. THORN's problems take a few percent fewer instructions.
The first two were contributed by @pyrex41 in #19 and
#20. - The JIT reuses scratch buffers across liveness checks while compiling each code object.
Reported by @pyrex41 in #17. - Converting strings to byte lists for
read-from-stringtakes time linear in the string's length.
Reported by @pyrex41 in #16. - Compiling code with many distinct constants no longer searches all of them for each new one: a list of 32000
numbers takes about a thirtieth of what it did.
Contributed by @pyrex41 in #13. - Lowering is faster: looking up a fixed name no longer scans them all, and a long definition with many inlined calls
no longer takes time that grows with the square of its size.
Contributed by @pyrex41 in #15. - Many threads waiting on sockets use far less CPU: giving up the runtime lock wakes the next thread, not every
waiting one, so 1000 such threads no longer take over the machine.
Fixed
handle.closeinvalidates the handle even if its release function raises, so nothing can keep using the memory
that function freed.- Under
SHEN_JIT_MAX_HEAP, a vector or string of 256 KB or more no longer raisesout of memorywith the heap nearly
empty, as it did for good once the heap had grown past half the limit. The process can use more memory at the limit
as a result, up to about three times it. - Writing to a closed pipe raises an error that a program can catch, instead of ending the process. So
shen-jit script f | headcan now printwrite-byte: Broken pipeto stderr and exit with status 1. - A
c#N;escape past 255 in a string, such asc#955;, no longer fails to load:n->stringgives a Unicode scalar
value's UTF-8 bytes. - File read errors raise instead of looking like end of file: whole-file reads no longer return empty or
partial data on failure, andread-bytereports failed file reads. - Loading code with more than 255 parameters or call arguments, or a capture index above 255, reports which limit
was exceeded. Reported by @pyrex41 in #18. - The error for defining a function with a system function's name ends its line, as the kernel's does.
v0.4
Added
make test-differentialruns each primitive over generated values, however it is compiled and through C, and
make differential-schemelists what differs from Shen/Scheme.
Changed
- Moved to the Shen kernel 43.4, from 43.2.
- Moved to Shen/Scheme 0.54, from 0.53, as the other host that can build a checkout, and what
make benchcompares
against. - Compiled code keeps more values in registers between instructions, which speeds up small interpreters and other code
that works on values it has just taken apart. - Compiling a long literal list takes far less, and with constant elements the list uses one frame slot instead of one
per element.
Contributed by @pyrex41 in #10 and
#11.
Fixed
defineno longer fails on acondwith no true clause. The definition compiles, and raises an error when no
clause applies.absvectortoo large forSHEN_JIT_MAX_HEAPgave a handler[], on whicherror-to-stringfailed, instead of
an "out of memory" error.absvectorwith a length of 2^56 or more crashed. It now raises an error from 2^48 up, asshen-jit.bytesdoes.shen-jit.pvarandshen-jit.pvar-offsetraised past atrap-errorin the same function whose handler ignores
the error.write-byteandcloseraise an error when the write fails, as on a full disk, instead of losing the data silently.
v0.3
Added
- Memory outside the heap:
shen-jit.pointer-sizedmakes a C pointer readable and writable in place, with
the same functions as a byte buffer, each access checked against the length stated.lib/memory.shen
allocates and frees such memory. shen-jit.s32,s64,f32andf64and their stores, on byte buffers too, andshen-jit.pointer!.lib/mmap.shen: all of a file as memory, on each system, withmmap.read,mmap.read-write,mmap.create
andmmap.close.lib/handle.shen: memory that releases itself once nothing reaches it, withhandle.wrap,handle.closeand
handle.sweep, overshen-jit.pointer-guard,shen-jit.pointer-ownerandshen-jit.pointers-dead.shen-jit.collectcollects now.shen-jit.pointer-read-onlymakes a pointer that raises when stored to, which is whatmmap.readgives.- Real registers in native code written by hand:
real,f64!,jump-unlessandreturn-realkeep doubles
unboxed in loops that call nothing, andloopandagainmake those loops, which can nest. - Word registers there too:
word,jump-unless-word,return-word,word-box, andu8!tou64!keep 64-bit
integers that wrap, for hashes and random numbers, and as indices with no tag to check. make bench-numericruns numeric programs and a path tracer in C and in Shen.make test-thornruns THORN, from the kernel, with no time limit, and checks its inference counts and what it leaves
unproved, which Shen/Scheme also gives.
Contributed by @pyrex41 in #9.- The rendered guide now has how Shen/JIT works, its semantics, its instructions and calling C as pages of
their own.
Changed
- Arithmetic and comparisons on reals, and division, compile inline.
- A loop that calls nothing works out the memory it reads and stores through once, on the way in.
- In native code, machine registers go to what the deepest loops use most, whatever the order of the names, and
an access to memory reached at one width takes one comparison. - New objects now always go in the same memory, so a program that allocates uses much less of it, and allocates
faster where two semispaces taking turns outgrew the cache. A process that only starts takes about 2 MB more. - On x86-64 outside Windows, a loop that calls nothing keeps up to four values in registers, where it was two.
- The heap grows with what is live, not by doubling, so a program holding a lot of data no longer slows down as it
nears the next doubling. Such a program can use more memory than before, at most about 1.7 times. get-timetakes about half as long, as it no longer looks up the symbolsrunandunixat each call. THORN asks
for the time at every predicate call.
Contributed by @pyrex41 in #8.
Fixed
=,<,>,<=and>=now compare an integer with a real exactly. From 2^53 up the integer was rounded to a
double first, so=was not transitive, unification could depend on the order of its arguments, and two keys that
were=could have different hashes.
Contributed by @pyrex41 in #6.=no longer crashes on terms nested deeper than the C stack, in the head of a pair or in an absvector. A cyclic
term still ends the process, now with a message.
Contributed by @pyrex41 in #7.- An integer literal too big for a fixnum, and one with a large exponent such as
1e300, now reads as the
nearest real. They could land slightly off it, as1e100read as1.0000000000000006e100. - A burst of new symbols, such as from
gensymin a loop, no longer slows every later collection for as long as
the process runs.