1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:57:45 +00:00

LibJS: Keep track of PrimitiveStrings and share them

VM now has a string cache which tracks all live PrimitiveStrings and
reuses an existing one if possible. This drastically reduces the number
of GC-allocated strings in many real-word situations.
This commit is contained in:
Andreas Kling 2021-10-02 01:36:57 +02:00
parent ba6e4c7ae1
commit f290c59dd8
3 changed files with 13 additions and 1 deletions

View file

@ -81,6 +81,7 @@ public:
Symbol* get_global_symbol(const String& description);
HashMap<String, PrimitiveString*>& string_cache() { return m_string_cache; }
PrimitiveString& empty_string() { return *m_empty_string; }
PrimitiveString& single_ascii_character_string(u8 character)
{
@ -294,6 +295,8 @@ private:
Exception* m_exception { nullptr };
HashMap<String, PrimitiveString*> m_string_cache;
Heap m_heap;
Vector<Interpreter*> m_interpreters;