

Another commenter already explained why this is unsound, so I’ll skip that, though static mut is almost universally unsound.
Note, of course, that main() won’t be called more than once, so if you can, I would honestly just make this a stack variable containing a Box<[u8; 0x400]> instead. Alternatively, a Box<[u8]> can make it simpler to pass around, and a Vec<u8> that is pre-allocated with Vec::with_capacity lets you track the current length as well with the buffer (if it’s going to have a variable length of actually useful data).
If you want to make it a static for some reason, I’d recommend making it just static and thread_local, then wrapping it in some kind of cell. Making it thread local will mean you don’t need to lock to access it safely.

This is super cool! I love seeing these new implementations of JS. boa is another JS runtime written in Rust as well.
I’m curious how easy it is to embed this. Can I use it from another Rust project? Can I customize module loading behavior, or set limits on the runtime to limit CPU usage or memory usage or intercept network calls? Can I use it from a non-Rust project? Or is this intended to be a standalone JS runtime called from the CLI? I’ve been looking at Boa as a JS engine for one of my projects, but I’m open to checking out brimstone too if it’ll work.