[build] Get release mode optimizations working

Added a release config, and fixed a few spots where optimizations broke things:

- Clang was generating incorrect code for run_ctor_list in libc's init.cpp (it
  ignored a check for the end of the list)
- my rep movsb memcpy implementation used incorrect inline asm constraints, so
  it was returning a pointer to the end of the copied range instead of the start.
  Since this function was just inline asm anyway, I rewrote it in asm by hand in
  a new memutils.s file.
This commit is contained in:
Justin C. Miller
2024-02-25 17:09:04 -08:00
parent bc46c9a7d5
commit f7ea46e49e
6 changed files with 28 additions and 27 deletions

View File

@@ -123,16 +123,19 @@ isr_handler(cpu_state *regs)
uintptr_t cr2 = 0;
__asm__ __volatile__ ("mov %%cr2, %0" : "=r"(cr2));
bool user = cr2 < mem::kernel_offset;
vm_space::fault_type ft =
static_cast<vm_space::fault_type>(regs->errorcode);
// The zero page is always invalid
if (cr2 > mem::frame_size) {
bool user = cr2 < mem::kernel_offset;
vm_space::fault_type ft =
static_cast<vm_space::fault_type>(regs->errorcode);
vm_space &space = user
? obj::process::current().space()
: vm_space::kernel_space();
vm_space &space = user
? obj::process::current().space()
: vm_space::kernel_space();
if (cr2 && space.handle_fault(cr2, ft))
break;
if (cr2 && space.handle_fault(cr2, ft))
break;
}
util::format({message, sizeof(message)},
"Page fault: %016lx%s%s%s%s%s", cr2,