@amritk/nish-x86_64-linux 0.37.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/INSTALL.md +28 -16
  2. package/bin/nish +0 -0
  3. package/docs/AI.md +380 -47
  4. package/package.json +1 -1
  5. package/runtime/core/arrays.d.ts +4 -0
  6. package/runtime/core/arrays.mjs +33 -0
  7. package/runtime/core/host.d.ts +11 -0
  8. package/runtime/core/host.mjs +35 -0
  9. package/runtime/nish.d.ts +645 -66
  10. package/runtime/nish.h +101 -15
  11. package/runtime/nish.mjs +69 -6
  12. package/runtime/node.mjs +117 -0
  13. package/runtime/runtime-aes.c +12 -4
  14. package/runtime/runtime-async.c +267 -51
  15. package/runtime/runtime-checksum.c +207 -15
  16. package/runtime/runtime-cross.c +2 -1
  17. package/runtime/runtime-net.c +32 -3
  18. package/runtime/runtime-os.c +174 -27
  19. package/runtime/runtime-region.c +170 -8
  20. package/runtime/runtime-sandbox.c +377 -17
  21. package/runtime/runtime-sha256.c +11 -4
  22. package/runtime/runtime-text.c +1068 -0
  23. package/runtime/runtime-wasm.c +18 -3
  24. package/runtime/runtime.c +55 -961
  25. package/runtime/vite.mjs +48 -11
  26. package/scripts/build.sh +113 -36
  27. package/std/LICENSE-fdlibm +8 -0
  28. package/std/README.md +7 -4
  29. package/std/array.ts +266 -0
  30. package/std/compress/checksum.ts +13 -0
  31. package/std/compress/deflate.ts +0 -2
  32. package/std/crypto/p256.ts +247 -74
  33. package/std/crypto/p384.ts +3 -1
  34. package/std/crypto/pki.ts +35 -9
  35. package/std/crypto/x25519.ts +153 -64
  36. package/std/crypto/x509.ts +113 -10
  37. package/std/host/text.ts +86 -0
  38. package/std/json-tokenizer.ts +20 -0
  39. package/std/json-typed.ts +217 -8
  40. package/std/math.ts +743 -41
  41. package/std/net/dns-resolver.ts +46 -6
  42. package/std/net/dns.ts +50 -13
  43. package/std/net/fetch.ts +691 -129
  44. package/std/net/handler.ts +142 -16
  45. package/std/net/http-compress.ts +17 -9
  46. package/std/net/http-fields.ts +19 -4
  47. package/std/net/http1-codec.ts +517 -154
  48. package/std/net/http1-server.ts +508 -25
  49. package/std/net/http2-cleartext.ts +526 -0
  50. package/std/net/http2-tls.ts +48 -0
  51. package/std/net/http2.ts +84 -0
  52. package/std/net/postgres-async.ts +2223 -0
  53. package/std/net/postgres-carrier.ts +343 -10
  54. package/std/net/postgres.ts +129 -11
  55. package/std/net/prefork.ts +195 -11
  56. package/std/net/quic-datagram.ts +30 -0
  57. package/std/net/quic-listener.ts +38 -12
  58. package/std/net/quic-packet.ts +19 -6
  59. package/std/net/quic-recovery.ts +134 -19
  60. package/std/net/quic-stream.ts +174 -36
  61. package/std/net/quic.ts +418 -18
  62. package/std/net/router.ts +39 -17
  63. package/std/net/serve.ts +867 -0
  64. package/std/net/tls/codec.ts +110 -32
  65. package/std/net/tls/record-server.ts +37 -7
  66. package/std/net/tls-tcp.ts +56 -1
  67. package/std/net/tls.ts +196 -50
  68. package/std/net/websocket.ts +55 -18
  69. package/std/net/webtransport.ts +179 -1
  70. package/std/regex.ts +69 -47
  71. package/std/region.ts +62 -11
  72. package/std/secret.ts +26 -59
  73. package/std/text.ts +464 -5
