sunfishcode/mustang

Optimize `memchr` etc.

sunfishcode opened this issue · 6 comments

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 :-).

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

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

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.

I'm interested in working on this!

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

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