fix: Make StdClock monotonic using std::time::Instant#4841
fix: Make StdClock monotonic using std::time::Instant#4841abhinavs1920 wants to merge 5 commits intoboa-dev:mainfrom
Conversation
|
Heyy @jedel1043 , I have refactored the API design as we discussed. Please take a look when ever you are available :) |
Test262 conformance changes
Tested main commit: |
|
Heyy I have put pushed my latest commit, but it doesn't seem to be pushed here due to some github issue. 🥲 |
jedel1043
left a comment
There was a problem hiding this comment.
Yep, pretty much what I expected. Thanks!
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4841 +/- ##
===========================================
+ Coverage 47.24% 57.89% +10.65%
===========================================
Files 476 557 +81
Lines 46892 60968 +14076
===========================================
+ Hits 22154 35300 +13146
- Misses 24738 25668 +930 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This Pull Request fixes/closes #4330 .
Previously,
StdClockusedSystemTimewhich isn't monotonic—it can jump backward when the system clock adjusts. This broke the guarantees thatJsInstantis supposed to provide for engine timing.Now
StdClockusesstd::time::Instantwith a base instant, measuring elapsed time from that point. This makesJsInstanttruly monotonic likestd::time::Instant, so time never goes backward forsetTimeout,setInterval, and job scheduling.For
Dateobjects that need actual wall-clock time, I added a separatesystem_time_millis()method to theClocktrait. Clean separation of concerns.Added tests to verify the monotonic behavior works as expected.