From 669b1131adacb75fa40336454b3cd0c06ee3ecb2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 20 Apr 2025 13:16:52 +0200 Subject: [PATCH] LibJS: Streamline CreateMappedArgumentsObject [[ParameterMap]] creation Instead of using the more generic define_native_accessor() here, we poke directly at indexed property storage for the parameter map. We can also construct the NativeFunction objects directly, without giving them names like "get 0" etc, since these are not observable by userspace. Finally, by using default property attributes (not observable anyway), we get simple indexed storage instead of generic (hash map) storage. --- .../LibJS/Runtime/AbstractOperations.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Libraries/LibJS/Runtime/AbstractOperations.cpp index 3ff069b1a68..306fda013fc 100644 --- a/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -1131,17 +1131,16 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Nonnull // 1. Let g be MakeArgGetter(name, env). // 2. Let p be MakeArgSetter(name, env). // 3. Perform ! map.[[DefineOwnProperty]](! ToString(𝔽(index)), PropertyDescriptor { [[Set]]: p, [[Get]]: g, [[Enumerable]]: false, [[Configurable]]: true }). - object->parameter_map().define_native_accessor( - realm, - PropertyKey { index }, - [&environment, name](VM& vm) -> ThrowCompletionOr { - return MUST(environment.get_binding_value(vm, name, false)); - }, - [&environment, name](VM& vm) { - MUST(environment.set_mutable_binding(vm, name, vm.argument(0), false)); - return js_undefined(); - }, - Attribute::Configurable); + object->parameter_map().indexed_properties().put( + index, + Accessor::create(vm, + NativeFunction::create(realm, FlyString {}, [&environment, name](VM& vm) -> ThrowCompletionOr { + return MUST(environment.get_binding_value(vm, name, false)); + }), + NativeFunction::create(realm, FlyString {}, [&environment, name](VM& vm) { + MUST(environment.set_mutable_binding(vm, name, vm.argument(0), false)); + return js_undefined(); + }))); } }