mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
UserspaceEmulator: Make big malloc block lookup O(1) as well
By passing the Region& to the auditing functions, we know exactly which block we are hitting. This allows us to track big mallocations the same way we already do chunked ones. This gets rid of the O(n) scan in find_mallocation() for allocations larger than the maximum malloc chunk size. :^)
This commit is contained in:
parent
8d9dd4c518
commit
e1f617950e
4 changed files with 57 additions and 55 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "SoftMMU.h"
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
@ -71,8 +72,8 @@ public:
|
|||
void target_did_free(Badge<SoftCPU>, FlatPtr address);
|
||||
void target_did_realloc(Badge<SoftCPU>, FlatPtr address, size_t);
|
||||
|
||||
void audit_read(FlatPtr address, size_t);
|
||||
void audit_write(FlatPtr address, size_t);
|
||||
void audit_read(const Region&, FlatPtr address, size_t);
|
||||
void audit_write(const Region&, FlatPtr address, size_t);
|
||||
|
||||
void dump_leak_report();
|
||||
|
||||
|
@ -80,13 +81,12 @@ private:
|
|||
template<typename Callback>
|
||||
void for_each_mallocation(Callback callback) const;
|
||||
|
||||
Mallocation* find_mallocation(const Region&, FlatPtr);
|
||||
Mallocation* find_mallocation(FlatPtr);
|
||||
Mallocation* find_mallocation_before(FlatPtr);
|
||||
Mallocation* find_mallocation_after(FlatPtr);
|
||||
bool is_reachable(const Mallocation&) const;
|
||||
|
||||
Vector<Mallocation> m_big_mallocations;
|
||||
|
||||
bool m_auditing_enabled { true };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue