Add runtime detection for toResizableBuffer#27096
Conversation
4a2b43f to
11fb3c6
Compare
A nice thing about emscripten/system/lib/standalone/standalone.c Lines 138 to 141 in d1fbb02 It also skips the emscripten/tools/acorn-optimizer.mjs Lines 1081 to 1084 in d1fbb02 Thinking about this more, since emscripten/tools/feature_matrix.py Lines 143 to 151 in d1fbb02 |
|
Yes, GROWABLE_ARRAYBUFFERS should certainly be auto-enabled when the feature matrix allows is. If that isn't the case today we should fix that. |
1ef543f to
70630b5
Compare
70630b5 to
7df7165
Compare
7df7165 to
2781f78
Compare
2781f78 to
e6316ef
Compare
bda5ef7 to
6b6a0c6
Compare
…allow (#27097) See #27096 (comment) Also, remove the experimental status, since this feature is now available in all browser and we hope to feature-detect it soon and start using it even without this flag. Fixes: #26099
66aedad to
86aa197
Compare
Since this is now shipping in the current version of all major browsers we want to take advantage of it whenever possible. I am leaving the GROWABLE_ARRAYBUFFERS setting in place for now since enabling it unconditionally can still save a little on codesize but we may want to to just remove that at some point. As a side effect this addresses emscripten-core#27084.
86aa197 to
95d431f
Compare
|
I think this change should be good to go now. PTAL. |
| // and Node.js. | ||
| // and Node.js. Even when this setting is disabled, Emscripten will still use this | ||
| // feature when available, but it include the fall back code for handling | ||
| // non-growable memories. |
There was a problem hiding this comment.
Perhaps explain why? We don't do this with other features afaik?
There was a problem hiding this comment.
I think we do do feature detection in some places.
The reason we want both approaches in this case is kind of important. There are two main cases:
-
For all users or pthreads+memory growth we probably want to use
toResizableBufferwhen available in all cases. It slightly fast since we don't need to rebuild the views each time the memory grows. There is very little cost to probing for, and using the features if its found. -
For users that know that they are only targetting newer browsers they can opt in with
-sGROWABLE_ARRAYBUFFERSwhich means we don't need run the wholegrowableHeapJS optimizer path (which is the thing that slows down all the HEAP accesses in normal builder). These users see even more of a benefit, but their code won't run on older browsers.
There was a problem hiding this comment.
For example of where we do feature detection you can see many by doing git grep "if .*globalThis" src.
In most cases we don't have setting to opt out of the feature-detection and just assume the feature is present. In some cases we can use the feature matrix to detect when the feature-detection is not needed.
In the long run I think we may just want to delete this setting (or at least make it internal) since it can be driven completely by the feature matrix.
Since this is now shipping in the current version of all major browsers
we want to take advantage of it whenever possible.
I am leaving the GROWABLE_ARRAYBUFFERS setting in place for now since
enabling it unconditionally can still save a little on codesize but we
may want to to just remove that at some point.
As a side effect this change also works around #27084.