mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibJS: Skip allocating locals for arguments that allowed to be local
This allows us to get rid of instructions that move arguments to locals and allocate smaller JS::Value vector in ExecutionContext by reusing slots that were already allocated for arguments. With this change for following function: ```js function f(x, y) { return x + y; } ``` we now produce following bytecode: ``` [ 0] 0: Add dst:reg6, lhs:arg0, rhs:arg1 [ 10] Return value:reg6 ``` instead of: ``` [ 0] 0: GetArgument 0, dst:x~1 [ 10] GetArgument 1, dst:y~0 [ 20] Add dst:reg6, lhs:x~1, rhs:y~0 [ 30] Return value:reg6 ```
This commit is contained in:
parent
3f04d18ef7
commit
2d732b2251
Notes:
github-actions[bot]
2025-04-26 09:03:23 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 2d732b2251
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4481
6 changed files with 102 additions and 39 deletions
|
@ -44,14 +44,15 @@ public:
|
|||
CodeGenerationErrorOr<void> emit_function_declaration_instantiation(ECMAScriptFunctionObject const& function);
|
||||
|
||||
[[nodiscard]] ScopedOperand allocate_register();
|
||||
[[nodiscard]] ScopedOperand local(u32 local_index);
|
||||
[[nodiscard]] ScopedOperand local(Identifier::Local const&);
|
||||
[[nodiscard]] ScopedOperand accumulator();
|
||||
[[nodiscard]] ScopedOperand this_value();
|
||||
|
||||
void free_register(Register);
|
||||
|
||||
void set_local_initialized(u32 local_index);
|
||||
void set_local_initialized(Identifier::Local const&);
|
||||
[[nodiscard]] bool is_local_initialized(u32 local_index) const;
|
||||
[[nodiscard]] bool is_local_initialized(Identifier::Local const&) const;
|
||||
|
||||
class SourceLocationScope {
|
||||
public:
|
||||
|
@ -411,6 +412,7 @@ private:
|
|||
Vector<ScopedOperand> m_home_objects;
|
||||
|
||||
HashTable<u32> m_initialized_locals;
|
||||
HashTable<u32> m_initialized_arguments;
|
||||
|
||||
bool m_finished { false };
|
||||
bool m_must_propagate_completion { true };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue