4 ms·
Compiling C++ to asm.js with Emscripten is another weird architecture you might actually use these days. Unaligned accesses don't trap with a SIGBUS or anythin
by chadaustin 8y ago
Compiling C++ to asm.js with Emscripten is another weird architecture you might actually use these days.
Unaligned accesses don't trap with a SIGBUS or anything, they just round the pointer value down to an aligned address and read whatever that is.
Reading from and writing to NULL will generally succeed (just as on SGI).
Function pointers are just indices into tables of functions, one table per "function type" (number of arguments, whether the arguments are int or float, whether it returns an argument or not). Thus, two different function pointers may have the same bit pattern.
- mappu 8y ago> Thus, two different function pointers may have the same bit pattern. Is this likely/guaranteed to happen by the wasm standard itself, or, could runtimes/emcc fill in stub table entries to avoid this?
- gpderetta 8y agoRe functions pointers, how does Emscripten gurantee the POSIX behavior that you can roundtrip function pointers to void*?
- rcxdude 8y agoSo long as you cast it back to the correct type, there isn't any issue. Casting back to a different type is undefined behaviour anyway.
- gpderetta 8y agoBut this means that two distinct function pointers might compare equal when converted to void*, unless the type is somehow encoded.
- chadaustin 8y agoThis is the first I'm hearing that arbitrary function pointers converted to void* should be distinct on POSIX - do you have a reference?
- gpderetta 8y agoPointers to different objects should not compare equal in C (or at least in C++, can't remember if this is also a rule in C). Then again, functions are not objects.
- leni536 8y agoDoes Emscripten aim to be POSIX compliant?
- gpderetta 8y agoI hope so if it want to have any chance to support most software out there.