1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:18:11 +00:00

LibELF: Don't recompute the same ELF hashes over and over

When performing a global symbol lookup, we were recomputing the symbol
hashes once for every dynamic object searched. The hash function was
at the very top of a profile (15%) of program startup.

With this change, the hash function is no longer visible among the top
stacks in the profile. :^)
This commit is contained in:
Andreas Kling 2021-02-23 18:44:09 +01:00
parent af6a633468
commit d6af3302e8
4 changed files with 29 additions and 27 deletions

View file

@ -31,6 +31,7 @@
#include <AK/StringBuilder.h>
#include <LibELF/DynamicLinker.h>
#include <LibELF/DynamicLoader.h>
#include <LibELF/Hashes.h>
#include <LibELF/Validation.h>
#include <assert.h>
#include <dlfcn.h>
@ -142,7 +143,7 @@ bool DynamicLoader::validate()
void* DynamicLoader::symbol_for_name(const StringView& name)
{
auto result = m_dynamic_object->hash_section().lookup_symbol(name);
auto result = m_dynamic_object->hash_section().lookup_symbol(name, compute_gnu_hash(name), compute_sysv_hash(name));
if (!result.has_value())
return nullptr;
auto symbol = result.value();