mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
UserspaceEmulator: Devirtualize read/write/execute region permissions
These are getting quite hot (~4% of general emulation profile combined) so let's just devirtualize them and turn the function calls into simple boolean checks.
This commit is contained in:
parent
f41b9946e2
commit
3c64cec4d7
Notes:
sideshowbarker
2024-07-19 01:22:26 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3c64cec4d70
3 changed files with 17 additions and 10 deletions
|
@ -50,8 +50,8 @@ NonnullOwnPtr<MmapRegion> MmapRegion::create_file_backed(u32 base, u32 size, u32
|
|||
|
||||
MmapRegion::MmapRegion(u32 base, u32 size, int prot)
|
||||
: Region(base, size)
|
||||
, m_prot(prot)
|
||||
{
|
||||
set_prot(prot);
|
||||
m_shadow_data = (u8*)malloc(size);
|
||||
memset(m_shadow_data, 1, size);
|
||||
}
|
||||
|
|
|
@ -53,14 +53,15 @@ public:
|
|||
virtual u8* data() override { return m_data; }
|
||||
virtual u8* shadow_data() override { return m_shadow_data; }
|
||||
|
||||
virtual bool is_readable() const override { return m_prot & PROT_READ; }
|
||||
virtual bool is_writable() const override { return m_prot & PROT_WRITE; }
|
||||
virtual bool is_executable() const override { return m_prot & PROT_EXEC; }
|
||||
|
||||
bool is_malloc_block() const { return m_malloc; }
|
||||
void set_malloc(bool b) { m_malloc = b; }
|
||||
|
||||
void set_prot(int prot) { m_prot = prot; }
|
||||
void set_prot(int prot)
|
||||
{
|
||||
set_readable(prot & PROT_READ);
|
||||
set_writable(prot & PROT_WRITE);
|
||||
set_executable(prot & PROT_EXEC);
|
||||
}
|
||||
|
||||
MallocRegionMetadata* malloc_metadata() { return m_malloc_metadata; }
|
||||
void set_malloc_metadata(Badge<MallocTracer>, NonnullOwnPtr<MallocRegionMetadata> metadata) { m_malloc_metadata = move(metadata); }
|
||||
|
@ -71,7 +72,6 @@ private:
|
|||
|
||||
u8* m_data { nullptr };
|
||||
u8* m_shadow_data { nullptr };
|
||||
int m_prot { 0 };
|
||||
bool m_file_backed { false };
|
||||
bool m_malloc { false };
|
||||
|
||||
|
|
|
@ -69,9 +69,13 @@ public:
|
|||
bool is_text() const { return m_text; }
|
||||
void set_text(bool b) { m_text = b; }
|
||||
|
||||
virtual bool is_readable() const { return true; }
|
||||
virtual bool is_writable() const { return true; }
|
||||
virtual bool is_executable() const { return true; }
|
||||
bool is_readable() const { return m_readable; }
|
||||
bool is_writable() const { return m_writable; }
|
||||
bool is_executable() const { return m_executable; }
|
||||
|
||||
void set_readable(bool b) { m_readable = b; }
|
||||
void set_writable(bool b) { m_writable = b; }
|
||||
void set_executable(bool b) { m_executable = b; }
|
||||
|
||||
virtual u8* data() = 0;
|
||||
virtual u8* shadow_data() = 0;
|
||||
|
@ -89,6 +93,9 @@ public:
|
|||
|
||||
bool m_stack { false };
|
||||
bool m_text { false };
|
||||
bool m_readable { true };
|
||||
bool m_writable { true };
|
||||
bool m_executable { true };
|
||||
};
|
||||
|
||||
ValueWithShadow<u8> read8(X86::LogicalAddress);
|
||||
|
|
Loading…
Add table
Reference in a new issue