mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibJS: Store strings in a string table
Instead of using Strings in the bytecode ops this adds a global string table to the Executable struct which individual operations can refer to using indices. This brings bytecode ops one step closer to being pointer free.
This commit is contained in:
parent
4efccbd030
commit
6a0d1fa259
Notes:
sideshowbarker
2024-07-18 12:33:32 +09:00
Author: https://github.com/gunnarbeutner
Commit: 6a0d1fa259
Pull-request: https://github.com/SerenityOS/serenity/pull/7940
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
16 changed files with 173 additions and 82 deletions
|
@ -12,13 +12,17 @@
|
|||
#include <LibJS/Bytecode/BasicBlock.h>
|
||||
#include <LibJS/Bytecode/Label.h>
|
||||
#include <LibJS/Bytecode/Register.h>
|
||||
#include <LibJS/Bytecode/StringTable.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
struct Executable {
|
||||
NonnullOwnPtrVector<BasicBlock> basic_blocks;
|
||||
NonnullOwnPtr<StringTable> string_table;
|
||||
size_t number_of_registers { 0 };
|
||||
|
||||
String const& get_string(StringTableIndex index) const { return string_table->get(index); }
|
||||
};
|
||||
|
||||
class Generator {
|
||||
|
@ -74,6 +78,11 @@ public:
|
|||
return m_current_basic_block->is_terminated();
|
||||
}
|
||||
|
||||
StringTableIndex intern_string(StringView const& string)
|
||||
{
|
||||
return m_string_table->insert(string);
|
||||
}
|
||||
|
||||
private:
|
||||
Generator();
|
||||
~Generator();
|
||||
|
@ -83,6 +92,7 @@ private:
|
|||
|
||||
BasicBlock* m_current_basic_block { nullptr };
|
||||
NonnullOwnPtrVector<BasicBlock> m_root_basic_blocks;
|
||||
NonnullOwnPtr<StringTable> m_string_table;
|
||||
|
||||
u32 m_next_register { 1 };
|
||||
u32 m_next_block { 1 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue