-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add intrinsics for operating on raw_ptrs #3157
Conversation
That's amazing 🚀 . Do you mind checking the impact of this on the sway-applications repo? |
a42772b
to
2ae963d
Compare
I was surprised at first to see not even a single app's size change, but then realized we use So 0% change on sway-applications. |
sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
Outdated
Show resolved
Hide resolved
Ok so one more comment. Otherwise, is this ready for review? You also seem to have a merge conflict now :/ |
Well IDK really. This only improves If we had typed pointers, then the signature would be |
You may be right in the sense that it's odd to reuse the binary intrinsics |
Yeah, you're (both) right. |
2ae963d
to
5ad8e49
Compare
Ok, so this version adds I've also made I've also removed a test that was broken. It was a test I was familiar with, and what's being tested there should have no way of not being caught by other tests since we started making heavy usage of it after it was fixed. |
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 seems more reasonable and safer. Thanks!
- Just one small question in one of the tests
- Also, why are we deleting the test
fixing_generic_type
? - Finally, will you please update the PR description to reflect the new approach?
test/src/e2e_vm_tests/test_programs/should_pass/stdlib/alloc/src/main.sw
Show resolved
Hide resolved
@mohammadfawaz updated the PR desc! |
This PR:
__ptr_add<T>(ptr: raw_ptr, count: u64)
(which basically doesptr + __size_of::<T>() * count
) and its sub counterpart to be used in pointer offset calculations.std::alloc::*
andraw_ptr::*
have type arguments and work in increments ofsize_of::<T>()
instead of bytes.fixing_generic_type
which was broken instead of maintaining it. This test was created to reproduce an issue I was having a few months ago. Fixing this allowed other things to be built so there are other tests that touch this case.This abstracts away more hacky stuff from the Sway side, and also significantly reduces bytecode size in some tests, especially in
Vec
stuff:Related: #3112