package/INSTALL.md CHANGED
@@ -56,8 +56,12 @@ the Homebrew LLVM is needed for the `wasm`, `wasm-host` and `wasi` profiles (`wa
56
56
 
57
57
  `wasm-opt` (binaryen: `apt-get install binaryen`, `brew install binaryen`) is
58
58
  optional. When it is on `PATH`, `scripts/build.sh --profile wasm-host` runs
59
- `wasm-opt -Oz` on the module, and the build line says whether it ran. Without
60
- it the module is complete, just not as small.
59
+ `wasm-opt -Oz --strip-target-features` on the module, and the build line says
60
+ whether it ran: `add.wasm` goes from 102 bytes to 74. Without it the module
61
+ is complete and works the same. clang 18 also runs a `wasm-opt` it finds,
62
+ after any optimising wasm link, and keeps a `target_features` section for it
63
+ that build.sh's pass then drops. `NISH_WASM_OPT=0` links with neither pass,
64
+ even with binaryen installed: the bytes a machine without it builds.
61
65
 
62
66
  <a id="wasi-optional-for---profile-wasi" style="scroll-margin-top: 65px"></a>
63
67
 
@@ -261,11 +265,11 @@ routes are
261
265
  # in the glibc container, where build/nish runs
262
266
  build/nish app.ts -o app.ll
263
267
  # on the musl host, with its own clang and the runtime from this repository
264
- clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
268
+ clang app.ll runtime/runtime.c runtime/runtime-text.c runtime/runtime-os.c runtime/runtime-parallel.c \
265
269
  runtime/runtime-cross.c runtime/runtime-host.c runtime/runtime-net.c \
266
270
  runtime/runtime-simd.c runtime/runtime-aes.c runtime/runtime-sha256.c runtime/runtime-chacha20.c \
267
271
  runtime/runtime-term.c runtime/runtime-bytes.c runtime/runtime-checksum.c runtime/runtime-sandbox.c \
268
- runtime/runtime-shm.c runtime/runtime-region.c -lm -o app
272
+ runtime/runtime-shm.c runtime/runtime-region.c -ffp-contract=off -lm -o app
269
273
  ```
270
274
 
271
275
  `--link`ing inside the container is the mistake to avoid: it shells out to the
@@ -374,7 +378,8 @@ release exists, take its version from
374
378
  Unpack it and run `bin/nish` from wherever you like; put that on `PATH` if you
375
379
  want it there. Keep the directory intact rather than moving the binary out of
376
380
  it: `--link` runs `scripts/build.sh` and compiles the C runtime
377
- (`runtime/runtime.c` and `runtime/runtime-os.c`, the system-call half), and the
381
+ (`runtime/runtime.c`, `runtime/runtime-text.c`, the strings and number
382
+ formatting, `runtime/runtime-os.c`, the system-call half, and the rest), and the
378
383
  compiler finds all of them relative to its own location — `bin/nish` alone in a
379
384
  directory can still emit IR with `-o`, but `--link` will tell you it cannot
380
385
  find `scripts/build.sh`.
@@ -401,7 +406,7 @@ it into `build/seed/`; `NISH_BOOTSTRAP=<path>` names one you already have and
401
406
  skips the download. §2a has what the build does with it.
402
407
 
403
408
  The published package ships `bin/` (the `nish` command, which is a launcher),
404
- `runtime/` (the C runtime — sixteen translation units, the wasm subset and their
409
+ `runtime/` (the C runtime — seventeen translation units, the wasm subset and their
405
410
  header — and `runtime/sqlite/`, SQLite's vendored source),
406
411
  `scripts/build.sh` (the link pipeline), `std/` (the standard library) and
407
412
  `docs/AI.md` (the rules card). The
@@ -416,19 +421,24 @@ any working directory — and the binary runs from inside its own platform
416
421
  package for exactly that reason.
417
422
 
418
423
  Building the IR yourself rather than through `--link` means naming the runtime
419
- on the `clang` line, and it is sixteen files:
424
+ on the `clang` line, and it is seventeen files:
420
425
 
421
426
  ```bash
422
- clang app.ll runtime/runtime.c runtime/runtime-os.c runtime/runtime-parallel.c \
427
+ clang app.ll runtime/runtime.c runtime/runtime-text.c runtime/runtime-os.c runtime/runtime-parallel.c \
423
428
  runtime/runtime-cross.c runtime/runtime-host.c runtime/runtime-net.c \
424
429
  runtime/runtime-simd.c runtime/runtime-aes.c runtime/runtime-sha256.c runtime/runtime-chacha20.c \
425
430
  runtime/runtime-term.c runtime/runtime-bytes.c runtime/runtime-checksum.c runtime/runtime-sandbox.c \
426
- runtime/runtime-shm.c runtime/runtime-region.c -lm -o app
431
+ runtime/runtime-shm.c runtime/runtime-region.c -ffp-contract=off -lm -o app
427
432
  ```
428
433
 
429
- `runtime.c` is the part every program touches — the arena, strings, arrays,
430
- number formatting, the panics — and `runtime-os.c` wraps the system calls:
431
- files, directories, subprocesses, `getenv`, the monotonic clock.
434
+ `runtime.c` is the part every program touches — the arena, arrays, the
435
+ panics — `runtime-text.c` holds strings and number formatting, and
436
+ `runtime-os.c` wraps the system calls: files, directories, subprocesses,
437
+ `getenv`, the monotonic clock.
438
+
439
+ `-ffp-contract=off` keeps clang from fusing a C `a*b+c` into one rounding
440
+ where the CPU has a fused multiply-add (every arm64, x86-64 at v3): the runtime
441
+ then prints the same float on every target, as `scripts/build.sh` compiles it.
432
442
 
433
443
  `runtime-parallel.c` divides work across threads for `nish/threads` (a program
434
444
  built with `--threads`, as every importer of `nish/threads` is, also needs
@@ -449,12 +459,14 @@ kernels of `nish/compress/checksum`, `runtime-sandbox.c` the confinement a
449
459
  `nish/sync/shm`. They are separate so that each carries its own measured size
450
460
  ceiling
451
461
  ([docs/wp7-runtime.md](https://github.com/amritk/nish/blob/main/docs/wp7-runtime.md));
452
- nothing in the core calls into the others, so a line that names only
453
- `runtime.c` and `runtime-os.c` still links a program that uses none of the
454
- other nine.
462
+ the core is three files that call each other — `runtime-os.c` builds strings
463
+ with `runtime-text.c`'s `nish_str_new` — and calls into none of the others, so a
464
+ line that names only `runtime.c`, `runtime-text.c` and `runtime-os.c` links a
465
+ program that uses none of the other fourteen. Leave out `runtime-text.c` and it
466
+ does not link at all: `nish_str_new` is undefined.
455
467
 
456
468
  `scripts/build.sh` compiles the other
457
- nine beside any
469
+ sixteen beside any
458
470
  `runtime.c` it is handed, so a build that goes through it — every `--link`,
459
471
  and every `--profile` recipe in these documents — needs to name only the one.
460
472
 
package/bin/nish CHANGED
Binary file