mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibJS: Give VM a cache of single-ASCII-character PrimitiveString
A large number of JS strings are a single ASCII character. This patch adds a 128-entry cache for those strings to the VM. The cost of the cache is 1536 byte of GC heap (all in same block) + 2304 bytes malloc. This avoids a lot of GC heap allocations, and packing all of these in the same heap block is nice for fragmentation as well.
This commit is contained in:
parent
5c2520e6b2
commit
619cd613d0
3 changed files with 17 additions and 0 deletions
|
@ -108,6 +108,11 @@ public:
|
|||
Symbol* get_global_symbol(const String& description);
|
||||
|
||||
PrimitiveString& empty_string() { return *m_empty_string; }
|
||||
PrimitiveString& single_ascii_character_string(u8 character)
|
||||
{
|
||||
ASSERT(character < 0x80);
|
||||
return *m_single_ascii_character_strings[character];
|
||||
}
|
||||
|
||||
CallFrame& push_call_frame(bool strict_mode = false)
|
||||
{
|
||||
|
@ -247,6 +252,7 @@ private:
|
|||
HashMap<String, Symbol*> m_global_symbol_map;
|
||||
|
||||
PrimitiveString* m_empty_string { nullptr };
|
||||
PrimitiveString* m_single_ascii_character_strings[128] {};
|
||||
|
||||
#define __JS_ENUMERATE(SymbolName, snake_name) \
|
||||
Symbol* m_well_known_symbol_##snake_name { nullptr };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue