Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstreaming WASM changes #58

Open
3 of 10 tasks
guregu opened this issue Oct 9, 2022 · 3 comments
Open
3 of 10 tasks

Upstreaming WASM changes #58

guregu opened this issue Oct 9, 2022 · 3 comments

Comments

@guregu
Copy link
Contributor

guregu commented Oct 9, 2022

Thanks for merging my WASM PRs. I'm making this issue to help me keep track of what hasn't been upstreamed yet.
All of this stuff is available at: https://github.com/guregu/trealla

  • WASM build action: Fix WASM build and build action #57
    • This should help us know when we break the WASM build.
    • I'll keep doing releases to WAPM from guregu/trealla until the fork no longer needs to exist.
  • Use Wizer to pre-initialize a global interpreter for WASM
    • This brings the startup time of new interpreters from ~180ms to ~5ms in browsers.
    • Includes one Apache 2.0 licensed header file. It's a very simple macro so I might just rewrite it to keep us all MIT.
  • library(js) JSON-based programmatic toplevel & javascript native predicates
    • Need to split this into 2 modules: JSON toplevel (js_ask/1) and Javsascript-specific helpers like js_fetch/3 (trealla-prolog/go needs the toplevel but not the JS helpers)
  • JSON related hacks: Fast JSON library guregu/trealla#5
  • Host call stuff: '$host_call'/2 and '$host_resume'/1. These are two native predicates for passing data between guest → host → guest, used for calling JS from Prolog.
    • Includes Makefile changes to build the pure WASI version and the 'libtpl.wasm' version with host call predicates.
    • If we use better WASI libraries for trealla-js, we might not need these at all, and we can use pipes/sockets/whatever instead.
  • Toplevel formatting hacks for WASM/pl_query.
    • In pl_query mode, don't print spaces before var dumps.
    • In pl_query mode, always include the dot for terms and don't print "; " on redo, etc. This gives us uniform results in the WASM library query iterators.
    • For WASM, print warnings to stderr instead of stdout (keeps stdout clean and easy to parse).
  • Export all of trealla.h and add a query_did_yield API in trealla.h
  • Memory streams (Memory stream create/delete #595)
    • Implemented in fork, need to port over. Generalization of with_output_to etc. Used to capture stdout/stderr for wasm client.
  • string/1?
    • Need predicate for "string but not atom", probably already exists?

Wow, that was a lot of stuff. Anyway, instead of dumping one huge PR on you I will make small ones that add things as they are stabilized.
Of course, I'd be happy to change how things work so feel free to reject anything. My aim is to be minimally invasive :-)

@infradig
Copy link
Contributor

How's this at?

@guregu
Copy link
Contributor Author

guregu commented Sep 18, 2024

Still have lots to do, updated it. I can break it into smaller issues instead of leaving this one open forever if that's preferable (I don't mind either way).

Biggest change will be #595

@infradig
Copy link
Contributor

infradig commented Sep 18, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants