Repository navigation
feature: wasm.ray, Ray writes the kernel's JMP as a wasm module - #45
Open
benjaminshawki wants to merge 28 commits into
Open
benjaminshawki wants to merge 28 commits into
benjaminshawki wants to merge 28 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Selfhosting.md §7, step 5: the kernel's module written by Ray.
src/wasm.raywrites the modulemodule_byteswrites, byte for byte, for the whole kernel; withkernel.rayreadingkernel.tsit does so from Ray alone, and the kernel it writes runs the library as the one built in TypeScript does.Carries #47 (its one commit, merged in): without it no run holds the whole kernel. Merge #47 first.
What it adds:
src/wasm.ray, on the interfacescripts/kernel-wasm.mtsgives it (wj_context,wj_begin,wj_label,wj_statement,wj_module): types, imports, functions, exports, code and names, asmodule_byteswrites them; each body ascontextandstructuredo.structure's fix of crossing scopes compares each scope with each (652 inapply); here it is a linear pass that gives the same beginnings (scopes by where they end, a stack of the outermost; the same on all 236 kernel functions, checked in TypeScript). A call names a context by where it is, so bodies are kept until every context is given; when every one is given first (wj_announced), each body is written as its context ends (wj_end) and nothing of it kept.kernel.raywithkjs.writing = true: every function given to the writer in its first reading, each written and ended in its second, so the JMP comes from Ray.Int32.byte), how many bytes a text is (Int32.bytes_in),--writeof a text of bytes as it is; Number.ray's ownbyte_by_bits(IB25, IB26).RAY_KERNEL_WASM=<file>(language.ts): the kernel module in that file run instead of the onemodule_bytesmakes.kernel-wasm.mts:--checkalso takes a.wasm;--parts <dir> --module <file>writes the module in runs of their own, about--statements(6000) a run, a context past--slice(7000) in slices (wj_cell,wj_slice_begins,wj_slice_ends,wasm.sized_as).kernel-ray.mts --wasm <file>: the module fromkernel.rayandwasm.ray, in ranges of about 250 lines.Checked (main b12cb48 with #47):
kernel-ray.mts --wasm k.wasm(22 ranges, 33 minutes with 8 at once), thenkernel-wasm.mts --check k.wasm --pages 32768: the same 375,834 bytes asmodule_bytes.kernel-wasm.mts --parts <dir> --module k.wasm --check k.wasm(12 runs, 22 minutes): the same 375,830 bytes (16 pages).-t --threads 1 ../ray/bootstrap/.entrypoint.ray3) withRAY_KERNEL_WASMset to the module Ray wrote answer as on the kernel built in TypeScript, assert for assert (916 pass, 405 errors).else if,continue, natives,cas,fill): the same 882 bytes, in one run, in parts and in slices; the functions run as JavaScript answers.kernel-ray.mtsthenkernel-jmp.mts --check, the same, 54,254 lines and 576 contexts.Not yet: the whole kernel in one run. Its reading is one application (
export function kernel, read twice), and what is held and later dropped inside an application still running is not let go of;kernel.rayalone runs out of the 2 GB a run has. The ranges are runs of their own for that.The failing
vscodecheck fails on main too (Release, b12cb48).