1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:27:35 +00:00

AK+LibC: Always use REP MOVSB/STOSB for memcpy()/memset()

There's no great advantage to using MMX instructions here on modern
processors, since REP MOVSB/STOSB are optimized in microcode anyway
and tend to run much faster than MMX/SSE/AVX variants.

This also makes it much easier to implement high-level emulation of
memcpy/memset in UserspaceEmulator once we get there. :^)
This commit is contained in:
Andreas Kling 2020-07-27 15:54:39 +02:00
parent 272dbb82ff
commit 1366557094
2 changed files with 9 additions and 100 deletions

View file

@ -35,23 +35,11 @@
# include <string.h>
#endif
#if defined(__serenity__) && !defined(KERNEL)
extern "C" void* mmx_memcpy(void* to, const void* from, size_t);
#endif
ALWAYS_INLINE void fast_u32_copy(u32* dest, const u32* src, size_t count)
{
#if defined(__serenity__) && !defined(KERNEL)
if (count >= 256) {
mmx_memcpy(dest, src, count * sizeof(count));
return;
}
#endif
asm volatile(
"rep movsl\n"
: "=S"(src), "=D"(dest), "=c"(count)
: "S"(src), "D"(dest), "c"(count)
: "memory");
: "+S"(src), "+D"(dest), "+c"(count)::"memory");
}
ALWAYS_INLINE void fast_u32_fill(u32* dest, u32 value, size_t count)