WebAssembly and C++

#107 · 🔥 112 · 💬 95 · one year ago · neugierig.org · mariuz · 📷
Emscripten is the C++ to browser Wasm toolchain that manages this, giving you an emcc compiler that goes from C sources to. In typical C environments dereferencing a null pointer crashes. C code that reads/writes a null pointer is something we generally try to avoid already, but in a Wasm environment null pointers feel a bit like On Error Resume Next. To this non-expert, I have idly wondered if you could restore the C semantics around null pointer handling when compiling C to Wasm if you could instead make null pointers refer to some memory address so high as to trap. On one hand, null pointers not crashing is pretty bad for running C. But on the other, it's interesting to reflect upon how much support C gets from modern hardware and operating systems. On the other hand, Wasm's Harvard architecture also just excludes by construction a bunch of C's problems such as ROP; the more I've worked with it, the more it feels like it would have been the "Right" choice. To map C to this, emscripten puts the stack at some fixed offset and has it grow downwards, and has the heap start at the same point and grow upwards.
WebAssembly and C++



Send Feedback | WebAssembly Version (beta)