mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
Don't use dword-by-dword memset/memcpy if the addresses are unaligned.
Also don't enable the large kmalloc catcher by default.
This commit is contained in:
parent
3ac977f50b
commit
c43903eebd
Notes:
sideshowbarker
2024-07-19 16:03:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c43903eebd2
@ -9,7 +9,8 @@ void memcpy(void *dest_ptr, const void *src_ptr, dword n)
|
||||
{
|
||||
dword dest = (dword)dest_ptr;
|
||||
dword src = (dword)src_ptr;
|
||||
if (n >= 12) {
|
||||
// FIXME: Support starting at an unaligned address.
|
||||
if (!(dest & 0x3) && !(src & 0x3) && n >= 12) {
|
||||
size_t dwords = n / sizeof(dword);
|
||||
asm volatile(
|
||||
"rep movsl\n"
|
||||
@ -36,7 +37,8 @@ void strcpy(char* dest, const char *src)
|
||||
void* memset(void* dest_ptr, byte c, dword n)
|
||||
{
|
||||
dword dest = (dword)dest_ptr;
|
||||
if (n >= 12) {
|
||||
// FIXME: Support starting at an unaligned address.
|
||||
if (!(dest & 0x3) && n >= 12) {
|
||||
size_t dwords = n / sizeof(dword);
|
||||
dword expanded_c = c;
|
||||
expanded_c <<= 8;
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
//#define KMALLOC_DEBUG_LARGE_ALLOCATIONS
|
||||
|
||||
void kmalloc_init();
|
||||
void* kmalloc_impl(dword size) __attribute__ ((malloc));
|
||||
void* kmalloc_eternal(size_t) __attribute__ ((malloc));
|
||||
@ -20,8 +22,10 @@ inline void* operator new[](size_t, void* p) { return p; }
|
||||
|
||||
ALWAYS_INLINE void* kmalloc(size_t size)
|
||||
{
|
||||
// Any kernel allocation >= 32K is very suspicious, catch them.
|
||||
if (size >= 0x8000)
|
||||
#ifdef KMALLOC_DEBUG_LARGE_ALLOCATIONS
|
||||
// Any kernel allocation >= 1M is 99.9% a bug.
|
||||
if (size >= 1048576)
|
||||
asm volatile("cli;hlt");
|
||||
#endif
|
||||
return kmalloc_impl(size);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user