mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 18:47:15 +02:00
LibJS: Use local variables to store function parameters in some cases
Using local variables to store function parameters makes Kraken tests run 7-10% faster. For now this optimization is limited to only be applied if: - Parameter does not use destructuring assignment - None of the function params has default value - There is no access to "arguments" variable inside function body
This commit is contained in:
committed by
Andreas Kling
parent
2e81cc4cf7
commit
b1af91d8c4
Notes:
sideshowbarker
2024-07-17 00:47:29 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/b1af91d8c4 Pull-request: https://github.com/SerenityOS/serenity/pull/19858
@@ -479,12 +479,18 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
|
||||
Environment* used_environment = has_duplicates ? nullptr : environment;
|
||||
|
||||
if constexpr (IsSame<NonnullRefPtr<Identifier const> const&, decltype(param)>) {
|
||||
Reference reference = TRY(vm.resolve_binding(param->string(), used_environment));
|
||||
// Here the difference from hasDuplicates is important
|
||||
if (has_duplicates)
|
||||
return reference.put_value(vm, argument_value);
|
||||
else
|
||||
return reference.initialize_referenced_binding(vm, argument_value);
|
||||
if (vm.bytecode_interpreter_if_exists() && param->is_local()) {
|
||||
// NOTE: Local variables are supported only in bytecode interpreter
|
||||
callee_context.local_variables[param->local_variable_index()] = argument_value;
|
||||
return {};
|
||||
} else {
|
||||
Reference reference = TRY(vm.resolve_binding(param->string(), used_environment));
|
||||
// Here the difference from hasDuplicates is important
|
||||
if (has_duplicates)
|
||||
return reference.put_value(vm, argument_value);
|
||||
else
|
||||
return reference.initialize_referenced_binding(vm, argument_value);
|
||||
}
|
||||
}
|
||||
if constexpr (IsSame<NonnullRefPtr<BindingPattern const> const&, decltype(param)>) {
|
||||
// Here the difference from hasDuplicates is important
|
||||
|
||||
Reference in New Issue
Block a user