-
-
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] - [Merged by Bors] - Decouple bytecompiler from CodeBlock #2669
Conversation
d68cc24
to
8bec300
Compare
Test262 conformance changes
New panics (2):
|
c0e79bb
to
f03a3e7
Compare
Codecov Report
@@ Coverage Diff @@
## main #2669 +/- ##
==========================================
+ Coverage 49.70% 50.32% +0.62%
==========================================
Files 385 391 +6
Lines 39256 38788 -468
==========================================
+ Hits 19512 19521 +9
+ Misses 19744 19267 -477
... and 52 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. |
f03a3e7
to
75edd12
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.
All looks good :) just a couple of comments. Thanks!
self.code_block.bytecode[index + 2] = bytes[1]; | ||
self.code_block.bytecode[index + 3] = bytes[2]; | ||
self.code_block.bytecode[index + 4] = bytes[3]; | ||
self.bytecode[index + 1] = bytes[0]; |
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.
At some point we should check if this adds bound checking, and if we can do the bounds checking only once. Might enhance performance slightly.
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.
From my checking it seems that it does generate a bounds check per array access, my guess is that so it can give accurate panic locations if out-of-bounds
See generated assembly instructions: https://godbolt.org/z/q8azssz5K
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.
Explicitly checking beforehand and using a little unsafe we can remove the bounds checks: https://godbolt.org/z/bKT9ozr8s
It can create a PR after this one to address this :)
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.
Sometimes in Rust, if you check the full range before all the array access with an assert, it will remove all bounds checking without needing "unsafe". We would need to test that :)
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.
Yeah, but through by testing it doesn't seem so do so https://godbolt.org/z/q15WGh9n8 in this case...
Benchmark for 4d5e85dClick to view benchmark
|
This also give us some memory benefits, it reduces CodeBlock size from 264 => 208 (removes 56 bytes). Additionally calling `into_boxed_slice` If the vector has excess capacity, its items will be moved into a newly-allocated buffer with exactly the right capacity.
75edd12
to
36cc7bd
Compare
Benchmark for 5a9e612Click to view benchmark
|
bors r+ |
Hopefully this is a PR in a series of PRs to implement a bytecode optimizer, before that can happen there needs to be a lot of refactoring in the way we store and compile it. This also give us some memory benefits, it reduces `CodeBlock` size from `264` **=>** `208` (removes `56` bytes). Additionally when calling `into_boxed_slice`, If the vector has excess capacity, its items will be moved into a newly-allocated buffer with exactly the right capacity removing wasted space.
Pull request successfully merged into main. Build succeeded: |
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.
Hopefully this is a PR in a series of PRs to implement a bytecode optimizer, before that can happen there needs to be a lot of refactoring in the way we store and compile it.
This also give us some memory benefits, it reduces
CodeBlock
size from264
=>208
(removes56
bytes).Additionally when calling
into_boxed_slice
, If the vector has excess capacity, its items will be moved into a newly-allocated buffer with exactly the right capacity removing wasted space.