Skip to content

TVM-Consortium/fift-wasm-showcase

 
 

Repository files navigation

FIFT WASM showcase

WARNING: the code shown in this repo is highly experimental and unpolished. While it does work, it needs some work before it can be safely shipped to any kind of production. Read on to learn more.

This repo contains sample code that allows one to run fift in a JS environment using WASM. funcfiftlib.js and funcfiftlib.wasm are taken from the artifacts of this pipeline. Some helper functions are taken from this file.

Here's the possibly incomplete list of things that need to be done to this code in order for it to be shippable to production:

  • Handle all created pointers and free them after execution. func-js does that using an array (link) to which all pointers are pushed after their creation, and then by calling mod._free on them at the end of execution.
  • Handle all callbacks. This code issues every call that gets routed to JS, readfile and writefile are already implemented, but 2 others are missing.
  • Check that the new C++ code that makes it possible is sound. The implementation was done very quickly and not much attention was paid to any possible bugs and UBs (although the added code is quite small and simple).
  • Possibly rethink the use of CStyleCallback (from C++ code) at least in some cases. For example, the writefile callback expects an encoded status JSON object as a response, but the callback is capable of returning errors in another way too (which is actually used for readfile callback), so it's just a little weird. This mishap is a consequence of the C++ part of this experiment having been implemented quickly and without much thought.
  • Extract a lot of stuff as params/arguments. Obviously right now a lot of stuff is hardcoded as it's all just sample code, to actually run other stuff using this some refactoring needs to be done.
  • Possibly make this an npm package, similarly to func-js. If there is demand for fift packaged for running in JS environments, I'll likely do that myself, otherwise we'll see.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • TypeScript 100.0%