Comments (7)
It should indeed be simple to add. However, these instructions are meant to be very fast (implemented using native CPU instructions dedicated to them), and emulating them in JS will be very slow. So I am curious what optimization generates them, perhaps the best thing is to avoid it somehow.
from emscripten.
I haven't looked into it, but I'm guessing it won't be generated unless the overflow is significant, in which case doing it the fast way will simply produce incorrect code, and the unoptimized version might be doing the same extra operations as we'd be doing by implementing it.
from emscripten.
I agree. But my question is then, how does one write C/C++ code that actually cares about overflows? The C/C++ standards were very careful to not allow such things to be detected directly. Are these compiler-specific extensions perhaps? The only alternative I can think of is that the compiler detects code that manually checks for overflows, like
void func(char x) {
x++;
if (x == 0) printf("overflow!");
}
and optimizes that, which seems unlikely but possible. Would be simple to just tell the compiler to not perform that optimization though, since it won't help us here (in fact it will hurt).
from emscripten.
This is - again - a total guess on my part, but it might be translating int64_t
additions into two manual int32_t
additions with carry/overflow correction on a 32-bit machine - unoptimized is a straightforward implementation while optimized is one with intrinsics.
from emscripten.
Hmm, that could be. If so, it sounds like specialization for a very specific architecture (one that doesn't have 64-bit math ops) so hopefully something we can avoid. (Also, we should try to avoid 64-bit math anyhow because it's a poor fit for JavaScript's native types.)
No harm in implementing this stuff, though.
from emscripten.
We added support for this (but it can't be fast...)
from emscripten.
We should now have all the overflow add/mul intrinsics on incoming.
from emscripten.
Related Issues (20)
- Python `TypeError` when trying to add a `sourceMappingURL` section to a WASM file
- emscripten_receive_on_main_thread_js cannot read properties of undefined(reading apply) HOT 1
- Chromium CI tests are failing flakily, probably due to a race between installing and using port headers
- emsdk/upstream/emscripten/cache/sysroot/include/compat/emmintrin.h is not lib/clang/19/include/**/emmintrin.h HOT 7
- ReferenceError: _setThrew is not defined when linking as C++ HOT 18
- Bug in page: Emscripten Documentation | Small Typo HOT 1
- [Question] How to write unit tests for multithreaded WASM? HOT 3
- undefined symbol: emscripten_compute_dom_pk_code HOT 2
- Cannot compile after switching to 3.1.63 HOT 3
- [BUG]: Incorrect Parameter Order in Promise Constructor Causes Program Errors
- wasm-opt: unknown option '--no-stack-ir' HOT 13
- Unexpected error in system/lib/libcxx/include/__format/format_arg_store.h HOT 2
- Is `--fatal-warnings` too strict for `STRICT` mode? HOT 4
- Met `function signature mismatch` warning and got `RuntimeError: unreachable` in execution HOT 1
- doWritev has a race condition HOT 5
- Unexpected error in system/lib/libcxx/include/__utility/no_destroy.h HOT 1
- Opening a JS based file with WASMFS hits unimplemented code HOT 1
- Linking against `noderawfs.js` causes `ioctl_tiocgwinsz` to fail HOT 1
- Argument order passed to the em_dlopen_callback does not match the declaration.
- FEATURE REQUEST: browser's jpg, png, webp decoders should be usable from emscripten HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emscripten.