1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

LibJS: Add a separate "identifier table" to bytecode executables

This is a specialized string table for storing identifiers only.
Identifiers are always FlyStrings, which makes many common operations
faster by allowing O(1) comparison.
This commit is contained in:
Andreas Kling 2021-10-24 15:34:30 +02:00
parent 13f04e37e5
commit da98212001
10 changed files with 121 additions and 37 deletions

View file

@ -11,6 +11,7 @@
#include <AK/SinglyLinkedList.h>
#include <LibJS/Bytecode/BasicBlock.h>
#include <LibJS/Bytecode/Executable.h>
#include <LibJS/Bytecode/IdentifierTable.h>
#include <LibJS/Bytecode/Label.h>
#include <LibJS/Bytecode/Op.h>
#include <LibJS/Bytecode/Register.h>
@ -102,6 +103,11 @@ public:
return m_string_table->insert(move(string));
}
IdentifierTableIndex intern_identifier(FlyString string)
{
return m_identifier_table->insert(move(string));
}
bool is_in_generator_function() const { return m_is_in_generator_function; }
void enter_generator_context() { m_is_in_generator_function = true; }
void leave_generator_context() { m_is_in_generator_function = false; }
@ -116,6 +122,7 @@ private:
BasicBlock* m_current_basic_block { nullptr };
NonnullOwnPtrVector<BasicBlock> m_root_basic_blocks;
NonnullOwnPtr<StringTable> m_string_table;
NonnullOwnPtr<IdentifierTable> m_identifier_table;
u32 m_next_register { 2 };
u32 m_next_block { 1 };