LibJS: Mark JS::Cell::initialize() as MUST_UPCALL

Intermediate classes in the initialize() chain set up prototypes and
define properties. Forgetting to call Base::initialize() in any
override would silently skip that setup.
This commit is contained in:
Andreas Kling 2026-01-30 10:45:09 +01:00 committed by Jelle Raaijmakers
parent 5b26777904
commit 74a80b7bfc
5 changed files with 7 additions and 3 deletions

View file

@ -17,7 +17,7 @@ class JS_API Cell : public GC::Cell {
GC_CELL(Cell, GC::Cell);
public:
virtual void initialize(Realm&);
MUST_UPCALL virtual void initialize(Realm&);
virtual bool is_generator_result() const { return false; }
virtual bool is_environment() const { return false; }

View file

@ -24,8 +24,9 @@ CollatorCompareFunction::CollatorCompareFunction(Realm& realm, Collator& collato
{
}
void CollatorCompareFunction::initialize(Realm&)
void CollatorCompareFunction::initialize(Realm& realm)
{
Base::initialize(realm);
auto& vm = this->vm();
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
define_direct_property(vm.names.name, PrimitiveString::create(vm, String {}), Attribute::Configurable);

View file

@ -99,8 +99,9 @@ Object::~Object()
s_intrinsics.remove(this);
}
void Object::initialize(Realm&)
void Object::initialize(Realm& realm)
{
Base::initialize(realm);
}
void Object::unsafe_set_shape(Shape& shape)

View file

@ -24,6 +24,7 @@ Set::Set(Object& prototype)
void Set::initialize(Realm& realm)
{
Base::initialize(realm);
m_values = Map::create(realm);
}

View file

@ -3487,6 +3487,7 @@ GC_DEFINE_ALLOCATOR(@named_properties_class@);
void @named_properties_class@::initialize(JS::Realm& realm)
{
Base::initialize(realm);
auto& vm = realm.vm();
// The class string of a named properties object is the concatenation of the interface's identifier and the string "Properties".