| ▲ | MobiusHorizons 9 hours ago | ||||||||||||||||||||||||||||||||||||||||
What is the purpose of compiling this to web assembly? What web assembly runtimes are there where there is not already an easily accessible (substantially faster) js execution environment? I know wasmtime exists and is not tied to a js execution engine like basically every other web assembly implementation, but the uses of wasmtime are not restricted from dependencies like v8 or jsc. Usually web assembly is used for providing sandboxing something a js execution environment is already designed to provide, and is only used when the code that requires sandboxing is native code not javascript. It sounds like a good way to waste a lot of performance for some additional sandboxing, but I can't imagine why you would ever design a system that way if you could choose a different (already available and higher performance) sandbox. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | simonw 8 hours ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||
I want to build features - both client- and server-side - where users can provide JavaScript code that I then execute safely. Just having a WebAssembly engine available isn't enough for this - something has to take that user-provided string of JavaScript and execute it within a safe sandbox. Generally that means you need a JavaScript interpreter that has itself been compiled to WebAssembly. I've experimented with QuickJS itself for that in the past - demo here: https://tools.simonwillison.net/quickjs - but MicroQuickJS may be interesting as a smaller alternative. If there's a better option than that I'd love to hear about it! | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| ▲ | kettlecorn 2 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||
As I noted in another comment Figma has used QuickJS to run JS inside Wasm ever since a security vulnerability was discovered in their previous implementation. In a browser environment it's much easier to sandbox Wasm successfully than to sandbox JS. | |||||||||||||||||||||||||||||||||||||||||