mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
UserspaceEmulator: Hang malloc metadata on malloc block MmapRegions
Instead of tracking known malloc blocks in a separate hash table, add an optional malloc metadata pointer to MmapRegion. This makes finding the malloc metadata for a given pointer extremely fast since it can piggyback on the page table array. :^)
This commit is contained in:
parent
395313039d
commit
f41b9946e2
4 changed files with 77 additions and 83 deletions
|
@ -31,6 +31,9 @@
|
|||
|
||||
namespace UserspaceEmulator {
|
||||
|
||||
class MallocRegionMetadata;
|
||||
class MallocTracer;
|
||||
|
||||
class MmapRegion final : public SoftMMU::Region {
|
||||
public:
|
||||
static NonnullOwnPtr<MmapRegion> create_anonymous(u32 base, u32 size, u32 prot);
|
||||
|
@ -59,6 +62,9 @@ public:
|
|||
|
||||
void set_prot(int prot) { m_prot = prot; }
|
||||
|
||||
MallocRegionMetadata* malloc_metadata() { return m_malloc_metadata; }
|
||||
void set_malloc_metadata(Badge<MallocTracer>, NonnullOwnPtr<MallocRegionMetadata> metadata) { m_malloc_metadata = move(metadata); }
|
||||
|
||||
private:
|
||||
MmapRegion(u32 base, u32 size, int prot);
|
||||
virtual bool is_mmap() const override { return true; }
|
||||
|
@ -68,6 +74,8 @@ private:
|
|||
int m_prot { 0 };
|
||||
bool m_file_backed { false };
|
||||
bool m_malloc { false };
|
||||
|
||||
OwnPtr<MallocRegionMetadata> m_malloc_metadata;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue