diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-12 13:25:16 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-12 13:45:15 +0100 |
commit | dea474dfd5e92878f774738e8a49084ceb9b7757 (patch) | |
tree | 57d2bf831d949d75df7b8ed0adc681ced3c93782 /Kernel/i386.h | |
parent | 1cf20a2fe25231e3e45873448dac808477511d2f (diff) | |
download | serenity-dea474dfd5e92878f774738e8a49084ceb9b7757.zip |
Make loading /bin/bash ~250x faster.
The ELF loader was doing huge amounts of unnecessary work.
Got rid of the "export symbols" and relocation passes since we don't need them.
They were useful things when bringing up the ELF loading code.
Also added a simple TSC-based Stopwatch RAII thingy to help debug performance issues.
Diffstat (limited to 'Kernel/i386.h')
-rw-r--r-- | Kernel/i386.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Kernel/i386.h b/Kernel/i386.h index 0eaae76ce0..b4c64b6247 100644 --- a/Kernel/i386.h +++ b/Kernel/i386.h @@ -1,6 +1,7 @@ #pragma once #include "types.h" +#include "kprintf.h" #define PAGE_SIZE 4096 #define PAGE_MASK 0xfffff000 @@ -218,3 +219,35 @@ private: dword m_ecx { 0xffffffff }; dword m_edx { 0xffffffff }; }; + +inline void read_tsc(dword& lsw, dword& msw) +{ + asm volatile("rdtsc":"=d"(msw),"=a"(lsw)); +} + +struct Stopwatch { +public: + Stopwatch(const char* name) + : m_name(name) + { + read_tsc(m_start_lsw, m_start_msw); + } + + ~Stopwatch() + { + dword end_lsw; + dword end_msw; + read_tsc(end_lsw, end_msw); + if (m_start_msw != end_msw) { + dbgprintf("differing msw's\n"); + asm volatile("cli;hlt"); + } + dword diff = end_lsw - m_start_lsw; + dbgprintf("Stopwatch(%s): %u ticks\n", m_name, diff); + } + +private: + const char* m_name { nullptr }; + dword m_start_lsw { 0 }; + dword m_start_msw { 0 }; +}; |