Cheerp 1.1 – C++ for the Web with fast startup times, dynamic memory
leaningtech.com
leaningtech.com
AFAIK emscripten can grow heap now and the security implications seem irrelevant to me (you're still inside of a managed memory pool you're not going to do anything that JS code can't do already) - maybe it can allow for more XSS opportunities but I'm not a security expert, seems to me there are much easier ways to do XSS than exploiting bugs in compiled C++ code.
While allocating heap objects trough JS objects might allow VM to reduce fragmentation it's going to put big pressure on the GC (which is a big downside).
With WebAssembly coming up this approach will get even worse in terms of performance
Another issue is that native code, assuming that it's secure, is still not portable across different architectures. So you still end up having to have some sort of VM anyway to ensure portability.
That's basically where asm.js comes in. It's a static subset of javascript that allows it to be compiled, it becomes a VM. But since it is javascript, it will work on all existing browsers, they don't need to support a new standard. It'll just be slower.
Or are you wandering why you can't just run a high privileged system/machine specific binary directly from a web page?
So yeah, not good enough to be used in production.
https://github.com/kripken/emscripten/wiki/Split-Memory
In that mode, memory allocation is basically like in C and C++: each block can be allocated and freed independently.
Of course, this does have a performance cost, so it's a tradeoff.
I guess the browsers should specialize on very large typed arrays, because with asm.js etc they will most likely be very sparse (e.g. allocate 2gb of zeros, use 50mb).
1. Singleton fixed typed array (what most users use; the fastest)
2. Singleton growable typed array (aka asm.js memory growth; still not optimized in all browsers, though)
3. Split memory, in which each chunk of memory can be allocated separately, which allows fully dynamic memory usage the way C and C++ do natively (allocating and freeing pages to the OS), https://github.com/kripken/emscripten/wiki/Split-Memory (but the flexibility makes it harder for JS engines to optimize)