1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:58:11 +00:00
serenity/Userland/Libraries/LibJS
Andreas Kling d7578ddebb LibJS: Share "parsed identifiers" between copied JS::Lexer instances
When we save/load state in the parser, we preserve the lexer state by
simply making a copy of it. This was made extremely heavy by the lexer
keeping a cache of all parsed identifiers.

It keeps the cache to ensure that StringViews into parsed Unicode escape
sequences don't become dangling views when the Token goes out of scope.

This patch solves the problem by replacing the Vector<FlyString> which
was used to cache the identifiers with a ref-counted
HashTable<FlyString> instead.

Since the purpose of the cache is just to keep FlyStrings alive, it's
fine for all Lexer instances to share the cache. And as a bonus, using a
HashTable instead of a Vector replaces the O(n) accesses with O(1) ones.

This makes a 1.9 MiB JavaScript file parse in 0.6s instead of 24s. :^)
2021-09-10 23:18:00 +02:00
..
Bytecode LibJS: Change ExecutionContext's arguments list to a MarkedValueList 2021-08-10 23:07:50 +02:00
Heap AK+Everywhere: Reduce the number of template parameters of IntrusiveList 2021-09-10 18:05:46 +03:00
Runtime AK+Everywhere: Reduce the number of template parameters of IntrusiveList 2021-09-10 18:05:46 +03:00
Tests LibJS: Implement Temporal.PlainYearMonth.compare 2021-09-09 09:06:23 +01:00
AST.cpp LibJS: Restore the environment if an exception is thrown in 'with' block 2021-09-08 20:37:39 +01:00
AST.h LibJS: Add support for public fields in classes 2021-09-01 13:39:14 +01:00
CMakeLists.txt LibJS: Start adding a JS::Script class (spec's "Script Record") 2021-09-09 21:25:10 +02:00
Console.cpp LibJS: Rename CallFrame => ExecutionContext 2021-06-24 19:28:00 +02:00
Console.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Forward.h LibJS: Implement a nearly empty Intl.ListFormat object 2021-09-06 23:49:56 +01:00
Interpreter.cpp LibJS: Change ExecutionContext's arguments list to a MarkedValueList 2021-08-10 23:07:50 +02:00
Interpreter.h LibJS: Drop "Record" suffix from all the *Environment record classes 2021-07-01 12:28:57 +02:00
Lexer.cpp LibJS: Share "parsed identifiers" between copied JS::Lexer instances 2021-09-10 23:18:00 +02:00
Lexer.h LibJS: Share "parsed identifiers" between copied JS::Lexer instances 2021-09-10 23:18:00 +02:00
MarkupGenerator.cpp LibJS: Remove unused includes out of Cell.h, move to the users 2021-08-01 08:10:16 +02:00
MarkupGenerator.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Parser.cpp LibJS: Fix that windows style line endings were not ignored or converted 2021-09-06 08:43:38 +01:00
Parser.h Everywhere: Prevent risky implicit casts of (Nonnull)RefPtr 2021-09-03 23:20:23 +02:00
Script.cpp LibJS: Implement the ParseScript AO (as JS::Script::parse()) 2021-09-09 21:25:10 +02:00
Script.h LibJS: Implement the ParseScript AO (as JS::Script::parse()) 2021-09-09 21:25:10 +02:00
SourceRange.h LibJS: Implement parsing and evaluation for AssignmentPatterns 2021-07-11 21:41:54 +01:00
SyntaxHighlighter.cpp LibJS: Remove unused header includes 2021-08-01 08:10:16 +02:00
SyntaxHighlighter.h LibWeb+LibSyntax: Implement nested syntax highlighters 2021-06-07 14:45:49 +04:30
Token.cpp LibJS: Fix that windows style line endings were not ignored or converted 2021-09-06 08:43:38 +01:00
Token.h LibJS: Clean up token constructor and use method instead for identifiers 2021-09-06 08:43:38 +01:00