1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:07:36 +00:00

LibWasm: Avoid pointless vector copies in Validator::Context

These vector copies accounted for more than 50% of the current runtime
of the validator on a large wasm file, this commit makes them
copy-on-write to avoid the copies where possible, gaining nearly a 50%
speedup.
This commit is contained in:
Ali Mohammad Pur 2024-03-11 16:54:37 +01:00 committed by Ali Mohammad Pur
parent cefe177a56
commit cced555879
2 changed files with 17 additions and 15 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/COWVector.h>
#include <AK/Debug.h>
#include <AK/HashTable.h>
#include <AK/SourceLocation.h>
@ -17,15 +18,15 @@
namespace Wasm {
struct Context {
Vector<FunctionType> types;
Vector<FunctionType> functions;
Vector<TableType> tables;
Vector<MemoryType> memories;
Vector<GlobalType> globals;
Vector<ValueType> elements;
Vector<bool> datas;
Vector<ValueType> locals;
Vector<ResultType> labels;
COWVector<FunctionType> types;
COWVector<FunctionType> functions;
COWVector<TableType> tables;
COWVector<MemoryType> memories;
COWVector<GlobalType> globals;
COWVector<ValueType> elements;
COWVector<bool> datas;
COWVector<ValueType> locals;
COWVector<ResultType> labels;
Optional<ResultType> return_;
AK::HashTable<FunctionIndex> references;
size_t imported_function_count { 0 };
@ -345,7 +346,7 @@ private:
Vector<ChildScopeKind> m_entered_scopes;
Vector<BlockDetails> m_block_details;
Vector<FunctionType> m_entered_blocks;
Vector<GlobalType> m_globals_without_internal_globals;
COWVector<GlobalType> m_globals_without_internal_globals;
};
}