ladybird/Userland/Libraries/LibJS
Aliaksandr Kalenik 4d5823a5bc LibWeb+LibJS: Skip function environment allocation if possible
If a function has the following properties:
- uses only local variables and registers
- does not use `this`
- does not use `new.target`
- does not use `super`
- does not use direct eval() calls

then it is possible to entirely skip function environment allocation
because it will never be used

This change adds gathering of information whether a function needs to
access `this` from environment and updates `prepare_for_ordinary_call()`
to skip allocation when possible.

For now, this optimisation is too aggressively blocked; e.g. if `this`
is used in a function scope, then all functions in outer scopes have to
allocate an environment. It could be improved in the future, although
this implementation already allows skipping >80% of environment
allocations on Discord, GitHub and Twitter.
2024-05-04 06:48:07 +02:00
..
Bytecode LibWeb+LibJS: Skip function environment allocation if possible 2024-05-04 06:48:07 +02:00
Contrib/Test262 LibJS: Make ParserError::to_string infallible 2024-04-05 20:01:37 -04:00
Heap LibJS: Merge CallFrame into ExecutionContext 2024-05-02 07:26:13 +02:00
Runtime LibWeb+LibJS: Skip function environment allocation if possible 2024-05-04 06:48:07 +02:00
Tests LibJS: Cleanup unwind state when transferring control out of a finalizer 2024-05-02 07:27:45 +02:00
AST.cpp LibWeb+LibJS: Skip function environment allocation if possible 2024-05-04 06:48:07 +02:00
AST.h LibWeb+LibJS: Skip function environment allocation if possible 2024-05-04 06:48:07 +02:00
CMakeLists.txt Revert "LibJS/Bytecode: Bring back the bytecode optimization pipeline" 2024-03-06 08:39:29 +01:00
Console.cpp LibJS+LibWeb: Make Console, ConsoleClient & subclasses GC-allocated 2024-04-21 09:12:25 +02:00
Console.h LibJS+LibWeb: Make Console, ConsoleClient & subclasses GC-allocated 2024-04-21 09:12:25 +02:00
CyclicModule.cpp LibJS+LibWeb: Use new Cell::Visitor helpers to avoid manual iteration 2024-04-16 07:40:01 +02:00
CyclicModule.h
Forward.h LibJS: Make PromiseJob store callback as a HeapFunction 2024-03-26 05:47:24 +01:00
Lexer.cpp Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
Lexer.h LibJS: Lex 1/2/3-byte tokens without HashMap lookups 2024-03-24 13:28:24 +01:00
MarkupGenerator.cpp AK+Userland: Remove some needlessly explicit conversions to StringView 2024-04-04 11:23:21 +02:00
MarkupGenerator.h
Module.cpp LibJS: Add calls to JS_{DECLARE,DEFINE}_ALLOCATOR() 2024-04-09 09:13:06 +02:00
Module.h LibJS: Add calls to JS_{DECLARE,DEFINE}_ALLOCATOR() 2024-04-09 09:13:06 +02:00
ModuleLoading.h
Parser.cpp LibWeb+LibJS: Skip function environment allocation if possible 2024-05-04 06:48:07 +02:00
Parser.h LibWeb+LibJS: Skip function environment allocation if possible 2024-05-04 06:48:07 +02:00
ParserError.cpp LibJS: Make ParserError::to_string infallible 2024-04-05 20:01:37 -04:00
ParserError.h LibJS: Make ParserError::to_string infallible 2024-04-05 20:01:37 -04:00
Position.h
Print.cpp
Print.h
SafeFunction.h
Script.cpp
Script.h
SourceCode.cpp
SourceCode.h
SourceRange.h
SourceTextModule.cpp LibWeb+LibJS: Skip function environment allocation if possible 2024-05-04 06:48:07 +02:00
SourceTextModule.h
SyntaxHighlighter.cpp
SyntaxHighlighter.h
SyntheticModule.cpp
SyntheticModule.h
Token.cpp
Token.h Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00