-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
[Merged by Bors] - Avoid unneeded bounds checks in bytecode address patching #2680
Conversation
Test262 conformance changes
|
Codecov Report
@@ Coverage Diff @@
## main #2680 +/- ##
==========================================
+ Coverage 49.19% 49.41% +0.22%
==========================================
Files 397 395 -2
Lines 39739 39531 -208
==========================================
- Hits 19548 19533 -15
+ Misses 20191 19998 -193
... and 11 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Got it to optimize the bounds check without using unsafe: https://godbolt.org/z/9eEs13TjW EDIT: Another alternative that clarifies why the second condition is needed: const U32_SIZE: usize = std::mem::size_of::<u32>();
assert!(code.len() > index + U32_SIZE && usize::MAX - U32_SIZE >= index);
let values = value.to_ne_bytes();
code[index..index + U32_SIZE].copy_from_slice(values.as_slice()) |
bcff86c
to
4f867db
Compare
4f867db
to
bba7043
Compare
Benchmark for 4fc8be4Click to view benchmark
|
Benchmark for 8d1a5b9Click to view benchmark
|
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.
Looks great!
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.
Nice!
bors r+ |
As discussed in this comment #2669 (comment), `rustc` doesn't seem to optimize out the bounds checks.
Pull request successfully merged into main. Build succeeded: |
As discussed in this comment #2669 (comment),
rustc
doesn't seem to optimize out the bounds checks.