Skip to content
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

Optimize memchr etc. #5

Closed
sunfishcode opened this issue Sep 9, 2021 · 6 comments
Closed

Optimize memchr etc. #5

sunfishcode opened this issue Sep 9, 2021 · 6 comments
Labels
good first issue Good for newcomers

Comments

@sunfishcode
Copy link
Owner

Currently c-scape's implementation of memchr and similar functions is very simple. It may be possible to optimize them using the memx crate.

c-scape is compiled with #![no_builtins] to discourage the compiler from optimizing the definitions of C library functions into calls to C library functions, however the compiler can still generate calls to memcpy, memmove, memset, and memcmpy, so we need to be careful the compiler doesn't do that with the implementations of those functions :-).

@sunfishcode sunfishcode added the good first issue Good for newcomers label Sep 9, 2021
@bjorn3
Copy link
Contributor

bjorn3 commented Sep 9, 2021

Would it be possible to directly use compiler-builtins? It gets published on crates.io and should also be part of the sysroot.

@sunfishcode
Copy link
Owner Author

Cool, I didn't know compiler-builtins had memcpy etc., that looks like a good idea.

@sunfishcode
Copy link
Owner Author

And another resource here is the memchr crate.

If anyone's interested in working on this, the first step would be to use the mem* functions in compiler_builtins to implement the corresponding mem* functions in mustang.

@cole-miller
Copy link
Contributor

I'm interested in working on this!

@sunfishcode
Copy link
Owner Author

Thanks! If you're interested, I think the next step would be memchr and memrchr using either the memchr or memx crates.

@sunfishcode
Copy link
Owner Author

With #9 and #10 merged, this is now implemented!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants