LibJS: Make internal_define_own_property() save added property offset

...in `PropertyDescriptor`. This is required for the upcoming change
that needs to know offset of newly added properties to set up inline
caching.
This commit is contained in:
Aliaksandr Kalenik 2025-09-15 16:43:27 +02:00 committed by Andreas Kling
commit a54215c07d
Notes: github-actions[bot] 2025-09-17 10:45:42 +00:00
32 changed files with 88 additions and 60 deletions

View file

@ -457,8 +457,10 @@ void ECMAScriptFunctionObject::initialize(Realm& realm)
prototype->put_direct(realm.intrinsics().normal_function_prototype_constructor_offset(), this);
put_direct(realm.intrinsics().normal_function_prototype_offset(), prototype);
} else {
MUST(define_property_or_throw(vm.names.length, { .value = Value(function_length()), .writable = false, .enumerable = false, .configurable = true }));
MUST(define_property_or_throw(vm.names.name, { .value = m_name_string, .writable = false, .enumerable = false, .configurable = true }));
PropertyDescriptor length_descriptor { .value = Value(function_length()), .writable = false, .enumerable = false, .configurable = true };
MUST(define_property_or_throw(vm.names.length, length_descriptor));
PropertyDescriptor name_descriptor { .value = m_name_string, .writable = false, .enumerable = false, .configurable = true };
MUST(define_property_or_throw(vm.names.name, name_descriptor));
if (!is_arrow_function()) {
Object* prototype = nullptr;
@ -915,7 +917,8 @@ void ECMAScriptFunctionObject::set_name(Utf16FlyString const& name)
auto& vm = this->vm();
const_cast<SharedFunctionInstanceData&>(shared_data()).m_name = name;
m_name_string = PrimitiveString::create(vm, name);
MUST(define_property_or_throw(vm.names.name, { .value = m_name_string, .writable = false, .enumerable = false, .configurable = true }));
PropertyDescriptor descriptor { .value = m_name_string, .writable = false, .enumerable = false, .configurable = true };
MUST(define_property_or_throw(vm.names.name, descriptor));
}
ECMAScriptFunctionObject::ClassData& ECMAScriptFunctionObject::ensure_class_data() const