-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move more time functions to native code. NFC #16439
Conversation
071e9be
to
d755dfe
Compare
f6098a6
to
cc94147
Compare
…unction. NFC This test was under `core` instead of `other`. Avoiding the use of `clock_gettime` since I'm about move that to natice code with #16439.
cc94147
to
01febf8
Compare
01febf8
to
e29e125
Compare
e29e125
to
61b3005
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left a possible further improvement as inline comment.
@@ -2463,8 +2382,9 @@ LibraryManager.library = { | |||
|
|||
// Represents whether emscripten_get_now is guaranteed monotonic; the Date.now | |||
// implementation is not :( | |||
$nowIsMonotonic__internal: true, | |||
#if MIN_IE_VERSION <= 9 || MIN_FIREFOX_VERSION <= 14 || MIN_CHROME_VERSION <= 23 || MIN_SAFARI_VERSION <= 80400 // https://caniuse.com/#feat=high-resolution-time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional directive is duplicated three times in this file. As an possible follow-up, perhaps we could make a performance.now()
polyfill in src/polyfill
that calls Date.now() - nowOffset
if unsupported (e.g. https://gist.github.com/paulirish/5438650)? Then we could just call that polyfill throughout this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Feel free to propose a PR.. or open a bug to refactor that.
I'm pretty this is going to be codesize win for a lot of codebases even though its not showing up in our (minimal) codesize tests.
61b3005
to
6229f01
Compare
This brings us back in line with upstream musl. The change to 32-bit was only recently made in #16966. The reason we made this change was made was because we had certain C library calls that were implemented in JS that returned `time_t`. Since returning 64-bit values from JS functions is not always easy (we don't always have WASM_BIGINT available) that simplest solution was to define `time_t` to 32-bit which doesn't have issues at the JS boundary. However, in the intervening time many of the `time_t`-returning function have been moved into native code (See #16606 and #16439) with only two remaining: _mktime_js and _timegm_js. So this change redefines just those two functions to return `int` while keeping `time_t` itself as 64-bit. Fixes: #17393
This brings us back in line with upstream musl. The change to 32-bit was only recently made in #16966. The reason we made this change was made was because we had certain C library calls that were implemented in JS that returned `time_t`. Since returning 64-bit values from JS functions is not always easy (we don't always have WASM_BIGINT available) that simplest solution was to define `time_t` to 32-bit which doesn't have issues at the JS boundary. However, in the intervening time many of the `time_t`-returning function have been moved into native code (See #16606 and #16439) with only two remaining: _mktime_js and _timegm_js. So this change redefines just those two functions to return `int` while keeping `time_t` itself as 64-bit. Fixes: #17393
This brings us back in line with upstream musl. The change to 32-bit was only recently made in #16966. The reason we made this change was made was because we had certain C library calls that were implemented in JS that returned `time_t`. Since returning 64-bit values from JS functions is not always easy (we don't always have WASM_BIGINT available) that simplest solution was to define `time_t` to 32-bit which doesn't have issues at the JS boundary. However, in the intervening time many of the `time_t`-returning function have been moved into native code (See #16606 and #16439) with only two remaining: _mktime_js and _timegm_js. So this change redefines just those two functions to return `int` while keeping `time_t` itself as 64-bit. Fixes: #17393
This brings us back in line with upstream musl. The change to 32-bit was only recently made in #16966. The reason we made this change was made was because we had certain C library calls that were implemented in JS that returned `time_t`. Since returning 64-bit values from JS functions is not always easy (we don't always have WASM_BIGINT available) that simplest solution was to define `time_t` to 32-bit which doesn't have issues at the JS boundary. However, in the intervening time many of the `time_t`-returning function have been moved into native code (See #16606 and #16439) with only two remaining: _mktime_js and _timegm_js. So this change redefines just those two functions to return `int` while keeping `time_t` itself as 64-bit. Fixes: #17393
This brings us back in line with upstream musl. The change to 32-bit was only recently made in #16966. The reason we made this change was made was because we had certain C library calls that were implemented in JS that returned `time_t`. Since returning 64-bit values from JS functions is not always easy (we don't always have WASM_BIGINT available) that simplest solution was to define `time_t` to 32-bit which doesn't have issues at the JS boundary. However, in the intervening time many of the `time_t`-returning function have been moved into native code (See #16606 and #16439) with only two remaining: _mktime_js and _timegm_js. So this change redefines just those two functions to return `int` while keeping `time_t` itself as 64-bit. Fixes: #17393
This brings us back in line with upstream musl. The change to 32-bit was only recently made in emscripten-core#16966. The reason we made this change was made was because we had certain C library calls that were implemented in JS that returned `time_t`. Since returning 64-bit values from JS functions is not always easy (we don't always have WASM_BIGINT available) that simplest solution was to define `time_t` to 32-bit which doesn't have issues at the JS boundary. However, in the intervening time many of the `time_t`-returning function have been moved into native code (See emscripten-core#16606 and emscripten-core#16439) with only two remaining: _mktime_js and _timegm_js. So this change redefines just those two functions to return `int` while keeping `time_t` itself as 64-bit. Fixes: emscripten-core#17393
I'm pretty this is going to be codesize win for a lot of
codebases even though its not showing up in our (minimal)
codesize tests.
Inspired by #16401