Conversation
84eb0f3 to
69f1f24
Compare
…l_refill Allow overriding channel I/O with custom callbacks, matching the JavaScript runtime behavior.
Add a virtual filesystem for embedding files (e.g. CMIs for the toplevel) into the wasm output. Files specified via --file are base64-encoded in the runtime arguments and decoded at startup.
3795d67 to
80eab5a
Compare
--dynlink links all primitives and compilation units, skipping dead code elimination.
Add a dynlink library (wasm_of_ocaml-compiler.dynlink) that can dynamically load pre-compiled .wasmo/.wasma files at runtime. The wasmo/wasma ZIP archives now include a link_order entry to ensure compilation units are initialized in the correct order.
Add Generate.compile and Generate.from_string to compile OCaml bytecode to wasm binary in memory, without writing to disk. Add Wasm_output.to_string for in-memory wasm serialization. This enables runtime compilation of plugins from bytecode to loadable .wasmo files.
caml_global_data is a $block whose index 0 is the tag. Generated code accesses it via Field(gdata, i) which compiles to array.get gdata (i+1), so the runtime must store at i+1 as well. Adjust caml_register_global, caml_realloc_global, and all predefined exception indices in fail.wat accordingly.
Implement Dynlink.loadfile for wasm_of_ocaml. Dynamically loaded modules are compiled from bytecode to Wasm and instantiated at runtime. Cross-module references go through caml_global_data by index, while statically linked modules continue to use named Wasm globals.
--toplevel compiles for toplevel/REPL use, embedding CMI files and implying --linkall. --no-cmis disables CMI embedding. --export restricts the set of exported units and their CRCs.
When building a .wasma library with --linkall, set force_link on all compilation units so they are included when the library is linked into an executable.
…set_raw_field The toplevel accesses a closure's code pointer field for tracing purposes. Since Wasm closures are not represented as blocks, the cast would trap. Add a type check and return a dummy value for non-block inputs.
…efaults These primitives are needed by the toplevel/dynlink but were missing from the Wasm runtime. caml_exn_with_js_backtrace returns the exception unchanged (backtrace attachment is not supported). caml_xdg_defaults returns an empty list.
Move JsooTop, JsooTopPpx, and JsooTopError into a new js_of_ocaml-toplevel.common sublibrary that depends on js_of_ocaml-compiler (without .dynlink), making it usable by both JS and Wasm backends. The existing js_of_ocaml-toplevel becomes a thin wrapper that re-exports the common code and pulls in the JS dynlink dependency for backward compatibility.
Implement all Graphics primitives for the Wasm backend by reusing the existing JS canvas code. JS helper functions (suffixed _for_wasm) take plain JS values and perform the canvas operations; WAT wrappers handle OCaml value conversion, state checking, and exception raising.
Refactor the Lwt toplevel example to support both JS and Wasm backends. Extract the shared UI logic (history, syntax highlighting, examples, pseudo-fs, toplevel setup) into a lwt_toplevel_lib library. The JS and Wasm entry points are now thin wrappers that call Toplevel_main.run. The HTML page auto-detects Wasm support (via WebAssembly.JSTag) and loads the appropriate script; a #js fragment parameter forces the JS backend.
Member
|
Are there tests or examples that can run in wasm now that we support virtual filesystem ? |
Member
Author
|
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.
No description provided.