LibJS: Use premade shape when creating mapped arguments objects

Knocks out a 0.4% profile item on Speedometer 3.
This commit is contained in:
Andreas Kling 2025-04-18 18:11:10 +02:00 committed by Andreas Kling
parent ed5ad267c7
commit e0b32b1863
Notes: github-actions[bot] 2025-04-18 23:14:55 +00:00
4 changed files with 25 additions and 5 deletions

View file

@ -1101,13 +1101,13 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Nonnull
auto value = arguments[index];
// b. Perform ! CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), val).
MUST(object->create_data_property_or_throw(index, value));
object->indexed_properties().put(index, value);
// c. Set index to index + 1.
}
// 16. Perform ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
MUST(object->define_property_or_throw(vm.names.length, { .value = Value(length), .writable = true, .enumerable = false, .configurable = true }));
object->put_direct(realm.intrinsics().mapped_arguments_object_length_offset(), Value(length));
// 17. Let mappedNames be a new empty List.
HashTable<FlyString> mapped_names;
@ -1147,10 +1147,10 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Nonnull
// 20. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
auto array_prototype_values = realm.intrinsics().array_prototype_values_function();
MUST(object->define_property_or_throw(vm.well_known_symbol_iterator(), { .value = array_prototype_values, .writable = true, .enumerable = false, .configurable = true }));
object->put_direct(realm.intrinsics().mapped_arguments_object_well_known_symbol_iterator_offset(), array_prototype_values);
// 21. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
MUST(object->define_property_or_throw(vm.names.callee, { .value = &function, .writable = true, .enumerable = false, .configurable = true }));
object->put_direct(realm.intrinsics().mapped_arguments_object_callee_offset(), Value(&function));
// 22. Return obj.
return object;